From 5b4e348267b5541d54fffcc75c7b307ad514a692 Mon Sep 17 00:00:00 2001 From: wwl <xchao828@163.com> Date: 星期六, 15 二月 2025 18:24:58 +0800 Subject: [PATCH] 20250215 --- src/views/index.vue | 180 +++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 99 insertions(+), 81 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index 8ccd4ef..8d43c82 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -92,103 +92,121 @@ getList() { this.loading = true; - // 鏌ヨ浠婃棩鐧昏 + + // 淇敼API璋冪敤鐨勯敊璇鐞� getCustomer().then((response) => { - this.Customer = response - this.loading = false; + this.Customer = response || 0; // 娣诲姞榛樿鍊� + }).catch(error => { + console.error('鑾峰彇浠婃棩鐧昏鏁版嵁澶辫触:', error); + this.Customer = 0; }); - // 鏌ヨ浠婃棩宸叉 + getOrder().then((response) => { - this.Order = response - this.loading = false; + this.Order = response || 0; + }).catch(error => { + console.error('鑾峰彇浠婃棩宸叉鏁版嵁澶辫触:', error); + this.Order = 0; }); - // 鏌ヨ浠婃棩鎶ュ憡 + getReportToday().then((response) => { - this.ReportToday = response - this.loading = false; + this.ReportToday = response || 0; + }).catch(error => { + console.error('鑾峰彇浠婃棩鎶ュ憡鏁版嵁澶辫触:', error); + this.ReportToday = 0; }); - // 鏌ヨ浠婃棩寰呮 + getTobeToday().then((response) => { - this.TobeToday = response - this.loading = false; + this.TobeToday = response || 0; + }).catch(error => { + console.error('鑾峰彇浠婃棩寰呮鏁版嵁澶辫触:', error); + this.TobeToday = 0; }); - // 鎶樼嚎鍥� + + // 淇敼鎶樼嚎鍥炬暟鎹鐞� getChart().then((response) => { - response.data.forEach(item => { - this.LineChart.push(item.date) - this.reportNum.push(item.tdcoun); - this.personYYNum.push(item.grcoun); - this.teamYYNum.push(item.bgcoun); + if (response && response.data) { + this.LineChart = []; + this.reportNum = []; + this.personYYNum = []; + this.teamYYNum = []; + + response.data.forEach(item => { + this.LineChart.push(item.date); + this.reportNum.push(item.tdcoun || 0); + this.personYYNum.push(item.grcoun || 0); + this.teamYYNum.push(item.bgcoun || 0); + }); + let myChart = this.$echarts.init(document.getElementById('main')); - }); - let myChart = this.$echarts.init(document.getElementById('main')); - - myChart.setOption({ - tooltip: { - trigger: 'axis' - }, - legend: { - data: ['姣忔棩浣撴鐧昏鏁�', '姣忔棩鍥綋鐧昏鏁�', '姣忔棩鍙戝竷鎶ュ憡鏁�'] - }, - grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true - }, - toolbox: { - feature: { - saveAsImage: {} - } - }, - xAxis: { - type: 'category', - boundaryGap: false, - axisLine: { - show: true, - lineStyle: { - color: "blue", - size: 12, - width: 0, - tyle: "solid" + myChart.setOption({ + tooltip: { + trigger: 'axis' + }, + legend: { + data: ['姣忔棩浣撴鐧昏鏁�', '姣忔棩鍥綋鐧昏鏁�', '姣忔棩鍙戝竷鎶ュ憡鏁�'] + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + toolbox: { + feature: { + saveAsImage: {} } }, - data: this.LineChart - }, - yAxis: { - type: 'value', - min: 0, - max: 100, - interval: 5 - }, - series: [ - { - name: '姣忔棩浣撴鐧昏鏁�', - type: 'line', - stack: 'Total', - data: this.personYYNum + xAxis: { + type: 'category', + boundaryGap: false, + axisLine: { + show: true, + lineStyle: { + color: "blue", + size: 12, + width: 0, + tyle: "solid" + } + }, + data: this.LineChart }, - { - name: '姣忔棩鍥綋鐧昏鏁�', - type: 'line', - stack: 'Total', - data: this.reportNum + yAxis: { + type: 'value', + min: 0, + max: 100, + interval: 5 }, - { - name: '姣忔棩鍙戝竷鎶ュ憡鏁�', - type: 'line', - stack: 'Total', - data: this.teamYYNum - }, - ] + series: [ + { + name: '姣忔棩浣撴鐧昏鏁�', + type: 'line', + stack: 'Total', + data: this.personYYNum + }, + { + name: '姣忔棩鍥綋鐧昏鏁�', + type: 'line', + stack: 'Total', + data: this.reportNum + }, + { + name: '姣忔棩鍙戝竷鎶ュ憡鏁�', + type: 'line', + stack: 'Total', + data: this.teamYYNum + }, + ] - }) - let sizeFun = ()=> { - myChart.resize() + }) + let sizeFun = ()=> { + myChart.resize() + } + window.addEventListener("resize", sizeFun) + + this.loading = false; } - window.addEventListener("resize", sizeFun) - - this.loading = false; + }).catch(error => { + console.error('鑾峰彇鍥捐〃鏁版嵁澶辫触:', error); }); // 楗肩姸鍥� -- Gitblit v1.8.0