Commit cafd30eb by 李伟康

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

2 parents 3022b8bc 77e67c21
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2022-06-28 14:58:30 * @Date: 2022-06-28 14:58:30
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2022-06-29 15:56:22 * @LastEditTime: 2022-06-30 14:27:04
*/ */
import Request from '../request' import Request from '../request'
const request = new Request() const request = new Request()
...@@ -23,6 +23,11 @@ const saleTrans = params => { ...@@ -23,6 +23,11 @@ const saleTrans = params => {
return request.get('brand/saleTrans', params) return request.get('brand/saleTrans', params)
} }
// 获取品牌客流转化趋势
const saleTransTrend = params => {
return request.get('brand/saleTransTrend', params)
}
// 门店相关 // 门店相关
// 获取门店销售转化总数据 // 获取门店销售转化总数据
const storeTotal = params => { const storeTotal = params => {
...@@ -37,11 +42,18 @@ const storeSaleTrans = params => { ...@@ -37,11 +42,18 @@ const storeSaleTrans = params => {
const getMerchantSales = params => { const getMerchantSales = params => {
return request.get('merchant/sale', params) return request.get('merchant/sale', params)
} }
// 获取门店客流转化趋势
const storeTransTrend = params => {
return request.get('merchant/saleTransTrend', params)
}
export default { export default {
getSales, getSales,
saleTotal, saleTotal,
saleTrans, saleTrans,
storeTotal, storeTotal,
storeSaleTrans, storeSaleTrans,
getMerchantSales getMerchantSales,
saleTransTrend,
storeTransTrend
} }
...@@ -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,10 +83,13 @@ export default { ...@@ -81,10 +83,13 @@ 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() {
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]
var txt = '' var txt = ''
...@@ -97,49 +102,48 @@ export default { ...@@ -97,49 +102,48 @@ 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.dataIndex = data.dataIndex
this.chartAction('downplay') this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}) })
// 鼠标划出 // 移除图表
this.lineDom.addEventListener('mouseout', () => { this[this.domId].on('globalout', () => {
this.moveAttr.dataIndex = -1 this.chartAction()
this.autoMove()
}) })
}, },
chartAction(type) { chartAction(type) {
this.echartsLine.dispatchAction({ 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
}) })
}, },
getRankList(idx, attrName = 'topList') { getRankList(idx, attrName = 'topList') {
this.$set(this, 'rankList', this.dataList[idx][attrName]) this.dataList[idx][attrName].length ? this.$set(this, 'rankList', this.dataList[idx][attrName]) : this.resetRankList()
}, },
drawLine() { drawLine() {
...@@ -147,31 +151,21 @@ export default { ...@@ -147,31 +151,21 @@ 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) {
this.rankFlag = value this.rankFlag = value
this.getRankList(this.moveAttr.seriesIndex, this.rankFlag + 'List') this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
} }
} }
} }
...@@ -229,6 +223,7 @@ p { ...@@ -229,6 +223,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;
} }
......
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
}, },
colors: { colors: {
type: Array, type: Array,
default: () => ['#4FA0FF', '#7CFFB2', '#FDF006', '#EB6001', '#F5AA01', '#BF98FF', '#58D9F9'] default: () => ['#4FA0FF', '#FF6E76', '#7CFFB2','#FDF006','#EB6001','#F5AA01','#BF98FF','#4FA0FF']
} }
}, },
......
...@@ -43,20 +43,23 @@ export default { ...@@ -43,20 +43,23 @@ export default {
background: #262525; background: #262525;
.ranking-title { .ranking-title {
background: rgba(53, 53, 53, 0.6); background: rgba(53, 53, 53, 0.6);
font-size: 10px; font-size: 0.694vw;
color: #eb6001; color: #eb6001;
font-weight: 400; font-weight: 400;
padding: 0.4vh 0 0.4vh 20%; padding: 0.4vh 0 0.4vh 20%;
box-sizing: border-box; box-sizing: border-box;
} }
.ranking { .ranking {
font-size: 10px; font-size: 0.694vw;
color: #ffffff; color: #ffffff;
letter-spacing: 0; letter-spacing: 0;
font-weight: 400; font-weight: 400;
padding:0.1vh 0 0.4vh 8px; padding: 0.2vh 0 0.3vh 8px;
.brand { .brand {
line-height: 1.9vh; // line-height: 1.9vh;
height: 1.9vh;
display:flex;
align-items: center;
.brand-num { .brand-num {
color: #606266; color: #606266;
margin-right: 0.6vw; margin-right: 0.6vw;
...@@ -64,6 +67,7 @@ export default { ...@@ -64,6 +67,7 @@ export default {
.marquee { .marquee {
width: 80%; width: 80%;
height: 1.9vh; height: 1.9vh;
font-weight: 400;
} }
} }
} }
......
...@@ -4,6 +4,7 @@ function getLineOptions(obj) { ...@@ -4,6 +4,7 @@ function getLineOptions(obj) {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
borderWidth: 0, borderWidth: 0,
show: true,
backgroundColor: 'rgba(68,68,68,0.80)', backgroundColor: 'rgba(68,68,68,0.80)',
textStyle: { textStyle: {
color: '#FFFFFF', color: '#FFFFFF',
...@@ -38,13 +39,14 @@ function getLineOptions(obj) { ...@@ -38,13 +39,14 @@ function getLineOptions(obj) {
series: [ series: [
{ {
type: 'line', type: 'line',
symbol: 'circle',
itemStyle: { itemStyle: {
color: '#F5AA01' color: '#F5AA01'
}, },
// 节点,平滑曲线 // 平滑曲线
symbol: 'none',
smooth: true, smooth: true,
showSymbol: false,
// 折线背景色 // 折线背景色
areaStyle: { areaStyle: {
color: { color: {
......
export default { export default {
data() {
return {
corporateGroupName: '集团1'
}
},
watch: { watch: {
watchReportParams: { watchReportParams: {
immediate: true, immediate: true,
......
...@@ -11,18 +11,18 @@ export default { ...@@ -11,18 +11,18 @@ export default {
}, },
mixins: [changeMixin], mixins: [changeMixin],
created() { created() {
this.getClientData() // this.getClientData()
}, },
methods: { methods: {
getClientData() { getClientData() {
let clientApi = !this.isBrand ? 'overalldistribution' : 'merchantOveralldistribution' let clientApi = !this.isBrand ? 'overalldistribution' : 'merchantOveralldistribution'
const params = { const params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: this.corporateGroupName,
queryItem: this.type, queryItem: this.type,
// queryTime: this.getCurrentDate, // queryTime: this.getCurrentDate,
queryTime: '2022-06-23', queryTime: '2022-06-23',
queryType: this.watchReportParams.reportType // queryType: this.watchReportParams.reportType
} }
} }
if (this.isBrand) params.req.brandName = this.brandName if (this.isBrand) params.req.brandName = this.brandName
......
...@@ -11,14 +11,14 @@ export default { ...@@ -11,14 +11,14 @@ export default {
}, },
mixins: [changeMixin], mixins: [changeMixin],
created() { created() {
this.getSalesData() // this.getSalesData()
}, },
methods: { methods: {
getSalesData() { getSalesData() {
let salesApi = !this.isBrand ? 'getSales' : 'getMerchantSales' let salesApi = !this.isBrand ? 'getSales' : 'getMerchantSales'
const params = { const params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: this.corporateGroupName,
queryItem: this.type, queryItem: this.type,
// queryTime: this.getCurrentDate, // queryTime: this.getCurrentDate,
queryTime: '2022-06-23', queryTime: '2022-06-23',
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
<div> <div>
<div class="title">售后客户价值分析</div> <div class="title">售后客户价值分析</div>
<template v-if="barData.length > 0"> <template v-if="barData.length > 0">
<div class="analyze-content" :style="{ height: height - 4.9 + 'vh' }"> <div class="analyze-content" :style="{ height: height - 5 + 'vh'}">
<div class="content-left bg"> <div class="content-left bg">
<div id="analyzeBar" style="height: 100%"></div> <div id="analyzeBar" style="height: 100%"></div>
</div> </div>
<div class="contetn-right bg"> <div class="contetn-right bg">
<pie-chart :id="chart.id" :list="analyzeData" :height="height - 4.9 + 'vh'" :radius="chart.radius"></pie-chart> <pie-chart :id="chart.id" :list="analyzeData" :height="height - 5 + 'vh'" :radius="chart.radius"></pie-chart>
</div> </div>
</div> </div>
</template> </template>
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
barChart: '', barChart: '',
option: {}, option: {},
barData: [], barData: [],
key: 1, key: '重要价值',
isBrand: false, isBrand: false,
brandName: '' brandName: ''
} }
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
let analyzeApi = !this.isBrand ? 'aftersaleother' : 'afterMerchantSaleother' let analyzeApi = !this.isBrand ? 'aftersaleother' : 'afterMerchantSaleother'
const params = { const params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: this.corporateGroupName,
queryItem: 'valueanalyse', queryItem: 'valueanalyse',
// queryTime: this.getCurrentDate, // queryTime: this.getCurrentDate,
queryTime: '2022-06-23', queryTime: '2022-06-23',
...@@ -154,18 +154,23 @@ export default { ...@@ -154,18 +154,23 @@ export default {
} }
this.$nextTick(() => { this.$nextTick(() => {
this.getChart() this.getChart()
this.initPieData() this.initPieData(this.key)
}) })
} }
}) })
}, },
initPieData(name) { initPieData(name) {
const distributionRank = this.distributionRank[this.key] this.analyzeData = []
Object.keys(distributionRank).forEach(item => { datas.Customer.valueType.value.map(item => {
this.analyzeData.push({ if (item.name == name) {
name: item, const distributionRank = this.distributionRank[item.value]
value: distributionRank[item] Object.keys(distributionRank).forEach(item => {
}) this.analyzeData.push({
name: item,
value: distributionRank[item]
})
})
}
}) })
}, },
init(newVal) { init(newVal) {
...@@ -181,6 +186,9 @@ export default { ...@@ -181,6 +186,9 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.title{
padding:1vh 0.556vw;
}
.analyze-content { .analyze-content {
display: flex; display: flex;
padding: 0 8px 1.8vh; padding: 0 8px 1.8vh;
......
...@@ -43,7 +43,6 @@ export default { ...@@ -43,7 +43,6 @@ export default {
}, },
methods: { methods: {
init(val) { init(val) {
// console.log(val)
this.isEmpty = true this.isEmpty = true
var params = { var params = {
req: { req: {
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
<div> <div>
<div class="title">售后车辆里程</div> <div class="title">售后车辆里程</div>
<template v-if="mileageData.length > 0"> <template v-if="mileageData.length > 0">
<div class="flex"> <div class="flex container">
<pie-chart :id="chart.id" :list="mileageData" :height="height - 4.9 + 'vh'" :radius="chart.radius" @pieAction="pieAction"></pie-chart> <pie-chart :id="chart.id" :list="mileageData" :height="height - 5 + 'vh'" :radius="chart.radius" @pieAction="pieAction"></pie-chart>
<div class="ranking-container"> <div class="ranking-container">
<div class="ranking-title"> <div class="ranking-title">
<div class="ranking-title-brand">品牌</div> <div class="ranking-title-brand">品牌</div>
<div>客户数</div> <div>客户数</div>
</div> </div>
<div class="ranking"> <div class="ranking">
<div class="brand flex" v-for="(item, index) in rankingData" :key="index"> <div class="brand flex" v-for="(item, index) in rankingData.slice(0, 5)" :key="index">
<span class="brand-num">{{ index + 1 }}</span> <span class="brand-num">{{ index + 1 }}</span>
<marquee class="marquee" :direction="directionTimer" :delay="delayTimer" :text="item.brand" /> <marquee class="marquee" :direction="directionTimer" :delay="delayTimer" :text="item.brand" />
<span>{{ item.value }}</span> <span>{{ item.value }}</span>
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
let mileageApi = !this.isBrand ? 'aftersaleother' : 'afterMerchantSaleother' let mileageApi = !this.isBrand ? 'aftersaleother' : 'afterMerchantSaleother'
const params = { const params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: this.corporateGroupName,
queryItem: 'mileage', queryItem: 'mileage',
// queryTime: this.getCurrentDate, // queryTime: this.getCurrentDate,
queryTime: '2022-06-23', queryTime: '2022-06-23',
...@@ -108,6 +108,9 @@ export default { ...@@ -108,6 +108,9 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.title {
padding: 1vh 0.556vw;
}
.ranking-container { .ranking-container {
flex: 1; flex: 1;
margin-left: 0.6vw; margin-left: 0.6vw;
...@@ -117,20 +120,23 @@ export default { ...@@ -117,20 +120,23 @@ export default {
background: #262525; background: #262525;
.ranking-title { .ranking-title {
padding: 0.5vh 1.5vw 0.4vh 1.5vw; padding: 0.5vh 1.5vw 0.4vh 1.5vw;
font-size: 12px; font-size: 0.833vw;
color: #eb6001; color: #eb6001;
letter-spacing: 0; letter-spacing: 0;
font-weight: 400; font-weight: 400;
background: rgba(53, 53, 53, 0.6); background: rgba(53, 53, 53, 0.6);
display: flex; display: flex;
align-items: center; align-items: center;
div {
white-space: nowrap;
}
.ranking-title-brand { .ranking-title-brand {
width: 4.9vw; width: 4.9vw;
margin-right: 0.6vw; margin-right: 0.6vw;
} }
} }
.ranking { .ranking {
font-size: 10px; font-size: 0.694vw;
color: #ffffff; color: #ffffff;
letter-spacing: 0; letter-spacing: 0;
font-weight: 400; font-weight: 400;
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户性别</span> <span>客户性别</span>
</div> </div>
<div class="container flex"> <div class="container flex">
<template v-if="clientData.length > 0"> <template v-if="clientData.length > 0">
<pie-chart :id="chart.id" :list="clientData" :colors="chart.colors" @pieAction="pieAction"></pie-chart> <pie-chart :id="chart.id" :list="clientData" :colors="chart.colors" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king> <ran-king :list="brandList"></ran-king>
</template> </template>
<div class="empty" style="height:12.7vh" v-else> <div class="empty" style="height: 12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" /> <img src="../../assets/images/empty.png" alt="" />
</div> </div>
</div> </div>
...@@ -26,20 +26,30 @@ ...@@ -26,20 +26,30 @@
import { clientMixin } from '../../mixins/index' import { clientMixin } from '../../mixins/index'
export default { export default {
name: 'Sex', name: 'Sex',
mixins: [clientMixin], mixins: [clientMixin],
data() { data() {
return { return {
type: 'gender', type: 'gender',
chart: { chart: {
id: 'sex-pie', id: 'sex-pie',
colors:["#EB6001","#BF98FF","#FF6E76"] colors: ['#EB6001', '#BF98FF', '#FF6E76']
} }
} }
}, },
<<<<<<< HEAD
methods:{ methods:{
pieAction(data){ pieAction(data){
// console.log(this.distributionRank,'客户性别') // console.log(this.distributionRank,'客户性别')
this.brandList = this.distributionRank&&this.distributionRank[data.name]&&Object.keys(this.distributionRank[data.name]) this.brandList = this.distributionRank&&this.distributionRank[data.name]&&Object.keys(this.distributionRank[data.name])
=======
methods: {
pieAction(data) {
this.brandList = []
let array = this.distributionRank && this.distributionRank[data.name]
for (let i of array) {
this.brandList.push(Object.keys(i)[0])
}
>>>>>>> 77e67c217ff8def255652d759823d1248a2b7735
} }
} }
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</div> </div>
<div class="flex container"> <div class="flex container">
<template v-if="salesData.length > 0"> <template v-if="salesData.length > 0">
<pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart> <pie-chart :id="chart.id" :list="salesData" :colors="chart.colors" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king> <ran-king :list="brandList"></ran-king>
</template> </template>
<div class="empty" style="height: 12.7vh" v-else> <div class="empty" style="height: 12.7vh" v-else>
...@@ -32,7 +32,8 @@ export default { ...@@ -32,7 +32,8 @@ export default {
return { return {
type: 'entertype', type: 'entertype',
chart: { chart: {
id: 'enterCategory-pie' id: 'enterCategory-pie',
colors: ['#F5AA01', '#FF6E76', '#4FA0FF']
} }
} }
}, },
......
...@@ -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-29 19:45:27 * @LastEditTime: 2022-06-30 10:59:56
--> -->
<template> <template>
<div> <div>
...@@ -95,7 +95,6 @@ export default { ...@@ -95,7 +95,6 @@ export default {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.echartsFunnel.resize() this.echartsFunnel.resize()
}) })
this.init()
}, },
methods: { methods: {
init(val) { init(val) {
......
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
return { return {
type: 'infosource', type: 'infosource',
chart: { chart: {
id: 'infoFrom-pie' id: 'infoFrom-pie',
} }
} }
}, },
......
/*
* @Description:
* @Author: huyue
* @Date: 2022-06-30 10:57:14
* @LastEditors: huyue
* @LastEditTime: 2022-06-30 10:57:17
*/
function getLineOptions(obj) {
const { tooltipFormatter } = obj
var lineOptions = {
tooltip: {
trigger: 'axis',
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
textStyle: {
color: '#FFFFFF',
fontSize: '8px'
},
extraCssText: 'width: 60px;',
formatter: tooltipFormatter || ''
},
grid: {
left: '3%',
right: '4%',
top: '10%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'category',
axisLabel: {
color: '#606266',
fontSize: '0.8em'
},
data: []
},
yAxis: {
type: 'value',
splitLine: {
lineStyle: {
color: '#606266'
}
}
},
series: [
{
type: 'line',
itemStyle: {
color: '#F5AA01'
},
// 节点,平滑曲线
symbol: 'none',
smooth: true,
// 折线背景色
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(254, 84, 0, 0.6)'
},
{
offset: 1,
color: 'rgba(254, 84, 0, 0.05)'
}
]
}
},
data: []
}
]
}
return lineOptions
}
export default getLineOptions
\ No newline at end of file \ No newline at end of file
...@@ -3,16 +3,185 @@ ...@@ -3,16 +3,185 @@
* @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-23 17:08:12 * @LastEditTime: 2022-06-30 17:04:25
--> -->
<template> <template>
<div> <div>
<div class="title">转化趋势</div> <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> </div>
</template> </template>
<script> <script>
import * as echarts from 'echarts'
import { changeMixin } from '@/mixins'
export default { export default {
name: 'Trend' name: 'Trend',
props: ['height'],
mixins: [changeMixin],
data() {
return {
echartsTrend: {},
option: {},
dataList: [],
paramsData: [],
list: ['enter', 'stayfile', 'test', 'placeorder', 'success'],
hasData: true
}
},
mounted() {
this.echartsTrend = echarts.init(document.getElementById('lineTrend'))
},
methods: {
init(val) {
this.getChartData(val)
},
getChartData(val) {
var params = {
req: {
corporateGroupName: '集团1',
// 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
}
}
var brandName = val.brand ? val.brand.name : ''
this.storeOrBrandTxt = brandName ? '门店' : '品牌'
if (brandName) {
params.req.brandName = brandName
}
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],
textStyle: {
color: '#FFFFFF',
fontSize: 8
},
extraCssText: 'width: 80px;',
formatter: e => {
var txt = ''
e.forEach(item => {
if (txt) {
txt = txt + '<br>'
}
txt = txt + item.seriesName + ':' + item.value
})
return txt
}
},
color: ['#4FA0FF', '#7CFFB2', '#FDF006', '#EB6001', '#F5AA01', '#BF98FF', '#58D9F9'],
grid: {
left: '3%',
right: '4%',
top: '10%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'category',
axisLabel: {
color: '#606266',
fontSize: '0.8em'
},
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
name: '客流',
type: 'line',
symbol: 'circle',
smooth: true,
showSymbol: false,
stack: 'Total',
data: []
},
{
name: '留档',
type: 'line',
symbol: 'circle',
smooth: true,
showSymbol: false,
stack: 'Total',
data: []
},
{
name: '试驾',
type: 'line',
symbol: 'circle',
smooth: true,
showSymbol: false,
stack: 'Total',
data: []
},
{
name: '订单',
type: 'line',
symbol: 'circle',
showSymbol: false,
smooth: true,
stack: 'Total',
data: []
},
{
name: '成交',
type: 'line',
symbol: 'circle',
showSymbol: false,
smooth: true,
stack: 'Total',
data: []
}
]
}
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)
}
}
} }
</script> </script>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!