3
0

index.vue 9.5 KB

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