This commit is contained in:
lnn19986213 2024-05-13 09:42:06 +08:00
parent 59b78327da
commit 3f7964aa2e
3 changed files with 140 additions and 41 deletions

View File

@ -3,20 +3,49 @@
</template> </template>
<script setup > <script setup >
import { onMounted, reactive, ref } from "vue"; import { onBeforeMount, reactive, ref,defineProps } from "vue";
// echarts // echarts
import * as echarts from "echarts"; import * as echarts from "echarts";
const chart = ref(); // DOM const chart = ref(); // DOM
let option = { const props = defineProps({
list1: {
type: Array,
default: () => {
return [];
},
},
list2: {
type: Array,
default: () => {
return [];
},
},
year: {
type: Array,
default: () => {
return [];
},
},
});
const data = reactive({
list1: [],
list2: [],
year: [],
option: {}
})
const getOption = () =>{
data.option = {
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
padding: [20, 10, 20, 10], padding: [20, 10, 20, 10],
formatter: "{b0}<br />{a1}:{c1} <br />{a2}:{c2} ", formatter: "{b0}<br />{a1}:{c1} <br />{a2}:{c2} ",
}, },
legend: { legend: {
data: ["职工养老保险金额", "城乡养老保险金额"], data: ["特困发放人次", "低保发放人次"],
top: "8%", top: "8%",
right: "11%", right: "11%",
textStyle: { textStyle: {
@ -34,7 +63,7 @@ let option = {
xAxis: { xAxis: {
type: "category", type: "category",
// boundaryGap: false, // boundaryGap: false,
data: ["1月", "2月", "3月", "4月", "5月"], data: data.year,
axisLabel: { axisLabel: {
// //
textStyle: { textStyle: {
@ -69,9 +98,8 @@ let option = {
}, },
}, },
{ {
name: "职工养老保险金额", name: "特困发放人次",
type: "line", type: "line",
stack: "Total",
symbol: "emptyCircle", symbol: "emptyCircle",
symbolSize: 10, symbolSize: 10,
@ -80,12 +108,11 @@ let option = {
borderWidth: 1, borderWidth: 1,
color: "#00FCFF", color: "#00FCFF",
}, },
data: [120, 132, 101, 134, 90], data: data.list1,
}, },
{ {
name: "城乡养老保险金额", name: "低保发放人次",
type: "line", type: "line",
stack: "Total",
symbol: "emptyCircle", symbol: "emptyCircle",
symbolSize: 10, symbolSize: 10,
@ -94,27 +121,28 @@ let option = {
borderWidth: 1, borderWidth: 1,
color: "#2468FF", color: "#2468FF",
}, },
data: data.list2,
data: [150, 232, 201, 154, 190],
}, },
], ],
}; };
}
// 使 const setChart = () => {
onMounted(() => {
// domecharts
// var myChart = echarts.init(document.getElementById('main'));
// Vue3 // Vue3
var myChart = echarts.init(chart.value); var myChart = echarts.init(chart.value);
// init(); // vue3.2this
// 使 // 使
myChart.setOption(option); myChart.setOption(data.option);
}
// : // 使
// window.addEventListener("resize", () => { onBeforeMount(() => {
// myChart.resize(); setTimeout(() => {
// }); data.list1 = props.list1
data.list2 = props.list2
data.year = props.year
getOption()
setChart()
}, 600)
}); });
</script> </script>

View File

@ -3,13 +3,42 @@
</template> </template>
<script setup > <script setup >
import { onMounted, reactive, ref } from "vue"; import { onBeforeMount, reactive, ref,defineProps } from "vue";
// echarts // echarts
import * as echarts from "echarts"; import * as echarts from "echarts";
const chart = ref(); // DOM const chart = ref(); // DOM
let option = { const props = defineProps({
list1: {
type: Array,
default: () => {
return [];
},
},
list2: {
type: Array,
default: () => {
return [];
},
},
year: {
type: Array,
default: () => {
return [];
},
},
});
const data = reactive({
list1: [],
list2: [],
year: [],
option: {}
})
const getOption = () =>{
data.option = {
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
formatter: "{b0}<br />{a0}:{c0} <br />{a1}:{c1} ", formatter: "{b0}<br />{a0}:{c0} <br />{a1}:{c1} ",
@ -38,12 +67,12 @@ let option = {
color: "#ffffff", color: "#ffffff",
}, },
}, },
data: ["2019", "2020", "2021", "2022", "2023"], data: data.year,
}, },
{ {
axisTick: false, axisTick: false,
type: "category", type: "category",
data: ["2019", "2020", "2021", "2022", "2023"], data: data.year,
axisLabel: { axisLabel: {
show: false, show: false,
}, },
@ -99,7 +128,7 @@ let option = {
{ {
name: "特困补助金额", name: "特困补助金额",
type: "bar", type: "bar",
data: [2.0, 4.9, 7.0, 23.2, 25.6], data: data.list1,
barWidth: "18%", barWidth: "18%",
itemStyle: { itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
@ -117,7 +146,7 @@ let option = {
{ {
name: "低保补助金额", name: "低保补助金额",
type: "bar", type: "bar",
data: [2.6, 5.9, 9.0, 26.4, 28.7], data: data.list2,
barWidth: "18%", barWidth: "18%",
itemStyle: { itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
@ -144,22 +173,24 @@ let option = {
}, },
], ],
}; };
}
// 使 const setChart = () => {
onMounted(() => {
// domecharts
// var myChart = echarts.init(document.getElementById('main'));
// Vue3 // Vue3
var myChart = echarts.init(chart.value); var myChart = echarts.init(chart.value);
// init(); // vue3.2this
// 使 // 使
myChart.setOption(option); myChart.setOption(data.option);
}
// : // 使
// window.addEventListener("resize", () => { onBeforeMount(() => {
// myChart.resize(); setTimeout(() => {
// }); data.list1 = props.list1
data.list2 = props.list2
data.year = props.year
getOption()
setChart()
}, 600)
}); });
</script> </script>

