index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. <!-- 核心:判断record是否有有效数据,无则显示- -->
  20. <template #action="{ record }">
  21. <button @click="openModal(record, 'detail')" class="action-btn detail-btn" title="操作">
  22. <span class="action-text">详情</span>
  23. </button>
  24. </template>
  25. <template #empty>
  26. <!-- 无数据时显示-,样式居中对齐 -->
  27. <span class="empty-placeholder">-</span>
  28. </template>
  29. </BasicTable>
  30. </TabPane>
  31. <TabPane tab="历史数据" key="history">
  32. <!-- 历史数据表格 -->
  33. <BasicTable @register="registerHistoryTable" :scroll="{ x: 'max-content' }" :style="{ padding: 0 }">
  34. <template #action="{ record }">
  35. <div class="action-buttons">
  36. <button @click="openModal(record, 'history')" class="action-btn">
  37. <SvgIcon name="details" />
  38. </button>
  39. </div>
  40. </template>
  41. </BasicTable>
  42. </TabPane>
  43. </Tabs>
  44. <!-- 弹窗组件 -->
  45. <a-modal
  46. style="top: 30%; left: 170px"
  47. v-model:visible="visibleModal"
  48. :width="450"
  49. title="实时监测数据"
  50. @ok="handleOkEdit"
  51. @cancel="handleCancelEdit"
  52. >
  53. <a-table></a-table>
  54. </a-modal>
  55. </template>
  56. <script setup lang="ts">
  57. import { ref, onMounted } from 'vue';
  58. import { BasicTable, useTable } from '/@/components/Table';
  59. import { Tabs, TabPane } from 'ant-design-vue';
  60. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  61. import { SvgIcon } from '/@/components/Icon';
  62. // 引入模拟数据
  63. import { boardData, columns, searchFormSchema, historicalMinesData } from './sealRiskJudgeAnalysis.data';
  64. import { getMineData, getProvinceAlarm, getGoafData, getProvinceAlarmHistory, getProvinceAlarmNum } from './sealRiskJudge.api';
  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 boardData = ref([
  74. {
  75. label: '采空区数量',
  76. value: '',
  77. },
  78. {
  79. label: '增减风安全区',
  80. value: '',
  81. },
  82. {
  83. label: '减风危险区',
  84. value: '',
  85. },
  86. {
  87. label: '增风危险区',
  88. value: '',
  89. },
  90. {
  91. label: '爆炸危险区',
  92. value: '',
  93. },
  94. ]);
  95. const minesData = ref([]);
  96. // 注册实时数据表格
  97. const [registerTable] = useTable({
  98. dataSource: minesData,
  99. columns,
  100. api: getProvinceAlarm,
  101. formConfig: {
  102. labelWidth: 120,
  103. schemas: [
  104. {
  105. label: '煤矿名称',
  106. field: 'mineCode', // 对应组件的value.mineCode(最终传给Table的查询参数)
  107. component: 'MineCascader', // 自定义组件名
  108. colProps: { span: 6 },
  109. rules: [],
  110. },
  111. ],
  112. showAdvancedButton: false,
  113. schemaGroupNames: ['常规查询'],
  114. },
  115. pagination: true,
  116. striped: true,
  117. useSearchForm: true,
  118. bordered: true,
  119. showIndexColumn: false,
  120. actionColumn: {
  121. width: 60,
  122. title: '操作',
  123. dataIndex: 'action',
  124. slots: { customRender: 'action' },
  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: 'leakageAlarm',
  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: 'explosionAlarm',
  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>