Commit d63ac4e5 by wangren

大客户数据分析请求优化

parent 2ccdcd0f
...@@ -35,35 +35,35 @@ export default { ...@@ -35,35 +35,35 @@ export default {
1: "iaefts", 1: "iaefts",
2: "expben", 2: "expben",
}, },
category: [],
seriesData : [] ,
seriesData1 : [] ,
seriesData2 : [] ,
}; };
}, },
mounted() { mounted() {
this.$nextTick(() => { // 仅在整个视图都被渲染之后才会运行的代码
this.$nextTick(async() => {
await this.loadData();
this.loadCharts(); this.loadCharts();
this.loadChartsBind = this.loadCharts.bind(this); this.loadChartsBind = this.loadCharts.bind(this);
window.addEventListener("resize", this.loadChartsBind); window.addEventListener("resize", this.loadChartsBind);
}); });
}, },
methods: { methods: {
//加载图标函数 async loadData() {
async loadCharts() {
if (this.echartInstance) {
this.echartInstance.dispose();
}
this.echartInstance = echarts.init(
this.$el.querySelector(".chart-container .chartWrapper .chart")
);
//统计 业务量 //统计 业务量
let volume = await busvolume(); const volume = await busvolume();
//统计 融资量 //统计 融资量
let amount = await finamount(); const amount = await finamount();
//统计 费用收益 //统计 费用收益
let income = await expincome(); const income = await expincome();
let categoryArr = [];
//定义 seriesData数组 金额 category数组 客户名 //定义 seriesData数组 金额 category数组 客户名
let seriesData = []; // let seriesData = [];
let seriesData1 = []; // let seriesData1 = [];
let seriesData2 = []; // let seriesData2 = [];
let category = [];
// 优先遍历客户名,方便后续的数组匹配 // 优先遍历客户名,方便后续的数组匹配
// volume.forEach((v) => { // volume.forEach((v) => {
// console.log(v.nam1) // console.log(v.nam1)
...@@ -73,18 +73,17 @@ export default { ...@@ -73,18 +73,17 @@ export default {
// console.log(category) // console.log(category)
// }); // });
console.log("volume.length:" + volume.length);
console.log(category);
for (let i = 0; i < volume.length; i++) { for (let i = 0; i < volume.length; i++) {
let v = volume[i].nam1; let v = volume[i].nam1;
// console.log(typeof v); // console.log(typeof v);
// console.log(volume[i].nam1); // console.log(volume[i].nam1);
category.push(v); categoryArr.push(v);
// console.log(category.toString()); // console.log(category.toString());
// console.log(category); // console.log(category);
// console.log(typeof category); // console.log(typeof category);
} }
this.category = categoryArr;
//存在bug后续要解决 //存在bug后续要解决
// amount.forEach((v) => { // amount.forEach((v) => {
...@@ -107,37 +106,45 @@ export default { ...@@ -107,37 +106,45 @@ export default {
// } // }
// } // }
// }); // });
const volumeArr = []
volume.forEach((v) => { volume.forEach((v) => {
for (let i = 0; i < category.length; i++) { for (let i = 0; i < categoryArr.length; i++) {
if (category[i] == v.nam1) { if (categoryArr[i] == v.nam1) {
seriesData[i] = v.amount; volumeArr.push(v.amount)
break; break;
} }
} }
}); });
this.seriesData = volumeArr;
const amountArr = []
amount.forEach((v) => { amount.forEach((v) => {
for (let i = 0; i < category.length; i++) { for (let i = 0; i < categoryArr.length; i++) {
if (category[i] == v.nam1) { if (categoryArr[i] == v.nam1) {
seriesData1[i] = v.amount; amountArr.push(v.amount);
break; break;
} }
} }
}); });
this.seriesData1 = amountArr;
const incomeArr = []
income.forEach((v) => { income.forEach((v) => {
for (let i = 0; i < category.length; i++) { for (let i = 0; i < categoryArr.length; i++) {
if (category[i] == v.nam1) { if (categoryArr[i] == v.nam1) {
seriesData2[i] = v.amount; incomeArr.push(v.amount);
break; break;
} }
} }
}); });
console.log(category); this.seriesData2 = incomeArr;
console.log(seriesData); },
console.log(seriesData1); //加载图标函数
console.log(seriesData2); loadCharts() {
if (this.echartInstance) {
this.echartInstance.dispose();
}
this.echartInstance = echarts.init(
this.$el.querySelector(".chart-container .chartWrapper .chart")
);
const option = { const option = {
tooltip: { tooltip: {
...@@ -161,23 +168,23 @@ export default { ...@@ -161,23 +168,23 @@ export default {
}, },
yAxis: { yAxis: {
type: "category", type: "category",
data: category, data: this.category,
}, },
series: [ series: [
{ {
name: "业务量金额(美元)", name: "业务量金额(美元)",
type: "bar", type: "bar",
data: seriesData, data: this.seriesData,
}, },
{ {
name: "融资量金额(万美元)", name: "融资量金额(万美元)",
type: "bar", type: "bar",
data: seriesData1, data: this.seriesData1,
}, },
{ {
name: "费用收益金额(千美元)", name: "费用收益金额(千美元)",
type: "bar", type: "bar",
data: seriesData2, data: this.seriesData2,
}, },
], ],
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment