index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="monitoring-page">
  3. <!-- 新增Tabs组件区分实时/历史数据 -->
  4. <Tabs v-model:activeKey="activeTab" type="line" 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' }" :style="{ padding: 0 }">
  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' }" :style="{ padding: 0 }">
  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 { onMounted, ref } 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, historicalMinesData } from './fireAreaJudgeAnalysis.data';
  63. import { getMineData, getProvinceAlarm, getGoafData, getProvinceAlarmHistory, getProvinceAlarmNum } from './fireAreaJudge.api';
  64. // 激活的Tab页签
  65. const activeTab = ref('realtime');
  66. const visibleModal = ref(false);
  67. //煤矿列表数据
  68. const deviceOptions = ref([]);
  69. const goafOptions = ref([]);
  70. const mineCode = ref('');
  71. const goafId = ref('');
  72. const boardData = ref([
  73. {
  74. label: '采空区数量',
  75. value: '',
  76. },
  77. {
  78. label: '可以启封',
  79. value: '',
  80. },
  81. {
  82. label: '不可启封',
  83. value: '',
  84. },
  85. ]);
  86. const minesData = ref([]);
  87. // 注册实时数据表格
  88. const [registerTable] = useTable({
  89. dataSource: minesData,
  90. columns,
  91. api: getProvinceAlarm,
  92. formConfig: {
  93. labelWidth: 120,
  94. schemas: [
  95. {
  96. label: '煤矿名称',
  97. field: 'mineCode', // 对应组件的value.mineCode(最终传给Table的查询参数)
  98. component: 'MineCascader', // 自定义组件名
  99. colProps: { span: 6 },
  100. rules: [],
  101. },
  102. ],
  103. showAdvancedButton: false,
  104. schemaGroupNames: ['常规查询'],
  105. },
  106. pagination: false,
  107. striped: false,
  108. useSearchForm: true,
  109. bordered: true,
  110. showIndexColumn: false,
  111. canResize: false,
  112. actionColumn: {
  113. width: 120,
  114. title: '详情',
  115. dataIndex: 'action',
  116. slots: { customRender: 'action' },
  117. fixed: undefined,
  118. },
  119. });
  120. // 注册历史数据表格
  121. const [registerHistoryTable] = useTable({
  122. dataSource: historicalMinesData,
  123. columns,
  124. api: getProvinceAlarmHistory,
  125. formConfig: {
  126. labelWidth: 120,
  127. schemas: [
  128. {
  129. label: '开始时间',
  130. field: 'startTime',
  131. component: 'DatePicker',
  132. componentProps: {
  133. showTime: true,
  134. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  135. placeholder: '请选择开始时间',
  136. },
  137. colProps: { span: 6 }, // 占比可根据布局调整
  138. rules: [{ required: true, message: '请选择开始时间' }],
  139. },
  140. {
  141. label: '结束时间',
  142. field: 'endTime',
  143. component: 'DatePicker',
  144. componentProps: {
  145. showTime: true,
  146. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  147. placeholder: '请选择结束时间',
  148. },
  149. colProps: { span: 6 },
  150. rules: [{ required: true, message: '请选择结束时间' }],
  151. },
  152. {
  153. label: '煤矿名称',
  154. field: 'mineCode', // 对应组件的value.mineCode(最终传给Table的查询参数)
  155. component: 'MineCascader', // 自定义组件名
  156. componentProps: {
  157. onChange: async (e, option) => {
  158. mineCode.value = e;
  159. await getGoafDataList(e);
  160. },
  161. },
  162. colProps: { span: 6 },
  163. rules: [],
  164. },
  165. {
  166. label: '采空区查询',
  167. field: 'goafId',
  168. component: 'Select',
  169. defaultValue: goafOptions.value[0] ? goafOptions.value[0]['value'] : '',
  170. componentProps: {
  171. showSearch: true,
  172. filterOption: (input: string, option: any) => {
  173. return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  174. },
  175. options: goafOptions,
  176. onChange: async (e, option) => {
  177. goafId.value = e;
  178. },
  179. },
  180. colProps: {
  181. span: 6,
  182. },
  183. },
  184. {
  185. field: 'alarmFiled',
  186. label: '预警字段',
  187. component: 'Select',
  188. componentProps: {
  189. options: [
  190. { label: '甲烷', value: 'ch4Val' },
  191. { label: '氧气', value: 'o2Val' },
  192. { label: '一氧化碳', value: 'coVal' },
  193. { label: '二氧化碳', value: 'co2Val' },
  194. { label: '乙烯', value: 'c2h4Val' },
  195. { label: '乙炔', value: 'c2h2Val' },
  196. { label: '压差', value: 'sourcePressure' },
  197. { label: '温度', value: 'temperature' },
  198. ],
  199. },
  200. colProps: { span: 6 },
  201. },
  202. ],
  203. showAdvancedButton: false,
  204. schemaGroupNames: ['常规查询'],
  205. },
  206. pagination: false,
  207. striped: false,
  208. useSearchForm: true,
  209. bordered: true,
  210. showIndexColumn: false,
  211. canResize: false,
  212. actionColumn: {
  213. width: 60,
  214. title: '操作',
  215. dataIndex: 'action',
  216. slots: { customRender: 'action' },
  217. fixed: undefined,
  218. },
  219. });
  220. // 弹窗引用
  221. const realtimeModalRef = ref(null);
  222. const historyModalRef = ref(null);
  223. // 打开弹窗方法(区分实时/历史)
  224. const openModal = (record, type) => {
  225. if (type === 'realtime') {
  226. // 可向实时弹窗传递当前记录数据
  227. realtimeModalRef.value?.showModal(record);
  228. } else if (type === 'detail') {
  229. visibleModal.value = true;
  230. } else {
  231. // 可向历史弹窗传递当前记录数据
  232. historyModalRef.value?.showModal(record);
  233. }
  234. };
  235. const handleOkEdit = () => {
  236. visibleModal.value = false;
  237. };
  238. const handleCancelEdit = () => {
  239. visibleModal.value = false;
  240. };
  241. async function fetchAlarmData(id) {
  242. const params = {
  243. alarmType: 'unsealAlarm',
  244. mineId: id,
  245. pageNo: 1,
  246. pageSize: 50,
  247. };
  248. const result = await getProvinceAlarm(params);
  249. minesData.value = result.records;
  250. }
  251. const getMineDataList = async () => {
  252. const params = {
  253. pageNo: 1,
  254. pageSize: 50,
  255. };
  256. const response = await getMineData(params);
  257. deviceOptions.value = response.records.map((item, index) => {
  258. return {
  259. label: item['mineName'],
  260. value: item['mineCode'],
  261. };
  262. });
  263. };
  264. const getGoafDataList = async (mineId) => {
  265. const params = {
  266. mineCode: mineId,
  267. };
  268. const response = await getGoafData(params);
  269. goafOptions.value = response.map((item, index) => {
  270. return {
  271. label: item['devicePos'],
  272. value: item['deviceCode'],
  273. };
  274. });
  275. };
  276. async function getAlarmTotalData() {
  277. const params = {
  278. alarmType: 'unsealAlarm',
  279. };
  280. const result = await getProvinceAlarmNum(params);
  281. boardData.value[1].value = result.alarmLevel5;
  282. boardData.value[2].value = result.alarmLevel1 + result.alarmLevel2 + result.alarmLevel3 + result.alarmLevel4;
  283. boardData.value[0].value = result.alarmLevel1 + result.alarmLevel2 + result.alarmLevel3 + result.alarmLevel4 + result.alarmLevel5;
  284. }
  285. onMounted(() => {
  286. // 页面挂载时的逻辑
  287. getMineDataList();
  288. getAlarmTotalData();
  289. });
  290. </script>
  291. <style lang="less" scoped>
  292. .monitoring-page {
  293. padding: 16px;
  294. }
  295. .board-info {
  296. display: grid;
  297. grid-template-columns: repeat(5, auto); /* 3列:改5则为5列 */
  298. gap: auto;
  299. justify-content: start;
  300. flex-wrap: wrap;
  301. box-sizing: border-box;
  302. background-color: #fff;
  303. padding: 10px;
  304. // margin: 0 10px;
  305. margin-bottom: 5px;
  306. gap: 100px;
  307. }
  308. .board-item {
  309. box-sizing: border-box;
  310. }
  311. .action-btn {
  312. cursor: pointer;
  313. border: none;
  314. padding: 4px;
  315. }
  316. .action-icon {
  317. width: 16px;
  318. height: 16px;
  319. }
  320. </style>