2 Commits 2cd0110e7f ... 50ff60dd24

Autor SHA1 Mensagem Data
  xiongxing 50ff60dd24 Merge branch 'master' of http://47.107.245.0:3000/xiongxing/kyj-yanglao-web-new há 5 dias atrás
  xiongxing 30bd80db7c 小工具增加各院档案及数据完整率 há 5 dias atrás

+ 7 - 0
src/api/elderly/elder/elderly-Info/index.ts

@@ -194,4 +194,11 @@ export const getWeeklyOperationSummary = () => {
   return request.get({
     url: '/elderlyInfo/getWeeklyOperationSummary'
   })
+}
+
+export const getOtherFilesStatistics = (params) => {
+  return request.get({
+    url: `/elderlyInfo/getOtherFilesStatistics`,
+    params
+  })
 }

+ 6 - 1
src/utils/excel-export.ts

@@ -38,7 +38,7 @@ export const exportMultiSheetExcel = async (sheetData:any, filename:string = 'ex
 /**
  * 自定义表头的Excel导出
  * @param {Array} data - 数据
- * @param {Array} headers - 表头配置 [{key: 'name', title: '姓名'}, ...]
+ * @param {Array} headers - 表头配置 [{key: 'name', title: '姓名', width: 20}, ...]
  * @param {String} filename - 文件名
  * @param {String} sheetName - 工作表名称
  */
@@ -53,6 +53,11 @@ export const exportWithCustomHeaders = async (data:any, headers:any, filename:st
   })
   const wb = XLSX.utils.book_new()
   const ws = XLSX.utils.json_to_sheet(exportData)
+  
+  // 设置列宽
+  const colWidths = headers.map(header => ({ wch: header.width || 15 }))
+  ws['!cols'] = colWidths
+  
   XLSX.utils.book_append_sheet(wb, ws, sheetName)
   XLSX.writeFile(wb, filename)
 }

+ 51 - 7
src/views/system/little-tools/index.vue

@@ -23,6 +23,11 @@ import MarkCheckinBillsPaidForm from "./MarkCheckinBillsPaidForm.vue"
 import AddItemForm from "./AddItemForm.vue"
 import DeleteItemForm from "./DeleteItemForm.vue"
 import {useUserStore} from "@/store/modules/user";
+import { getOtherFilesStatistics } from '@/api/elderly/elder/elderly-Info'
+import { exportWithCustomHeaders } from '@/utils/excel-export'
+import { ElLoading } from 'element-plus'
+import { getUserGroupTenant } from '@/api/system/user'
+
 const message = useMessage() // 消息弹窗
 const userStore = useUserStore()
 const refMarkCheckinBillsPaid = ref()
@@ -36,8 +41,50 @@ const cards = ref([
   { id: 3, title: '统计院区档案上传情况', content: '所有院区的档案上传情况统计' },
 ])
 
-
-
+const handleExportStatistics = async () => {
+  const fullscreenLoading = ElLoading.service({
+    lock: true,
+    text: '正在获取机构数据...',
+    background: 'rgba(0, 0, 0, 0.7)'
+  })
+  try {
+    // 获取机构数据
+    const treeRes = await getUserGroupTenant({ userId: 1 })
+    console.log('getUserGroupTenant 返回:', treeRes)
+    const tenantIds = treeRes.map((item: any) => item.orgTenantId)
+    console.log('tenantIds:', tenantIds)
+    
+    fullscreenLoading.setText('正在导出,请稍候...')
+    
+    const data = await getOtherFilesStatistics({ tenantIds: tenantIds.join(',') })
+    console.log('getOtherFilesStatistics 返回:', data)
+    if (data && data.length > 0) {
+      // 处理数据,添加已上传档案数
+      const processedData = data.map((item: any) => ({
+        ...item,
+        uploadedOtherFilesCount: item.totalCount - item.emptyOtherFilesCount
+      }))
+      
+      const headers = [
+        { key: 'tenantName', title: '机构名称', width: 45 },
+        { key: 'totalCount', title: '长者总数', width: 12 },
+        { key: 'uploadedOtherFilesCount', title: '已上传档案数', width: 15 },
+        { key: 'emptyOtherFilesCount', title: '未上传档案数', width: 15 },
+        { key: 'emptyOtherFilesPercentage', title: '档案为空占比', width: 15 }
+      ]
+      console.log('准备导出的数据:', processedData)
+      await exportWithCustomHeaders(processedData, headers, '各院档案及数据完整率.xlsx')
+      message.success('导出成功')
+    } else {
+      message.warning('没有数据可以导出')
+    }
+  } catch (e) {
+    console.error('导出失败:', e)
+    message.error(e instanceof Error ? e.message : '导出失败')
+  } finally {
+    fullscreenLoading.close()
+  }
+}
 
 const itemClick=(id:any)=>{
   switch (id){
@@ -53,11 +100,8 @@ const itemClick=(id:any)=>{
       deleteItemForm.value.open(undefined,false,"月度费用",undefined,userStore.orgTenantId)
 
       break
-    case 3: //统计院区档案上传情况
-      //1.获取所有院区的tenantId
-      //2.调用接口获取数据
-      //3.导出数据
-
+    case 3: //各院档案及数据完整率
+      handleExportStatistics()
       break
   }