This commit is contained in:
duanxiaohai 2024-06-04 13:58:49 +08:00
parent 1386572720
commit c2df36a341
2 changed files with 247 additions and 206 deletions

View File

@ -3,17 +3,41 @@
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref } from "vue"; import {
onBeforeMount,
onMounted,
ref,
reactive,
defineProps,
watch,
nextTick,
} from "vue";
// echarts // echarts
import * as echarts from "echarts"; import * as echarts from "echarts";
const props = defineProps({
list: {
type: Array,
default: () => {
return [];
},
},
});
const chart = ref(); // DOM const chart = ref(); // DOM
const data = [120, 200, 150, 80, 70, 110, 130]; const data = reactive({
list: [],
list1: [],
list2: [],
day: [],
option: {},
initialLegendData: ["上门服务时长", "上门服务次数"],
});
const data1 = [120, 200, 150, 80, 70, 110, 130];
const lineData = [150, 230, 224, 218, 135, 147, 260]; const lineData = [150, 230, 224, 218, 135, 147, 260];
const max = data const max = data.list1.concat(data.list2).reduce((pre, cur) => (pre > cur ? pre : cur), 0); //
.concat(lineData)
.reduce((pre, cur) => (pre > cur ? pre : cur), 0); //
// //
const color = [ const color = [
{ {
@ -38,7 +62,8 @@ const color = [
], ],
}, },
]; ];
const option = { const getOption = () => {
data.option = {
color, color,
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
@ -51,7 +76,7 @@ const option = {
}, },
}, },
legend: { legend: {
data: ["上门服务时长", "上门服务次数"], data: data.initialLegendData,
// top: "8%", // top: "8%",
textStyle: { textStyle: {
fontSize: 16, fontSize: 16,
@ -82,12 +107,12 @@ const option = {
axisTick: { axisTick: {
show: false, // show: false, //
}, },
data: ["4.07", "4.08", "4.09", "4.10", "4.11"], data: data.day,
}, },
{ {
type: "category", type: "category",
show: false, show: false,
data: ["4.07", "4.08", "4.09", "4.10", "4.11"], data: data.day,
}, },
], ],
yAxis: [ yAxis: [
@ -128,7 +153,8 @@ const option = {
name: "次数/次", name: "次数/次",
min: 0, min: 0,
max: max, max: max,
splitLine: {//线 splitLine: {
//线
show: false, show: false,
lineStyle: { lineStyle: {
color: "rgba(255, 255, 255, 0.3)", color: "rgba(255, 255, 255, 0.3)",
@ -136,7 +162,8 @@ const option = {
fontSize: 16, fontSize: 16,
}, },
}, },
axisLabel: {//y axisLabel: {
//y
textStyle: { textStyle: {
color: "#ffffff", color: "#ffffff",
fontSize: 16, fontSize: 16,
@ -157,28 +184,28 @@ const option = {
series: [ series: [
{ {
name: "上门服务时长", name: "上门服务时长",
data: data, data: data.list1,
barWidth: 20, barWidth: 20,
type: "bar", type: "bar",
label: { label: {
show: true, show: true,
color:'#ffffff', color: "#ffffff",
formatter: function (data) { formatter: function (data) {
return data.value return data.value;
} },
}, },
}, },
{ {
name: "上门服务次数", name: "上门服务次数",
data: lineData, data: data.list2,
type: "line", //线 type: "line", //线
label: { label: {
show: true, show: true,
position:'top', position: "top",
color:'#ffffff', color: "#ffffff",
formatter: function (data) { formatter: function (data) {
return data.value return data.value;
} },
}, },
itemStyle: { itemStyle: {
borderColor: "#00FCFF", borderColor: "#00FCFF",
@ -191,7 +218,7 @@ const option = {
itemStyle: { itemStyle: {
color: "rgba(180, 180, 180, 0.2)", // color: "rgba(180, 180, 180, 0.2)", //
}, },
data: data.map(() => max), data: data.list1.map(() => max),
barWidth: 40, // barWidth: 40, //
emphasis: { emphasis: {
itemStyle: { itemStyle: {
@ -218,23 +245,35 @@ const option = {
}, },
], ],
}; };
};
const setChart = () => {
var myChart = echarts.init(chart.value);
myChart.setOption(data.option);
};
const setChart1 = () => {
data.list1 = [];
data.list2 = [];
data.list.data.forEach((item) => {
data.list1.push(item.sc); //
data.list2.push(item.fwcs); //
});
console.log(data.list1,data.list2, "助老服务");
};
// 使 // 使
onMounted(() => { onBeforeMount(() => {
// domecharts setTimeout(() => {
// var myChart = echarts.init(document.getElementById('main')); data.list = props.list;
// Vue3 data.day = props.list.day;
var myChart = echarts.init(chart.value); // console.log(data.list, "");
setChart1();
// init(); // vue3.2this getOption();
// 使 setChart();
myChart.setOption(option); }, 600);
// :
// window.addEventListener("resize", () => {
// myChart.resize();
// });
}); });
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -215,7 +215,7 @@
<div class="serviceTop"> <div class="serviceTop">
<div class="visit"> <div class="visit">
<img class="serviceimg" src="@/assets/YLimg/ylimg8.png" alt="" /> <img class="serviceimg" src="@/assets/YLimg/ylimg8.png" alt="" />
<ylSMFW></ylSMFW> <ylSMFW :list="data.smfwcs"></ylSMFW>
</div> </div>
<div class="medicalService"> <div class="medicalService">
<img class="serviceimg" src="@/assets/YLimg/ylimg9.png" alt="" /> <img class="serviceimg" src="@/assets/YLimg/ylimg9.png" alt="" />
@ -392,6 +392,7 @@ const data = reactive({
yljgzlzx: { yljg: "", zlzx: "" }, yljgzlzx: { yljg: "", zlzx: "" },
zccs1: [], zccs1: [],
zccs2: [], zccs2: [],
smfwcs: [],
}); });
onBeforeMount(async () => { onBeforeMount(async () => {
getData(); getData();
@ -454,6 +455,7 @@ const getData = async () => {
data.yljgzlzx.yljg = res.data.yljgzlzx.yljg; data.yljgzlzx.yljg = res.data.yljgzlzx.yljg;
data.yljgzlzx.zlzx = res.data.yljgzlzx.zlzx; data.yljgzlzx.zlzx = res.data.yljgzlzx.zlzx;
// //
data.smfwcs = res.data.zlfw.smfwcs;
// //
res.data.zlfw.xzzccs.forEach((element) => { res.data.zlfw.xzzccs.forEach((element) => {
data.zccs1.push(element.xzjd); // data.zccs1.push(element.xzjd); //