Commit e441c520 by 王志慧

commit-wzh

1 parent 72476d0b
...@@ -33,11 +33,15 @@ const storeTotal = params => { ...@@ -33,11 +33,15 @@ const storeTotal = params => {
const storeSaleTrans = params => { const storeSaleTrans = params => {
return request.get('merchant/saleTrans', params) return request.get('merchant/saleTrans', params)
} }
// 获取门店销售相关信息
const getMerchantSales = params => {
return request.get('merchant/sale', params)
}
export default { export default {
getSales, getSales,
saleTotal, saleTotal,
saleTrans, saleTrans,
storeTotal, storeTotal,
storeSaleTrans storeSaleTrans,
getMerchantSales
} }
...@@ -56,10 +56,14 @@ export default { ...@@ -56,10 +56,14 @@ export default {
watch: { watch: {
list: { list: {
handler(newVal) { handler(newVal) {
this.initData() if (newVal.length > 0) {
this.draw() this.initData()
this.$nextTick(() => {
this.draw()
})
}
}, },
immediate:false immediate: true
} }
}, },
...@@ -71,19 +75,22 @@ export default { ...@@ -71,19 +75,22 @@ export default {
methods: { methods: {
//初始化数据 //初始化数据
initData() { initData() {
let { list, viewData, keys } = this let { list, keys } = this
this.viewData = []
list.forEach(item => { list.forEach(item => {
viewData.push({ this.viewData.push({
name: item[keys[0]], name: item[keys[0]],
value: item[keys[1]] value: item[keys[1]]
}) })
}) })
}, },
draw() { draw() {
if (this.mTime) clearInterval(this.mTime)
this.echartsPie = echarts.init(document.getElementById(this.id)) this.echartsPie = echarts.init(document.getElementById(this.id))
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.echartsPie.resize() this.echartsPie.resize()
}) })
// 指定图表的配置项和数据 // 指定图表的配置项和数据
this.option = { this.option = {
// tooltip: { // tooltip: {
...@@ -91,29 +98,6 @@ export default { ...@@ -91,29 +98,6 @@ export default {
// }, // },
color: this.colors, color: this.colors,
title: {
text: this.text,
// 副标题
subtext: this.subtext,
// 主副标题间距
itemGap: 5,
x: 'center',
y: 'center',
top: '50',
// 主标题样式
textStyle: {
fontSize: '12',
color: '#ffffff',
textAlign: 'center',
fontWeight: 500
},
// 副标题样式
subtextStyle: {
fontSize: '10',
fontWeight: '400',
color: '#606266'
}
},
series: [ series: [
{ {
name: '客户年龄分布', name: '客户年龄分布',
...@@ -139,16 +123,16 @@ export default { ...@@ -139,16 +123,16 @@ export default {
labelLine: { labelLine: {
show: false show: false
}, },
animationType: 'scale',
animationEasing: 'elasticOut',
animationDurationUpdate: 3000,
animationTypeUpdate: 'transition',
animation: true,
data: this.viewData data: this.viewData
} }
] ]
} }
this.echartsPie.clear()
this.mainValue = 0
this.numDesc = ''
this.setAnamiteText()
this.echartsPie.setOption(this.option) this.echartsPie.setOption(this.option)
this.mTime = setInterval(this.pieActive, 3000) this.mTime = setInterval(this.pieActive, 3000)
// 鼠标划出 // 鼠标划出
this.echartsPie.on('mouseout', () => { this.echartsPie.on('mouseout', () => {
...@@ -161,7 +145,6 @@ export default { ...@@ -161,7 +145,6 @@ export default {
this.setAnamiteText() this.setAnamiteText()
// 停止定时器,清除之前的高亮 // 停止定时器,清除之前的高亮
clearInterval(this.mTime) clearInterval(this.mTime)
console.log('mouseover')
this.currentIndex = data.dataIndex this.currentIndex = data.dataIndex
this.highlightPie() this.highlightPie()
this.emitEvent(data.data) this.emitEvent(data.data)
...@@ -212,7 +195,7 @@ export default { ...@@ -212,7 +195,7 @@ export default {
.pie-box { .pie-box {
background: #262525; background: #262525;
position: relative; position: relative;
flex:1; flex: 1;
.center-content { .center-content {
position: absolute; position: absolute;
top: 50%; top: 50%;
......
...@@ -46,8 +46,7 @@ export default { ...@@ -46,8 +46,7 @@ export default {
font-size: 10px; font-size: 10px;
color: #eb6001; color: #eb6001;
font-weight: 400; font-weight: 400;
text-align: center; padding: 0.4vh 0 0.4vh 20%;
padding: 0.4vh 0;
box-sizing: border-box; box-sizing: border-box;
} }
.ranking { .ranking {
...@@ -61,10 +60,9 @@ export default { ...@@ -61,10 +60,9 @@ export default {
.brand-num { .brand-num {
color: #606266; color: #606266;
margin-right: 0.6vw; margin-right: 0.6vw;
max-width:20px;
} }
.marquee { .marquee {
width: calc(100% - 1.5vw); width: 80%;
height: 1.9vh; height: 1.9vh;
} }
} }
......
// import{changeMixin} from "./changeMixin" import { changeMixin } from './index'
export default { export default {
data() { data() {
return { return {
now: new Date().format('yyyy-MM-dd'),
clientData: [], clientData: [],
brandList: [], brandList: [],
distributionRank: '' distributionRank: '',
isBrand: false,
brandName: ''
} }
}, },
// mixins: [changeMixin], mixins: [changeMixin],
created() { created() {
this.getClientData() this.getClientData()
}, },
methods: { methods: {
getClientData() { getClientData() {
let clientApi = this.isBrand ? 'overalldistribution' : 'merchantOveralldistribution'
const params = { const params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: '集团1',
queryItem: this.type, queryItem: this.type,
// queryTime: this.now, // queryTime: this.getCurrentDate,
queryTime: '2022-06-23', queryTime: '2022-06-23',
queryType: 0 queryType: this.watchReportParams.reportType
} }
} }
this.api.customer.overalldistribution(params).then(res => { if (this.isBrand) params.req.brandName = this.brandName
let distribution = JSON.parse(res.data.dataList[0].distribution) this.api.customer[clientApi](params).then(res => {
const keys = Object.keys(distribution) if (res.data.dataList.length > 0) {
keys.forEach((item, index) => { let distribution = JSON.parse(res.data.dataList[0].distribution)
this.clientData.push({ const keys = Object.keys(distribution)
name: item, keys.forEach((item, index) => {
value: distribution[item] this.clientData.push({
name: item,
value: distribution[item]
})
}) })
}) this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank)
this.distributionRank = JSON.parse(res.data.dataList[0].distributionRank) } else {
this.clientData = []
}
}) })
}, },
init(newVal){ init(newVal) {
// console.log(newVal,1111111111111111111111111) console.log(newVal, 99999999999999999)
this.isBrand = false
if (newVal.brand) {
this.isBrand = true
this.brandName = newVal.brand.name
}
this.getClientData()
} }
} }
} }
import { changeMixin } from './index'
export default { export default {
data() { data() {
return { return {
now: new Date().format('yyyy-MM-dd'),
salesData: [], salesData: [],
brandList: [], brandList: [],
typeRanking: '' typeRanking: '',
isBrand: false,
brandName: ''
} }
}, },
mixins: [changeMixin],
created() { created() {
this.getSalesData() this.getSalesData()
}, },
methods: { methods: {
getSalesData() { getSalesData() {
let salesApi = this.isBrand ? 'getSales' : 'getMerchantSales'
const params = { const params = {
req: { req: {
corporateGroupName: '集团1', corporateGroupName: '集团1',
queryItem: this.type, queryItem: this.type,
// queryTime: this.now, // queryTime: this.getCurrentDate,
queryTime: '2022-06-23', queryTime: '2022-06-23',
queryType: 0 queryType: this.watchReportParams.reportType
} }
} }
this.api.sales.getSales(params).then(res => { if (this.isBrand) params.req.brandName = this.brandName
let typeNum = JSON.parse(res.data.dataList[0].typeNum) this.api.sales[salesApi](params).then(res => {
Object.keys(typeNum).forEach((item, index) => { if (res.data.dataList.length > 0) {
this.salesData.push({ let typeNum = JSON.parse(res.data.dataList[0].typeNum)
name: item, Object.keys(typeNum).forEach((item, index) => {
value: typeNum[item] this.salesData.push({
name: item,
value: typeNum[item]
})
}) })
})
this.typeRanking = JSON.parse(res.data.dataList[0].typeRanking) this.typeRanking = JSON.parse(res.data.dataList[0].typeRanking)
}else{
this.salesData = []
}
}) })
},
init(newVal) {
this.isBrand = false
if (newVal.brand) {
this.isBrand = true
this.brandName = newVal.brand.name
}
this.getSalesData()
} }
} }
} }
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
this.dealList(data.dataList) this.dealList(data.dataList)
break break
default: default:
alert(message) // alert(message)
} }
}) })
}, },
......
...@@ -12,8 +12,13 @@ ...@@ -12,8 +12,13 @@
<span>客户年龄分布</span> <span>客户年龄分布</span>
</div> </div>
<div class="container flex"> <div class="container flex">
<pie-chart :id="chart.id" :list="clientData" @pieAction="pieAction"></pie-chart> <template v-if="clientData.length > 0">
<ran-king :list="brandList"></ran-king> <pie-chart :id="chart.id" :list="clientData" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king>
</template>
<div class="empty" style="height:12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div> </div>
</div> </div>
</template> </template>
...@@ -25,16 +30,16 @@ export default { ...@@ -25,16 +30,16 @@ export default {
mixins: [clientMixin], mixins: [clientMixin],
data() { data() {
return { return {
type:'age', type: 'age',
chart: { chart: {
id: 'age-pie' id: 'age-pie'
} }
} }
}, },
methods:{ methods: {
pieAction(data){ pieAction(data) {
this.brandList=Object.keys(this.distributionRank[data.name]) this.brandList = Object.keys(this.distributionRank[data.name])
}, }
} }
} }
</script> </script>
...@@ -11,9 +11,14 @@ ...@@ -11,9 +11,14 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户购车年限</span> <span>客户购车年限</span>
</div> </div>
<div class="container flex"> <div class="container flex">
<pie-chart :id="chart.id" :list="clientData" @pieAction="pieAction"></pie-chart> <template v-if="clientData.length > 0">
<ran-king :list="brandList"></ran-king> <pie-chart :id="chart.id" :list="clientData" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king>
</template>
<div class="empty" style="height:12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -11,9 +11,14 @@ ...@@ -11,9 +11,14 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户性别</span> <span>客户性别</span>
</div> </div>
<div class="container flex"> <div class="container flex">
<pie-chart :id="chart.id" :list="clientData" @pieAction="pieAction"></pie-chart> <template v-if="clientData.length > 0">
<ran-king :list="brandList"></ran-king> <pie-chart :id="chart.id" :list="clientData" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king>
</template>
<div class="empty" style="height:12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -12,8 +12,13 @@ ...@@ -12,8 +12,13 @@
<span>客户级别</span> <span>客户级别</span>
</div> </div>
<div class="flex container"> <div class="flex container">
<pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart> <template v-if="salesData.length > 0">
<ran-king :list="brandList"></ran-king> <pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king>
</template>
<div class="empty" style="height:12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -11,9 +11,14 @@ ...@@ -11,9 +11,14 @@
<span class="icon"></span> <span class="icon"></span>
<span>进店类型</span> <span>进店类型</span>
</div> </div>
<div class="container flex"> <div class="flex container">
<pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart> <template v-if="salesData.length > 0">
<ran-king :list="brandList"></ran-king> <pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king>
</template>
<div class="empty" style="height:12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -11,9 +11,14 @@ ...@@ -11,9 +11,14 @@
<span class="icon"></span> <span class="icon"></span>
<span>信息来源</span> <span>信息来源</span>
</div> </div>
<div class="container flex"> <div class="flex container">
<pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart> <template v-if="salesData.length > 0">
<ran-king :list="brandList"></ran-king> <pie-chart :id="chart.id" :list="salesData" @pieAction="pieAction"></pie-chart>
<ran-king :list="brandList"></ran-king>
</template>
<div class="empty" style="height: 12.7vh" v-else>
<img src="../../assets/images/empty.png" alt="" />
</div>
</div> </div>
</div> </div>
</template> </template>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!