index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 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. </template>
  54. <script setup lang="ts">
  55. import { ref, onMounted } from 'vue';
  56. import { BasicTable, useTable } from '/@/components/Table';
  57. import { Tabs, TabPane } from 'ant-design-vue';
  58. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  59. import { SvgIcon } from '/@/components/Icon';
  60. // 引入模拟数据
  61. import { boardData, columns, searchFormSchema, minesData, historicalMinesData } from './overlimitAlarm.data';
  62. import { getMineData, getProvinceAlarm, getGoafData, getProvinceAlarmHistory, getProvinceAlarmNum } from './overlimit.api';
  63. // 激活的Tab页签
  64. const activeTab = ref('realtime');
  65. const visibleModal = ref(false);
  66. //煤矿列表数据
  67. const deviceOptions = ref([]);
  68. const goafOptions = ref([]);
  69. const mineCode = ref('');
  70. const goafId = ref('');
  71. const visibleresolveModal = ref(false);
  72. const resolveValue = 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: 'mineCodeList', // 对应组件的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: 80,
  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. componentProps: {
  178. options: goafOptions,
  179. onChange: async (e, option) => {
  180. goafId.value = e;
  181. },
  182. },
  183. colProps: {
  184. span: 6,
  185. },
  186. },
  187. {
  188. field: 'alarmFiled',
  189. label: '预警字段',
  190. component: 'Select',
  191. componentProps: {
  192. options: [
  193. { label: '甲烷', value: 'ch4Val' },
  194. { label: '氧气', value: 'o2Val' },
  195. { label: '一氧化碳', value: 'coVal' },
  196. { label: '二氧化碳', value: 'co2Val' },
  197. { label: '乙烯', value: 'c2h4Val' },
  198. { label: '乙炔', value: 'c2h2Val' },
  199. { label: '压差', value: 'sourcePressure' },
  200. { label: '温度', value: 'temperature' },
  201. ],
  202. },
  203. colProps: { span: 6 },
  204. },
  205. ],
  206. showAdvancedButton: false,
  207. schemaGroupNames: ['常规查询'],
  208. },
  209. pagination: true,
  210. striped: true,
  211. useSearchForm: true,
  212. bordered: true,
  213. showIndexColumn: false,
  214. // actionColumn: {
  215. // width: 60,
  216. // title: '操作',
  217. // dataIndex: 'action',
  218. // slots: { customRender: 'action' },
  219. // fixed: undefined,
  220. // },
  221. });
  222. // 弹窗引用
  223. const realtimeModalRef = ref(null);
  224. const historyModalRef = ref(null);
  225. // 打开弹窗方法(区分实时/历史)
  226. const openModal = (record, type) => {
  227. if (type === 'realtime') {
  228. // 可向实时弹窗传递当前记录数据
  229. realtimeModalRef.value?.showModal(record);
  230. } else if (type === 'resolved') {
  231. visibleresolveModal.value = true;
  232. record.isResolved = resolveValue.value || '';
  233. } else if (type === 'detail') {
  234. visibleModal.value = true;
  235. } else {
  236. // 可向历史弹窗传递当前记录数据
  237. historyModalRef.value?.showModal(record);
  238. }
  239. };
  240. const handleOkEdit = () => {
  241. visibleresolveModal.value = false;
  242. };
  243. const handleCancelEdit = () => {
  244. visibleresolveModal.value = false;
  245. };
  246. async function fetchAlarmData(id) {
  247. const params = {
  248. alarmType: 'unsealAlarm',
  249. mineId: id,
  250. pageNo: 1,
  251. pageSize: 50,
  252. };
  253. const result = await getProvinceAlarm(params);
  254. minesData.value = result.records;
  255. }
  256. const getMineDataList = async () => {
  257. const params = {
  258. pageNo: 1,
  259. pageSize: 50,
  260. };
  261. const response = await getMineData(params);
  262. deviceOptions.value = response.records.map((item, index) => {
  263. return {
  264. label: item['mineName'],
  265. value: item['mineCode'],
  266. };
  267. });
  268. };
  269. const getGoafDataList = async (mineId) => {
  270. const params = {
  271. mineCode: mineId,
  272. };
  273. const response = await getGoafData(params);
  274. goafOptions.value = response.map((item, index) => {
  275. return {
  276. label: item['devicePos'],
  277. value: item['deviceCode'],
  278. };
  279. });
  280. };
  281. async function getAlarmTotalData() {
  282. const params = {
  283. alarmType: 'overLimitAlarm',
  284. };
  285. const result = await getProvinceAlarmNum(params);
  286. boardData.value[1].value = result.alarmLevel1;
  287. boardData.value[2].value = result.alarmLevel2;
  288. boardData.value[3].value = result.alarmLevel3;
  289. boardData.value[4].value = result.alarmLevel4;
  290. boardData.value[0].value = result.alarmLevel1 + result.alarmLevel2 + result.alarmLevel3 + result.alarmLevel4;
  291. }
  292. onMounted(() => {
  293. // 页面挂载时的逻辑
  294. getMineDataList();
  295. getAlarmTotalData();
  296. });
  297. </script>
  298. <style lang="less" scoped>
  299. .board-info {
  300. display: grid;
  301. grid-template-columns: repeat(5, auto); /* 3列:改5则为5列 */
  302. gap: auto;
  303. justify-content: start;
  304. flex-wrap: wrap;
  305. box-sizing: border-box;
  306. background-color: @white;
  307. padding: 10px;
  308. gap: 100px;
  309. // margin: 0 10px;
  310. margin-bottom: 5px;
  311. }
  312. .board-item {
  313. box-sizing: border-box;
  314. }
  315. </style>