echarts 双堆叠柱状图(数据整理)

1.后台返回的数据格式

{"code": "0000","message": "","messageCode": "操作成功","sign": null,"detail": null,"data": {"pieChart": [{"key": "产品问题","value": 32},{"key": "安装问题","value": 8},{"key": "其他","value": 1107},{"key": "远程服务","value": 1}],"list": null,"yearDimensionRespList": [{"month": 1,"lastYearPair": {"key": 2023,"value": [{"key": "安装问题","value": 1},{"key": "其他","value": 1031},{"key": "产品问题","value": 5}]},"currentYearPair": {"key": 2024,"value": [{"key": "其他","value": 1031},{"key": "产品问题","value": 5},{"key": "安装问题","value": 1}]}},{"month": 2,"lastYearPair": {"key": 2023,"value": [{"key": "安装问题","value": 1},{"key": "产品问题","value": 14},{"key": "其他","value": 53}]},"currentYearPair": {"key": 2024,"value": [{"key": "产品问题","value": 14},{"key": "安装问题","value": 1},{"key": "其他","value": 53}]}},{"month": 3,"lastYearPair": {"key": 2023,"value": [{"key": "产品问题","value": 5},{"key": "安装问题","value": 6},{"key": "其他","value": 17},{"key": "远程服务","value": 1}]},"currentYearPair": {"key": 2024,"value": [{"key": "其他","value": 17},{"key": "产品问题","value": 5},{"key": "安装问题","value": 6},{"key": "远程服务","value": 1}]}},{"month": 4,"lastYearPair": {"key": 2023,"value": [{"key": "其他","value": 15},{"key": "产品问题","value": 8}]},"currentYearPair": {"key": 2024,"value": [{"key": "其他","value": 6},{"key": "产品问题","value": 8}]}},{"month": 5,"lastYearPair": {"key": 2023,"value": [{"key": "产品问题","value": 2},{"key": "其他","value": 10}]},"currentYearPair": {"key": 2024,"value": []}},{"month": 6,"lastYearPair": {"key": 2023,"value": [{"key": "其他","value": 2},{"key": "产品问题","value": 1},{"key": "远程服务","value": 1}]},"currentYearPair": {"key": 2024,"value": []}},{"month": 7,"lastYearPair": {"key": 2023,"value": [{"key": "产品问题","value": 16},{"key": "远程服务","value": 4},{"key": "其他","value": 15}]},"currentYearPair": {"key": 2024,"value": []}},{"month": 8,"lastYearPair": {"key": 2023,"value": []},"currentYearPair": {"key": 2024,"value": []}},{"month": 9,"lastYearPair": {"key": 2023,"value": [{"key": "其他","value": 2},{"key": "产品问题","value": 5},{"key": "远程服务","value": 1}]},"currentYearPair": {"key": 2024,"value": []}},{"month": 10,"lastYearPair": {"key": 2023,"value": []},"currentYearPair": {"key": 2024,"value": []}},{"month": 11,"lastYearPair": {"key": 2023,"value": []},"currentYearPair": {"key": 2024,"value": []}},{"month": 12,"lastYearPair": {"key": 2023,"value": []},"currentYearPair": {"key": 2024,"value": []}}]},"success": true
}

2.代码 indexC optionC optionCYear

