Commit 8cefb039 by 胡悦

优化

1 parent a46390b8
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2022-06-23 15:05:21 * @Date: 2022-06-23 15:05:21
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2022-06-30 19:18:15 * @LastEditTime: 2022-06-30 19:40:27
--> -->
<template> <template>
<div> <div>
...@@ -111,7 +111,8 @@ export default { ...@@ -111,7 +111,8 @@ export default {
} }
} }
var brandName = val.brand ? val.brand.name : '' var brandName = val.brand ? val.brand.name : ''
this.api.sales[brandName ? 'storeTotal' : 'saleTotal'](params).then(res => { this.api.sales[brandName ? 'storeTotal' : 'saleTotal'](params)
.then(res => {
if (res.code === '0') { if (res.code === '0') {
if (res.data.dataList.length) { if (res.data.dataList.length) {
res.data.dataList[0].num.forEach((item, index) => { res.data.dataList[0].num.forEach((item, index) => {
...@@ -124,6 +125,9 @@ export default { ...@@ -124,6 +125,9 @@ export default {
} }
} }
}) })
.catch(() => {
this.hasData = false
})
}, },
draw() { draw() {
this.option = { this.option = {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2022-06-23 15:05:21 * @Date: 2022-06-23 15:05:21
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2022-06-30 19:15:13 * @LastEditTime: 2022-06-30 19:38:58
--> -->
<template> <template>
<div> <div>
...@@ -60,12 +60,17 @@ export default { ...@@ -60,12 +60,17 @@ export default {
this.list.forEach((i, idx) => { this.list.forEach((i, idx) => {
p[idx] = new Promise((resolve, reject) => { p[idx] = new Promise((resolve, reject) => {
params.req.queryItem = i params.req.queryItem = i
this.api.sales[api](params).then(res => { this.api.sales[api](params)
.then(res => {
resolve(res.data.dataList) resolve(res.data.dataList)
}) })
.catch(() => {
reject()
}) })
}) })
Promise.all([p[0], p[1], p[2], p[3], p[4]]).then(results => { })
Promise.all([p[0], p[1], p[2], p[3], p[4]])
.then(results => {
this.dataList = results this.dataList = results
const flag = results.map(item => { const flag = results.map(item => {
if (item.length) { if (item.length) {
...@@ -77,6 +82,9 @@ export default { ...@@ -77,6 +82,9 @@ export default {
this.$set(this, 'hasData', !flag.every(i => !i)) this.$set(this, 'hasData', !flag.every(i => !i))
this.draw() this.draw()
}) })
.catch(() => {
this.hasData = false
})
}, },
draw() { draw() {
this.option = { this.option = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!