index.vue 9.3 KB

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