From 49459f64d5a4e4a40f98715ce650297cf99437a3 Mon Sep 17 00:00:00 2001 From: Euni4U <958079825@qq.com> Date: Mon, 21 Apr 2025 09:14:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/sta/index.vue | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/views/sta/index.vue b/src/views/sta/index.vue index 79a07a4..75c61a5 100644 --- a/src/views/sta/index.vue +++ b/src/views/sta/index.vue @@ -29,7 +29,8 @@ :data="data1" show-summary max-height="650" default-expand-all row-key="orgname" - :tree-props="{ children: 'children' }"> + :tree-props="{ children: 'children' }" + :default-sort="{ prop: 'sum', order: 'descending' }"> @@ -121,12 +122,23 @@ const changeRadio = (e) => { let start = new Date() let date = null switch (e){ - case 2 : break - case 3 : start.setDate(start.getDate() - 7);break - case 4 : start.setMonth(start.getMonth() - 1);break - default : start.setDate(start.getDate() -7) + case 2 : + start = new Date() + end = new Date() + break + case 3 : + start.setDate(start.getDate() - 7) + break + case 4 : + start.setMonth(start.getMonth() - 1) + break + default : + start.setDate(start.getDate() - 7) } time.value = [formatDate(start,'YYYY-MM-DD'),formatDate(end,'YYYY-MM-DD')] + // 清空现有数据 + data1.value = [] + // 重新获取数据 getList() } const changeDatePick = () => { @@ -137,16 +149,23 @@ const changeDatePick = () => { * 获取统计数据 */ const getList = async ()=>{ + // 清空现有数据 + data1.value = [] + const params = { dates: [ dayjs(time.value[0]).format('YYYY-MM-DD'), dayjs(time.value[1]).format('YYYY-MM-DD') ] } - let resp = await PatientApi.getData(params) - const rawData = toRaw(resp) - data1.value = dataProcessing(rawData) - console.log(data1.value) + try { + let resp = await PatientApi.getData(params) + const rawData = toRaw(resp) + data1.value = dataProcessing(rawData) + console.log(data1.value) + } catch (error) { + console.error('获取数据失败:', error) + } } /** * 统计数据处理