소스 검색

[Feat 0000] 对接数据质量、密闭监测的导出功能

houzekong 3 달 전
부모
커밋
654cb65cd5
2개의 변경된 파일82개의 추가작업 그리고 130개의 파일을 삭제
  1. 75 126
      src/views/dashboard/basicInfo/dataQuality/index.vue
  2. 7 4
      src/views/monitor/sealedMonitor/index.vue

+ 75 - 126
src/views/dashboard/basicInfo/dataQuality/index.vue

@@ -6,7 +6,7 @@
       <BasicTable style="padding: 0" @register="registerUnresolvedTable">
         <template #resetBefore>
           <a-button type="primary" class="ml-8px" preIcon="mdi:page-next-outline" @click="handleOpenModal({}, 'add')"> 新增问题 </a-button>
-          <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="handleExportExcel"> 导出 </a-button>
+          <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXlsA"> 导出 </a-button>
         </template>
         <!-- <template #submitBefore>
           <a-button type="primary" preIcon="mdi:page-next-outline" @click="handleOpenModal({}, 'add')"> 新增问题 </a-button>
@@ -61,7 +61,7 @@
     <TabPane key="resolved" tab="已解决">
       <BasicTable style="padding: 0" @register="registerResolvedTable">
         <template #resetBefore>
-          <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="handleExportExcel"> 导出 </a-button>
+          <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXlsB"> 导出 </a-button>
         </template>
         <template #queJson="{ record }">
           <div style="display: flex; align-items: center; gap: 8px; width: 100%">
@@ -90,7 +90,7 @@
 <script setup lang="ts">
   import { ref, nextTick, computed, onMounted } from 'vue';
   import { useRouter } from 'vue-router';
-  import { BasicTable, useTable } from '/@/components/Table';
+  import { BasicTable } from '/@/components/Table';
   import { useModal } from '/@/components/Modal';
   import { Tabs, TabPane, Popconfirm, message } from 'ant-design-vue';
   import DataQualityModal from './components/DataQualityModal.vue';
@@ -101,7 +101,8 @@
   import { useMineDepartmentStore } from '/@/store/modules/mine';
   import { getDictItemsByCode } from '/@/utils/dict';
   import dayjs from 'dayjs';
-  import * as XLSX from 'xlsx';
+  import { useListPage } from '/@/hooks/system/useListPage';
+
   // 路由实例
   const router = useRouter();
   // 实例化矿井Store
@@ -163,63 +164,85 @@
   const searchFormSchema = computed(() => getSearchFormSchema(dynamicProductionStatusOptions));
 
   // 未解决表格注册
