ADD file via upload

main
pjhmizn49 1 year ago
parent 9b6b8c16b1
commit 8160c594ad

@ -0,0 +1,277 @@
<template>
<el-row>
<el-col :span="24">
<div class="num">
<el-card class="top-num" shadow="hover" :body-style="{display:'flex',padding:0}">
<i class="icon el-icon-s-goods" style="background:#2ec7c9"></i>
<div class="detail">
<p class="number">{{this.topData.order_pay_num}}</p>
<p class="desc">今日下单数</p>
</div>
</el-card>
<el-card class="top-num" shadow="hover" :body-style="{display:'flex',padding:0}">
<i class="icon el-icon-success" style="background:#2ec7c9"></i>
<div class="detail">
<p class="number">{{this.topData.order_ok_num}}</p>
<p class="desc">今日成交订单数</p>
</div>
</el-card>
<el-card class="top-num" shadow="hover" :body-style="{display:'flex',padding:0}">
<i class="icon el-icon-s-finance" style="background:#5ab1ef"></i>
<div class="detail">
<p class="number">{{this.topData.order_today_money}}</p>
<p class="desc">今日成交金额</p>
</div>
</el-card>
<el-card class="top-num" shadow="hover" :body-style="{display:'flex',padding:0}">
<i class="icon el-icon-s-finance" style="background:#5ab1ef"></i>
<div class="detail">
<p class="number">{{this.topData.order_month_money}}</p>
<p class="desc">本月成交金额</p>
</div>
</el-card>
<el-card class="top-num" shadow="hover" :body-style="{display:'flex',padding:0}">
<i class="icon el-icon-s-promotion" style="background:#ffb980"></i>
<div class="detail">
<p class="number">{{this.topData.order_delivery_num}}</p>
<p class="desc">待发货</p>
</div>
</el-card>
<el-card class="top-num" shadow="hover" :body-style="{display:'flex',padding:0}">
<i class="icon el-icon-s-release" style="background:#ffb980"></i>
<div class="detail">
<p class="number">{{this.topData.order_refund_num}}</p>
<p class="desc">待退款</p>
</div>
</el-card>
</div>
<el-card shadow="hover" style="height: 350px">
<!-- 折线图 -->
<div ref="echarts1" style="height: 330px;width: auto"></div>
</el-card>
<div class="bottom-num">
<!-- 柱状图 -->
<el-card shadow="hover" style="height:500px;width:48%;">
<div ref="echarts2" style="height: 450px; width: auto"></div>
</el-card>
<!-- 饼图 -->
<el-card shadow="hover" style="height:650px;width:48%">
<div ref="echarts3" style="height: 650px; width: auto"></div>
</el-card>
</div>
</el-col>
</el-row>
</template>
<script>
import Cookie from "js-cookie";
import * as echarts from "echarts";
import {watch} from "vue";
export default {
data(){
return {
timer:null,
//()
topData: [{
order_pay_num:1,
order_ok_num:1,
order_today_money:1.00,
order_month_money:1.00,
order_delivery_num:1,
order_refund_num:1
}],
//线
middleData: [{
'1月':1,
'2月':1,
'3月':1,
'4月':1,
'5月':1,
}],
//
bottomData1:[{
name:'',
value:1
}],
//
bottomData2:[{
name:'',
value:1
}]
}
},
mounted(){
const _this = this
this.timer = setTimeout(() => {
//线
// domecharts
const echarts1 = echarts.init(this.$refs.echarts1)
//
const option1 = {
title: { text:'每月成交金额折线图' },
xAxis: { data: Object.keys(_this.middleData).reverse() },
yAxis: {},
tooltip: { trigger: 'item' },
series: [{
data: Object.values(_this.middleData).reverse(),
type: 'line'
}]
};
// 使
echarts1.setOption(option1)
//
const echarts2 = echarts.init(this.$refs.echarts2)
const option2 = {
title: { text:'商品销售量TOP3' },
xAxis: {
data:_this.bottomData1.map(item => item.name),
// x
axisLabel: {
interval: 0,
//
formatter: function (value) {
let res = ""; // \n
let maxLength = 15; //
let valLength = value.length; // X
let rowN = Math.ceil(valLength / maxLength); //
// 1,
if (rowN > 1) {
for (let i = 0; i < rowN; i++) {
let temp = ""; //
let start = i * maxLength; //
let end = start + maxLength; //
temp = value.substring(start, end) + "\n";
res += temp; //
}
return res;
} else {
return value;
}
},
},
},
yAxis: {},
tooltip: { trigger: 'item' },
series: [{
data: _this.bottomData1.map(item => item.value),
type: 'bar',
color:'#62acee'
}]
}
echarts2.setOption(option2)
//
const echarts3 = echarts.init(this.$refs.echarts3)
const option3 = {
title: { text:'花卉种类销售量占比' },
legend: {
top: '10%',
left: 'center'
},
tooltip: { trigger: 'item' },
series: [
{
type: 'pie',
radius: ['30%', '60%'],
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
data: _this.bottomData2
}
]
}
echarts3.setOption(option3)
},500);
},
beforeDestroy() { // beforeDestroy()
clearTimeout(this.timer);
this.timer = null;
},
created() {
this.fetchData();
},
methods: {
fetchData(){
//
const _this=this;
try {
axios({
method: 'post',
url: 'http://localhost:8181/order/statistic',
headers: {
Authorization: Cookie.get('token'),
'Content-Type': 'application/json'
}
}).then(function (response){
if (response.data.code===200){
//
_this.topData = response.data.data.data_top;
_this.middleData = response.data.data.data_middle;
_this.bottomData1 = response.data.data.data_bottom1;
_this.bottomData2 = response.data.data.data_bottom2;
// console.log(_this.bottomData2)
}
if (response.data.code===401){
_this.$message.warning('身份验证失败,请重新登录!')
}
if (response.data.code===403){
const message = response.data.msg;
this.$alert("页面加载出错,具体原因如下:\n"+message, '页面加载失败', {
confirmButtonText: '确定'
})
}
});
}catch (error){
this.$message.warning('页面加载出错,请重试!')
}
},
}
}
</script>
<style>
.num{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.top-num{
width: 32%;
margin-bottom: 20px;
}
.icon{
width: 70px;
height: 55px;
padding-top: 15px;
font-size: 30px;
text-align: center;
line-height: 70px;
color:#fff;
}
.detail{
margin-left: 15px;
margin-top: 5px;
display: flex;
flex-direction: column;
justify-content: center;
}
.number{
font-size: 25px;
margin: -5px;
line-height: 25px;
}
.desc{
font-size: 14px;
color: #999;
text-align: center;
margin-bottom: 0;
}
.bottom-num{
margin-top: 20px;
display: flex;
justify-content: space-between;
}
</style>
Loading…
Cancel
Save