3
0

index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. <!-- 已解决按钮 -->
  26. <button @click="openModal(record, 'resolved')" class="action-btn resolved-btn" title="已解决">
  27. <span class="action-text">已解决</span>
  28. </button>
  29. </div>
  30. </template>
  31. </BasicTable>
  32. </TabPane>
  33. <TabPane tab="历史数据" key="history">
  34. <!-- 历史数据表格 -->
  35. <BasicTable @register="registerHistoryTable" :scroll="{ x: 'max-content' }" :style="{ padding: 0 }">
  36. <template #action="{ record }">
  37. <div class="action-buttons">
  38. <button @click="openModal(record, 'history')" class="action-btn">
  39. <SvgIcon name="details" />
  40. </button>
  41. </div>
  42. </template>
  43. </BasicTable>
  44. </TabPane>
  45. </Tabs>
  46. <!-- 弹窗组件 -->
  47. <a-modal
  48. style="top: 30%; left: 170px"
  49. v-model:visible="visibleModal"
  50. :width="450"
  51. title="实时监测数据"
  52. @ok="handleOkEdit"
  53. @cancel="handleCancelEdit"
  54. >
  55. <a-table></a-table>
  56. </a-modal>
  57. <!-- 弹窗组件 -->
  58. <a-modal
  59. style="height: 400px"
  60. v-model:visible="visibleresolveModal"
  61. :width="600"
  62. centered
  63. title="密闭漏风处理情况"
  64. @ok="handleOkEdit()"
  65. @cancel="handleCancelEdit"
  66. >
  67. <a-textarea style="width: 90%; margin-left: 20px; margin-right: 20px" v-model:value="resolveValue" placeholder="请输入解决情况" :rows="4" />
  68. </a-modal>
  69. </div>
  70. </template>
  71. <script setup lang="ts">
  72. import { ref, onMounted } from 'vue';
  73. import { BasicTable, useTable } from '/@/components/Table';
  74. import { Tabs, TabPane } from 'ant-design-vue';
  75. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  76. import { SvgIcon } from '/@/components/Icon';
  77. // 引入模拟数据
  78. import { columns, searchFormSchema, historicalMinesData } from './pressureDiffAnalysis.data';
  79. import { getMineData, getProvinceAlarm, getGoafData, getProvinceAlarmHistory, getProvinceAlarmNum } from './pressureDiff.api';
  80. // 激活的Tab页签
  81. const activeTab = ref('realtime');
  82. const visibleModal = ref(false);
  83. const visibleresolveModal = ref(false);
  84. const resolveValue = ref('');
  85. //煤矿列表数据
  86. const deviceOptions = ref([]);
  87. const goafOptions = ref([]);
  88. const mineCode = ref('');
  89. const goafId = ref('');
  90. const boardData = ref([
  91. {
  92. label: '存在风险情况数量',
  93. value: '',
  94. },
  95. {
  96. label: '低风险',
  97. value: '',
  98. },
  99. {
  100. label: '一般风险',
  101. value: '',
  102. },
  103. {
  104. label: '较高风险',
  105. value: '',
  106. },
  107. {
  108. label: '高风险',
  109. value: '',
  110. },
  111. ]);
  112. const minesData = ref([]);
  113. // 注册实时数据表格
  114. const [registerTable] = useTable({
  115. dataSource: minesData,
  116. columns,
  117. api: getProvinceAlarm,
  118. formConfig: {
  119. labelWidth: 120,
  120. schemas: [
  121. {
  122. label: '煤矿名称',
  123. field: 'mineCode', // 对应组件的value.mineCode(最终传给Table的查询参数)
  124. component: 'MineCascader', // 自定义组件名
  125. colProps: { span: 6 },
  126. rules: [],
  127. },
  128. ],
  129. showAdvancedButton: false,
  130. schemaGroupNames: ['常规查询'],
  131. },
  132. pagination: false,
  133. striped: false,
  134. useSearchForm: true,
  135. bordered: true,
  136. showIndexColumn: false,
  137. canResize: false,
  138. actionColumn: {
  139. width: 120,
  140. title: '操作',
  141. dataIndex: 'action',
  142. slots: { customRender: 'action' },
  143. fixed: undefined,
  144. },
  145. });
  146. // 注册历史数据表格
  147. const [registerHistoryTable] = useTable({
  148. dataSource: historicalMinesData,
  149. columns,
  150. api: getProvinceAlarmHistory,
  151. formConfig: {
  152. labelWidth: 120,
  153. schemas: [
  154. {
  155. label: '开始时间',
  156. field: 'startTime',
  157. component: 'DatePicker',
  158. componentProps: {
  159. showTime: true,
  160. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  161. placeholder: '请选择开始时间',
  162. },
  163. colProps: { span: 6 }, // 占比可根据布局调整
  164. rules: [{ required: true, message: '请选择开始时间' }],
  165. },
  166. {
  167. label: '结束时间',
  168. field: 'endTime',
  169. component: 'DatePicker',
  170. componentProps: {
  171. showTime: true,
  172. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  173. placeholder: '请选择结束时间',
  174. },
  175. colProps: { span: 6 },
  176. rules: [{ required: true, message: '请选择结束时间' }],
  177. },
  178. {
  179. label: '煤矿名称',
  180. field: 'mineCode', // 对应组件的value.mineCode(最终传给Table的查询参数)
  181. component: 'MineCascader', // 自定义组件名
  182. componentProps: {
  183. onChange: async (e, option) => {
  184. mineCode.value = e;
  185. await getGoafDataList(e);
  186. },
  187. },
  188. colProps: { span: 6 },
  189. rules: [],
  190. },
  191. {
  192. label: '采空区查询',
  193. field: 'goafId',
  194. component: 'Select',
  195. defaultValue: goafOptions.value[0] ? goafOptions.value[0]['value'] : '',
  196. componentProps: {
  197. showSearch: true,
  198. filterOption: (input: string, option: any) => {
  199. return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  200. },
  201. options: goafOptions,
  202. onChange: async (e, option) => {
  203. goafId.value = e;
  204. },
  205. },
  206. colProps: {
  207. span: 6,
  208. },
  209. },
  210. {
  211. field: 'alarmFiled',
  212. label: '预警字段',
  213. component: 'Select',
  214. componentProps: {
  215. options: [
  216. { label: '甲烷', value: 'ch4Val' },
  217. { label: '氧气', value: 'o2Val' },
  218. { label: '一氧化碳', value: 'coVal' },
  219. { label: '二氧化碳', value: 'co2Val' },
  220. { label: '乙烯', value: 'c2h4Val' },
  221. { label: '乙炔', value: 'c2h2Val' },
  222. { label: '压差', value: 'sourcePressure' },
  223. { label: '温度', value: 'temperature' },
  224. ],
  225. },
  226. colProps: { span: 6 },
  227. },
  228. ],
  229. showAdvancedButton: false,
  230. schemaGroupNames: ['常规查询'],
  231. },
  232. pagination: false,
  233. striped: false,
  234. useSearchForm: true,
  235. bordered: true,
  236. showIndexColumn: false,
  237. canResize: false,
  238. actionColumn: {
  239. width: 120,
  240. title: '操作',
  241. dataIndex: 'action',
  242. slots: { customRender: 'action' },
  243. fixed: undefined,
  244. },
  245. });
  246. // 弹窗引用
  247. const realtimeModalRef = ref(null);
  248. const historyModalRef = ref(null);
  249. // 打开弹窗方法(区分实时/历史)
  250. const openModal = (record, type) => {
  251. if (type === 'realtime') {
  252. // 可向实时弹窗传递当前记录数据
  253. realtimeModalRef.value?.showModal(record);
  254. } else if (type === 'resolved') {
  255. visibleresolveModal.value = true;
  256. record.isResolved = resolveValue.value || '';
  257. } else if (type === 'detail') {
  258. visibleModal.value = true;
  259. } else {
  260. // 可向历史弹窗传递当前记录数据
  261. historyModalRef.value?.showModal(record);
  262. }
  263. };
  264. const handleOkEdit = () => {
  265. visibleresolveModal.value = false;
  266. };
  267. const handleCancelEdit = () => {
  268. visibleresolveModal.value = false;
  269. };
  270. // async function fetchAlarmData(id) {
  271. // const params = {
  272. // // 填写所需参数
  273. // alarmType: 'sourcePressureAlarm',
  274. // mineId: id,
  275. // pageNo: 1,
  276. // pageSize: 50,
  277. // };
  278. // const result = await getProvinceAlarm(params);
  279. // minesData.value = result.records;
  280. // }
  281. const getMineDataList = async () => {
  282. const params = {
  283. pageNo: 1,
  284. pageSize: 50,
  285. };
  286. const response = await getMineData(params);
  287. deviceOptions.value = response.records.map((item, index) => {
  288. return {
  289. label: item['mineName'],
  290. value: item['mineCode'],
  291. };
  292. });
  293. };
  294. const getGoafDataList = async (mineId) => {
  295. const params = {
  296. mineCode: mineId,
  297. };
  298. const response = await getGoafData(params);
  299. goafOptions.value = response.map((item, index) => {
  300. return {
  301. label: item['devicePos'],
  302. value: item['deviceCode'],
  303. };
  304. });
  305. };
  306. async function getAlarmTotalData() {
  307. const params = {
  308. alarmType: 'sourcePressureAlarm',
  309. };
  310. const result = await getProvinceAlarmNum(params);
  311. boardData.value[1].value = result.alarmLevel1;
  312. boardData.value[2].value = result.alarmLevel2;
  313. boardData.value[3].value = result.alarmLevel3;
  314. boardData.value[4].value = result.alarmLevel4;
  315. boardData.value[0].value = result.alarmLevel1 + result.alarmLevel2 + result.alarmLevel3 + result.alarmLevel4;
  316. }
  317. onMounted(() => {
  318. // 页面挂载时的逻辑
  319. getMineDataList();
  320. getAlarmTotalData();
  321. });
  322. </script>
  323. <style lang="less" scoped>
  324. .monitoring-page {
  325. padding: 16px;
  326. }
  327. .board-info {
  328. display: grid;
  329. grid-template-columns: repeat(5, auto); /* 3列:改5则为5列 */
  330. gap: auto;
  331. justify-content: start;
  332. flex-wrap: wrap;
  333. box-sizing: border-box;
  334. background-color: #fff;
  335. padding: 10px;
  336. // margin: 0 10px;
  337. margin-bottom: 5px;
  338. gap: 100px;
  339. }
  340. .board-item {
  341. box-sizing: border-box;
  342. }
  343. .action-buttons {
  344. display: flex;
  345. gap: 8px;
  346. }
  347. .action-btn {
  348. cursor: pointer;
  349. border: none;
  350. padding: 4px;
  351. }
  352. .action-icon {
  353. width: 16px;
  354. height: 16px;
  355. }
  356. .action-text {
  357. font-size: 12px;
  358. color: #6398fc;
  359. }
  360. </style>