Commit ce39783c by 前端

企业客户总览饼图

1 parent ef7a2781
......@@ -3,11 +3,11 @@ const getEnterpriseOverview = params => {
return window.$HTTP.get('enterpriseCustomer/getEnterpriseOverview', params)
}
// 获取门店年龄/性别/购车年限
const merchantOveralldistribution = params => {
return window.$HTTP.get('merchant/overalldistribution', params)
// 获取门店区域/品牌/类型
const getEnterpriseDistribution = params => {
return window.$HTTP.get('enterpriseCustomer/getEnterpriseDistribution', params)
}
export default {
getEnterpriseOverview,
merchantOveralldistribution
getEnterpriseDistribution
}
<template>
<div class="legend">
<div class="legend-item flex" v-for="item in 5">
<span></span>
湘
<div class="legend-item flex" v-for="(item, index) in dataList" :key="index">
<span :style="{ background: colors[index] }"></span>
{{ item.name }}
</div>
</div>
</template>
......@@ -10,7 +10,24 @@
export default {
name: 'Legend',
data() {
return {}
return {
dataList: this.list
}
},
props: {
list: {
type: Array,
default: () => []
},
colors: {
type: Array,
default: () => [' #FF6E76', '#7CFFB2', ' #FDF006', '#4FA0FF', '#EB6001']
}
},
watch: {
list(val) {
this.dataList = val
}
},
mounted() {},
methods: {}
......@@ -30,12 +47,11 @@ export default {
height: 2.44vh;
background: #0d133b;
align-items: center;
font-size: 9px;
font-size: 7px;
color: #fff;
margin: 0 2px 2px 0;
box-sizing: border-box;
line-height: 2.44vh;
margin: 2px 2px 0 0;
margin: 2px 0;
white-space: nowrap;
span {
width: 5px;
height: 5px;
......
......@@ -39,7 +39,7 @@ export default {
},
colors: {
type: Array,
default: () => ['#4FA0FF', '#FF6E76', '#7CFFB2', '#FDF006', '#EB6001', '#F5AA01', '#BF98FF', '#58D9F9']
default: () => [' #FF6E76', '#7CFFB2', ' #FDF006', '#4FA0FF', '#EB6001']
},
size: {
type: String,
......@@ -76,8 +76,8 @@ export default {
},
mounted() {
// this.initData()
// this.draw()
this.initData()
this.draw()
},
methods: {
......@@ -91,6 +91,7 @@ export default {
value: item[keys[1]]
})
})
console.log(this.viewData)
},
draw() {
if (this.mTime) clearInterval(this.mTime)
......
......@@ -40,7 +40,6 @@ export default {
methods: {
getEnterpriseOverview() {
this.api.customer.getEnterpriseOverview().then(res => {
console.log(res)
if(res.code == 0){
this.dataList = res.data.dataList[0]
}
......
......@@ -2,6 +2,9 @@ import { changeMixin } from './index'
export default {
data() {
return {
areaData:[],
brandData:[],
storeData:[],
clientData: [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
......@@ -17,56 +20,23 @@ export default {
},
mixins: [changeMixin],
created() {
// this.getClientData()
this.getClientData()
},
methods: {
getClientData() {
let clientApi = !this.isBrand ? '' : 'merchantOveralldistribution'
const params = {
req: {
queryItem: this.type,
queryTime: this.getCurrentDate()
this.api.customer.getEnterpriseDistribution().then(res => {
if(res.code == 0){
res.data.dataList.forEach(item => {
if(item.queryitem == '区域排名') this.areaData = item.rankDistributions
if(item.queryitem == '品牌分布') this.brandData = item.rankDistributions
if(item.queryitem == '门店类型') this.storeData = item.rankDistributions
});
}
}
if (this.isBrand) params.req.brandName = this.brandName
this.api.customer[clientApi](params).then(res => {
this.clientData = []
this.brandList = []
this.distributionRank = ''
if (res.data.dataList.length > 0) {
let distribution = JSON.parse(res.data.dataList[0].distribution)
// 删掉“未知”
delete distribution['未知']
let keys = Object.keys(distribution)
let total = Object.values(distribution).reduce((prev, next) => prev + next)
keys.forEach((item, index) => {
this.clientData.push({
name: item,
// value: distribution[item]
value: ((distribution[item] / total) * 100).toFixed(1)
})
})
console.log(this.clientData)
this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank)
}
})
},
init(newVal) {
this.isBrand = false
if (newVal.brand) {
this.isBrand = true
this.brandName = newVal.brand.name
}
// this.getClientData()
},
pieAction(data) {
this.brandList = []
let array = this.distributionRank && this.distributionRank[data.name]
if (array && array.length > 0) {
for (let i of array) {
this.brandList.push(i && Object.keys(i)[0])
}
}
}
}
}
......@@ -6,8 +6,8 @@
<span>区域分布</span>
</div>
<div class="container flex">
<pie-chart :id="chart.id" :list="clientData"></pie-chart>
<Legend></Legend>
<pie-chart :id="chart.id" :list="areaData" :keys="chart.keys"></pie-chart>
<Legend :list="areaData" :colors="chart.colors"></Legend>
</div>
</div>
</template>
......@@ -21,6 +21,7 @@ export default {
return {
chart: {
id: 'area',
keys: ['name', 'num']
}
}
}
......
......@@ -6,8 +6,8 @@
<span>品牌分布</span>
</div>
<div class="container flex">
<pie-chart :id="chart.id" :list="clientData"></pie-chart>
<Legend></Legend>
<pie-chart :id="chart.id" :list="brandData" :keys="chart.keys"></pie-chart>
<Legend :list="brandData"></Legend>
</div>
</div>
</template>
......@@ -21,7 +21,7 @@ export default {
type: 'gender',
chart: {
id: 'brand',
colors: ['#EB6001', '#BF98FF', '#FF6E76']
keys: ['name', 'num']
}
}
}
......
......@@ -5,8 +5,8 @@
<span>门店类型</span>
</div>
<div class="container flex">
<pie-chart :id="chart.id" :list="clientData"></pie-chart>
<Legend></Legend>
<pie-chart :id="chart.id" :list="storeData" :keys="chart.keys"></pie-chart>
<Legend :list="storeData" :colors="chart.colors"></Legend>
</div>
</div>
</template>
......@@ -18,9 +18,10 @@ export default {
mixins: [clientMixin],
data() {
return {
type: 'buycarRange',
chart: {
id: 'store'
id: 'store',
keys: ['name', 'num'],
colors: ['#4FA0FF', '#7CFFB2', '#FDF006', '#EB6001']
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!