index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="surface-monitor">
  4. <!-- 顶部统计卡片(getCurrentStatistics) -->
  5. <div class="board-info">
  6. <MiniBoard
  7. v-for="(item, index) in boardDataRef"
  8. :key="index"
  9. type="A"
  10. :label="item.label"
  11. :value="item.value"
  12. layout="label-top"
  13. class="board-item"
  14. />
  15. </div>
  16. <!-- Tab 切换 -->
  17. <Tabs v-model:activeKey="activeTab" type="line" class="common-page-tabs">
  18. <TabPane tab="实时监测" key="realtime">
  19. <BasicTable @register="registerRealtimeTable" :scroll="{ x: 'max-content' }" :style="{ padding: 0 }">
  20. <template #resetBefore>
  21. <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXlsTime"> 导出 </a-button>
  22. </template>
  23. <template #empty>
  24. <span class="empty-placeholder">-</span>
  25. </template>
  26. </BasicTable>
  27. </TabPane>
  28. <TabPane tab="历史数据" key="history">
  29. <BasicTable @register="registerHistoryTable" :scroll="{ x: 'max-content' }" :style="{ padding: 0 }">
  30. <template #resetBefore>
  31. <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
  32. </template>
  33. </BasicTable>
  34. </TabPane>
  35. </Tabs>
  36. </div>
  37. </template>
  38. <script setup lang="ts">
  39. import { ref } from 'vue';
  40. import { BasicTable } from '/@/components/Table';
  41. import { Tabs, TabPane } from 'ant-design-vue';
  42. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  43. import { useListPage } from '/@/hooks/system/useListPage';
  44. import { boardData, columns, historyColumns, historySchemas, schemas } from './surfaceMonitor.data';
  45. import { getMineData } from './surfaceMonitor.api';
  46. import { getCurrentStatistics } from '/@/api/workingface';
  47. import { useInitForm } from './hooks/form';
  48. // 路由参数初始化(迁移自密闭监测)
  49. const { departId, rawcode } = useInitForm();
  50. // 激活的Tab页签
  51. const activeTab = ref('realtime');
  52. // ====== 顶部统计卡片(getCurrentStatistics)======
  53. const boardDataRef = ref(boardData.map((item) => ({ ...item })));
  54. async function loadBoardData(params?: any) {
  55. try {
  56. const result = await getCurrentStatistics({ deptId: params?.deptId });
  57. boardDataRef.value[0].value = result.accessMineNum ?? '-';
  58. const onlineRate = result.areaNum ? Math.round((result.areaOnlineNum / result.areaNum) * 100) : '-';
  59. boardDataRef.value[1].value = onlineRate === '-' ? '-' : `${onlineRate}%`;
  60. boardDataRef.value[2].value = result.exceptionNum ?? '-';
  61. boardDataRef.value[3].value = result.suspectedNum ?? '-';
  62. } catch {
  63. // 使用默认值
  64. }
  65. }
  66. // ====== 实时监测表格(getMineData)======
  67. const wrappedGetMineData = (params) => {
  68. return Promise.all([loadBoardData(params), getMineData(params)]).then(([__, res]) => res);
  69. };
  70. const { tableContext: ctxRealtime, onExportXls: onExportXlsTime } = useListPage({
  71. tableProps: {
  72. immediate: false,
  73. columns,
  74. api: wrappedGetMineData,
  75. formConfig: {
  76. autoSearch: true,
  77. labelWidth: 120,
  78. model: { deptId: rawcode },
  79. schemas: [
  80. {
  81. field: 'deptId',
  82. label: '煤矿名称',
  83. component: 'MineCascader',
  84. colProps: { span: 6 },
  85. required: true,
  86. componentProps: {
  87. initFromStore: false,
  88. rootId: departId,
  89. },
  90. },
  91. ...schemas,
  92. ],
  93. showAdvancedButton: false,
  94. schemaGroupNames: ['常规查询'],
  95. },
  96. pagination: true,
  97. striped: true,
  98. useSearchForm: true,
  99. bordered: true,
  100. showIndexColumn: false,
  101. showActionColumn: false,
  102. },
  103. exportConfig: {
  104. url: '/workingface/mineData/exportRealtime',
  105. name: '隐蔽工作面判识实时数据',
  106. params: {},
  107. },
  108. });
  109. const [registerRealtimeTable] = ctxRealtime;
  110. // ====== 历史数据表格(暂无接口,空态占位)======
  111. const { tableContext, onExportXls } = useListPage({
  112. tableProps: {
  113. immediate: false,
  114. columns: historyColumns,
  115. // 历史数据接口暂未提供,返回空分页数据占位
  116. api: async () => ({ records: [], total: 0 }),
  117. formConfig: {
  118. autoSearch: true,
  119. labelWidth: 120,
  120. schemas: [
  121. {
  122. field: 'deptId',
  123. label: '煤矿名称',
  124. component: 'MineCascader',
  125. colProps: { span: 6 },
  126. required: true,
  127. componentProps: {
  128. initFromStore: false,
  129. rootId: departId,
  130. },
  131. },
  132. ...schemas,
  133. ...historySchemas,
  134. ],
  135. showAdvancedButton: false,
  136. schemaGroupNames: ['常规查询'],
  137. },
  138. pagination: true,
  139. striped: true,
  140. useSearchForm: true,
  141. bordered: true,
  142. showIndexColumn: true,
  143. showActionColumn: false,
  144. },
  145. exportConfig: {
  146. url: '/workingface/mineData/exportHistory',
  147. name: '隐蔽工作面判识历史数据',
  148. params: {},
  149. },
  150. });
  151. const [registerHistoryTable] = tableContext;
  152. </script>
  153. <style lang="less" scoped>
  154. @import url(../../analysis/common/board.less);
  155. .surface-monitor {
  156. height: 100%;
  157. overflow-y: auto;
  158. }
  159. .empty-placeholder {
  160. display: block;
  161. text-align: center;
  162. color: #999;
  163. padding: 16px 0;
  164. }
  165. </style>