index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. schemaGroupNames: ['常规查询'],
  164. },
  165. pagination: false,
  166. striped: false,
  167. useSearchForm: true,
  168. bordered: true,
  169. showIndexColumn: false,
  170. canResize: false,
  171. actionColumn: {
  172. width: 120,
  173. title: '详情',
  174. dataIndex: 'action',
  175. slots: { customRender: 'action' },
  176. fixed: undefined,
  177. },
  178. });
  179. // 注册历史数据表格
  180. const [registerHistoryTable] = useTable({
  181. dataSource: historicalMinesData,
  182. columns,
  183. formConfig: {
  184. labelWidth: 120,
  185. schemas: searchFormSchema,
  186. showAdvancedButton: false,
  187. },
  188. pagination: false,
  189. striped: false,
  190. useSearchForm: true,
  191. bordered: true,
  192. showIndexColumn: false,
  193. canResize: false,
  194. actionColumn: {
  195. width: 60,
  196. title: '操作',
  197. dataIndex: 'action',
  198. slots: { customRender: 'action' },
  199. fixed: undefined,
  200. },
  201. });
  202. // 弹窗引用
  203. const realtimeModalRef = ref(null);
  204. const historyModalRef = ref(null);
  205. // 打开弹窗方法(区分实时/历史)
  206. const openModal = (record, type) => {
  207. if (type === 'realtime') {
  208. // 可向实时弹窗传递当前记录数据
  209. realtimeModalRef.value?.showModal(record);
  210. } else if (type === 'detail') {
  211. visibleModal.value = true;
  212. } else {
  213. // 可向历史弹窗传递当前记录数据
  214. historyModalRef.value?.showModal(record);
  215. }
  216. };
  217. const handleOkEdit = () => {
  218. visibleModal.value = false;
  219. };
  220. const handleCancelEdit = () => {
  221. visibleModal.value = false;
  222. };
  223. async function fetchAlarmData(id) {
  224. const params = {
  225. alarmType: 'unsealAlarm',
  226. mineId: id,
  227. pageNo: 1,
  228. pageSize: 50,
  229. };
  230. const result = await getProvinceAlarm(params);
  231. minesData.value = result.records;
  232. }
  233. const getMineDataList = async () => {
  234. const params = {
  235. pageNo: 1,
  236. pageSize: 50,
  237. };
  238. const response = await getMineData(params);
  239. deviceOptions.value = response.records.map((item, index) => {
  240. return {
  241. label: item['mineName'],
  242. value: item['mineCode'],
  243. };
  244. });
  245. };
  246. onMounted(() => {
  247. // 页面挂载时的逻辑
  248. getMineDataList();
  249. });
  250. </script>
  251. <style lang="less" scoped>
  252. .monitoring-page {
  253. padding: 16px;
  254. }
  255. .board-info {
  256. display: grid;
  257. grid-template-columns: repeat(5, auto); /* 3列:改5则为5列 */
  258. gap: auto;
  259. justify-content: start;
  260. flex-wrap: wrap;
  261. box-sizing: border-box;
  262. background-color: #fff;
  263. padding: 10px;
  264. margin: 0 10px;
  265. gap: 100px;
  266. }
  267. .board-item {
  268. box-sizing: border-box;
  269. }
  270. .action-btn {
  271. cursor: pointer;
  272. border: none;
  273. padding: 4px;
  274. }
  275. .action-icon {
  276. width: 16px;
  277. height: 16px;
  278. }
  279. </style>