Commit a4a9fc41 by 胡悦

转化趋势

1 parent 14a1ec47
......@@ -3,15 +3,17 @@
* @Author: huyue
* @Date: 2022-06-23 15:05:21
* @LastEditors: huyue
* @LastEditTime: 2022-06-30 14:38:18
* @LastEditTime: 2022-06-30 17:04:25
-->
<template>
<div>
<div class="title">转化趋势</div>
<!-- <div class="empty">
<div class="title">转化趋势{{ hasData }}</div>
<div v-if="hasData" style="width: 100%">
<div id="lineTrend" :style="{ height: height - 4.1 + 'vh' }"></div>
</div>
<div v-else class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div> -->
<div id="lineTrend" :style="{ height: height - 4.1 + 'vh' }"></div>
</div>
</div>
</template>
......@@ -27,7 +29,9 @@ export default {
echartsTrend: {},
option: {},
dataList: [],
paramsData: []
paramsData: [],
list: ['enter', 'stayfile', 'test', 'placeorder', 'success'],
hasData: true
}
},
mounted() {
......@@ -41,7 +45,7 @@ export default {
var params = {
req: {
corporateGroupName: '集团1',
queryItem: 'enter',
// queryItem: 'enter',
querystartTime: +val.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12),
queryendTime: +val.reportType === 1 ? this.getNDate(-1) : this.getNMonth(-1),
queryType: val.reportType || 0
......@@ -52,37 +56,49 @@ export default {
if (brandName) {
params.req.brandName = brandName
}
this.api.sales[brandName ? 'storeTransTrend' : 'saleTransTrend'](params).then(res => {
var { code, data } = res
console.log(res)
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.dealList(data.dataList)
this.$nextTick(() => {
this.draw()
})
}
break
}
const api = brandName ? 'storeTransTrend' : 'saleTransTrend'
const p = []
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)
})
})
})
Promise.all([p[0], p[1], p[2], p[3], p[4]]).then(results => {
console.log(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
}
})
console.log(
flag,
flag.every(i => !i)
)
// this.hasData = !flag.every(i => !i)
this.$set(this, 'hasData', !flag.every(i => !i))
this.draw()
})
},
draw() {
this.option = {
tooltip: {
trigger: 'axis',
show: true,
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
position: [20, 20],
// position: [20, 20],
textStyle: {
color: '#FFFFFF',
fontSize: 8
},
extraCssText: 'width: 60px;',
// formatter: this.tooltipFormatter
extraCssText: 'width: 80px;',
formatter: e => {
console.log(e)
var txt = ''
e.forEach(item => {
if (txt) {
......@@ -110,83 +126,61 @@ export default {
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value',
splitLine: {
lineStyle: {
color: '#606266'
}
}
type: 'value'
},
series: [
{
name: '客流',
type: 'line',
symbol: 'none',
symbol: 'circle',
smooth: true,
showSymbol: false,
stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210]
data: []
},
{
name: '留档',
type: 'line',
symbol: 'circle',
smooth: true,
symbol: 'none',
showSymbol: false,
stack: 'Total',
data: [220, 182, 191, 234, 290, 330, 310]
data: []
},
{
name: '试驾',
type: 'line',
symbol: 'none',
symbol: 'circle',
smooth: true,
showSymbol: false,
stack: 'Total',
data: [150, 232, 201, 154, 190, 330, 410]
data: []
},
{
name: '订单',
type: 'line',
symbol: 'none',
symbol: 'circle',
showSymbol: false,
smooth: true,
stack: 'Total',
data: [320, 332, 301, 334, 390, 330, 320]
data: []
},
{
name: '成交',
type: 'line',
symbol: 'none',
symbol: 'circle',
showSymbol: false,
smooth: true,
stack: 'Total',
data: [820, 932, 901, 934, 1290, 1330, 1320]
data: []
}
// {
// type: 'line',
// itemStyle: {
// color: '#F5AA01'
// },
// // 节点,平滑曲线
// symbol: 'none',
// smooth: true,
// // 折线背景色
// data: []
// }
]
}
this.option.xAxis.data = this.dataList.map(item => item.statDate)
this.option.series[0].data = this.dataList.map(item => item.num)
console.log(this.option)
this.echartsTrend.setOption(this.option)
},
dealList(list) {
list.forEach(item => {
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate
})
this.option.xAxis.data = this.dataList[0].map(item => item.statDate)
this.list.forEach((i, index) => {
this.option.series[index].data = this.dataList[index].map(item => item.num)
})
this.echartsTrend.setOption(this.option)
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!