index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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="请选择" @change="historyTable.reload" />
  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. await initGoafOptions(params.deptId);
  146. if (!goafId.value) {
  147. return Promise.resolve([]);
  148. }
  149. params.goafId = goafId.value;
  150. return getProvinceAlarmHistory(params);
  151. },
  152. formConfig: {
  153. model: { deptId: hiscode },
  154. labelWidth: 120,
  155. schemas: [
  156. // {
  157. // label: '开始时间',
  158. // field: 'startTime',
  159. // component: 'DatePicker',
  160. // defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  161. // componentProps: {
  162. // showTime: true,
  163. // placeholder: '请选择开始时间',
  164. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  165. // },
  166. // colProps: { span: 6 },
  167. // rules: [{ required: true, message: '请选择开始时间' }],
  168. // },
  169. // {
  170. // label: '结束时间',
  171. // field: 'endTime',
  172. // component: 'DatePicker',
  173. // defaultValue: dayjs(),
  174. // componentProps: {
  175. // showTime: true,
  176. // placeholder: '请选择结束时间',
  177. // valueFormat: 'YYYY-MM-DD HH:mm:ss',
  178. // },
  179. // colProps: { span: 6 },
  180. // rules: [{ required: true, message: '请选择结束时间' }],
  181. // },
  182. {
  183. label: '煤矿名称',
  184. field: 'deptId',
  185. component: 'MineCascader', // 自定义组件名
  186. componentProps: {
  187. initFromStore: false,
  188. syncToStore: false,
  189. changeOnSelect: false,
  190. // onChange: (e) => {
  191. // historyTable.setLoading(true);
  192. // initGoafOptions(e).finally(() => {
  193. // historyTable.setLoading(false);
  194. // });
  195. // },
  196. },
  197. colProps: { span: 6 },
  198. rules: [],
  199. },
  200. ...historicalFormSchema,
  201. ],
  202. showAdvancedButton: false,
  203. schemaGroupNames: ['常规查询'],
  204. },
  205. pagination: true,
  206. striped: true,
  207. useSearchForm: true,
  208. bordered: true,
  209. showIndexColumn: true,
  210. // showActionColumn: false,
  211. },
  212. exportConfig: {
  213. url: '/province/alarm/exportProvinceAlarmHistory',
  214. name: '历史数据',
  215. params: {
  216. alarmType: 'overLimitAlarm',
  217. goafId,
  218. },
  219. },
  220. });
  221. const [registerHistoryTable, historyTable] = tableContext;
  222. async function getAlarmTotalData(p) {
  223. const params = {
  224. ...p,
  225. alarmType: 'overLimitAlarm',
  226. };
  227. const result = await getProvinceAlarmNum(params);
  228. boardData.value[1].value = result.alarmLevel1;
  229. boardData.value[2].value = result.alarmLevel2;
  230. boardData.value[3].value = result.alarmLevel3;
  231. boardData.value[4].value = result.alarmLevel4;
  232. boardData.value[0].value = result.alarmLevel1 + result.alarmLevel2 + result.alarmLevel3 + result.alarmLevel4;
  233. }
  234. /**
  235. * 通用页面跳转方法
  236. * @param record 当前行数据
  237. * @param path 目标路径
  238. */
  239. function handleGoToPageQuery(record: any, path: string) {
  240. advancedRoutePush({
  241. path,
  242. query: { deptId: record.deptId, goafId: record.goafId, filter: 'coVal,co2Val,ch4Val,c2h2Val,c2h4Val,o2Val,temperature' },
  243. });
  244. }
  245. </script>
  246. <style lang="less" scoped>
  247. @import url(../../common/board.less);
  248. </style>