Commit 8cefb039 by 胡悦

优化

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