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,19 +111,23 @@ export default { ...@@ -111,19 +111,23 @@ 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)
if (res.code === '0') { .then(res => {
if (res.data.dataList.length) { if (res.code === '0') {
res.data.dataList[0].num.forEach((item, index) => { if (res.data.dataList.length) {
this.funnelData[index].num = item 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() this.hasData = res.data.dataList[0].num.every(i => i != 0)
} else { if (this.hasData) this.draw()
this.hasData = false } else {
this.hasData = false
}
} }
} })
}) .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,23 +60,31 @@ export default { ...@@ -60,23 +60,31 @@ 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)
resolve(res.data.dataList) .then(res => {
}) 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]])
this.dataList = results .then(results => {
const flag = results.map(item => { this.dataList = results
if (item.length) { const flag = results.map(item => {
return item.map(i => i.num).some(j => j != 0) if (item.length) {
} else { return item.map(i => i.num).some(j => j != 0)
return false } 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() { 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!