index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. v-for="(item, index) in boardData"
  9. :key="index"
  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="registerRealtimeTable" :scroll="{ x: 'max-content' }" :style="{ padding: 0 }">
  19. <template #action="{ record }">
  20. <div class="action-buttons">
  21. <!-- 操作按钮 -->
  22. <button @click="openModal(record)" class="action-btn resolved-btn" title="解决">
  23. <SvgIcon name="solved" />
  24. </button>
  25. <button @click="handleGoToPageQuery(record, '/warningAnalysis/connectAnalysis')" class="action-btn" title="智能分析数据">
  26. <SvgIcon name="chart" />
  27. </button>
  28. </div>
  29. </template>
  30. <template #resetBefore>
  31. <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXlsTime"> 导出 </a-button>
  32. </template>
  33. </BasicTable>
  34. </TabPane>
  35. <TabPane tab="历史数据" key="history">
  36. <!-- 历史数据表格 -->
  37. <BasicTable @register="registerHistoryTable" :scroll="{ x: 'max-content' }" :style="{ padding: 0 }">
  38. <template #action="{ record }">
  39. <div class="action-buttons">
  40. <button @click="handleGoToPageQuery(record, '/warningAnalysis/connectAnalysis')" class="action-btn" title="智能分析数据">
  41. <SvgIcon name="chart" />
  42. </button>
  43. </div>
  44. </template>
  45. <template #resetBefore>
  46. <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
  47. </template>
  48. <template #form-goaf-select>
  49. <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
  50. </template>
  51. </BasicTable>
  52. </TabPane>
  53. </Tabs>
  54. <!-- 弹窗组件 -->
  55. <BasicModal @register="registerModal" :width="600" :minHeight="100" centered title="处理情况" @ok="handleResolve">
  56. <a-textarea class="ml-10px" :style="{ width: `calc(100% - 20px)` }" v-model:value="resolveValue" placeholder="请输入解决情况" :rows="4" />
  57. </BasicModal>
  58. </template>
  59. <script setup lang="ts">
  60. import { ref } from 'vue';
  61. import { BasicTable } from '/@/components/Table';
  62. import { Tabs, TabPane } from 'ant-design-vue';
  63. // import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  64. import { SvgIcon } from '/@/components/Icon';
  65. // 引入模拟数据
  66. import { columns, schemas } from './overlimitAlarm.data';
  67. import { getProvinceAlarm, getProvinceAlarmHistory, getProvinceAlarmNum } from './overlimit.api';
  68. import { useInitForm } from '../../common/analysis';
  69. import { BasicModal } from '/@/components/Modal/index';
  70. import { historicalFormSchema } from '/@/views/monitor/sealedMonitor/monitor.data';
  71. // import { useIntervalFn } from '@vueuse/core';
  72. import { useListPage } from '/@/hooks/system/useListPage';
  73. import { useRoute } from 'vue-router';
  74. import { advancedRoutePush } from '/@/utils';
  75. const route = useRoute();
  76. // 激活的Tab页签
  77. const activeTab = ref('realtime');
  78. const boardData = ref([
  79. {
  80. label: '存在风险情况数量',
  81. value: '-',
  82. },
  83. {
  84. label: '低风险',
  85. value: '-',
  86. },
  87. {
  88. label: '一般风险',
  89. value: '-',
  90. },
  91. {
  92. label: '较高风险',
  93. value: '-',
  94. },
  95. {
  96. label: '高风险',
  97. value: '-',
  98. },
  99. ]);
  100. const wrappedGetMineData = (params) => {
  101. // 调用原接口
  102. return Promise.all([getAlarmTotalData(params), getProvinceAlarm(params)]).then(([__, res]) => res);
  103. };
  104. // 注册实时数据表格
  105. const { tableContext: ctxRealtime, onExportXls: onExportXlsTime } = useListPage({
  106. tableProps: {
  107. columns,
  108. api: wrappedGetMineData,
  109. formConfig: {
  110. model: { alarmFiled: route.query.alarmFiled },
  111. labelWidth: 120,
  112. schemas,
  113. showAdvancedButton: false,
  114. schemaGroupNames: ['常规查询'],
  115. },
  116. pagination: true,
  117. striped: true,
  118. useSearchForm: true,
  119. bordered: true,
  120. showIndexColumn: false,
  121. actionColumn: {
  122. width: 80,
  123. title: '操作',
  124. dataIndex: 'action',
  125. slots: { customRender: 'action' },
  126. fixed: undefined,
  127. },
  128. },
  129. exportConfig: {
  130. url: '/ventanaly-province/province/alarm/exportProvinceAlarmReal',
  131. name: '超限报警',
  132. params: {
  133. alarmType: 'overLimitAlarm',
  134. },
  135. },
  136. });
  137. const [registerRealtimeTable] = ctxRealtime;
  138. const { goafOptions, goafId, hiscode, resolveValue, registerModal, openModal, initGoafOptions, handleResolve } = useInitForm();
  139. // 注册历史数据表格
  140. const { tableContext, onExportXls } = useListPage({
  141. tableProps: {
  142. columns,
  143. // columns: historyColumns,
  144. api: async (params) => {
  145. if (!goafId.value) {
  146. await initGoafOptions(params.deptId);
  147. }
  148. params.goafId = goafId.value;
  149. return getProvinceAlarmHistory(params);
  150. },
  151. formConfig: {
  152. model: { deptId: hiscode },
  153. labelWidth: 120,
  154. schemas: [
  155. // {
  156. // label: '开始时间',
  157. // field: 'startTime',
  158. // component: 'DatePicker',
  159. // defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  160. // componentProps: {
  161. // showTime: true,
  162. // placeholder: '请选择开始时间',
  163. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  164. // },
  165. // colProps: { span: 6 },
  166. // rules: [{ required: true, message: '请选择开始时间' }],
  167. // },
  168. // {
  169. // label: '结束时间',
  170. // field: 'endTime',
  171. // component: 'DatePicker',
  172. // defaultValue: dayjs(),
  173. // componentProps: {
  174. // showTime: true,
  175. // placeholder: '请选择结束时间',
  176. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  177. // },
  178. // colProps: { span: 6 },
  179. // rules: [{ required: true, message: '请选择结束时间' }],
  180. // },
  181. {
  182. label: '煤矿名称',
  183. field: 'deptId',
  184. component: 'MineCascader', // 自定义组件名
  185. componentProps: {
  186. initFromStore: true,
  187. syncToStore: false,
  188. changeOnSelect: false,
  189. onChange: (e) => {
  190. historyTable.setLoading(true);
  191. initGoafOptions(e).finally(() => {
  192. historyTable.setLoading(false);
  193. });
  194. },
  195. },
  196. colProps: { span: 6 },
  197. rules: [],
  198. },
  199. ...historicalFormSchema,
  200. ],
  201. showAdvancedButton: false,
  202. schemaGroupNames: ['常规查询'],
  203. },
  204. pagination: true,
  205. striped: true,
  206. useSearchForm: true,
  207. bordered: true,
  208. showIndexColumn: true,
  209. // showActionColumn: false,
  210. },
  211. exportConfig: {
  212. url: '/province/alarm/exportProvinceAlarmHistory',
  213. name: '历史数据',
  214. params: {
  215. alarmType: 'overLimitAlarm',
  216. goafId,
  217. },
  218. },
  219. });
  220. const [registerHistoryTable, historyTable] = tableContext;
  221. async function getAlarmTotalData(p) {
  222. const params = {
  223. ...p,
  224. alarmType: 'overLimitAlarm',
  225. };
  226. const result = await getProvinceAlarmNum(params);
  227. boardData.value[1].value = result.alarmLevel1;
  228. boardData.value[2].value = result.alarmLevel2;
  229. boardData.value[3].value = result.alarmLevel3;
  230. boardData.value[4].value = result.alarmLevel4;
  231. boardData.value[0].value = result.alarmLevel1 + result.alarmLevel2 + result.alarmLevel3 + result.alarmLevel4;
  232. }
  233. /**
  234. * 通用页面跳转方法
  235. * @param record 当前行数据
  236. * @param path 目标路径
  237. */
  238. function handleGoToPageQuery(record: any, path: string) {
  239. advancedRoutePush({
  240. path,
  241. query: { deptId: record.deptId, goafId: record.goafId, filter: 'coVal,co2Val,ch4Val,c2h2Val,c2h4Val,o2Val,temperature' },
  242. });
  243. }
  244. </script>
  245. <style lang="less" scoped>
  246. @import url(../../common/board.less);
  247. </style>