-  const [registerUnresolvedTable, { reload: reloadUnresolved }] = useTable({
-    api: async (params: any) => {
-      return await getDataQuaQueList({ ...params, isOk: false });
-    },
-    columns: columns, // 绑定动态列
-    formConfig: {
-      labelWidth: 120,
-      schemas: searchFormSchema.value,
-      showAdvancedButton: false,
-      schemaGroupNames: ['常规查询'],
-      actionColOptions: { span: 6 },
-    },
-    useSearchForm: true,
-    pagination: true,
-    showIndexColumn: false,
-    indexColumnProps: {
-      title: '序号',
+  const { tableContext: tableContextA, onExportXls: onExportXlsA } = useListPage({
+    tableProps: {
+      api: async (params: any) => {
+        return await getDataQuaQueList({ ...params, isOk: false });
+      },
+      columns: columns, // 绑定动态列
+      formConfig: {
+        labelWidth: 120,
+        schemas: searchFormSchema.value,
+        showAdvancedButton: false,
+        schemaGroupNames: ['常规查询'],
+        actionColOptions: { span: 6 },
+      },
+      useSearchForm: true,
+      pagination: true,
+      showIndexColumn: false,
+      indexColumnProps: {
+        title: '序号',
+      },
+      // canResize: false,
+      actionColumn: {
+        width: 200,
+        title: '操作',
+        dataIndex: 'action',
+        slots: { customRender: 'action' },
+      },
+      immediate: false, // 先不立即加载,等状态数据获取后再加载
     },
-    // canResize: false,
-    actionColumn: {
-      width: 200,
-      title: '操作',
-      dataIndex: 'action',
-      slots: { customRender: 'action' },
+    exportConfig: {
+      url: '/province/dataQuaQue/exportDataQuaQueList',
+      name: '数据质量',
+      params: {
+        isOk: 0,
+      },
     },
-    immediate: false, // 先不立即加载,等状态数据获取后再加载
   });
 
+  const [registerUnresolvedTable, { reload: reloadUnresolved }] = tableContextA;
+
   // 已解决表格注册
-  const [registerResolvedTable, { reload: reloadResolved }] = useTable({
-    api: async (params: any) => {
-      return await getDataQuaQueList({ ...params, isOk: true });
-    },
-    columns: columns,
-    formConfig: {
-      labelWidth: 120,
-      schemas: searchFormSchema.value,
-      showAdvancedButton: false,
-      schemaGroupNames: ['常规查询'],
+  const { tableContext: tableContextB, onExportXls: onExportXlsB } = useListPage({
+    tableProps: {
+      api: async (params: any) => {
+        return await getDataQuaQueList({ ...params, isOk: true });
+      },
+      columns: columns,
+      formConfig: {
+        labelWidth: 120,
+        schemas: searchFormSchema.value,
+        showAdvancedButton: false,
+        schemaGroupNames: ['常规查询'],
+      },
+      useSearchForm: true,
+      pagination: true,
+      striped: true,
+      // bordered: true,
+      showIndexColumn: false,
+      indexColumnProps: {
+        title: '序号',
+      },
+      actionColumn: {
+        width: 60,
+        title: '操作',
+        dataIndex: 'action',
+        slots: { customRender: 'action' },
+      },
+      immediate: false, // 先不立即加载
     },
-    useSearchForm: true,
-    pagination: true,
-    striped: true,
-    // bordered: true,
-    showIndexColumn: false,
-    indexColumnProps: {
-      title: '序号',
+    exportConfig: {
+      url: '/province/dataQuaQue/exportDataQuaQueList',
+      name: '数据质量',
+      params: {
+        isOk: 1,
+      },
     },
-    actionColumn: {
-      width: 60,
-      title: '操作',
-      dataIndex: 'action',
-      slots: { customRender: 'action' },
-    },
-    immediate: false, // 先不立即加载
   });
 
+  const [registerResolvedTable, { reload: reloadResolved }] = tableContextB;
+
   // 弹框注册
   const [registerModal, { openModal }] = useModal();
 
@@ -395,80 +418,6 @@
     }
   }
 
-  /**
-   * 获取全部未解决数据(不分页)
-   */
-  async function getAllUnresolvedData() {
-    try {
-      const res = await getDataQuaQueList({ pageNum: 1, pageSize: 9999, isOk: false });
-      return res.records || [];
-    } catch (error) {
-      console.error('获取未解决数据失败:', error);
-      return [];
-    }
-  }
-
-  /**
-   * 获取全部已解决数据(不分页)
-   */
-  async function getAllResolvedData() {
-    try {
-      const res = await getDataQuaQueList({ pageNum: 1, pageSize: 9999, isOk: true });
-      return res.records || [];
-    } catch (error) {
-      console.error('获取已解决数据失败:', error);
-      return [];
-    }
-  }
-
-  /**
-   * 格式化导出数据(统一字段名 + 状态文本)
-   */
-  function formatExportData(dataList: any[]) {
-    return dataList.map((item) => ({
-      煤矿名称: item.mineName || '',
-      煤矿简称: item.mineNameAbbr || '',
-      生产状态: dynamicProductionStatusMap.value[item.mineProStatus]?.label || '-',
-      在线状态: item.mineLinkStatus === 1 ? '在线' : item.mineLinkStatus === 0 ? '离线' : '/',
-      质量问题详情: formatQueJson(item.queJson),
-      当前状态: item.isOk ? '已解决' : '未解决',
-      处理时间: item.updateTime || '',
-    }));
-  }
-
-  /**
-   * 导出Excel核心方法
-   */
-  async function handleExportExcel() {
-    let hideLoading: () => void = () => {};
-    try {
-      hideLoading = message.loading('正在导出数据,请稍候...');
-
-      const unresolvedList = await getAllUnresolvedData();
-      const resolvedList = await getAllResolvedData();
-
-      const formattedUnresolved = formatExportData(unresolvedList);
-      const formattedResolved = formatExportData(resolvedList);
-
-      const workbook = XLSX.utils.book_new();
-      const unresolvedSheet = XLSX.utils.json_to_sheet(formattedUnresolved);
-      const resolvedSheet = XLSX.utils.json_to_sheet(formattedResolved);
-
-      XLSX.utils.book_append_sheet(workbook, unresolvedSheet, '未解决');
-      XLSX.utils.book_append_sheet(workbook, resolvedSheet, '已解决');
-
-      const fileName = `数据质量问题_${dayjs().format('YYYYMMDDHHmmss')}.xlsx`;
-      XLSX.writeFile(workbook, fileName);
-
-      hideLoading();
-      message.success('导出成功!');
-    } catch (error) {
-      if (hideLoading) hideLoading();
-      console.error('Excel导出失败:', error);
-      message.error('导出失败,请稍后重试');
-    }
-  }
-
   // ========== 初始化:先获取状态数据,再加载表格 ==========
   onMounted(async () => {
     await fetchProductionStatus(); // 先获取动态状态数据

+ 7 - 4
src/views/monitor/sealedMonitor/index.vue

@@ -16,12 +16,12 @@
     <TabPane tab="历史数据监测" key="history">
       <!-- 历史数据表格 -->
       <BasicTable style="padding: 0" @register="registerHistoryTable">
+        <template #resetBefore>
+          <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
+        </template>
         <template #form-goaf-select>
           <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
         </template>
-        <template #afterReset>
-          <a-button type="primary" @click="onExportXls">导出</a-button>
-        </template>
         <!-- <template #action="{ record }">
           <button @click="openModal(record)" class="action-btn">
             <SvgIcon name="details" />
@@ -137,8 +137,11 @@
       showActionColumn: false,
     },
     exportConfig: {
-      url: '/province/alarm/exportProvinceAlarmHistory',
+      url: '/province/device/exportGoafHistory',
       name: '历史数据',
+      params: {
+        goafId,
+      },
     },
     pagination: true,
   });