From 67a66170460c3a2fad90e9bfe4791e130f14d0f6 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Fri, 17 Oct 2025 18:26:01 +0800 Subject: [PATCH] up --- src/views/dashboard/index.vue | 45 ++++++++++++++++------- src/views/record/components/addRecord.vue | 2 +- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 6ae8fc5..3149d7f 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -230,6 +230,17 @@ }, // 获取当月员工人数 固定的数据获取 // http://sstt-dangan.ali251.langye.net/api/fill-datas-chart?business_id=20&year=2025&business_type_id=88&area_id=13 + findLastNonZeroTotal(list) { + const sortedKeys = Object.keys(list).sort((a, b) => Number(a) - Number(b)); + for (let i = sortedKeys.length - 1; i >= 0; i--) { + const currentArray = list[sortedKeys[i]]; + const totalItem = currentArray.find(item => item.name === '总人数'); + if (totalItem && totalItem.total > 0) { + return currentArray; // 返回符合条件的数组 + } + } + return null; // 无符合条件的数组时返回null + }, async getPerson(){ const res = await fillChart({ business_id: 20, @@ -239,21 +250,27 @@ }) const monthNum = (new Date()).getMonth() const currentMonth = monthNum===0?'01':String(new Date().getMonth()).padStart(2, '0'); + // const currentMonth = monthNum<10?'0'+monthNum:monthNum + console.log("currentMonth",currentMonth) + const currentMonthData = this.findLastNonZeroTotal(res.list); + + console.log("currentMonthData",currentMonthData) + if(currentMonthData){ + currentMonthData.forEach(item => { + switch (item.name) { + case "总人数": + this.list.person.total = item.total; // 赋值总人数 + break; + case "管理人员人数": + this.list.person.manage = item.total; // 赋值管理人员人数 + break; + case "服务人员人数": + this.list.person.serve = item.total; // 赋值服务人员人数 + break; + } + }); + } - const currentMonthData = res.list[currentMonth] || []; - currentMonthData.forEach(item => { - switch (item.name) { - case "总人数": - this.list.person.total = item.total; // 赋值总人数 - break; - case "管理人员人数": - this.list.person.manage = item.total; // 赋值管理人员人数 - break; - case "服务人员人数": - this.list.person.serve = item.total; // 赋值服务人员人数 - break; - } - }); }, // 获取财务部 填报的数据内容 // http://sstt-dangan.ali251.langye.net/api/admin/base-form/show?id=15&table_name=businesses&json_data_fields[]=area_ids diff --git a/src/views/record/components/addRecord.vue b/src/views/record/components/addRecord.vue index b282695..a6d7d2b 100644 --- a/src/views/record/components/addRecord.vue +++ b/src/views/record/components/addRecord.vue @@ -71,7 +71,7 @@ 标签: