2 Commits ccd6bb0762 ... 2b80a8e6cb

Autor SHA1 Mensagem Data
  xiongxing 2b80a8e6cb Merge branch 'master' of http://47.107.245.0:3000/xiongxing/kyj-yanglao-web-new 2 semanas atrás
  xiongxing 8d5d124e6e 1.修改批量导出床头卡2.点餐统计增加楼栋楼层搜索 2 semanas atrás

+ 47 - 20
src/views/elderly/elder/elder-file/index.vue

@@ -174,7 +174,7 @@
       <div class="description" style="margin-top: 20px">
         <p>说明:</p>
         <p>1. 请输入需要导出的卡片数量</p>
-        <p>2. 一次导不完的话,输入批次 2 再次导出,以此类推。</p>
+        <p>2. 一次导不完的话,输入批次 2 再次导出,以此类推;除最后一个批次外,请保持每批次数量一致。</p>
         <p>3. 导出的卡将按照列表顺序生成PNG图片压缩包</p>
         <p>4. 建议单次导出数量不超过200张,以免影响系统性能</p>
         <p>5. 导出需要较长时间,请耐心等待。200张大约需要20分钟!</p>
@@ -285,38 +285,65 @@ const startExport = async () => {
     return
   }
 
-  // console.log('开始导出床头卡,数量:', exportCount.value)
-  // message.success(`开始导出${exportCount.value}张床头卡`)
-  //
-  // // 关闭弹窗
-  // dialogVisible.value = false
   loadingImport.value = true
-  // 这里可以添加实际的导出逻辑
 
   try {
-    let queryParams = {
-      pageNo: exportBitch.value,
-      pageSize: exportCount.value,
-      elderName: undefined,
-      inStatus: '1',
-      bedId: undefined,
-      tenantIds: userStore.orgTenantId
+    // 批次 1 时记录基准导出数量;后续批次按该数量计算起始偏移,避免修改数量后出现重复
+    const storageKey = `bed_card_export_${type.value}`
+    let baseCount = exportCount.value
+    if (exportBitch.value === 1) {
+      window.sessionStorage.setItem(storageKey, String(exportCount.value))
+    } else {
+      const stored = window.sessionStorage.getItem(storageKey)
+      if (stored) {
+        baseCount = Number(stored)
+      } else {
+        message.warning('未找到前一批次导出记录,请从批次 1 开始')
+        loadingImport.value = false
+        return
+      }
     }
-    const data = await getElderlyPage(queryParams)
+
+    const offset = (exportBitch.value - 1) * baseCount
+    const needSize = offset + exportCount.value
+
+    // 拉取足够多的数据后本地切片,保证每批数据严格连续
+    let allList: any[] = []
+    let pageNo = 1
+    while (allList.length < needSize) {
+      const pageData = await getElderlyPage({
+        ...queryParams,
+        pageNo,
+        pageSize: 9999
+      })
+      const pageList = pageData.list || []
+      if (!pageList.length) break
+      allList = allList.concat(pageList)
+      if (pageList.length < 9999) break
+      pageNo++
+    }
+
+    if (offset >= allList.length) {
+      message.warning('该批次暂无数据可导出')
+      loadingImport.value = false
+      return
+    }
+
+    const exportList = allList.slice(offset, offset + exportCount.value)
+
     if (type.value == 1) {
-      for (const [index, item] of data.list.entries()) {
+      for (const [index, item] of exportList.entries()) {
         try {
           const res = await getElderHealthRecordById(item.id)
-          // console.log("长者健康档案:",index)
           // 判断是否为最后一个数据
-          const param = index === data.list.length - 1 ? 3 : 2
+          const param = index === exportList.length - 1 ? 3 : 2
           await importCard(res || {}, item, param)
         } catch (e) {}
       }
     } else {
-      for (const [index, item] of data.list.entries()) {
+      for (const [index, item] of exportList.entries()) {
         try {
-          const param = index === data.list.length - 1 ? 3 : 2
+          const param = index === exportList.length - 1 ? 3 : 2
           await importCard(undefined, item, param)
         } catch (e) {}
       }

+ 45 - 1
src/views/elderly/restaurant/order-statistics/index.vue

@@ -15,6 +15,31 @@
       <el-form-item label="点餐月份" prop="month">
         <TgDatePicker type="month" v-model="queryParams.month" class="!w-240px" />
       </el-form-item>
+      <el-form-item label="楼栋">
+        <el-select
+          v-model="queryParams.buildId"
+          placeholder="选择楼栋"
+          style="width: 180px"
+          @change="handleBuildChange"
+        >
+          <el-option
+            v-for="(item, index) in buildList"
+            :key="index"
+            :label="item.buildName"
+            :value="item.id"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="楼层">
+        <el-select v-model="queryParams.floorId" placeholder="选择楼层" style="width: 180px">
+          <el-option
+            v-for="(item, index) in floorList"
+            :key="index"
+            :label="item.floorName"
+            :value="item.id"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item label="长者姓名" prop="elderId">
         <SelectElder v-model="queryParams.elderId" class="!w-240px" />
       </el-form-item>
@@ -78,6 +103,11 @@ import Form from './Form.vue'
 import download from '@/utils/download'
 import Import from "@/components/ImportFile/index.vue";
 import {ref} from "vue";
+import { getBuildList } from '@/api/system/badManage'
+import { useUserStore } from '@/store/modules/user'
+
+const userStore = useUserStore()
+
 defineOptions({ name: 'OrderStatistics' })
 const message = useMessage() // 消息弹窗
 const { t } = useI18n() // 国际化
@@ -90,8 +120,12 @@ const queryParams = reactive({
   restaurantName: undefined,
   month: undefined,
   elderId: undefined,
+   buildId: '',
+  floorId: '',
 })
 const queryFormRef = ref() // 搜索的表单
+const floorList = ref([])
+const buildList = ref([])
 
 /** 查询列表 */
 const getList = async () => {
@@ -123,6 +157,13 @@ const openForm = (row: any = {}, detail: boolean = false) => {
   formRef.value.open(row.id, detail)
 }
 
+const handleBuildChange = (buildId: any) => {
+  const selectedBuild = buildList.value.find((item: any) => item.id === buildId)
+  if (selectedBuild) {
+    floorList.value = selectedBuild.floorList || []
+  }
+}
+
 const handleExport = async () => {
   const data = await exportDishesOrderStatisticsExcel(queryParams)
   download.excel(data, `点餐统计${Date.now()}.xls`)
@@ -165,7 +206,10 @@ const handleDelete = async (id) => {
 }
 
 /** 初始化 **/
-onMounted(() => {
+onMounted(async() => {
   getList()
+  try {
+    buildList.value = await getBuildList({ tenantIds: userStore.orgTenantId[0] })
+  } catch (e) {}
 })
 </script>