|
@ -0,0 +1,334 @@
|
|
|
|
<template>
|
|
|
|
<div class="index-OrderAnalyse mt10">
|
|
|
|
<div class="panel plr15 medicine">
|
|
|
|
<div class="kitbox pt15 box-flex-c">
|
|
|
|
<div class="box-flex-c c-333 fs-16 f-bold">订单分析</div>
|
|
|
|
<div class="box-flex-c c-333 fs-12 f-bold time">
|
|
|
|
<ul class="ul">
|
|
|
|
<li @click="prescriptionTime('1')" class="border-r" :class="prescriptionBag == '1' ? 'li-bag':''">今日</li>
|
|
|
|
<li @click="prescriptionTime('7')" class="border-r" :class="prescriptionBag == '7' ? 'li-bag':''">7日</li>
|
|
|
|
<li @click="prescriptionTime('30')" class="border-r" :class="prescriptionBag == '30' ? 'li-bag':''">30日</li>
|
|
|
|
<li @click="prescriptionTime('90')" class="border-r" :class="prescriptionBag == '90' ? 'li-bag':''">90日</li>
|
|
|
|
<li @click="prescriptionTime('-1')" :class="prescriptionBag == '-1' ? 'li-bag':''">全部</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class=" ">
|
|
|
|
<div>
|
|
|
|
<div class="pie-charts" ref="pie"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div class="kitbox pt15 box-flex-c bt-e1e1e1">
|
|
|
|
<div class="box-flex-c c-333 fs-16 f-bold">订单排行</div>
|
|
|
|
<div class="box-flex-c c-333 fs-12 type-list kitbox">
|
|
|
|
<div class="type-item blue">订单量</div>
|
|
|
|
<div class="type-item orange">药柜取药</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="bar-charts pt15 " :style="height + 'px'">
|
|
|
|
<div v-show="!nodata" ref="barChart"></div>
|
|
|
|
<NoData v-show="nodata"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import * as echarts from 'echarts';
|
|
|
|
import medicineAbinetApi from '@/api/api-medicineAbinet'
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dataIndex: 0,
|
|
|
|
prescriptionBag: "1",
|
|
|
|
nodata: false,
|
|
|
|
height: 200,
|
|
|
|
startDate: '',
|
|
|
|
endDate: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
refreshData(){
|
|
|
|
this.prescriptions();
|
|
|
|
this.getPrescriptionStaticsRank()
|
|
|
|
},
|
|
|
|
prescriptionTime(val){
|
|
|
|
this.prescriptionBag = val;
|
|
|
|
this.refreshData();
|
|
|
|
},
|
|
|
|
prescriptions(){
|
|
|
|
var p = this.$parent.getTownParams()
|
|
|
|
|
|
|
|
// if(!p.level){
|
|
|
|
// p.level = '1'
|
|
|
|
// p.area = '350200';
|
|
|
|
// }
|
|
|
|
var { startDate, endDate, prescriptionBag } = this
|
|
|
|
if(prescriptionBag){
|
|
|
|
if(prescriptionBag == -1){
|
|
|
|
|
|
|
|
} else {
|
|
|
|
p.endTime = this.$moment().format('YYYY-MM-DD 23:59:59')
|
|
|
|
p.startTime = this.$moment().add(-Number(prescriptionBag)+1, 'days').format('YYYY-MM-DD 00:00:00')
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
p.startTime = startDate + " 00:00:00"
|
|
|
|
p.endTime = endDate? (endDate + " 23:59:59") : ""
|
|
|
|
}
|
|
|
|
console.log('getprescriptions', p)
|
|
|
|
medicineAbinetApi
|
|
|
|
.getprescriptions(p)
|
|
|
|
.then(res=>{
|
|
|
|
console.log('getprescriptions', res)
|
|
|
|
if(res.status == 200){
|
|
|
|
var { onlineTotal, offlineTotal } = res.obj
|
|
|
|
this.initPie([
|
|
|
|
{ value: onlineTotal, name: '线上订单' },
|
|
|
|
{ value: offlineTotal, name: '线下订单' },
|
|
|
|
])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(err=>{
|
|
|
|
console.error(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
initPie(seriesData){
|
|
|
|
var { dataIndex } = this
|
|
|
|
var option = {
|
|
|
|
tooltip: {
|
|
|
|
show: false,
|
|
|
|
trigger: 'item'
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
top: 'middle',
|
|
|
|
left: '54%',
|
|
|
|
},
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
type: 'pie',
|
|
|
|
center: ['25%', '50%'],
|
|
|
|
radius: ['55%', '70%'],
|
|
|
|
avoidLabelOverlap: false,
|
|
|
|
label: {
|
|
|
|
show: false,
|
|
|
|
position: 'center'
|
|
|
|
},
|
|
|
|
emphasis: {
|
|
|
|
label: {
|
|
|
|
show: true,
|
|
|
|
fontSize: '12',
|
|
|
|
lineHeight: 20,
|
|
|
|
formatter: '{c}\n{d}%\n{b}',
|
|
|
|
// rich: {
|
|
|
|
// b: {
|
|
|
|
// lineHeight: 20
|
|
|
|
// },
|
|
|
|
// d: {
|
|
|
|
// fontSize: '14',
|
|
|
|
// },
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
labelLine: {
|
|
|
|
show: false
|
|
|
|
},
|
|
|
|
data: seriesData
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
if(!this.myChart){
|
|
|
|
this.myChart = echarts.init(this.$refs.pie);
|
|
|
|
this.myChart.on('click', (e)=>{
|
|
|
|
if(this.dataIndex !== e.dataIndex) {
|
|
|
|
this.myChart.dispatchAction({
|
|
|
|
type: 'downplay',
|
|
|
|
seriesIndex: 0,
|
|
|
|
dataIndex: this.dataIndex
|
|
|
|
})
|
|
|
|
// this.dataIndex = -1
|
|
|
|
}
|
|
|
|
this.dataIndex = e.dataIndex
|
|
|
|
this.myChart.dispatchAction({
|
|
|
|
type: 'highlight',
|
|
|
|
seriesIndex: 0,
|
|
|
|
dataIndex: e.dataIndex
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.myChart.setOption(option)
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
this.myChart.dispatchAction({
|
|
|
|
type: 'highlight',
|
|
|
|
seriesIndex: 0,
|
|
|
|
dataIndex
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
getPrescriptionStaticsRank(){
|
|
|
|
var p = this.$parent.getTownParams()
|
|
|
|
var { startDate, endDate, prescriptionBag } = this
|
|
|
|
if(prescriptionBag){
|
|
|
|
if(prescriptionBag == -1){
|
|
|
|
|
|
|
|
} else {
|
|
|
|
p.endTime = this.$moment().format('YYYY-MM-DD 23:59:59')
|
|
|
|
p.startTime = this.$moment().add(-Number(prescriptionBag)+1, 'days').format('YYYY-MM-DD 00:00:00')
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
p.startTime = startDate + " 00:00:00"
|
|
|
|
p.endTime = endDate? (endDate + " 23:59:59") : ""
|
|
|
|
}
|
|
|
|
console.log('getPrescriptionStaticsRank', p)
|
|
|
|
medicineAbinetApi
|
|
|
|
.getPrescriptionStaticsRank(p)
|
|
|
|
.then(res=>{
|
|
|
|
console.log('getPrescriptionStaticsRank', res)
|
|
|
|
if(res.status == 200){
|
|
|
|
if(res.detailModelList.length){
|
|
|
|
this.nodata = false
|
|
|
|
this.height = res.detailModelList.length * 60
|
|
|
|
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
var seriesData1 = [], seriesData2 = [], max = 0, yAxisData = []
|
|
|
|
_.each(res.detailModelList, v=>{
|
|
|
|
if(v.orderTotal > max){
|
|
|
|
max = v.orderTotal
|
|
|
|
}
|
|
|
|
if(v.sellTotal > max){
|
|
|
|
max = v.sellTotal
|
|
|
|
}
|
|
|
|
seriesData1.push(v.orderTotal)
|
|
|
|
seriesData2.push(v.sellTotal)
|
|
|
|
yAxisData.push(v.community.substring(0, 9)+ "\n" +v.community.substring(9))
|
|
|
|
})
|
|
|
|
this.initBar(yAxisData, seriesData1, seriesData2, max)
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.height = 200
|
|
|
|
this.nodata = true
|
|
|
|
})
|
|
|
|
.catch(err=>{
|
|
|
|
console.error(err)
|
|
|
|
this.nodata = true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
initBar(yAxisData, seriesData1, seriesData2, max){
|
|
|
|
var option = {
|
|
|
|
tooltip: {
|
|
|
|
trigger: 'axis',
|
|
|
|
axisPointer: {
|
|
|
|
type: 'shadow'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
top: "3%",
|
|
|
|
left: '0%',
|
|
|
|
right: '0%',
|
|
|
|
bottom: '3%',
|
|
|
|
containLabel: true
|
|
|
|
},
|
|
|
|
xAxis: {
|
|
|
|
type: 'value',
|
|
|
|
show: false,
|
|
|
|
max: Math.ceil(max / 4) + max
|
|
|
|
// boundaryGap: [0, 0.01]
|
|
|
|
},
|
|
|
|
yAxis: {
|
|
|
|
type: 'category',
|
|
|
|
data: yAxisData, //['XX社区卫生\n服务中心', 'XX社区卫生\n服务中心', 'XX社区卫生\n服务中心', 'XX社区卫生\n服务中心', 'XX社区卫生\n服务中心', 'XX社区卫生\n服务中心'],
|
|
|
|
axisLabel: {
|
|
|
|
with: 100
|
|
|
|
}
|
|
|
|
},
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: '订单量',
|
|
|
|
type: 'bar',
|
|
|
|
itemStyle: {
|
|
|
|
color: '#0099ff'
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
show: true,
|
|
|
|
position: 'right'
|
|
|
|
},
|
|
|
|
// label: {
|
|
|
|
// show: true,
|
|
|
|
// formatter: '{b}',
|
|
|
|
// align: 'right'
|
|
|
|
// },
|
|
|
|
data: seriesData1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '药柜取药',
|
|
|
|
type: 'bar',
|
|
|
|
label: {
|
|
|
|
show: true,
|
|
|
|
position: 'right'
|
|
|
|
},
|
|
|
|
itemStyle: {
|
|
|
|
color: '#ff9900'
|
|
|
|
},
|
|
|
|
data: seriesData2
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
if(!this.barChart){
|
|
|
|
this.barChart = echarts.init(this.$refs.barChart);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.barChart.setOption(option)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.index-OrderAnalyse{
|
|
|
|
.pie-charts{
|
|
|
|
height: 200px;
|
|
|
|
}
|
|
|
|
.bar-charts{
|
|
|
|
min-height: 200px;
|
|
|
|
>div{
|
|
|
|
height: 100%;
|
|
|
|
min-height: 200px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.type-list{
|
|
|
|
-webkit-box-align: center;
|
|
|
|
.type-item{
|
|
|
|
padding-right: 20px;
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-box-align: center;
|
|
|
|
&::before{
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
|
|
|
&.orange{
|
|
|
|
&::before{
|
|
|
|
background: #ff9900;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&.blue{
|
|
|
|
&::before{
|
|
|
|
background: #0099ff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&:last-child{
|
|
|
|
padding-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|