diff --git a/src/view/echarts_work/eP1.vue b/src/view/echarts_work/eP1.vue index 50fcd63..83e5a0a 100644 --- a/src/view/echarts_work/eP1.vue +++ b/src/view/echarts_work/eP1.vue @@ -298,12 +298,14 @@ const setChart = () => { }; const setChart1 = () => { + if(data.list.length !== 0) { data.list1 = []; data.list2 = []; - data.list.data.forEach((item) => { - data.list1.push(item.jzrs); //救助人数 - data.list2.push(item.jzje); //救助金额 - }); + data.list.data.forEach((item) => { + data.list1.push(item.jzrs); //救助人数 + data.list2.push(item.jzje); //救助金额 + }); + } }; watch( () => props.list, diff --git a/src/view/echarts_work/eP2.vue b/src/view/echarts_work/eP2.vue index 085f8dd..a948008 100644 --- a/src/view/echarts_work/eP2.vue +++ b/src/view/echarts_work/eP2.vue @@ -294,13 +294,15 @@ const setChart = () => { }; const setChart1 = () => { - data.list1 = []; - data.list2 = []; - data.list.data.forEach((item) => { - data.list1.push(item.jzrs); //救助人数 - data.list2.push(item.jzje); //救助金额 - }); - // console.log("救助人2", data.list1, data.list2); + if (data.list.length !== 0) { + data.list1 = []; + data.list2 = []; + data.list.data.forEach((item) => { + data.list1.push(item.jzrs); //救助人数 + data.list2.push(item.jzje); //救助金额 + }); + // console.log("救助人2", data.list1, data.list2); + } }; watch( () => props.list, diff --git a/src/view/echarts_work/eP3.vue b/src/view/echarts_work/eP3.vue index 78e10e1..60c5371 100644 --- a/src/view/echarts_work/eP3.vue +++ b/src/view/echarts_work/eP3.vue @@ -431,18 +431,20 @@ const setChart = () => { }; const setChart1 = () => { - data.list1 = []; - data.list2 = []; - data.list3 = []; - data.lineData = []; - data.lineData1 = []; - data.list.data.forEach((item) => { - data.lineData.push(item.tkjzje); //特困救助金额 - data.lineData1.push(item.dbjzje); //低保救助金额 - data.list1.push(item.tkjzrs); //特困救助人数 - data.list2.push(item.dbjzrs); //低保救助人数 - data.list3.push(item.dibianJzrs); //低边救助人数 - }); + if (data.list.length !== 0) { + data.list1 = []; + data.list2 = []; + data.list3 = []; + data.lineData = []; + data.lineData1 = []; + data.list.data.forEach((item) => { + data.lineData.push(item.tkjzje); //特困救助金额 + data.lineData1.push(item.dbjzje); //低保救助金额 + data.list1.push(item.tkjzrs); //特困救助人数 + data.list2.push(item.dbjzrs); //低保救助人数 + data.list3.push(item.dibianJzrs); //低边救助人数 + }); + } }; // 使用生命钩子 diff --git a/src/view/work.vue b/src/view/work.vue index 7ae4750..2882936 100644 --- a/src/view/work.vue +++ b/src/view/work.vue @@ -202,6 +202,7 @@ const jz = ref([ choose: "1", }, ]); + const jzChange = (index, value) => { jz.value[index].choose = value; if (index === 0) { @@ -219,6 +220,18 @@ const jzChange = (index, value) => { } }; +const typeSwitching = ref(true); + +const onTypeSwitching = () => { + const toggleShow = () => { + typeSwitching.value = !typeSwitching.value; + const type = typeSwitching.value ? "1" : "2"; + jzChange(0, type); + jzChange(1, type); + }; + setInterval(toggleShow, 2000); // 每2秒切换一次 +}; + const data = reactive({ list: {}, list1: {}, @@ -380,7 +393,8 @@ const getData = async () => { data.disabilitySubsidies.month = res.data.underprivileged.disabilitySubsidies.month; // 困难军人 - data.difficultSoldiers.data = res.data.underprivileged.difficultSoldiers.data; + data.difficultSoldiers.data = + res.data.underprivileged.difficultSoldiers.data; data.difficultSoldiers.year = res.data.underprivileged.difficultSoldiers.year; // 困难职工 @@ -429,6 +443,7 @@ onBeforeMount(() => { }); onMounted(() => { startAutoScroll(); + onTypeSwitching(); });