Browse Source

维修报表接口对接

duanxiaoduan 1 year ago
parent
commit
9d4d849f6b
2 changed files with 160 additions and 129 deletions
  1. 2 2
      .env.development
  2. 158 127
      src/views/report/queryRepair/index.vue

+ 2 - 2
.env.development

@@ -6,9 +6,9 @@ ENV = 'development'
 # 线上正式地址
 #  VUE_APP_BASE_API = 'http://eam.modernfarming.cn:8000/'
 #  白少后台本地
-# VUE_APP_BASE_API = 'http://192.168.1.77:8082/'
+VUE_APP_BASE_API = 'http://192.168.1.77:8082/'
 # 线上测试
-VUE_APP_BASE_API = 'http://tmrwatch.cn:8082/'
+# VUE_APP_BASE_API = 'http://tmrwatch.cn:8082/'
 # VUE_APP_BASE_API = 'http://127.0.0.1:8082/'
 
 # VUE_APP_BASE_API = 'http://36.155.144.182:18090/'

+ 158 - 127
src/views/report/queryRepair/index.vue

@@ -3,7 +3,7 @@
     <div class="filter-container">
       <div class="block">
         <el-date-picker v-model="monthDate" :clearable="false" type="monthrange" range-separator="至" start-placeholder="开始月份" end-placeholder="结束月份" @change="changeMonth()" />
-        <el-select v-model="type" placeholder="类型" @change="changeType()">
+        <el-select v-model="type" placeholder="类型" @change="changeType">
           <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"> </el-option>
         </el-select>
       </div>
@@ -11,7 +11,7 @@
 
     <el-row v-if="isChart1" style="position: relative;">
       <p style="position: absolute;top:-12px;left:40%;color:rgb(130, 165, 252);background:rgb(230, 243, 255);border:1px solid rgb(130, 165, 252);padding:10px;border-radius:10px">
-        集团维修费用:{{ total }}万元
+        集团{{costTypeName}}:{{ total }}万元
       </p>
        <el-radio-group v-model="radio1" class="group" @change="changeGroup">
           <el-radio :label="'集团'">集团</el-radio>
@@ -55,7 +55,7 @@
       </el-col>
       <el-col :span="12">
         <div style="height: 50px;">
-          <el-select style="float: right;margin-right: 20px;" v-model="getChart7Parm.parammaps.deptName" placeholder="部门" @change="changeDept('5')">
+          <el-select style="float: right;margin-right: 20px;" v-model="getChart7Parm.parammaps.deptName" placeholder="部门" @change="changeDept('7')">
             <el-option v-for="item in deptList" :key="item.id" :label="item.name" :value="item.name"> </el-option>
           </el-select>
         </div>
@@ -76,12 +76,14 @@ export default {
   data() {
     return {
       monthDate: [new Date(),new Date()],
+      costTypeName:'所有维修费',
       type:'',
       year: new Date().getFullYear(),
       month: new Date().getMonth() < 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1,
       pastureList:[],
       deptList:[{id:0,name:'挤奶处'},{id:1,name:'犊牛处'},{id:2,name:'办公室'},{id:3,name:'饲养处'},{id:4,name:'兽医处'},{id:5,name:'品控处'},{id:6,name:'设备处'}],
-      typeList:[{id:0,name:'全部费用'},{id:1,name:'制造费用'},{id:2,name:'直接费用'},{id:3,name:'管理费用'}],
+      // typeList:[{id:0,name:'全部费用'},{id:1,name:'制造费用'},{id:2,name:'直接费用'},{id:3,name:'管理费用'}],
+      typeList: [{ id: '', name: '全部费用' }, { id: '挤奶处', name: '直接费用' }, { id: '牧场办公室', name: '管理费用' }, { id: 1, name: '制造费用' }],
       total: '',
       radio1:'集团',
       pastureName:'',
@@ -192,8 +194,21 @@ export default {
         })
       })
     },
