index.vue 9.3 KB

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