2020-04-06 23:19:51 +08:00
|
|
|
<template>
|
2021-01-16 23:55:37 +08:00
|
|
|
<div class="divBox">
|
|
|
|
<el-row :gutter="24">
|
|
|
|
<el-col san="24" class="ivu-mb">
|
|
|
|
<el-card :bordered="false" class="dashboard-console-visit">
|
|
|
|
<div slot="header">
|
|
|
|
<div class="acea-row row-between-wrapper">
|
|
|
|
<div class="acea-row row-middle">
|
|
|
|
<el-avatar
|
|
|
|
icon="el-icon-s-data"
|
|
|
|
size="small"
|
|
|
|
style="color: #1890ff; background: #e6f7ff; font-size: 13px"
|
|
|
|
/>
|
|
|
|
<span class="ivu-pl-8">订单</span>
|
|
|
|
</div>
|
|
|
|
<div class="checkTime">
|
|
|
|
<!-- <el-radio-group v-model="visitDate" class="ivu-mr-8">
|
|
|
|
<el-radio label="last30" @change="handleChangeVisitType">30天</el-radio>
|
|
|
|
<el-radio label="week" @change="handleChangeWeek">周</el-radio>
|
|
|
|
<el-radio label="month" @change="handleChangeMonth">月</el-radio>
|
|
|
|
<el-radio label="year" @change="handleChangeYear">年</el-radio>
|
|
|
|
</el-radio-group> -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div :class="className" ref="chart" :style="{ height: height, width: width }" />
|
|
|
|
</el-card>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</div>
|
2020-04-06 23:19:51 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-01-16 23:55:37 +08:00
|
|
|
import echarts from "echarts";
|
|
|
|
require("echarts/theme/macarons"); // echarts theme
|
|
|
|
import { getOrderCount } from "@/api/visits";
|
|
|
|
import { debounce } from "@/utils";
|
2020-04-06 23:19:51 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
className: {
|
|
|
|
type: String,
|
2021-01-16 23:55:37 +08:00
|
|
|
default: "chart",
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: String,
|
2021-01-16 23:55:37 +08:00
|
|
|
default: "100%",
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
height: {
|
|
|
|
type: String,
|
2021-01-16 23:55:37 +08:00
|
|
|
default: "300px",
|
|
|
|
},
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
chart: null,
|
|
|
|
column: [],
|
2021-01-16 23:55:37 +08:00
|
|
|
orderCountDatas: [],
|
|
|
|
};
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
2021-01-16 23:55:37 +08:00
|
|
|
getOrderCount()
|
|
|
|
.then((res) => {
|
|
|
|
(this.column = res.column),
|
|
|
|
(this.orderCountDatas = res.orderCountDatas);
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.initChart();
|
|
|
|
});
|
2020-04-06 23:19:51 +08:00
|
|
|
|
|
|
|
this.__resizeHandler = debounce(() => {
|
|
|
|
if (this.chart) {
|
2021-01-16 23:55:37 +08:00
|
|
|
this.chart.resize();
|
2020-04-06 23:19:51 +08:00
|
|
|
}
|
2021-01-16 23:55:37 +08:00
|
|
|
}, 100);
|
|
|
|
window.addEventListener("resize", this.__resizeHandler);
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
if (!this.chart) {
|
2021-01-16 23:55:37 +08:00
|
|
|
return;
|
2020-04-06 23:19:51 +08:00
|
|
|
}
|
2021-01-16 23:55:37 +08:00
|
|
|
window.removeEventListener("resize", this.__resizeHandler);
|
|
|
|
this.chart.dispose();
|
|
|
|
this.chart = null;
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initChart() {
|
2021-01-16 23:55:37 +08:00
|
|
|
this.chart = echarts.init(this.$refs.chart, "macarons");
|
2020-04-06 23:19:51 +08:00
|
|
|
|
|
|
|
this.chart.setOption({
|
|
|
|
tooltip: {
|
2021-01-16 23:55:37 +08:00
|
|
|
trigger: "item",
|
|
|
|
formatter: "{a} <br/>{b} : {c} ({d}%)",
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
legend: {
|
2021-01-16 23:55:37 +08:00
|
|
|
left: "center",
|
|
|
|
bottom: "10",
|
|
|
|
data: this.column,
|
2020-04-06 23:19:51 +08:00
|
|
|
},
|
|
|
|
calculable: true,
|
|
|
|
series: [
|
|
|
|
{
|
2021-01-16 23:55:37 +08:00
|
|
|
name: "商品分类销售占总销售的比例",
|
|
|
|
type: "pie",
|
|
|
|
roseType: "radius",
|
2020-04-06 23:19:51 +08:00
|
|
|
radius: [15, 95],
|
2021-01-16 23:55:37 +08:00
|
|
|
center: ["50%", "38%"],
|
2020-04-06 23:19:51 +08:00
|
|
|
data: this.orderCountDatas,
|
2021-01-16 23:55:37 +08:00
|
|
|
animationEasing: "cubicInOut",
|
|
|
|
animationDuration: 2600,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.acea-row{
|
|
|
|
/deep/.el-avatar--small {
|
|
|
|
width: 22px;
|
|
|
|
height: 22px;
|
|
|
|
line-height: 22px;
|
2020-04-06 23:19:51 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-16 23:55:37 +08:00
|
|
|
.checkTime{
|
|
|
|
/deep/.el-radio__input{
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.ivu-pl-8{
|
|
|
|
margin-left: 8px;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
.divBox {
|
|
|
|
// padding: 0 20px !important;
|
|
|
|
}
|
|
|
|
.dashboard-console-visit {
|
|
|
|
/deep/.el-card__header{
|
|
|
|
padding: 14px 20px !important;
|
|
|
|
}
|
|
|
|
ul {
|
|
|
|
li {
|
|
|
|
list-style-type: none;
|
|
|
|
margin-top: 12px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.ivu-mb{
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|