View File

@ -95,8 +95,8 @@
/> />
</span> </span>
</div> </div>
<eP3 v-if="leftchoose.third == '1'"></eP3> <eP3 v-if="leftchoose.third == '1'" :list1="data.leftbottom1" :list2="data.leftbottom2" :year="data.leftbottomYear"></eP3>
<eP3_2 v-else></eP3_2> <eP3_2 v-else :list1="data.leftbottom3" :list2="data.leftbottom4" :year="data.leftbottomYear"></eP3_2>
</div> </div>
</div> </div>
<div class="displayFlex center_bg"> <div class="displayFlex center_bg">
@ -210,7 +210,14 @@ const data = reactive({
leftCenterYear:[], leftCenterYear:[],
leftbottom1:[], leftbottom1:[],
leftbottom2:[], leftbottom2:[],
leftbottom3:[],
leftbottom4:[],
leftbottomYear:[], leftbottomYear:[],
centerBottom1:[],
centerBottom2:[],
centerBottomYear:[],
zccs1: [],
zccs2: []
}) })
onBeforeMount(() => { onBeforeMount(() => {
getData(); getData();
@ -218,24 +225,57 @@ onBeforeMount(() => {
const getData = () => { const getData = () => {
http.get("/api/ggfwyth/yl").then((res) => { http.get("/api/ggfwyth/yl").then((res) => {
if (res.code == 200) { if (res.code == 200) {
//
//
res.data.endowmentInsurance.ffrc.forEach(element => { res.data.endowmentInsurance.ffrc.forEach(element => {
data.leftTop1.push(element.zgffrc) data.leftTop1.push(element.zgffrc)
data.leftTop2.push(element.cxffrc) data.leftTop2.push(element.cxffrc)
}); });
//
res.data.endowmentInsurance.ffje.forEach(element => { res.data.endowmentInsurance.ffje.forEach(element => {
data.leftTop3.push(element.zgffje) data.leftTop3.push(element.zgffje)
data.leftTop4.push(element.cxffje) data.leftTop4.push(element.cxffje)
}); });
//
data.leftTopYear = res.data.endowmentInsurance.year data.leftTopYear = res.data.endowmentInsurance.year
//
//
res.data.oldAgeSubsidy.btrs.forEach(element => { res.data.oldAgeSubsidy.btrs.forEach(element => {
data.leftCenter1.push(element.ninetyNinetyEight) data.leftCenter1.push(element.ninetyNinetyEight)
data.leftCenter2.push(element.ninetyNine) data.leftCenter2.push(element.ninetyNine)
}); });
//
res.data.oldAgeSubsidy.btje.forEach(element => { res.data.oldAgeSubsidy.btje.forEach(element => {
data.leftCenter3.push(element.ninetyNinetyEight) data.leftCenter3.push(element.ninetyNinetyEight)
data.leftCenter4.push(element.ninetyNine) data.leftCenter4.push(element.ninetyNine)
}); });
data.leftCenterYear = res.data.oldAgeSubsidy.year data.leftCenterYear = res.data.oldAgeSubsidy.year
//
//
res.data.tkdbOldAge.tkdbffrc.forEach(element => {
data.leftbottom1.push(element.tkjzrc)
data.leftbottom2.push(element.dbjzrc)
});
//
res.data.tkdbOldAge.tkdbffje.forEach(element => {
data.leftbottom3.push(element.tkjzje)
data.leftbottom4.push(element.dbjzje)
});
//
data.leftbottomYear = res.data.tkdbOldAge.year
//
res.data.familyPlanning.familyPlanningData.forEach(element => {
data.centerBottom1.push(element.jhsyrs) //
data.centerBottom2.push(element.jhsybtje) //
});
//
data.centerBottomYear = res.data.familyPlanning.year
//
//
res.data.zlfw.xzzccs.forEach(element => {
data.zccs1.push(element.xzjd) //
data.zccs2.push(element.zccs) //
});
} }
}); });
}; };