|
@@ -1,11 +1,20 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="statistically-all">
|
|
|
+ <div class="yeardate">
|
|
|
+ <el-date-picker
|
|
|
+ @change="yearchange"
|
|
|
+ style="width:200px;"
|
|
|
+ v-model="year"
|
|
|
+ type="year"
|
|
|
+ placeholder="选择年">
|
|
|
+ </el-date-picker>
|
|
|
+ </div>
|
|
|
<div class="canvas-box">
|
|
|
- <div id="statisticallyone" style="width: 50%;height:400px;"></div>
|
|
|
- <div id="grossmargin" style="width: 50%;height:400px;"></div>
|
|
|
- <div id="grossmargins" style="width: 50%;height:400px;"></div>
|
|
|
- <div id="grossmarginss" style="width: 50%;height:400px;"></div>
|
|
|
+ <div id="statisticallyone" style="width: 100%;height:400px;"></div>
|
|
|
+ <div id="grossmargin" style="width: 100%;height:400px;"></div>
|
|
|
+ <div id="grossmargins" style="width: 100%;height:400px;"></div>
|
|
|
+ <!-- <div id="grossmarginss" style="width: 50%;height:400px;"></div> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -15,6 +24,10 @@ import * as echarts from 'echarts';
|
|
|
export default {
|
|
|
data () {
|
|
|
return {
|
|
|
+ year:new Date(),
|
|
|
+ businessincome:[],
|
|
|
+ Grossprofit:[],
|
|
|
+ costing:[],
|
|
|
aaa:[
|
|
|
['product', '去年销售额', '今年销售额'],
|
|
|
['1月', 43.3, 85.8],
|
|
@@ -48,101 +61,121 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ //处理时间
|
|
|
+ getdate(val){
|
|
|
+ var date=new Date(val);
|
|
|
+ var y=date.getFullYear();
|
|
|
+ return y
|
|
|
+ },
|
|
|
statisone(){
|
|
|
+ console.log(this.businessincome,this.Grossprofit,this.costing);
|
|
|
var myChart = echarts.init(document.getElementById('statisticallyone'));
|
|
|
myChart.setOption({
|
|
|
title:{
|
|
|
- text: '业务总收入额',
|
|
|
+ text: '业务总营业额',
|
|
|
},
|
|
|
legend: {},
|
|
|
tooltip: {},
|
|
|
dataset: {
|
|
|
- source: this.aaa
|
|
|
+ source: this.businessincome
|
|
|
},
|
|
|
xAxis: { type: 'category' },
|
|
|
yAxis: {
|
|
|
- name: '销售额',
|
|
|
+ name: '营业额',
|
|
|
},
|
|
|
-
|
|
|
- // Declare several bar series, each will be mapped
|
|
|
- // to a column of dataset.source by default.
|
|
|
series: [{ type: 'bar' }, { type: 'bar' },]
|
|
|
});
|
|
|
var grossmargins = echarts.init(document.getElementById('grossmargins'));
|
|
|
grossmargins.setOption({
|
|
|
title:{
|
|
|
- text: '业务总收入额',
|
|
|
- },
|
|
|
- legend: {},
|
|
|
- tooltip: {},
|
|
|
- dataset: {
|
|
|
- source: this.aaa
|
|
|
- },
|
|
|
- xAxis: { type: 'category' },
|
|
|
- yAxis: {
|
|
|
- name: '销售额',
|
|
|
- },
|
|
|
-
|
|
|
- // Declare several bar series, each will be mapped
|
|
|
- // to a column of dataset.source by default.
|
|
|
- series: [{ type: 'bar' }, { type: 'bar' },]
|
|
|
- });
|
|
|
- var grossmarginss = echarts.init(document.getElementById('grossmarginss'));
|
|
|
- grossmarginss.setOption({
|
|
|
- title:{
|
|
|
- text: '业务总收入额',
|
|
|
+ text: '成本',
|
|
|
},
|
|
|
legend: {},
|
|
|
tooltip: {},
|
|
|
dataset: {
|
|
|
- source: this.aaa
|
|
|
+ source: this.costing
|
|
|
},
|
|
|
xAxis: { type: 'category' },
|
|
|
yAxis: {
|
|
|
- name: '销售额',
|
|
|
+ name: '成本额',
|
|
|
},
|
|
|
-
|
|
|
- // Declare several bar series, each will be mapped
|
|
|
- // to a column of dataset.source by default.
|
|
|
series: [{ type: 'bar' }, { type: 'bar' },]
|
|
|
});
|
|
|
var grossmargin = echarts.init(document.getElementById('grossmargin'));
|
|
|
grossmargin.setOption({
|
|
|
title:{
|
|
|
- text: '毛利率',
|
|
|
+ text: '毛利润',
|
|
|
},
|
|
|
legend: {},
|
|
|
tooltip: {
|
|
|
- formatter:function(params){
|
|
|
- // console.log(params);
|
|
|
- console.log(params.data)
|
|
|
- var html = params.data[0]+'毛利率'+"<br/>"+ params.data[1]+"%";
|
|
|
- // for(var i=0;i<params.length;i++){
|
|
|
-
|
|
|
- // html +=
|
|
|
- // params[i].marker +params[i].seriesName+
|
|
|
- // params[i].value +"人"+"<br/>";
|
|
|
+ // formatter:function(params){
|
|
|
+ // var html = params.data[0]+'毛利率'+"<br/>"+ params.data[1]+"%";
|
|
|
+ // return html
|
|
|
// }
|
|
|
- return html
|
|
|
- }
|
|
|
|
|
|
},
|
|
|
dataset: {
|
|
|
- source: this.bbb
|
|
|
+ source: this.Grossprofit
|
|
|
},
|
|
|
xAxis: { type: 'category' },
|
|
|
yAxis: {
|
|
|
name: '毛利额',
|
|
|
},
|
|
|
- color:['#EEAD0E'],
|
|
|
+ color:['#EEAD0E','#a0a7e6'],
|
|
|
// Declare several bar series, each will be mapped
|
|
|
// to a column of dataset.source by default.
|
|
|
- series: [{ type: 'bar' },]
|
|
|
+ series: [{ type: 'bar' },{ type: 'bar' }]
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
+ //年change
|
|
|
+ yearchange(){
|
|
|
+ this.businessincome=[];
|
|
|
+ this.Grossprofit=[];
|
|
|
+ this.costing=[];
|
|
|
+ this.StatisticsYOY()
|
|
|
+ },
|
|
|
+ //获取数据
|
|
|
+ StatisticsYOY(){
|
|
|
+ var url = "/api/Statistics/StatisticsYOY"
|
|
|
+ var that = this
|
|
|
+ this.$axios({
|
|
|
+ method: 'post',
|
|
|
+ url: url,
|
|
|
+ headers: {
|
|
|
+ Authorization: 'Bearer '
|
|
|
+ },
|
|
|
+ data:{
|
|
|
+ year:that.getdate(that.year),
|
|
|
+ }
|
|
|
+ }).then(function (res) {
|
|
|
+ if(res.data.code==200){
|
|
|
+ //营业额
|
|
|
+ that.businessincome.push(['product', '前一年该月营业额', '本年该月营业额']);
|
|
|
+ for(let i=0;i<res.data.data.salesYOYData.length;i++){
|
|
|
+ that.businessincome.push([res.data.data.salesYOYData[i].month+'月',res.data.data.salesYOYData[i].lastAmount,res.data.data.salesYOYData[i].thisAmount]);
|
|
|
+ }
|
|
|
+ //毛利润
|
|
|
+ that.Grossprofit.push(['product', '前一年该月毛利润', '本年该月毛利润']);
|
|
|
+ for(let j=0;j<res.data.data.grossProfitYOYData.length;j++){
|
|
|
+ that.Grossprofit.push([res.data.data.grossProfitYOYData[j].month+'月',res.data.data.grossProfitYOYData[j].lastAmount,res.data.data.grossProfitYOYData[j].thisAmount]);
|
|
|
+ }
|
|
|
+ //成本
|
|
|
+ that.costing.push(['product', '前一年该月成本', '本年该月成本']);
|
|
|
+ for(let g=0;g<res.data.data.costYOYData.length;g++){
|
|
|
+ that.costing.push([res.data.data.costYOYData[g].month+'月',res.data.data.costYOYData[g].lastAmount,res.data.data.costYOYData[g].thisAmount]);
|
|
|
+ }
|
|
|
+ that.statisone()
|
|
|
+ }else{
|
|
|
+ that.$message({
|
|
|
+ message: res.data.msg,
|
|
|
+ type: 'warning'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
},
|
|
|
mounted(){
|
|
|
- this.statisone()
|
|
|
+ this.StatisticsYOY();
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -158,5 +191,8 @@ export default {
|
|
|
.canvas-box{
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
- }
|
|
|
+}
|
|
|
+.yeardate{
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
</style>
|