index.vue 9.0 KB

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