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(() => {

本车间统计

一车间 · 近一年

- +
- + 至 - +