Commit 8539ac6e by chenwq

折线图

1 parent 3cdb955e
<template> <template>
<div class="line-box"> <div class="line-box">
<div id="line-chart" class="line-chart"></div> <div :id="domId" class="line-chart"></div>
<div class="rank-box"> <div class="rank-box">
<div class="rank-title-block"> <div class="rank-title-block">
<p :class="[ 'rank-title', rankFlag == 'top' ? 'rank-title-active' : '' ]" @click="handleRankChange('top')">前5{{ storeOrBrandTxt }}</p> <p :class="[ 'rank-title', rankFlag == 'top' ? 'rank-title-active' : '' ]" @click="handleRankChange('top')">前5{{ storeOrBrandTxt }}</p>
...@@ -23,6 +23,10 @@ import getLineOptions from './lineOptions' ...@@ -23,6 +23,10 @@ import getLineOptions from './lineOptions'
export default { export default {
name: 'LineChart', name: 'LineChart',
props: { props: {
domId: {
type: String,
default: 'line-chart'
},
storeOrBrandTxt: { storeOrBrandTxt: {
type: String, type: String,
default: '品牌' default: '品牌'
...@@ -42,7 +46,7 @@ export default { ...@@ -42,7 +46,7 @@ export default {
rankList: [], rankList: [],
echartsLine: '', echartsLine: '',
moveAttr: { moveAttr: {
speed: 2000, speed: 900,
seriesIndex: 0, seriesIndex: 0,
dataIndex: -1 dataIndex: -1
}, },
...@@ -55,7 +59,7 @@ export default { ...@@ -55,7 +59,7 @@ export default {
}, },
mounted() { mounted() {
this.lineDom = document.getElementById('line-chart') this.lineDom = document.getElementById(this.domId)
this.echartsLine = echarts.init(this.lineDom) this.echartsLine = echarts.init(this.lineDom)
}, },
...@@ -134,7 +138,7 @@ export default { ...@@ -134,7 +138,7 @@ export default {
this.getRankList(0) this.getRankList(0)
// this.autoMove() this.autoMove()
}, },
handleRankChange(value) { handleRankChange(value) {
......
...@@ -8,6 +8,15 @@ ...@@ -8,6 +8,15 @@
<template> <template>
<div> <div>
<div class="title">有效客户</div> <div class="title">有效客户</div>
<div v-if="!dataList.length" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<div v-else>
<div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<LineChart v-else ref="lineChartRef" domId="efficientChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart>
</div>
</div> </div>
</template> </template>
...@@ -24,48 +33,77 @@ export default { ...@@ -24,48 +33,77 @@ export default {
}, },
data() { data() {
return { return {
rankList: [ isEmpty: true,
{ storeOrBrandTxt: '品牌',
name: '奥迪', dataList: []
num: 599604
},
{
name: '宝马',
num: 599604
},
{
name: '现代起亚',
num: 599604
},
{
name: '奔驰',
num: 599604
},
{
name: '沃尔沃',
num: 599604
}
]
} }
}, },
mounted() { mounted() { },
// this.dealList()
},
methods: { methods: {
init(val) { init(val) {
}, this.isEmpty = true
// 折线图数据 var params = {
getList() { }, req: {
// 排名数据 // corporateGroupName: '广汇',
getRankList() { }, corporateGroupName: '集团1',
dealList() { queryItem: 'valid',
this.rankList.forEach(item => { querystartTime: +val.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12),
item.num = this.numAddSymbol(item.num) 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
}
this.api.afterSales[brandName ? 'getMerchantAfterSale' : 'getAfterSale'](params).then(res => {
var { code, data } = res
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.isEmpty = false
this.dealList(data.dataList)
this.$nextTick(() => {
this.$refs.lineChartRef.drawLine()
})
}
break
}
}) })
}, },
handleRankChange(value) { dealList(list) {
console.log(value) var topList = []
var lastList = []
list.forEach(item => {
const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: this.numAddSymbol(topTempList[item])
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: this.numAddSymbol(lastTempList[item])
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
} }
} }
} }
</script> </script>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div v-if="isEmpty" class="empty"> <div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" /> <img src="../../assets/images/empty.png" alt="" />
</div> </div>
<LineChart v-else ref="lineChartRef" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart> <LineChart v-else ref="lineChartRef" domId="fileChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart>
</div> </div>
</div> </div>
</template> </template>
...@@ -80,8 +80,8 @@ export default { ...@@ -80,8 +80,8 @@ export default {
var topList = [] var topList = []
var lastList = [] var lastList = []
list.forEach(item => { list.forEach(item => {
const topTempList = item.topList == 'null' ? [] : JSON.parse(item.topList) const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList == 'null' ? [] : JSON.parse(item.lastList) const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = [] topList = []
lastList = [] lastList = []
Object.keys(topTempList).forEach(item => { Object.keys(topTempList).forEach(item => {
......
...@@ -8,11 +8,101 @@ ...@@ -8,11 +8,101 @@
<template> <template>
<div> <div>
<div class="title">首保回店</div> <div class="title">首保回店</div>
<div v-if="!dataList.length" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<div v-else>
<div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<LineChart v-else ref="lineChartRef" domId="firstChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart>
</div>
</div> </div>
</template> </template>
<script> <script>
import { changeMixin } from '@/mixins'
export default { export default {
name: 'First' name: 'First',
mixins: [changeMixin],
props: {
height: {
type: String,
default: '19.8vh'
}
},
data() {
return {
isEmpty: true,
storeOrBrandTxt: '品牌',
dataList: []
}
},
mounted() { },
methods: {
init(val) {
this.isEmpty = true
var params = {
req: {
// corporateGroupName: '广汇',
corporateGroupName: '集团1',
queryItem: 'first',
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
}
this.api.afterSales[brandName ? 'getMerchantAfterSale' : 'getAfterSale'](params).then(res => {
var { code, data } = res
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.isEmpty = false
this.dealList(data.dataList)
this.$nextTick(() => {
this.$refs.lineChartRef.drawLine()
})
}
break
}
})
},
dealList(list) {
var topList = []
var lastList = []
list.forEach(item => {
const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: this.numAddSymbol(topTempList[item].num)
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: this.numAddSymbol(lastTempList[item].num)
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
}
}
} }
</script> </script>
...@@ -8,11 +8,101 @@ ...@@ -8,11 +8,101 @@
<template> <template>
<div> <div>
<div class="title">客户保持</div> <div class="title">客户保持</div>
<div v-if="!dataList.length" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<div v-else>
<div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<LineChart v-else ref="lineChartRef" domId="keepChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart>
</div>
</div> </div>
</template> </template>
<script> <script>
import { changeMixin } from '@/mixins'
export default { export default {
name: 'Keep' name: 'Keep',
mixins: [changeMixin],
props: {
height: {
type: String,
default: '19.8vh'
}
},
data() {
return {
isEmpty: true,
storeOrBrandTxt: '品牌',
dataList: []
}
},
mounted() { },
methods: {
init(val) {
this.isEmpty = true
var params = {
req: {
// corporateGroupName: '广汇',
corporateGroupName: '集团1',
queryItem: 'retain',
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
}
this.api.afterSales[brandName ? 'getMerchantAfterSale' : 'getAfterSale'](params).then(res => {
var { code, data } = res
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.isEmpty = false
this.dealList(data.dataList)
this.$nextTick(() => {
this.$refs.lineChartRef.drawLine()
})
}
break
}
})
},
dealList(list) {
var topList = []
var lastList = []
list.forEach(item => {
const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: this.numAddSymbol(topTempList[item])
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: this.numAddSymbol(lastTempList[item])
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
}
}
} }
</script> </script>
...@@ -8,11 +8,101 @@ ...@@ -8,11 +8,101 @@
<template> <template>
<div> <div>
<div class="title">客户流失</div> <div class="title">客户流失</div>
<div v-if="!dataList.length" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<div v-else>
<div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<LineChart v-else ref="lineChartRef" domId="lostChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart>
</div>
</div> </div>
</template> </template>
<script> <script>
import { changeMixin } from '@/mixins'
export default { export default {
name: 'Lost' name: 'Lost',
mixins: [changeMixin],
props: {
height: {
type: String,
default: '19.8vh'
}
},
data() {
return {
isEmpty: true,
storeOrBrandTxt: '品牌',
dataList: []
}
},
mounted() { },
methods: {
init(val) {
this.isEmpty = true
var params = {
req: {
// corporateGroupName: '广汇',
corporateGroupName: '集团1',
queryItem: 'loss',
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
}
this.api.afterSales[brandName ? 'getMerchantAfterSale' : 'getAfterSale'](params).then(res => {
var { code, data } = res
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.isEmpty = false
this.dealList(data.dataList)
this.$nextTick(() => {
this.$refs.lineChartRef.drawLine()
})
}
break
}
})
},
dealList(list) {
var topList = []
var lastList = []
list.forEach(item => {
const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: this.numAddSymbol(topTempList[item])
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: this.numAddSymbol(lastTempList[item])
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
}
}
} }
</script> </script>
...@@ -8,11 +8,101 @@ ...@@ -8,11 +8,101 @@
<template> <template>
<div> <div>
<div class="title">定保回店</div> <div class="title">定保回店</div>
<div v-if="!dataList.length" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<div v-else>
<div v-if="isEmpty" class="empty">
<img src="../../assets/images/empty.png" alt="" />
</div>
<LineChart v-else ref="lineChartRef" domId="sadayasuChart" :dataList.sync="dataList" :storeOrBrandTxt="storeOrBrandTxt"></LineChart>
</div>
</div> </div>
</template> </template>
<script> <script>
import { changeMixin } from '@/mixins'
export default { export default {
name: 'Sadayasu' name: 'Sadayasu',
mixins: [changeMixin],
props: {
height: {
type: String,
default: '19.8vh'
}
},
data() {
return {
isEmpty: true,
storeOrBrandTxt: '品牌',
dataList: []
}
},
mounted() { },
methods: {
init(val) {
this.isEmpty = true
var params = {
req: {
// corporateGroupName: '广汇',
corporateGroupName: '集团1',
queryItem: 'regular',
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
}
this.api.afterSales[brandName ? 'getMerchantAfterSale' : 'getAfterSale'](params).then(res => {
var { code, data } = res
switch (+code) {
case 0:
this.dataList = []
if (!data.dataList.map(item => item.num).every(item => item === 0)) {
this.isEmpty = false
this.dealList(data.dataList)
this.$nextTick(() => {
this.$refs.lineChartRef.drawLine()
})
}
break
}
})
},
dealList(list) {
var topList = []
var lastList = []
list.forEach(item => {
const topTempList = item.topList === 'null' ? [] : JSON.parse(item.topList)
const lastTempList = item.lastList === 'null' ? [] : JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: this.numAddSymbol(topTempList[item].num)
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: this.numAddSymbol(lastTempList[item].num)
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
}
}
} }
</script> </script>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!