Commit d1aabe1b by 王志慧

Merge branch 'dev_v1.0.0' of http://192.168.3.233:8090/gh/data-view into dev_v1.0.0

2 parents bc8a39f7 e2ca2e40
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
</div> </div>
<div class="rank-block"> <div class="rank-block">
<div class="rank-line" v-for="(item, index) in rankList" :key="index"> <div class="rank-line" v-for="(item, index) in rankList" :key="index">
<marquee class="line-item" :direction="directionTimer" :delay="delayTimer" :text="item.label"></marquee> <div class="line-item">
<marquee :direction="directionTimer" :delay="delayTimer" :text="item.label"></marquee>
</div>
<p class="line-item txt-orange">{{ item.value }}</p> <p class="line-item txt-orange">{{ item.value }}</p>
</div> </div>
</div> </div>
...@@ -67,9 +69,9 @@ export default { ...@@ -67,9 +69,9 @@ export default {
rankList: [], rankList: [],
echartsLine: '', echartsLine: '',
moveAttr: { moveAttr: {
speed: 900, // speed: 900,
seriesIndex: 0, seriesIndex: 0,
dataIndex: -1 dataIndex: 0
}, },
timer: null timer: null
} }
...@@ -81,12 +83,12 @@ export default { ...@@ -81,12 +83,12 @@ export default {
mounted() { mounted() {
this.lineDom = document.getElementById(this.domId) this.lineDom = document.getElementById(this.domId)
this.echartsLine = echarts.init(this.lineDom) this[this.domId] = echarts.init(this.lineDom)
}, },
methods: { methods: {
resetRankList() { resetRankList() {
this.rankList = new Array(5).fill({ label: '-', value: '-' }) this.rankList = new Array(5).fill({ label: '- -', value: '- -' })
}, },
tooltipFormatter(obj) { tooltipFormatter(obj) {
var currentItem = this.dataList[obj[0].dataIndex] var currentItem = this.dataList[obj[0].dataIndex]
...@@ -100,41 +102,44 @@ export default { ...@@ -100,41 +102,44 @@ export default {
return txt return txt
}, },
autoMove() { // autoMove() {
clearInterval(this.timer) // clearInterval(this.timer)
this.timer = setInterval(() => { // this.timer = setInterval(() => {
this.moveAttr.dataIndex = this.moveAttr.dataIndex + 1 // this.moveAttr.dataIndex = this.moveAttr.dataIndex + 1
if (this.moveAttr.dataIndex === this.dataList.length) { // if (this.moveAttr.dataIndex === this.dataList.length) {
this.moveAttr.dataIndex = 0 // this.moveAttr.dataIndex = 0
} // }
this.chartAction() // this.chartAction()
this.autoMove() // this.autoMove()
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List') // this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}, this.moveAttr.speed) // }, this.moveAttr.speed)
}, // },
chartBindEvent() { chartBindEvent() {
// resize // resize
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.echartsLine.resize() this[this.domId].resize()
}) })
// 鼠标划入 // 鼠标划入
this.lineDom.addEventListener('mouseover', () => { this[this.domId].on('mouseover', data => {
clearInterval(this.timer) this.moveAttr.seriesIndex = data.dataIndex
this.chartAction('downplay') this.getRankList(this.moveAttr.seriesIndex, this.rankFlag + 'List')
}) })
// 鼠标划出 // 鼠标划出
this.lineDom.addEventListener('mouseout', () => { this[this.domId].on('mouseout', () => {
this.moveAttr.dataIndex = -1 console.log('0000000000')
this.autoMove() setTimeout(() => {
this.chartAction()
}, 1000)
}) })
}, },
chartAction(type) { chartAction(type) {
this.echartsLine.dispatchAction({ console.log(this.moveAttr, '???/cwq')
this[this.domId].dispatchAction({
type: type || 'showTip', type: type || 'showTip',
seriesIndex: this.moveAttr.seriesIndex, seriesIndex: this.moveAttr.seriesIndex,
dataIndex: this.moveAttr.dataIndex dataIndex: this.moveAttr.dataIndex
...@@ -150,26 +155,16 @@ export default { ...@@ -150,26 +155,16 @@ export default {
this.lineOptions.series[0].data = this.dataList.map(item => item.num) this.lineOptions.series[0].data = this.dataList.map(item => item.num)
this.echartsLine.setOption(this.lineOptions) this[this.domId].setOption(this.lineOptions)
// // 鼠标划入
// this.echartsLine.on('click', data => {
// clearInterval(this.timer)
// this.chartAction('downplay')
// })
// // 鼠标划出
// this.echartsLine.on('mouseout', () => {
// this.moveAttr.dataIndex = -1
// this.autoMove()
// })
// console.log(this.echartsLine)
this.chartBindEvent() this.chartBindEvent()
// 默认展示tooltip
this.chartAction()
this.getRankList(0) this.getRankList(0)
this.autoMove() // this.autoMove()
}, },
handleRankChange(value) { handleRankChange(value) {
...@@ -232,6 +227,7 @@ p { ...@@ -232,6 +227,7 @@ p {
border-left: 1px solid rgba(96, 98, 102, 0.4); border-left: 1px solid rgba(96, 98, 102, 0.4);
.line-item { .line-item {
height: 1.8vh; height: 1.8vh;
width: 100%;
font-size: 10px; font-size: 10px;
padding-bottom: 0.6vh; padding-bottom: 0.6vh;
} }
......
...@@ -3,16 +3,18 @@ ...@@ -3,16 +3,18 @@
* @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 14:38:18 * @LastEditTime: 2022-06-30 17:04:25
--> -->
<template> <template>
<div> <div>
<div class="title">转化趋势</div> <div class="title">转化趋势{{ hasData }}</div>
<!-- <div class="empty"> <div v-if="hasData" style="width: 100%">
<img src="../../assets/images/empty.png" alt="" />
</div> -->
<div id="lineTrend" :style="{ height: height - 4.1 + 'vh' }"></div> <div id="lineTrend" :style="{ height: height - 4.1 + 'vh' }"></div>
</div> </div>
<div v-else class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
</div>
</template> </template>
<script> <script>
...@@ -27,7 +29,9 @@ export default { ...@@ -27,7 +29,9 @@ export default {
echartsTrend: {}, echartsTrend: {},
option: {}, option: {},
dataList: [], dataList: [],
paramsData: [] paramsData: [],
list: ['enter', 'stayfile', 'test', 'placeorder', 'success'],
hasData: true
} }
}, },
mounted() { mounted() {
...@@ -41,7 +45,7 @@ export default { ...@@ -41,7 +45,7 @@ export default {
var params = { var params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: '集团1',
queryItem: 'enter', // queryItem: 'enter',
querystartTime: +val.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12), querystartTime: +val.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12),
queryendTime: +val.reportType === 1 ? this.getNDate(-1) : this.getNMonth(-1), queryendTime: +val.reportType === 1 ? this.getNDate(-1) : this.getNMonth(-1),
queryType: val.reportType || 0 queryType: val.reportType || 0
...@@ -52,37 +56,49 @@ export default { ...@@ -52,37 +56,49 @@ export default {
if (brandName) { if (brandName) {
params.req.brandName = brandName params.req.brandName = brandName
} }
this.api.sales[brandName ? 'storeTransTrend' : 'saleTransTrend'](params).then(res => { const api = brandName ? 'storeTransTrend' : 'saleTransTrend'
var { code, data } = res const p = []
console.log(res) this.list.forEach((i, idx) => {
switch (+code) { p[idx] = new Promise((resolve, reject) => {
case 0: params.req.queryItem = i
this.dataList = [] this.api.sales[api](params).then(res => {
if (!data.dataList.map(item => item.num).every(item => item === 0)) { resolve(res.data.dataList)
this.dealList(data.dataList)
this.$nextTick(() => {
this.draw()
}) })
})
})
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
} }
break })
} console.log(
flag,
flag.every(i => !i)
)
// this.hasData = !flag.every(i => !i)
this.$set(this, 'hasData', !flag.every(i => !i))
this.draw()
}) })
}, },
draw() { draw() {
this.option = { this.option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
show: true,
borderWidth: 0, borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)', backgroundColor: 'rgba(68,68,68,0.80)',
position: [20, 20], // position: [20, 20],
textStyle: { textStyle: {
color: '#FFFFFF', color: '#FFFFFF',
fontSize: 8 fontSize: 8
}, },
extraCssText: 'width: 60px;', extraCssText: 'width: 80px;',
// formatter: this.tooltipFormatter
formatter: e => { formatter: e => {
console.log(e)
var txt = '' var txt = ''
e.forEach(item => { e.forEach(item => {
if (txt) { if (txt) {
...@@ -110,83 +126,61 @@ export default { ...@@ -110,83 +126,61 @@ export default {
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
}, },
yAxis: { yAxis: {
type: 'value', type: 'value'
splitLine: {
lineStyle: {
color: '#606266'
}
}
}, },
series: [ series: [
{ {
name: '客流', name: '客流',
type: 'line', type: 'line',
symbol: 'none', symbol: 'circle',
smooth: true, smooth: true,
showSymbol: false,
stack: 'Total', stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210] data: []
}, },
{ {
name: '留档', name: '留档',
type: 'line', type: 'line',
symbol: 'circle',
smooth: true, smooth: true,
symbol: 'none', showSymbol: false,
stack: 'Total', stack: 'Total',
data: [220, 182, 191, 234, 290, 330, 310] data: []
}, },
{ {
name: '试驾', name: '试驾',
type: 'line', type: 'line',
symbol: 'none', symbol: 'circle',
smooth: true, smooth: true,
showSymbol: false,
stack: 'Total', stack: 'Total',
data: [150, 232, 201, 154, 190, 330, 410] data: []
}, },
{ {
name: '订单', name: '订单',
type: 'line', type: 'line',
symbol: 'none', symbol: 'circle',
showSymbol: false,
smooth: true, smooth: true,
stack: 'Total', stack: 'Total',
data: [320, 332, 301, 334, 390, 330, 320] data: []
}, },
{ {
name: '成交', name: '成交',
type: 'line', type: 'line',
symbol: 'none', symbol: 'circle',
showSymbol: false,
smooth: true, smooth: true,
stack: 'Total', 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.xAxis.data = this.dataList[0].map(item => item.statDate)
this.list.forEach((i, index) => {
this.option.series[0].data = this.dataList.map(item => item.num) this.option.series[index].data = this.dataList[index].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.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!