index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div class="monitoring-page">
  3. <!-- 新增Tabs组件区分实时/历史数据 -->
  4. <Tabs v-model:activeKey="activeTab" type="card" style="margin-bottom: 16px">
  5. <TabPane tab="实时监测" key="realtime">
  6. <div class="board-info">
  7. <MiniBoard
  8. :key="index"
  9. v-for="(item, index) in boardData"
  10. type="A"
  11. :label="item.label"
  12. :value="item.value"
  13. layout="label-top"
  14. class="board-item"
  15. />
  16. </div>
  17. <!-- 实时数据表格 -->
  18. <BasicTable @register="registerTable" :scroll="{ x: 'max-content' }">
  19. <template #action="{ record }">
  20. <div class="action-buttons">
  21. <!-- 操作按钮 -->
  22. <button @click="openModal(record, 'detail')" class="action-btn detail-btn" title="操作">
  23. <span class="action-text">详情</span>
  24. </button>
  25. </div>
  26. </template>
  27. </BasicTable>
  28. </TabPane>
  29. <TabPane tab="历史数据" key="history">
  30. <!-- 历史数据表格 -->
  31. <BasicTable @register="registerHistoryTable" :scroll="{ x: 'max-content' }">
  32. <template #action="{ record }">
  33. <div class="action-buttons">
  34. <button @click="openModal(record, 'history')" class="action-btn">
  35. <SvgIcon name="details" />
  36. </button>
  37. </div>
  38. </template>
  39. </BasicTable>
  40. </TabPane>
  41. </Tabs>
  42. <!-- 弹窗组件 -->
  43. <a-modal
  44. style="top: 30%; left: 170px"
  45. v-model:visible="visibleModal"
  46. :width="450"
  47. title="实时监测数据"
  48. @ok="handleOkEdit"
  49. @cancel="handleCancelEdit"
  50. >
  51. <a-table></a-table>
  52. </a-modal>
  53. </div>
  54. </template>
  55. <script setup lang="ts">
  56. import { ref, onMounted } from 'vue';
  57. import { BasicTable, useTable } from '/@/components/Table';
  58. import { Tabs, TabPane } from 'ant-design-vue';
  59. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  60. import { SvgIcon } from '/@/components/Icon';
  61. // 引入模拟数据
  62. import { boardData, columns, searchFormSchema, minesData, historicalMinesData } from './overlimitAlarm.data';
  63. import { getMineData, getProvinceAlarm } from './overlimit.api';
  64. // 激活的Tab页签
  65. const activeTab = ref('realtime');
  66. const visibleModal = ref(false);
  67. //煤矿列表数据
  68. const deviceOptions = ref([]);
  69. const mineID = ref('');
  70. const minesData = ref([]);
  71. // 注册实时数据表格
  72. const [registerTable] = useTable({
  73. dataSource: minesData,
  74. columns,
  75. formConfig: {
  76. labelWidth: 120,
  77. schemas: [
  78. {
  79. label: '查询煤矿',
  80. field: 'mineCode',
  81. component: 'Select',
  82. defaultValue: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '',
  83. componentProps: {
  84. showSearch: true,
  85. filterOption: (input: string, option: any) => {
  86. return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  87. },
  88. options: deviceOptions,
  89. onChange: async (e, option) => {
  90. await fetchAlarmData(e);
  91. },
  92. },
  93. colProps: {
  94. span: 6,
  95. },
  96. },
  97. {
  98. field: 'mineName',
  99. label: '所属执法处',
  100. component: 'Select',
  101. componentProps: {
  102. options: [
  103. { label: '执法一处', value: '0' },
  104. { label: '执法二处', value: '1' },
  105. { label: '执法三处', value: '2' },
  106. ],
  107. },
  108. colProps: { span: 6 },
  109. },
  110. {
  111. field: 'mineName',
  112. label: '所属区域',
  113. component: 'Select',
  114. componentProps: {
  115. options: [
  116. { label: '执法一处', value: '0' },
  117. { label: '执法二处', value: '1' },
  118. { label: '执法三处', value: '2' },
  119. ],
  120. },
  121. colProps: { span: 6 },
  122. },
  123. {
  124. field: 'mineName',
  125. label: '煤矿名称',
  126. component: 'Input',
  127. colProps: { span: 6 },
  128. },
  129. {
  130. field: 'mineNameAbbr',
  131. label: '煤矿简称',
  132. component: 'Input',
  133. colProps: { span: 6 },
  134. },
  135. {
  136. field: 'productStatus',
  137. label: '生产状态',
  138. component: 'Select',
  139. componentProps: {
  140. options: [
  141. { label: '拟建矿井', value: '0' },
  142. { label: '正常生产矿井', value: '1' },
  143. { label: '长期停产矿井', value: '2' },
  144. ],
  145. },
  146. colProps: { span: 6 },
  147. },
  148. {
  149. field: 'riskLevel',
  150. label: '自燃情况',
  151. component: 'Select',
  152. componentProps: {
  153. options: [
  154. { label: 'Ⅰ类容易自燃', value: '0' },
  155. { label: 'Ⅱ类自燃', value: '1' },
  156. { label: 'Ⅲ类不易自燃', value: '2' },
  157. ],
  158. },
  159. colProps: { span: 6 },
  160. },
  161. ],
  162. showAdvancedButton: false,
  163. },
  164. pagination: false,
  165. striped: false,
  166. useSearchForm: true,
  167. bordered: true,
  168. showIndexColumn: false,
  169. canResize: false,
  170. actionColumn: {
  171. width: 120,
  172. title: '详情',
  173. dataIndex: 'action',
  174. slots: { customRender: 'action' },
  175. fixed: undefined,
  176. },
  177. });
  178. // 注册历史数据表格
  179. const [registerHistoryTable] = useTable({
  180. dataSource: historicalMinesData,
  181. columns,
  182. formConfig: {
  183. labelWidth: 120,
  184. schemas: searchFormSchema,
  185. showAdvancedButton: false,
  186. },
  187. pagination: false,
  188. striped: false,
  189. useSearchForm: true,
  190. bordered: true,
  191. showIndexColumn: false,
  192. canResize: false,
  193. actionColumn: {
  194. width: 60,
  195. title: '操作',
  196. dataIndex: 'action',
  197. slots: { customRender: 'action' },
  198. fixed: undefined,
  199. },
  200. });
  201. // 弹窗引用
  202. const realtimeModalRef = ref(null);
  203. const historyModalRef = ref(null);
  204. // 打开弹窗方法(区分实时/历史)
  205. const openModal = (record, type) => {
  206. if (type === 'realtime') {
  207. // 可向实时弹窗传递当前记录数据
  208. realtimeModalRef.value?.showModal(record);
  209. } else if (type === 'detail') {
  210. visibleModal.value = true;
  211. } else {
  212. // 可向历史弹窗传递当前记录数据
  213. historyModalRef.value?.showModal(record);
  214. }
  215. };
  216. const handleOkEdit = () => {
  217. visibleModal.value = false;
  218. };
  219. const handleCancelEdit = () => {
  220. visibleModal.value = false;
  221. };
  222. async function fetchAlarmData(id) {
  223. const params = {
  224. alarmType: 'unsealAlarm',
  225. mineId: id,
  226. pageNo: 1,
  227. pageSize: 50,
  228. };
  229. const result = await getProvinceAlarm(params);
  230. minesData.value = result.records;
  231. }
  232. const getMineDataList = async () => {
  233. const params = {
  234. pageNo: 1,
  235. pageSize: 50,
  236. };
  237. const response = await getMineData(params);
  238. deviceOptions.value = response.records.map((item, index) => {
  239. return {
  240. label: item['mineName'],
  241. value: item['mineCode'],
  242. };
  243. });
  244. };
  245. onMounted(() => {
  246. // 页面挂载时的逻辑
  247. getMineDataList();
  248. });
  249. </script>
  250. <style lang="less" scoped>
  251. .monitoring-page {
  252. padding: 16px;
  253. }
  254. .board-info {
  255. display: grid;
  256. grid-template-columns: repeat(5, auto); /* 3列:改5则为5列 */
  257. gap: auto;
  258. justify-content: start;
  259. flex-wrap: wrap;
  260. box-sizing: border-box;
  261. background-color: #fff;
  262. padding: 10px;
  263. margin: 0 10px;
  264. gap: 100px;
  265. }
  266. .board-item {
  267. box-sizing: border-box;
  268. }
  269. .action-btn {
  270. cursor: pointer;
  271. border: none;
  272. padding: 4px;
  273. }
  274. .action-icon {
  275. width: 16px;
  276. height: 16px;
  277. }
  278. </style>