<template><!-- 售后服务工单 --><div class="production-box"><!-- 顶部时间切换 --><TopTab @handleClickDateTab="handleClickDateTab" /><!-- 主体内容 --><div class="content"><!-- !!!!售后工单渠道占比!!!!!! --><div class="sales"><!-- 顶部标题 --><div class="top-title"><div><div>售后工单渠道占比</div><div @click="showDialogs(0)"></div></div><div v-if="0">详情</div></div><!-- 中部标题 --><div class="middle-title"><div class="hardware-bg"></div><div>{{ state.titleA }}</div></div><!-- echarts图表环形 --><div class="chart-info"><EChart:option="state.circleOptionA":width="state.width":height="state.height"isClick/></div><!-- 底部标题 --><div class="bottom-title"><div><div class="data-bg"></div><div class="bottom-title_bold">{{ state.subtitleA }}</div></div><div><div style="width: 18px"></div><div class="bottom-title_think">{{ state.timeRangA }}</div></div></div><!-- echarts图表 --><div class="chart-info"><EChart:option="state.queryType != 'year' ? state.optionA : state.optionAYear":width="state.width":height="state.height"isClick/></div></div><!-- !!!!售后问题统计!!!!!! --><div class="sales"><!-- 顶部标题 --><div class="top-title"><div><div>售后问题统计</div><div @click="showDialogs(1)"></div></div><div  @click="handleClickDetailB">详情</div></div><!-- 中部标题 --><div class="middle-title"><div class="hardware-bg"></div><div>{{ state.titleB }}</div></div><!-- echarts图表环形 --><div class="chart-info"><EChart:option="state.circleOptionB":width="state.width":height="state.height"isClick/></div><!-- 底部标题 --><div class="bottom-title"><div><div class="data-bg"></div><div class="bottom-title_bold">{{ state.subtitleB }}</div></div><div><div style="width: 18px"></div><div class="bottom-title_think">{{ state.timeRangB }}</div></div></div><!-- echarts图表 --><div class="chart-info"><EChart:option="state.queryType != 'year' ? state.optionB : state.optionBYear":width="state.width":height="state.height"isClick/></div></div><!-- !!!!售后工单数统计!!!!!! --><div class="sales"><!-- 顶部标题 --><div class="top-title"><div><div>售后工单数统计</div><div @click="showDialogs(2)"></div></div><div @click="handleClickDetailC">详情</div></div><!-- 中部标题 --><div class="middle-title"><div class="hardware-bg"></div><div>{{ state.titleC }}</div></div><!-- echarts图表环形 --><div class="chart-info"><EChart:option="state.circleOptionC":width="state.width":height="state.height"isClick/></div><!-- 底部标题 --><div class="bottom-title"><div><div class="data-bg"></div><div class="bottom-title_bold">{{ state.subtitleC }}</div></div><div><div style="width: 18px"></div><div class="bottom-title_think">{{ state.timeRangC }}</div></div></div><!-- echarts图表 --><div class="chart-info"><EChart:option="state.queryType != 'year' ? state.optionC : state.optionCYear":width="state.width":height="state.height"isClick/></div></div><div class="up-time">数据更新时间:{{ store.state.updateTime }}</div></div><van-dialog v-model:show="state.show" title="" confirmButtonText="知道了"><div class="dialog-content"><divv-for="(item, index) in state.currentTipList":key="index"class="dia-cent">{{ item }}</div></div></van-dialog></div>
</template><script setup>
import { getCurrentInstance, onMounted, reactive, inject, ref } from "vue";
import TopTab from "../../component/top-tab.vue";
import EChart from "@/component/charts.vue";
import moment from "moment";
import {useRouter} from "vue-router";
import store from '@/store/index';// echart 初始化
const echarts = inject("ec");
const { proxy } = getCurrentInstance();
const router = useRouter();const tips = ref([{title: "售后工单渠道占比",list: ["「售后工单渠道占比」数据取自主服系统中售后服务工单表;","时间维度为分别为日(当日)、周(本周周一至当日)、月(本月1日至当日)、年(当年1月1日至当日)的出货总数量;","区分售后工单来源渠道,分别为车企、电商新零售、海外、公共配套;","饼状图统计各渠道同一时间维度下数量及占比情况;","柱状图统计各渠道同一时间维度下数量变化的趋势情况;",],},{title: "售后问题统计",list: ["「售后问题统计」数据取自主服系统售后服务工单表中状态为已完成的数据;","时间维度为分别为日(当日)、周(本周周一至当日)、月(本月1日至当日)、年(当年1月1日至当日)的工单总数量;","根据售后问题解决方案区分售后工单问题,分别为产品问题、安装问题、远程服务、检测无故障、其他;","工单问题类型为其他的表示该工单为填写解决方案;","饼状图统计各渠道同一时间维度下问题数量及占比情况;","柱状图统计各渠道同一时间维度下问题数量变化的趋势情况;",],},{title: "售后工单数统计",list: ["「售后工单数统计」数据取自主服系统售后服务工单表中状态为已完成的数据;","时间维度为分别为日(当日)、周(本周周一至当日)、月(本月1日至当日)、年(当年1月1日至当日)的工单总数量;","饼状图统计各渠道同一时间维度下售后工单数量在全部工单的占比情况;","柱状图统计各渠道同一时间维度下售后工单在全部工单的占比数量变化的趋势情况;",],},
]);const state = reactive({show: false,currentTipList: [],width: "100%",height: "240px",queryType: "day",eightWeek: {startTime: "",endTime: "",},currentYear: "",lastYear: "",year: moment().format("YYYY"),indexA: 0,indexB: 0,indexC: 0,titleA: "",subtitleA: "",timeRangA: "",titleB: "",subtitleB: "",timeRangB: "",titleC: "",subtitleC: "",timeRangC: "",optionA: {//日月周grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},tooltip: {trigger: "axis",confine: true,},legend: {x: "center",y: "bottom",// width: 60,itemWidth: 18, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 12,},selectedMode: true,},xAxis: [{type: "category",data: [],axisPointer: {type: "shadow",},axisTick: {show: false, // 隐藏刻度线},axisLine: {show: false,lineStyle: {color: "#A4A4A4", // 设置轴线的颜色,这里以红色为例},},axisLabel: {rotate: 35,interval: 0,textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],yAxis: [{type: "value",min: 0,// max: 10000,// interval: 2000,axisLabel: {formatter: "{value} ",textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],series: [],},optionAYear: {//年grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},tooltip: {trigger: "axis",confine: true,formatter: function (params) {console.log("state.currentYear=" + params.length);var res ="<div>时间:" +params[0].name +"</div><hr><div>" +state.lastYear +":</div>";for (var i = 0; i < params.length; i++) {res +="<div>" +params[i].marker +params[i].seriesName +":" +params[i].data +"</div>";if (i == state.indexA) {res += "<hr><div>" + state.currentYear + ":</div>";}}return res;},},legend: {x: "center",y: "bottom",// width: 60,itemWidth: 18, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 12,},selectedMode: false,},xAxis: [{type: "category",data: [],axisPointer: {type: "shadow",},axisTick: {show: false, // 隐藏刻度线},axisLine: {show: false,lineStyle: {color: "#A4A4A4", // 设置轴线的颜色,这里以红色为例},},axisLabel: {rotate: 35,interval: 0,textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],yAxis: [{type: "value",min: 0,// max: 10000,// interval: 2000,axisLabel: {formatter: "{value} ",textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],series: [],},optionB: {//日月周grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},tooltip: {trigger: "axis",confine: true,},legend: {x: "center",y: "bottom",// width: 60,itemWidth: 18, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 12,},selectedMode: true,},xAxis: [{type: "category",data: [],axisPointer: {type: "shadow",},axisTick: {show: false, // 隐藏刻度线},axisLine: {show: false,lineStyle: {color: "#A4A4A4", // 设置轴线的颜色,这里以红色为例},},axisLabel: {rotate: 35,interval: 0,textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],yAxis: [{type: "value",min: 0,// max: 10000,// interval: 2000,axisLabel: {formatter: "{value} ",textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],series: [],},optionBYear: {//年grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},tooltip: {trigger: "axis",confine: true,formatter: function (params) {console.log("state.currentYear=" + params.length);var res ="<div>时间:" +params[0].name +"</div><hr><div>" +state.lastYear +":</div>";for (var i = 0; i < params.length; i++) {res +="<div>" +params[i].marker +params[i].seriesName +":" +params[i].data +"</div>";if (i == state.indexB) {res += "<hr><div>" + state.currentYear + ":</div>";}}return res;},},legend: {x: "center",y: "bottom",// width: 60,itemWidth: 18, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 12,},selectedMode: false,},xAxis: [{type: "category",data: [],axisPointer: {type: "shadow",},axisTick: {show: false, // 隐藏刻度线},axisLine: {show: false,lineStyle: {color: "#A4A4A4", // 设置轴线的颜色,这里以红色为例},},axisLabel: {rotate: 35,interval: 0,textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],yAxis: [{type: "value",min: 0,// max: 10000,// interval: 2000,axisLabel: {formatter: "{value} ",textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],series: [],},optionC: {//日月周grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},tooltip: {trigger: "axis",confine: true,},legend: {x: "center",y: "bottom",// width: 60,itemWidth: 18, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 12,},selectedMode: true,},xAxis: [{type: "category",data: [],axisPointer: {type: "shadow",},axisTick: {show: false, // 隐藏刻度线},axisLine: {show: false,lineStyle: {color: "#A4A4A4", // 设置轴线的颜色,这里以红色为例},},axisLabel: {rotate: 35,interval: 0,textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],yAxis: [{type: "value",min: 0,// max: 10000,// interval: 2000,axisLabel: {formatter: "{value} ",textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],series: [],},optionCYear: {//年grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},tooltip: {trigger: "axis",confine: true,formatter: function (params) {console.log("state.currentYear=" + params.length);var res ="<div>时间:" +params[0].name +"</div><hr><div>" +state.lastYear +":</div>";for (var i = 0; i < params.length; i++) {res +="<div>" +params[i].marker +params[i].seriesName +":" +params[i].data +"</div>";if (i == state.indexC) {res += "<hr><div>" + state.currentYear + ":</div>";}}return res;},},legend: {x: "center",y: "bottom",// width: 60,itemWidth: 18, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 12,},selectedMode: false,},xAxis: [{type: "category",data: [],axisPointer: {type: "shadow",},axisTick: {show: false, // 隐藏刻度线},axisLine: {show: false,lineStyle: {color: "#A4A4A4", // 设置轴线的颜色,这里以红色为例},},axisLabel: {rotate: 35,interval: 0,textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],yAxis: [{type: "value",min: 0,// max: 10000,// interval: 2000,axisLabel: {formatter: "{value} ",textStyle: {color: "#A4A4A4", // 文本颜色fontSize: 8, // 文本大小},},},],series: [],},circleOptionA: {tooltip: {trigger: "item",confine: true,},grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},legend: {top: "80%",left: "center",// width: 60,itemWidth: 17, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 10,},},series: [{name: "",type: "pie",radius: ["40%", "55%"], //环形图的大小center: ["50%", "40%"], //环形图位置// adjust the start and end anglestartAngle: 180,endAngle: 360,data: [],},],},circleOptionB: {tooltip: {trigger: "item",confine: true,},grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},legend: {top: "80%",left: "center",// width: 60,itemWidth: 17, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 10,},},series: [{name: "",type: "pie",radius: ["40%", "55%"], //环形图的大小center: ["50%", "40%"], //环形图位置// adjust the start and end anglestartAngle: 180,endAngle: 360,data: [],},],},circleOptionC: {tooltip: {trigger: "item",confine: true,},grid: {top: "16px",left: "16px",right: "16px",bottom: "32px",containLabel: true,},legend: {top: "80%",left: "center",// width: 60,itemWidth: 17, //图例长度itemHeight: 6, //图例宽度icon: "roundRect",textStyle: {//图例文字color: "#000000",fontSize: 10,},},series: [{name: "",type: "pie",radius: ["40%", "55%"], //环形图的大小center: ["50%", "40%"], //环形图位置// adjust the start and end anglestartAngle: 180,endAngle: 360,data: [],},],},
});// 问号弹出框
const showDialogs = (val) => {state.show = true;state.currentTipList = tips.value[val].list;
};const handleClickDateTab = (row) => {console.log(row);state.queryType = row.value;init();
};// 售后工单渠道占比
const getaftersaleChannelNum = () => {proxy.$H.post(proxy, proxy.$A.aftersaleChannelNum, {accessType: "web",data: state.queryType,}).then((res) => {if (state.queryType != "year") {//饼状图数据if (res.data.data.pieChart.length > 0) {state.circleOptionA.series[0].data = res.data.data.pieChart.map((item) => {return {name: item.key,value: item.value,};});}//柱状堆叠图//X轴数据if (res.data.data.list.length > 0) {state.optionA.xAxis[0].data = res.data.data.list.map((item) => {return item.date;});//serios的name集合let seriosNameList = [];state.optionA.series = [];for (let item of res.data.data.list) {for (let ite of item.channelList) {if (!seriosNameList.includes(ite.key)) {seriosNameList.push(ite.key);}}}console.log("长度为:" + seriosNameList.length);seriosNameList.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: "total",data: [],barWidth: "50%",// itemStyle: {//   normal: {//     color: {//       type: "linear",//       x: 0,//       y: 0,//       x2: 0,//       y2: 1,//       colorStops: [//         {//           offset: 0,//           color: "rgba(253,148,12,0.54)", // 柱子上部颜色//         },//         {//           offset: 1,//           color: "rgba(254,71,1,0.54)", // 柱子下部颜色//         },//       ],//       globalCoord: false, // 缺省值false//     },//   },// },};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionA.series.push(seriesObj);console.log(state.optionA.series);for (let item of res.data.data.list) {if (item.channelList.length > 0) {if (item.channelList.some((ite) => ite.key == element)) {for (let it of item.channelList) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});}} else {//年的数据//饼状图数据if (res.data.data.pieChart.length > 0) {state.circleOptionA.series[0].data = res.data.data.pieChart.map((item) => {return {name: item.key,value: item.value,};});}//serios的name集合let seriosNameListA = []; //去年的let seriosNameListB = []; //今年的state.optionAYear.series = [];//柱状堆叠图//X轴数据if (res.data.data.yearDimensionRespList.length > 0) {state.optionAYear.xAxis[0].data = res.data.data.yearDimensionRespList.map((item) => {return item.month + "月";});for (let item of res.data.data.yearDimensionRespList) {state.currentYear = item.currentYearPair.key;state.lastYear = item.lastYearPair.key;for (let ite of item.lastYearPair.value) {if (!seriosNameListA.includes(ite.key)) {seriosNameListA.push(ite.key);}}for (let ite of item.currentYearPair.value) {if (!seriosNameListB.includes(ite.key)) {seriosNameListB.push(ite.key);}}}console.log(seriosNameListA);console.log(seriosNameListB);//去年堆叠图state.indexA = seriosNameListA.length - 1; //tooltip 转换的下标seriosNameListA.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: state.lastYear,data: [],// barWidth: "50%",};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionAYear.series.push(seriesObj);console.log(state.optionAYear.series);for (let item of res.data.data.yearDimensionRespList) {if (item.lastYearPair.value.length > 0) {if (item.lastYearPair.value.some((ite) => ite.key == element)) {for (let it of item.lastYearPair.value) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});//今年堆叠图seriosNameListB.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: state.currentYear,data: [],// barWidth: "50%",// itemStyle: {//   normal: {//     color: {//       type: "linear",//       x: 0,//       y: 0,//       x2: 0,//       y2: 1,//       colorStops: [//         {//           offset: 0,//           color: "rgba(253,148,12,0.54)", // 柱子上部颜色//         },//         {//           offset: 1,//           color: "rgba(254,71,1,0.54)", // 柱子下部颜色//         },//       ],//       globalCoord: false, // 缺省值false//     },//   },// },};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionAYear.series.push(seriesObj);console.log(state.optionAYear.series);for (let item of res.data.data.yearDimensionRespList) {if (item.currentYearPair.value.length > 0) {if (item.currentYearPair.value.some((ite) => ite.key == element)) {for (let it of item.currentYearPair.value) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});}}//标题变更const today = moment();let startDate = "";let endDate = "";if (state.queryType == "day") {state.titleA = `${moment().subtract(1, "days").format("YYYY-MM-DD")}售后工单渠道数量及占比`;state.subtitleA = `近7日售后工单渠道数量变化`;startDate = res.data.data.list[0].date;endDate = res.data.data.list[res.data.data.list.length - 1].date;state.timeRangA = `(${startDate}~${endDate})`;} else if (state.queryType == "week") {state.titleA = `本周(${res.data.data.list[res.data.data.list.length - 1].date})售后工单渠道数量及占比`;state.subtitleA = `近8周售后工单渠道数量变化`;state.timeRangA = `(${state.eightWeek.startTime}~${state.eightWeek.endTime})`;} else if (state.queryType == "month") {state.titleA = `售后工单渠道数量及占比`;state.subtitleA = `近6个售后工单渠道数量变化`;startDate = res.data.data.list[0].date;endDate = res.data.data.list[res.data.data.list.length - 1].date;state.timeRangA = `(${startDate}~${endDate})`;} else {state.titleA = `${state.year}售后工单渠道数量及占比`;state.subtitleA = "售后工单渠道数量对比变化";}});
};
// 售后问题统计
const getaftersaleFaultNum = () => {proxy.$H.post(proxy, proxy.$A.aftersaleFaultNum, {accessType: "web",data: state.queryType,}).then((res) => {if (state.queryType != "year") {//饼状图数据if (res.data.data.pieChart.length > 0) {state.circleOptionB.series[0].data = res.data.data.pieChart.map((item) => {return {name: item.key,value: item.value,};});}//柱状堆叠图//X轴数据if (res.data.data.list.length > 0) {state.optionB.xAxis[0].data = res.data.data.list.map((item) => {return item.date;});//serios的name集合let seriosNameList = [];state.optionB.series = [];for (let item of res.data.data.list) {for (let ite of item.channelList) {if (!seriosNameList.includes(ite.key)) {seriosNameList.push(ite.key);}}}console.log("长度为:" + seriosNameList.length);seriosNameList.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: "total",data: [],barWidth: "50%",// itemStyle: {//   normal: {//     color: {//       type: "linear",//       x: 0,//       y: 0,//       x2: 0,//       y2: 1,//       colorStops: [//         {//           offset: 0,//           color: "rgba(253,148,12,0.54)", // 柱子上部颜色//         },//         {//           offset: 1,//           color: "rgba(254,71,1,0.54)", // 柱子下部颜色//         },//       ],//       globalCoord: false, // 缺省值false//     },//   },// },};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionB.series.push(seriesObj);console.log(state.optionB.series);for (let item of res.data.data.list) {if (item.channelList.length > 0) {if (item.channelList.some((ite) => ite.key == element)) {for (let it of item.channelList) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});}} else {//年的数据//饼状图数据if (res.data.data.pieChart.length > 0) {state.circleOptionB.series[0].data = res.data.data.pieChart.map((item) => {return {name: item.key,value: item.value,};});}//serios的name集合let seriosNameListA = []; //去年的let seriosNameListB = []; //今年的state.optionBYear.series = [];//柱状堆叠图//X轴数据if (res.data.data.yearDimensionRespList.length > 0) {state.optionBYear.xAxis[0].data = res.data.data.yearDimensionRespList.map((item) => {return item.month + "月";});for (let item of res.data.data.yearDimensionRespList) {state.currentYear = item.currentYearPair.key;state.lastYear = item.lastYearPair.key;for (let ite of item.lastYearPair.value) {if (!seriosNameListA.includes(ite.key)) {seriosNameListA.push(ite.key);}}for (let ite of item.currentYearPair.value) {if (!seriosNameListB.includes(ite.key)) {seriosNameListB.push(ite.key);}}}console.log(seriosNameListA);console.log(seriosNameListB);//去年堆叠图state.indexB = seriosNameListA.length - 1; //tooltip 转换的下标seriosNameListA.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: state.lastYear,data: [],// barWidth: "50%",};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionBYear.series.push(seriesObj);console.log(state.optionBYear.series);for (let item of res.data.data.yearDimensionRespList) {if (item.lastYearPair.value.length > 0) {if (item.lastYearPair.value.some((ite) => ite.key == element)) {for (let it of item.lastYearPair.value) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});//今年堆叠图seriosNameListB.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: state.currentYear,data: [],// barWidth: "50%",// itemStyle: {//   normal: {//     color: {//       type: "linear",//       x: 0,//       y: 0,//       x2: 0,//       y2: 1,//       colorStops: [//         {//           offset: 0,//           color: "rgba(253,148,12,0.54)", // 柱子上部颜色//         },//         {//           offset: 1,//           color: "rgba(254,71,1,0.54)", // 柱子下部颜色//         },//       ],//       globalCoord: false, // 缺省值false//     },//   },// },};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionBYear.series.push(seriesObj);console.log(state.optionBYear.series);for (let item of res.data.data.yearDimensionRespList) {if (item.currentYearPair.value.length > 0) {if (item.currentYearPair.value.some((ite) => ite.key == element)) {for (let it of item.currentYearPair.value) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});}}//标题变更const today = moment();let startDate = "";let endDate = "";if (state.queryType == "day") {state.titleB = `${moment().subtract(1, "days").format("YYYY-MM-DD")}售后问题数量及占比`;state.subtitleB = `近7日售后问题数量变化`;startDate = res.data.data.list[0].date;endDate = res.data.data.list[res.data.data.list.length - 1].date;state.timeRangB = `(${startDate}~${endDate})`;} else if (state.queryType == "week") {state.titleB = `本周(${res.data.data.list[res.data.data.list.length - 1].date})售后问题数量及占比`;state.subtitleB = `近8周售后问题数量变化`;state.timeRangB = `(${state.eightWeek.startTime}~${state.eightWeek.endTime})`;} else if (state.queryType == "month") {state.titleB = `本月售后问题数量及占比`;state.subtitleB = `近6个售后问题数量变化`;startDate = res.data.data.list[0].date;endDate = res.data.data.list[res.data.data.list.length - 1].date;state.timeRangB = `(${startDate}~${endDate})`;} else {state.titleB = `${state.year}售后问题数量及占比`;state.subtitleB = "售后问题数量对比变化";}});
};
// 售后工单数统计
const getaftersaleAndInstallOrderNum = () => {proxy.$H.post(proxy, proxy.$A.aftersaleAndInstallOrderNum, {accessType: "web",data: state.queryType,}).then((res) => {if (state.queryType != "year") {//饼状图数据if (res.data.data.pieChart.length > 0) {state.circleOptionC.series[0].data = res.data.data.pieChart.map((item) => {return {name: item.key,value: item.value,};});}//柱状堆叠图//X轴数据if (res.data.data.list.length > 0) {state.optionC.xAxis[0].data = res.data.data.list.map((item) => {return item.date;});//serios的name集合let seriosNameList = [];state.optionC.series = [];for (let item of res.data.data.list) {for (let ite of item.channelList) {if (!seriosNameList.includes(ite.key)) {seriosNameList.push(ite.key);}}}console.log("长度为:" + seriosNameList.length);seriosNameList.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: "total",data: [],barWidth: "50%",// itemStyle: {//   normal: {//     color: {//       type: "linear",//       x: 0,//       y: 0,//       x2: 0,//       y2: 1,//       colorStops: [//         {//           offset: 0,//           color: "rgba(253,148,12,0.54)", // 柱子上部颜色//         },//         {//           offset: 1,//           color: "rgba(254,71,1,0.54)", // 柱子下部颜色//         },//       ],//       globalCoord: false, // 缺省值false//     },//   },// },};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionC.series.push(seriesObj);console.log(state.optionC.series);for (let item of res.data.data.list) {if (item.channelList.length > 0) {if (item.channelList.some((ite) => ite.key == element)) {for (let it of item.channelList) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});}} else {//年的数据//饼状图数据if (res.data.data.pieChart.length > 0) {state.circleOptionC.series[0].data = res.data.data.pieChart.map((item) => {return {name: item.key,value: item.value,};});}//serios的name集合let seriosNameListA = []; //去年的let seriosNameListB = []; //今年的state.optionCYear.series = [];//柱状堆叠图//X轴数据if (res.data.data.yearDimensionRespList.length > 0) {state.optionCYear.xAxis[0].data = res.data.data.yearDimensionRespList.map((item) => {return item.month + "月";});for (let item of res.data.data.yearDimensionRespList) {state.currentYear = item.currentYearPair.key;state.lastYear = item.lastYearPair.key;for (let ite of item.lastYearPair.value) {if (!seriosNameListA.includes(ite.key)) {seriosNameListA.push(ite.key);}}for (let ite of item.currentYearPair.value) {if (!seriosNameListB.includes(ite.key)) {seriosNameListB.push(ite.key);}}}console.log(seriosNameListA);console.log(seriosNameListB);//去年堆叠图state.indexC = seriosNameListA.length - 1; //tooltip 转换的下标seriosNameListA.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: state.lastYear,data: [],// barWidth: "50%",};console.log(index);console.log("name=" + element);seriesObj.name = element;state.optionCYear.series.push(seriesObj);console.log(state.optionCYear.series);for (let item of res.data.data.yearDimensionRespList) {if (item.lastYearPair.value.length > 0) {if (item.lastYearPair.value.some((ite) => ite.key == element)) {for (let it of item.lastYearPair.value) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});//今年堆叠图seriosNameListB.forEach((element, index) => {let seriesObj = {name: "",type: "bar",stack: state.currentYear,data: [],// barWidth: "50%",// itemStyle: {//   normal: {//     color: {//       type: "linear",//       x: 0,//       y: 0,//       x2: 0,//       y2: 1,//       colorStops: [//         {//           offset: 0,//           color: "rgba(253,148,12,0.54)", // 柱子上部颜色//         },//         {//           offset: 1,//           color: "rgba(254,71,1,0.54)", // 柱子下部颜色//         },//       ],//       globalCoord: false, // 缺省值false//     },//   },// },};console.log(state.indexC);console.log("name=" + element);seriesObj.name = element;state.optionCYear.series.push(seriesObj);console.log(state.optionCYear.series);for (let item of res.data.data.yearDimensionRespList) {if (item.currentYearPair.value.length > 0) {if (item.currentYearPair.value.some((ite) => ite.key == element)) {for (let it of item.currentYearPair.value) {if (it.key == element) {seriesObj.data.push(it.value);}}} else {seriesObj.data.push(0);}} else {seriesObj.data.push(0);}}});}}// 标题变更const today = moment();let startDate = "";let endDate = "";if (state.queryType == "day") {state.titleC = `${moment().subtract(1, "days").format("YYYY-MM-DD")}售后上门工单数及占比`;state.subtitleC = `近7日售后上门工单数量变化`;startDate = res.data.data.list[0].date;endDate = res.data.data.list[res.data.data.list.length - 1].date;state.timeRangC = `(${startDate}~${endDate})`;} else if (state.queryType == "week") {state.titleC = `本周(${res.data.data.list[res.data.data.list.length - 1].date})售后上门工单数及占比`;state.subtitleC = `近8周售后上门工单数量变化`;state.timeRangC = `(${state.eightWeek.startTime}~${state.eightWeek.endTime})`;} else if (state.queryType == "month") {state.titleC = `本月售后上门工单数及占比`;state.subtitleC = `近6个售后上门工单数量变化`;startDate = res.data.data.list[0].date;endDate = res.data.data.list[res.data.data.list.length - 1].date;state.timeRangC = `(${startDate}~${endDate})`;} else {state.titleC = `${state.year}售后上门工单数及占比`;state.subtitleC = "售后上门工单数量对比变化";}});
};
// 售后问题统计
const handleClickDetailB = () => {router.push({ name: "problem-statistics" });
};
// 售后工单数统计
const handleClickDetailC = () => {router.push({ name: "visit-statistics" });
};
// 初始化
const init = () => {getaftersaleChannelNum();getaftersaleFaultNum();getaftersaleAndInstallOrderNum();
};
onMounted(() => {const today = moment();// 计算前八周的周一的日期const eightWeeksAgo = today.clone().subtract(7, "weeks");const mondayOfEightWeeksAgo = eightWeeksAgo.day(1); // 1 represents Mondaystate.eightWeek.startTime = mondayOfEightWeeksAgo.format("MM/DD");state.eightWeek.endTime = today.format("MM/DD");init();
});
</script><style lang="less" scoped>
@import "./index.less";
.dialog-content {max-height: 60vh;overflow-y:scroll;padding: 20px;.dia-cent {margin-bottom: 3px;}
}
</style>

3.效果
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/2009.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C语言--基础面试真题

1、局部变量和静态变量的区别 普通局部变量和静态局部变量区别 存储位置&#xff1a; 普通局部变量存储在栈上 静态局部变量存储在静态存储区 生命周期&#xff1a; 当函数执行完毕时&#xff0c;普通局部变量会被销毁 静态局部变量的生命周期则是整个程序运行期间&#…

基于51单片机的电子秤LCD1602液晶显示( proteus仿真+程序+设计报告+讲解视频)

基于51单片机电子秤LCD显示 1. 主要功能&#xff1a;2. 讲解视频&#xff1a;3. 仿真设计4. 程序代码5. 设计报告6. 设计资料内容清单&&下载链接 基于51单片机电子秤LCD显示( proteus仿真程序设计报告讲解视频&#xff09; 仿真图proteus8.9及以上 程序编译器&#xf…

深兰科技入选2024全国“人工智能+”行动创新案例TOP100

近日&#xff0c;中科院《互联网周刊》联合eNET研究院、德本咨询、中国社会科学院信息化研究中心共同发布了《2024全国“人工智能”行动创新案例TOP100》榜单。经评委会层层遴选&#xff0c;深兰科技专为洛阳市打造的“工业智能化洛阳中心”项目成功入围该榜单。一同入围的还包…

高通发布电脑CPU,比英特尔Ultra9领先51%

要说2024年最热门的关键词&#xff0c;那肯定非 AI 莫属&#xff0c;当前 AI 已经开始深入各行各业&#xff0c;AI 电视、AI 手机、AI 车机、AI 家电&#xff0c;以及 AI PC ,这些都意味着 AI 将对各个行业带来的新风向和不小的冲击。 2024 年了&#xff0c;PC 处理器还能卷出什…

安居水站:自来水安全性影响因素分析及监测管理对策

摘要&#xff1a;自来水作为人们日常生活的重要组成部分&#xff0c;其安全性直接关系到公众健康。本文深入探讨了可能影响自来水安全性的多种因素&#xff0c;包括水源污染、水处理工艺、供水管网问题、二次供水设施维护不当、工业及农业污染、重金属和微生物污染、季节变化以…

论文笔记:Large Language Models Are Zero-Shot Time Series Forecasters

2023 neurips 完全是零样本&#xff08;zero-shot&#xff09;的&#xff0c;不需要微调 1 方法 1.1 Tokenization&#xff08;分词和编码&#xff09; 现有的LLM&#xff08;比如GPT3&#xff09;的tokenizer不能直接用来编码时间序列的句子 比如对数字42235630&#xff0…

负载均衡的原理及算法

一、定义 负载均衡&#xff08;Load Balancing&#xff09;是一种计算机网络和服务器管理技术&#xff0c;旨在分配网络流量、请求或工作负载到多个服务器或资源&#xff0c;以确保这些服务器能够高效、均匀地处理负载&#xff0c;并且能够提供更高的性能、可用性和可扩展性。…

数据科学与大数据(3)

数据分析&#xff0c;它不应该是在一个不适合的工具下生搬硬套 工具为具体的场景服务&#xff0c;换一个场景大概率会很鸡肋&#xff0c;对于一个成熟的分析师来说&#xff0c;十八般武艺样样精通到后期为常态&#xff0c;不要产生工具上的路径依赖&#xff0c;不要想着学一个工…

IDEA更换新版本启动没反应

目前安装了新的IDEA(压缩包方式)&#xff0c;由于老版本的IDEA还在用&#xff0c;所以并没有删除&#xff0c;但是安装完后发现点击idea64.exe后没有反应&#xff0c;于是网上找了好多方法最后解决了 下面是我的解决过程 新版本&#xff1a;IntelliJIdea2024.1 老版本: Intelli…

ubuntu系统安装配置gitlab+Jenkins+发布持续集成持续部署保姆级教程。

1、服务器环境 名称 系统 IP 备注 gitlab ubuntu20.04.2图形化 192.168.26.130 要求有6G的内存 Jenkins Ubuntu20.04.2图形化 …

Pytorch下张量的形状操作(详细)

目录 一、基本操作函数 二、分类&#xff1a;维度改变&#xff0c;张量变形&#xff0c;维度重排 2.1维度改变 2.2张量变形 2.3维度重排 三、实例 一、基本操作函数 在PyTorch中&#xff0c;对张量的形状进行操作是常见的需求&#xff0c;因为它允许我们重新组织、选择和…

大模型训练及推理【硬件选型指南】及 GPU 通识

我们在做大模型应用部署时&#xff08;如训练、微调、RAG&#xff09;&#xff0c;往往需要在前期就分析好硬件选型指标&#xff0c;或者我们给客户报方案之前&#xff0c;可能你已经有了一个方案&#xff0c;但是由于实践经验缺乏&#xff0c;不知道在硬件上该如何评估并上报。…

CTF练习-BUUCTF(1~25)

文章目录 Crypto题目1 一眼就解密题目解题思路flag 题目2 md5题目解题思路flag 题目3 Url编码题目解题思路flag 题目4 看我回旋踢题目解题思路1解题思路2flag 题目5 摩丝题目解题思路flag 题目6 passwd题目解题思路flag 题目7 变异凯撒题目解题思路flag 题目8 Quoted-printable…

AJAX——封装_简易axios

1.简易axios_获取身份列表 需求&#xff1a;基于Promise XHR 封装 myAxios函数&#xff0c;获取省份列表展示 步骤&#xff1a; 1.定义 myAxios函数&#xff0c;接收配置对象&#xff0c;返回Promise对象 2.发起XHR请求&#xff0c;默认请求方法为GET 3.调用成功/失败的处…

Python与数据库连接

新建表boss create table 创建表 Code import pymysqlcon pymysql.connect(hostlocalhost,\userroot,\password,\port3306,\dbbusiness) cursorcon.cursor() cursor.execute(create table if not exists boss(id int auto_increment primary key,name varchar(20)not null…

WPF2 样式布局

样式布局 WPF中的各类控件元素, 都可以自由的设置其样式。 诸如: 字体(FontFamily) 字体大小(FontSize) 背景颜色(Background) 字体颜色(Foreground) 边距(Margin) 水平位置(HorizontalAlignment) 垂直位置(VerticalAlignment) 等等。 而样式则是组织和重用以上的重要工具。…

Docker基础+虚拟化概念

目录 一、虚拟化简介 1、虚拟化概述 2、cpu的时间分片&#xff08;cpu虚拟化&#xff09; 3、cpu虚拟化性性能瓶颈 4、虚拟化工作 4.1虚拟机工作原理 4.2两大核心组件:QEMU、KVM 4.2.1QEMU&#xff1a; 4.2.2KVM&#xff1a; 5、虚拟化类型 ①全虚拟化&#xff1a; …

国内开通chatgpt plus会员方法

ChatGPT镜像 今天在知乎看到一个问题&#xff1a;“平民不参与内测的话没有账号还有机会使用ChatGPT吗&#xff1f;” 从去年GPT大火到现在&#xff0c;关于GPT的消息铺天盖地&#xff0c;真要有心想要去用&#xff0c;途径很多&#xff0c;别的不说&#xff0c;国内GPT的镜像…

微软如何打造数字零售力航母系列科普02 --- 微软低代码应用平台加速企业创新 - 解放企业数字零售力

微软低代码应用平台推动企业创新- 解放企业数字零售力 微软在2023年GARTNER发布的魔力象限图中处于头部领先&#xff08;leader&#xff09;地位。 其LCAP产品是Microsoft Power Apps&#xff0c;扩展了AI Builder、Dataverse、Power Automate和Power Pages&#xff0c;这些都包…

Vue3 Vite配置环境变量

Vue3 Vite配置环境变量 相关文档配置.env文件vite.config.jspackage.json 使用 相关文档 Vite 官方中文文档&#xff1a;https://cn.vitejs.dev/环境变量和模式&#xff1a;https://cn.vitejs.dev/guide/env-and-mode.html#env-file在配置中使用环境变量&#xff1a;https://c…