From b48d89d38904bb4fff1e64ba8c03b763e71a4a27 Mon Sep 17 00:00:00 2001 From: bestlee Date: Tue, 29 Sep 2026 13:09:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E9=97=B4=E4=B8=BB=E4=BB=BB=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/api/statistics.ts | 3 +- src/views/home/modules/template7.vue | 47 +++++++++++++++++++++------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/service/api/statistics.ts b/src/service/api/statistics.ts index 9cd7fd9..4f2a95d 100644 --- a/src/service/api/statistics.ts +++ b/src/service/api/statistics.ts @@ -23,10 +23,11 @@ export function homeSafeApi() { }); } // 首页(车间主任) -export function homeManagerApi() { +export function homeManagerApi(params: {from: string | null, to: string | null}) { return request({ url: `/api/workbench/dept`, method: 'get', + params }); } // 首页(分管领导) diff --git a/src/views/home/modules/template7.vue b/src/views/home/modules/template7.vue index 6b79088..156a7b0 100644 --- a/src/views/home/modules/template7.vue +++ b/src/views/home/modules/template7.vue @@ -3,7 +3,7 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'; import { Icon } from '@iconify/vue' import { useThemeStore } from '@/store/modules/theme'; import { useRouterPush } from '@/hooks/common/router'; -import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common'; +import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor, formatTimestamp, getTimeRangeStamp } from '@/utils/common'; import RingChart from "./ringChart.vue"; import { systemConfigApi } from "@/service/api/system"; import { urgeApi } from "@/service/api/change"; @@ -26,8 +26,8 @@ const btnLoading = ref(false); // 日期范围 const dateRange = ref('year'); // 自定义日期范围 -const form = ref(null); -const to = ref(null); +const from = ref(getTimeRangeStamp(dateRange.value)?.from ?? null); +const to = ref(getTimeRangeStamp(dateRange.value)?.to ?? null); // 变更临期天数 const remindDays = ref(0); // 变更类型列表 @@ -40,12 +40,32 @@ let timer: any = null; // 首页数据 const homeData = ref(null); -// 时间范围改变 -const timeChange = (type: string, value: number | null) => { +// 时间范围切换 +const timeChange = (val: string) => { + console.log(val); + dateRange.value = val; + if(val === 'custom'){ + from.value = null; + to.value = null; + return + }else{ + from.value = getTimeRangeStamp(val)?.from ?? null; + to.value = getTimeRangeStamp(val)?.to ?? null; + } + getData(); +} +// 自定义时间选择 +const customTimeChange = (type:string,val:any) => { if(type === 'start'){ - form.value = value; - }else if(type === 'end'){ - to.value = value; + from.value = val; + }else{ + to.value = val; + } + if(from.value && to.value){ + if(from.value > to.value){ + return window.$message?.warning('开始时间不能大于结束时间'); + } + getData(); } } @@ -99,7 +119,10 @@ const matchObj = (list:any,val:number) => { // 获取数据 const getData = async () => { loading.value = true; - const {data,error} = await homeManagerApi(); + const {data,error} = await homeManagerApi({ + from: formatTimestamp(from.value,'yyyy-MM-dd'), + to: formatTimestamp(to.value,'yyyy-MM-dd'), + }); if(!error){ homeData.value = data; } @@ -501,12 +524,12 @@ onUnmounted(() => {

本车间统计

一车间 · 近一年

- +
- + 至 - +