-    changeType(){
-
+    changeType(item){
+      console.log(item)
+      if (item == '挤奶处') {
+        this.costTypeName = '直接维修费'
+      } else if (item == '牧场办公室') {
+        this.costTypeName = '管理维修费'
+      } else if (item == 1) {
+        this.costTypeName = '制造维修费'
+      } else if (item == '') {
+        this.costTypeName = '所有维修费'
+        this.type = ''
+      } else {
+        this.costTypeName = '所有维修费'
+      }
+      this.getChart1()
     },
     changeGroup(){
       this.getChart1()
@@ -205,12 +220,14 @@ export default {
       this.getChart2()
     },
     changePasture(){
-      this.getChart4()
+      // this.getChart4()
       this.getChart6()
     },
     changeDept(item){
       if(item == 5){
         this.getChart5()
+      }else if(item == 7){
+        this.getChart7()
       }
     },
     get_auto_buttons() {
@@ -221,7 +238,7 @@ export default {
     },
     // 各牧场维修费用对比
     getChart1() {
-      let url = '/authdata/electricity/nowelectricity?'
+      let url = '/authdata/repair/nowelectricity?'
       let startTime = parseTime(this.monthDate[0],'{y}-{m}')
       let endTime = parseTime(this.monthDate[1],'{y}-{m}')
       let radio = ''
@@ -233,6 +250,7 @@ export default {
       let data = 'startTime=' + startTime
                 + '&endTime=' + endTime
                 + '&center=' + radio
+                + '&departmentName=' + this.type
       getJson(url,data).then(response => {
         console.log('图1', response)
         if(response.data){
@@ -254,7 +272,7 @@ export default {
     },
     // 单头牛维修费用
     getChart2() {
-      let url = '/authdata/electricity/singlecow?'
+      let url = '/authdata/repair/singlecow?'
       let startTime = parseTime(this.monthDate[0],'{y}-{m}')
       let endTime = parseTime(this.monthDate[1],'{y}-{m}')
       let radio = ''
@@ -287,8 +305,86 @@ export default {
 
     // XX牧场每月维修费对比
     getChart4() {
-      this.getChart5Parm.parammaps.deptName = this.deptList[0].name
-      let url = '/authdata/electricity/perhead?'
+      let startTime = parseTime(this.monthDate[0],'{y}-{m}') + '-01'
+      let date = this.monthDate[1];
+      let year = date.getFullYear()
+      let month = date.getMonth() + 1
+      let lastDay = new Date(year, month, 0).getDate();
+      let endTime = parseTime(this.monthDate[1],'{y}-{m}') + '-' + lastDay
+      let data = {
+        name:"getPastureSumMonth",
+        parammaps:{
+          startTime:startTime,
+          endTime:endTime,
+          pastureName:this.pastureName.toString(),
+          departmentName:this.type
+        },
+      }
+      GetReportform(data).then(response => {
+        console.log('图4', response)
+        if(response.data){
+          this.chart_data4 = {
+            data1:response.data.chart_data.lastYear,
+            data2:response.data.chart_data.nowYear,
+            data3:response.data.chart_data.monthBudgetList,
+            xdata:response.data.chart_data.months,
+            data_name:['去年同期用量','今年用量','预算']
+          }
+        }else{
+          this.chart_data4 = {
+            data1:[],
+            data2:[],
+            data3:[],
+            xdata:[],
+            data_name:['去年同期用量','今年用量','预算']
+          }
+        }
+        if(response.data.chart_data.months){
+          this.getChart5Parm.parammaps.date = response.data.chart_data.months[0]
+        }else{
+          this.getChart5Parm.parammaps.date = ''
+        }
+        this.getChart5Parm.parammaps.deptName = this.deptList[0].name
+        this.roadChart4(this.chart_data4)
+        this.getChart5()
+      })
+    },
+    // XX月部门统计
+    getChart5() {
+      let startTime = parseTime(this.getChart5Parm.parammaps.date,'{y}-{m}') + '-01'
+      let date =  new Date(this.getChart5Parm.parammaps.date);
+      let year = date.getFullYear()
+      let month = date.getMonth() + 1
+      let lastDay = new Date(year, month, 0).getDate();
+      let endTime = parseTime(this.getChart5Parm.parammaps.date,'{y}-{m}') + '-' + lastDay
+      let data = {
+        name:"geteqclassSumMonth",
+        parammaps:{
+          startTime:startTime,
+          endTime:endTime,
+          pastureName:this.pastureName.toString(),
+          deptName:this.getChart5Parm.parammaps.deptName,
+        },
+      }
+      GetReportform(data).then(response => {
+        console.log('图5', response)
+        if(response.data.chart_data){
+          this.chart_data5 = {
+            data1:response.data.chart_data.eqCost,
+            xdata:response.data.chart_data.typeName
+          }
+        }else{
+          this.chart_data5 = {
+            data1:[],
+            xdata:[]
+          }
+        }
+        this.roadChart5(this.chart_data5)
+      })
+    },
+    // XX牧场XX年每月用电量对比
+    getChart6() {
+      let url = '/authdata/repair/perhead?'
       let startTime = parseTime(this.monthDate[0],'{y}-{m}')
       let endTime = parseTime(this.monthDate[1],'{y}-{m}')
       let radio = ''
@@ -314,137 +410,72 @@ export default {
       getJson(url,data).then(response => {
         console.log('图4', response)
         if(response.data){
-          this.chart_data4.data1 = response.data.data3
-          this.chart_data4.data_name = ['去年同期','今年用量','预算']
-          this.chart_data4.xdata = response.data.data2
+          this.chart_data6.data1 = response.data.data3
+          this.chart_data6.data_name = ['去年同期','今年用量','预算']
+          this.chart_data6.xdata = response.data.data2
         }else{
-          this.chart_data4.data1 = []
-          this.chart_data4.data_name = ['去年同期','今年用量','预算']
-          this.chart_data4.xdata = []
-          this.chart_data4.line =0
+          this.chart_data6.data1 = []
+          this.chart_data6.data_name = ['去年同期','今年用量','预算']
+          this.chart_data6.xdata = []
+          this.chart_data6.line =0
         }
         if(response.data.data1 == null){
-          this.chart_data4.data_name = []
+          this.chart_data6.data_name = []
         }
         if(response.data.data2 == null ){
-          this.chart_data4.xdata = []
-          this.getChart5Parm.parammaps.date = ''
+          this.chart_data6.xdata = []
+          this.getChart7Parm.parammaps.date = ''
         }else{
-          this.getChart5Parm.parammaps.date = response.data.data2[0]
+          this.getChart7Parm.parammaps.date = response.data.data2[0]
         }
         if(response.data.data3 == null){
-          this.chart_data4.data1 = []
+          this.chart_data6.data1 = []
         }
 
-        console.log(this.chart_data4,'chart_data4')
-        this.roadChart4(this.chart_data4)
-        this.getChart5()
+        console.log(this.chart_data6,'chart_data6')
+        this.roadChart6(this.chart_data6)
+        this.getChart7Parm.parammaps.deptName = this.deptList[0].name
+        this.getChart7()
       })
     },
     // XX月部门统计
-    getChart5() {
-      let startTime = parseTime(this.monthDate[0],'{y}-{m}') + '-01'
-      let date = this.monthDate[1];
+    getChart7() {
+      let startTime = parseTime(this.getChart7Parm.parammaps.date,'{y}-{m}') + '-01'
+      let date =  new Date(this.getChart7Parm.parammaps.date);
       let year = date.getFullYear()
       let month = date.getMonth() + 1
       let lastDay = new Date(year, month, 0).getDate();
-      let endTime = parseTime(this.monthDate[1],'{y}-{m}') + '-' + lastDay
+      let endTime = parseTime(this.getChart7Parm.parammaps.date,'{y}-{m}') + '-' + lastDay
       let data = {
-        name:"getdeptSumMonthElec",
+        name:"getdeptSumMonth",
         parammaps:{
           startTime:startTime,
           endTime:endTime,
           pastureName:this.pastureName.toString(),
-          deptname:this.getChart5Parm.parammaps.deptName,
+          departmentName:this.getChart7Parm.parammaps.deptName
         },
       }
       GetDataByName(data).then(response => {
-        console.log('图5', response)
-        let data1 = []
-        let xdata = []
+        console.log('图7', response)
+        // this.chart_data7 = response.data.chart_data
         if(response.data){
+          var data1 = []
+          var data2 = []
+          var xdata = []
           response.data.list.forEach((item)=>{
             data1.push(item.value)
+            data2.push(item.monthBudget)
             xdata.push(item.name)
           })
-        }
-        this.chart_data5 = {
-          data1:data1,
-          xdata:xdata
-        }
-        this.roadChart5(this.chart_data5)
-      })
-    },
-    // XX牧场XX年每月用电量对比
-    getChart6() {
-      let startTime = parseTime(this.monthDate[0],'{y}-{m}') + '-01'
-      let date = this.monthDate[1];
-      let year = date.getFullYear()
-      let month = date.getMonth() + 1
-      let lastDay = new Date(year, month, 0).getDate();
-      let endTime = parseTime(this.monthDate[1],'{y}-{m}') + '-' + lastDay
-      let data = {
-        name:"getPastureSumMonthElec",
-        parammaps:{
-          startTime:startTime,
-          endTime:endTime,
-          pastureName:this.pastureName.toString(),
-        },
-      }
-      GetReportform(data).then(response => {
-        console.log('图6', response)
-        // this.chart_data6 = response.data.chart_data
-        if(response.data){
-          this.chart_data6 = {
-            data1:response.data.chart_data.lastYear,
-            data2:response.data.chart_data.nowYear,
-            xdata:response.data.chart_data.months,
-            data_name:response.data.chart_data.pastureName
-          }
-        }else{
-          this.chart_data6 = {
-            data1:[],
-            data2:[],
-            xdata:[],
-            data_name:[]
-          }
-        }
-        if(response.data.chart_data.months){
-          this.getChart7Parm.parammaps.date = response.data.chart_data.months[0]
-        }else{
-          this.getChart7Parm.parammaps.date = ''
-        }
-
-        this.roadChart6(this.chart_data6)
-        this.getChart7()
-      })
-    },
-    // XX月每日用电量
-    getChart7() {
-      this.getChart7Parm.parammaps.deptName = this.deptList[0].name
-      let startTime = this.getChart7Parm.parammaps.date
-      let endTime = this.getChart7Parm.parammaps.date
-      let data = {
-        name:"getPastureSumDayElec",
-        parammaps:{
-          startTime:startTime,
-          endTime:endTime,
-          pastureName:this.pastureName.toString(),
-        },
-      }
-      GetReportform(data).then(response => {
-        console.log('图7', response)
-        // this.chart_data7 = response.data.chart_data
-        if(response.data){
           this.chart_data7 = {
-            data1:response.data.chart_data.nowYear,
-            data_name:this.pastureName,
-            xdata:response.data.chart_data.day
+            data1:data1,
+            data2:data2,
+            xdata:xdata
           }
         }else{
           this.chart_data7 = {
             data1:[],
-            data_name:[],
+            data2:[],
             xdata:[]
           }
         }
@@ -468,7 +499,7 @@ export default {
         color: ['#61A5E8', '#9933FF'],
         grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
         xAxis: [{ type: 'category',  name: '牧场',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
-        yAxis: [{ type: 'value', name: '元', axisLabel: { formatter: '{value}万' }}],
+        yAxis: [{ type: 'value', name: '费用()', axisLabel: { formatter: '{value}万' }}],
         series: [
           {
             name: '实际费用',
@@ -515,7 +546,7 @@ export default {
         color:  ['#61A5E8', '#9933FF','#FFB800'],
         grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
         xAxis: [{ type: 'category',  name: '牧场',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
-        yAxis: [{ type: 'value', name: '价格(元)'}],
+        yAxis: [{ type: 'value', name: '费用(元)'}],
         series: [
           {
             name: '实际费用',
@@ -569,20 +600,20 @@ export default {
         grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
         xAxis: [{ type: 'category',  name: '月份',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
         yAxis: [{ type: 'value', name: '费用(元)'}],
-        series: (function() {
-          var serie = []
-          if(chart_data.data1 !== null){
-            for (var i = 0; i < chart_data.data1.length; i++) {
-              var item = {
-                name: chart_data.data_name[i],
-                type: 'line',
-                data: chart_data.data1[i]
-              }
-              serie.push(item)
-            }
-          }
-          return serie
-        }())
+        series: [{
+          name: '去年同期用量',
+          type: 'line',
+          data: chart_data.data1[0]
+        },
+        {
+          name: '今年用量',
+          type: 'line',
+          data: chart_data.data2[0]
+        },{
+          name: '预算',
+          type: 'line',
+          data: chart_data.data3[0]
+        }]
       }
       this.chart4.setOption(option)
       window.onresize = function() {
@@ -612,7 +643,7 @@ export default {
         color: ['#2dc0e8', '#769cfc'],
         grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
         xAxis: [{ type: 'category',  name: '设备',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
-        yAxis: [{ type: 'value',name: '价格(元)', axisLabel: { formatter:'{value} 万'}}],
+        yAxis: [{ type: 'value',name: '费用(元)', axisLabel: { formatter:'{value} 万'}}],
         series: [
           {
             type: 'bar',
@@ -649,7 +680,7 @@ export default {
         color: ['#2dc0e8', '#769cfc', '#FFB800'],
         grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
         xAxis: [{ type: 'category',  name: '月份',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
-        yAxis: [{ type: 'value',name: ''}],
+        yAxis: [{ type: 'value',name: '费用(元)'}],
         series: (function() {
           var serie = []
           if(chart_data.data1 !== null){
@@ -695,7 +726,7 @@ export default {
         // color: ['#2dc0e8', '#769cfc', '#FFB800'],
         grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
         xAxis: [{ type: 'category',  name: '部门',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
-        yAxis: [{ type: 'value', name: ''}],
+        yAxis: [{ type: 'value', name: '费用(元)'}],
         series: [
           {
             name: '实际',