From 12fb4b8e4fb75347b25f3ba473b930408ed2ec05 Mon Sep 17 00:00:00 2001
From: zhuzhuanzhuan
Date: 星期五, 22 九月 2023 17:49:18 +0800
Subject: [PATCH] 1、优化查询时若无选择日期的提示信息 2、增加部分加载时间较长的数据的加载动画

---
 src/views/mdc/base/modules/equipmentAvailCompare/equipmentAvailCompareMain.vue |  408 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 213 insertions(+), 195 deletions(-)

diff --git a/src/views/mdc/base/modules/equipmentAvailCompare/equipmentAvailCompareMain.vue b/src/views/mdc/base/modules/equipmentAvailCompare/equipmentAvailCompareMain.vue
index fd413b7..faba4d8 100644
--- a/src/views/mdc/base/modules/equipmentAvailCompare/equipmentAvailCompareMain.vue
+++ b/src/views/mdc/base/modules/equipmentAvailCompare/equipmentAvailCompareMain.vue
@@ -1,52 +1,53 @@
 <template>
-  <a-card :bordered="false" class="device_list">
-    <div class="com_box">
-      <!-- 鏌ヨ鍖哄煙 -->
-      <div style="width: 100%; background-color: #fff" class="table-page-search-wrapper">
-        <a-form layout="inline" @keyup.enter.native="searchQuery">
-          <a-row :gutter="24">
-            <a-col :md="4" :sm="4">
-              <a-form-item label="璁惧缂栧彿">
-                <a-input placeholder="杈撳叆璁惧缂栧彿鏌ヨ" :readOnly="readOnly" v-model="queryParams.equipmentId"></a-input>
-              </a-form-item>
-            </a-col>
-            <a-col :md="4" :sm="4">
-              <a-form-item label="璁惧鍚嶇О">
-                <a-input placeholder="杈撳叆璁惧鍚嶇О鏌ヨ" :readOnly="readOnly" v-model="queryParams.equipmentName"></a-input>
-              </a-form-item>
-            </a-col>
-            <a-col :md="5" :sm="5" :xs="5">
-              <a-form-item label="鏃堕棿">
-                <a-range-picker @change="dateParamChange" v-model="dates"  format="YYYYMMDD"/>
-              </a-form-item>
-            </a-col>
-            <a-col :md="7" :sm="7" :xs="7">
-             <a-form-item label="鏃堕棿娈�">
-               <a-time-picker :default-value="moment('00:00', 'HH:mm')" format="HH:mm" @change="onChangeStart" />
-               鑷�
-               <a-time-picker :default-value="moment('08:00', 'HH:mm')" format="HH:mm" @change="onChangeEnd" />
-             </a-form-item>
-            </a-col>
-            <a-col :md="2" :sm="3" :xs="3">
-              <a-button type="primary" @click="searchQuery" icon="search">鏌ヨ</a-button>
-            </a-col>
-            <!--<a-col :md="2" :sm="2" :xs="2">-->
-            <!--<a-button type="primary" @click="searchReset" icon="reload">閲嶇疆</a-button>-->
-            <!--</a-col>-->
-          </a-row>
-        </a-form>
-      </div>
-      <!-- table鍖哄煙-begin -->
-      <div id="DeviceList">
-
-        <div style="padding: 5px;width: 100%;height: 100%">
-          <div style="width: 100%;height: 100%" id="dayAvailBar"></div>
-          <!--<div id="dayAvailLine"></div>-->
+  <a-spin :spinning="loading">
+    <a-card :bordered="false" class="device_list">
+      <div class="com_box">
+        <!-- 鏌ヨ鍖哄煙 -->
+        <div style="width: 100%; background-color: #fff" class="table-page-search-wrapper">
+          <a-form layout="inline" @keyup.enter.native="searchQuery">
+            <a-row :gutter="24">
+              <a-col :md="4" :sm="4">
+                <a-form-item label="璁惧缂栧彿">
+                  <a-input placeholder="杈撳叆璁惧缂栧彿鏌ヨ" :readOnly="readOnly" v-model="queryParams.equipmentId"></a-input>
+                </a-form-item>
+              </a-col>
+              <a-col :md="4" :sm="4">
+                <a-form-item label="璁惧鍚嶇О">
+                  <a-input placeholder="杈撳叆璁惧鍚嶇О鏌ヨ" :readOnly="readOnly" v-model="queryParams.equipmentName"></a-input>
+                </a-form-item>
+              </a-col>
+              <a-col :md="5" :sm="5" :xs="5">
+                <a-form-item label="鏃堕棿">
+                  <a-range-picker @change="dateParamChange" v-model="dates" format="YYYYMMDD"/>
+                </a-form-item>
+              </a-col>
+              <a-col :md="7" :sm="7" :xs="7">
+                <a-form-item label="鏃堕棿娈�">
+                  <a-time-picker :default-value="moment('00:00', 'HH:mm')" format="HH:mm" @change="onChangeStart"/>
+                  鑷�
+                  <a-time-picker :default-value="moment('08:00', 'HH:mm')" format="HH:mm" @change="onChangeEnd"/>
+                </a-form-item>
+              </a-col>
+              <a-col :md="2" :sm="3" :xs="3">
+                <a-button type="primary" @click="searchQuery" icon="search">鏌ヨ</a-button>
+              </a-col>
+              <!--<a-col :md="2" :sm="2" :xs="2">-->
+              <!--<a-button type="primary" @click="searchReset" icon="reload">閲嶇疆</a-button>-->
+              <!--</a-col>-->
+            </a-row>
+          </a-form>
         </div>
+        <!-- table鍖哄煙-begin -->
+        <div id="DeviceList">
+          <div style="padding: 5px;width: 100%;height: 100%">
+            <div style="width: 100%;height: 100%" id="dayAvailBar"></div>
+            <!--<div id="dayAvailLine"></div>-->
+          </div>
+        </div>
+        <!-- table鍖哄煙-end -->
       </div>
-      <!-- table鍖哄煙-end -->
-    </div>
-  </a-card>
+    </a-card>
+  </a-spin>
 </template>
 
 <script>
@@ -68,6 +69,7 @@
   import Tooltip from 'ant-design-vue/es/tooltip'
   import { ajaxGetDictItems, getDictItemsFromCache, duplicateCheck } from '@/api/api'
   import AFormItem from 'ant-design-vue/es/form/FormItem'
+
   export default {
     name: 'equipmentAvailCompareMain',
     // mixins: [JeecgListMixin],
@@ -82,37 +84,38 @@
       JDate,
       JEllipsis
     },
-    props: {  nodeTree: '', Type:'',nodePeople: '' },
+    props: { nodeTree: '', Type: '', nodePeople: '' },
     data() {
       return {
         activeKey: '1',
-        typeTree:"",
-        typeParent:1,
-        typeEquipment:1,
-        spaceTime:[],
-        useingRates:[],
+        typeTree: '',
+        typeParent: 1,
+        typeEquipment: 1,
+        spaceTime: [],
+        useingRates: [],
         dates: [],
-        xianshi:"",
-        readOnly:true,
+        xianshi: '',
+        readOnly: true,
         queryParam: {
           // dateTime:undefined,
           // timeType:'2'
         },
-        queryParams:{},
-        queryParamEquip:{},
-        queryParamPeople:{},
-        dataStartsoucre:[],
+        queryParams: {},
+        queryParamEquip: {},
+        queryParamPeople: {},
+        dataStartsoucre: [],
         url: {
-          dayUtilizationRateContrast:'/mdc/efficiencyReport/dayUtilizationRateContrast',
+          dayUtilizationRateContrast: '/mdc/efficiencyReport/dayUtilizationRateContrast',
           getEquipmentByPid: '/mdc/mdcEquipment/getEquipmentByPid',
-          getEquipmentByDepPid:'/mdc/mdcEquipment/getEquipmentByDepPid'
+          getEquipmentByDepPid: '/mdc/mdcEquipment/getEquipmentByDepPid'
         },
-        AnalysisList:{}
+        AnalysisList: {},
+        loading: false
       }
     },
-    watch:{
-      Type(valmath){
-        this.dataList = [];
+    watch: {
+      Type(valmath) {
+        this.dataList = []
         this.queryParams.typeTree = valmath
         // console.log(this.queryParams.typeTree)
       },
@@ -120,7 +123,7 @@
         if (JSON.stringify(val) != '{}') {
           if (val.equipmentId) {
             // this.$set(this.queryParam, 'tierName', val.title)
-            this.queryParamEquip.parentId =  ""
+            this.queryParamEquip.parentId = ''
             this.queryParams.equipmentId = val.equipmentId
             this.queryParamEquip.equipmentId = val.equipmentId
             this.searchQuery()
@@ -131,14 +134,13 @@
             this.initEquipment(val.key)
           }
 
-
         }
       },
-      nodePeople(val){
+      nodePeople(val) {
         if (JSON.stringify(val) != '{}') {
           if (val.equipmentId) {
             // this.$set(this.queryParam, 'tierName', val.title)
-            this.queryParamEquip.parentId =  ""
+            this.queryParamEquip.parentId = ''
             this.queryParams.equipmentId = val.equipmentId
             this.queryParamEquip.equipmentId = val.equipmentId
             this.searchQuery()
@@ -153,8 +155,8 @@
       }
     },
     methods: {
-      drawTu(){
-        let dayAvailBar = this.$echarts.init(document.getElementById('dayAvailBar'), 'macarons');
+      drawTu() {
+        let dayAvailBar = this.$echarts.init(document.getElementById('dayAvailBar'), 'macarons')
         //dayAvailLine = echarts.init(document.getElementById('dayAvailLine'));
         let dayAvailBarOption = {
           title: {
@@ -163,21 +165,21 @@
             textStyle: {
               fontSize: 18,
               fontWeight: 'bolder',
-              color: "#151414"
+              color: '#151414'
             }
           },
           tooltip: {
             trigger: 'axis',
-            formatter: "{a} <br/>{b} :({c}%)"
+            formatter: '{a} <br/>{b} :({c}%)'
           },
           toolbox: {
             show: true,
             feature: {
-              mark: {show: true},
-              dataView: {show: true, readOnly: false},
-              magicType: {show: true, type: ['line', 'bar']},
-              restore: {show: true},
-              saveAsImage: {show: true}
+              mark: { show: true },
+              dataView: { show: true, readOnly: false },
+              magicType: { show: true, type: ['line', 'bar'] },
+              restore: { show: true },
+              saveAsImage: { show: true }
             }
           },
           calculable: true, //鏄惁鍚敤鎷栨嫿閲嶈绠楃壒鎬�
@@ -208,14 +210,14 @@
               data: this.useingRates,
               markPoint: {
                 data: [
-                  {type: 'max', name: '鏈�澶у��', symbolSize: 70},
-                  {type: 'min', name: '鏈�灏忓��', symbolSize: 70}
+                  { type: 'max', name: '鏈�澶у��', symbolSize: 70 },
+                  { type: 'min', name: '鏈�灏忓��', symbolSize: 70 }
                 ]
               }
             }
           ]
-        };
-        dayAvailBar.setOption(dayAvailBarOption);
+        }
+        dayAvailBar.setOption(dayAvailBarOption)
       },
       moment,
       onChangeStart(time, timeString) {
@@ -226,12 +228,12 @@
         this.queryParam.endTime = timeString
         // console.log(time, timeString);
       },
-      disabledDate(current){
+      disabledDate(current) {
         //Can not slect days before today and today
-        return current && current > moment().subtract('days', 1);
+        return current && current > moment().subtract('days', 1)
       },
       dataChange(val) {
-        this.queryParam.dateTime = val.format('YYYYMMDD')
+        if (val) this.queryParam.dateTime = val.format('YYYYMMDD')
       },
       handleChange(value) {
         this.queryParam.timeType = value
@@ -246,11 +248,12 @@
         this.queryParam.endDate = v2[1]
         // console.log(v2[0],v2[1])
       },
-      loadAnalysis(){
-        getAction(this.url.dayUtilizationRateContrast,this.queryParam).then(res => {
+      loadAnalysis() {
+        this.loading = true
+        getAction(this.url.dayUtilizationRateContrast, this.queryParam).then(res => {
           if (res.success) {
             this.spaceTime.push(res.result.dataList)
-            for(let i = 0;i<res.result.dayRateDto.length;i++){
+            for (let i = 0; i < res.result.dayRateDto.length; i++) {
               this.useingRates.push(res.result.dayRateDto[i].utilizationRate)
             }
             this.drawTu()
@@ -268,112 +271,120 @@
           return '0'
         }
       },
-      searchQuery(){
-        this.spaceTime = []
-        this.useingRates = []
-        if(this.queryParams.typeTree == "1"){
-          this.queryParams.parentId =  this.queryParamEquip.parentId
-          // this.queryParams.equipmentId =  this.queryParamEquip.equipmentId
+      searchQuery() {
+        if (this.queryParam.startTime && this.queryParam.endTime && this.dates && this.dates.length > 0) {
+          this.loading = true
+          this.spaceTime = []
+          this.useingRates = []
+          if (this.queryParams.typeTree == '1') {
+            this.queryParams.parentId = this.queryParamEquip.parentId
+            // this.queryParams.equipmentId =  this.queryParamEquip.equipmentId
 
-        }else{
-          this.queryParams.parentId = this.queryParamEquip.parentId
-
-          // this.queryParams.equipmentId = ""
-        }
-        this.AnalysisList = [];
-        //鑾峰彇鏌ヨ鏉′欢
-        this.queryParam.parentId = this.queryParams.parentId;
-        this.queryParam.equipmentId = this.queryParams.equipmentId;
-        this.queryParam.typeTree = this.queryParams.typeTree
-        getAction(this.url.dayUtilizationRateContrast,this.queryParam).then((res) => {
-          if(res.success){
-            this.spaceTime=res.result.dateList
-            for(let i = 0;i<res.result.dayRateDto.length;i++){
-              // res.result[i].useRateDayShift = this.numFilter(res.result[i].useRateDayShift)
-              this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
-            }
-            this.drawTu()
-          }else{
-            // this.$message.warning(res.message)
-            this.$notification.warning({
-              message:'娑堟伅',
-              description:res.message
-            });
+          } else {
+            this.queryParams.parentId = this.queryParamEquip.parentId
+            // this.queryParams.equipmentId = ""
           }
-        }).finally(() => {
-          this.loading = false
-        })
+          this.AnalysisList = []
+          //鑾峰彇鏌ヨ鏉′欢
+          this.queryParam.parentId = this.queryParams.parentId
+          this.queryParam.equipmentId = this.queryParams.equipmentId
+          this.queryParam.typeTree = this.queryParams.typeTree
+          getAction(this.url.dayUtilizationRateContrast, this.queryParam).then((res) => {
+            if (res.success) {
+              this.spaceTime = res.result.dateList
+              for (let i = 0; i < res.result.dayRateDto.length; i++) {
+                // res.result[i].useRateDayShift = this.numFilter(res.result[i].useRateDayShift)
+                this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
+              }
+              this.drawTu()
+            } else {
+              // this.$message.warning(res.message)
+              this.$notification.warning({
+                message: '娑堟伅',
+                description: res.message
+              })
+            }
+          }).finally(() => {
+            this.loading = false
+          })
+        } else {
+          this.$notification.warning({
+            message: '娑堟伅',
+            description: '璇烽�夋嫨鏃堕棿鎴栨椂闂存'
+          })
+        }
       },
       searchReset() {
+        this.loading = true
         this.spaceTime = []
         this.useingRates = []
-        if(this.queryParams.typeTree == "1"){
+        if (this.queryParams.typeTree == '1') {
           this.typeTree = this.queryParams.typeTree
-          this.typeParent =  this.queryParams.parentId
+          this.typeParent = this.queryParams.parentId
           this.typeEquipment = this.queryParams.equipmentId
           this.queryParams = {}
           this.queryParam = {}
           this.queryParams.typeTree = this.typeTree
           this.queryParams.parentId = this.typeParent
-          if(this.queryParams.parentId !=  ""){
-            this.queryParams.equipmentId =  ""
+          if (this.queryParams.parentId != '') {
+            this.queryParams.equipmentId = ''
             this.initEquipment()
-          }else{
-            if(this.queryParams.equipmentId == this.queryParamEquip.equipmentId){
-              this.queryParams.equipmentId =  this.typeEquipment
-            }else{
+          } else {
+            if (this.queryParams.equipmentId == this.queryParamEquip.equipmentId) {
+              this.queryParams.equipmentId = this.typeEquipment
+            } else {
               this.queryParams.equipmentId = this.queryParamEquip.equipmentId
             }
           }
-          getAction(this.url.dayUtilizationRateContrast,this.queryParams).then((res) => {
-            if(res.success){
-              this.spaceTime=res.result.dateList
-              for(let i = 0;i<res.result.dayRateDto.length;i++){
+          getAction(this.url.dayUtilizationRateContrast, this.queryParams).then((res) => {
+            if (res.success) {
+              this.spaceTime = res.result.dateList
+              for (let i = 0; i < res.result.dayRateDto.length; i++) {
                 this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
               }
               this.drawTu()
-            }else{
+            } else {
               // this.$message.warning(res.message)
               this.$notification.warning({
-                message:'娑堟伅',
-                description:res.message
-              });
+                message: '娑堟伅',
+                description: res.message
+              })
             }
           }).finally(() => {
             this.loading = false
           })
-        }else{
+        } else {
           this.typeTree = this.queryParams.typeTree
-          this.typeParent =  this.queryParams.parentId
+          this.typeParent = this.queryParams.parentId
           this.typeEquipment = this.queryParams.equipmentId
           this.queryParams = {}
           this.queryParam = {}
           this.dates = []
           this.queryParams.typeTree = this.typeTree
           this.queryParams.parentId = this.typeParent
-          if(this.queryParams.parentId !=  ""){
-            this.queryParams.equipmentId =  ""
+          if (this.queryParams.parentId != '') {
+            this.queryParams.equipmentId = ''
             this.initEquipment()
-          }else{
-            if(this.queryParams.equipmentId == this.queryParamEquip.equipmentId){
-              this.queryParams.equipmentId =  this.typeEquipment
-            }else{
+          } else {
+            if (this.queryParams.equipmentId == this.queryParamEquip.equipmentId) {
+              this.queryParams.equipmentId = this.typeEquipment
+            } else {
               this.queryParams.equipmentId = this.queryParamEquip.equipmentId
             }
           }
-          getAction(this.url.dayUtilizationRateContrast,this.queryParams).then((res) => {
-            if(res.success){
-              this.spaceTime=res.result.dateList
-              for(let i = 0;i<res.result.dayRateDto.length;i++){
+          getAction(this.url.dayUtilizationRateContrast, this.queryParams).then((res) => {
+            if (res.success) {
+              this.spaceTime = res.result.dateList
+              for (let i = 0; i < res.result.dayRateDto.length; i++) {
                 this.useingRates.push(this.numFilter(res.result.dayRateDto[i].utilizationRate))
               }
               this.drawTu()
-            }else{
+            } else {
               // this.$message.warning(res.message)
               this.$notification.warning({
-                message:'娑堟伅',
-                description:res.message
-              });
+                message: '娑堟伅',
+                description: res.message
+              })
             }
           }).finally(() => {
             this.loading = false
@@ -397,16 +408,16 @@
               this.equipment = {}
               // _this.$message.warning('璇疯仈绯荤鐞嗗憳锛屽紑鏀捐澶囨潈闄愶紒')
               _this.$notification.warning({
-                message:'娑堟伅',
-                description:'璇疯仈绯荤鐞嗗憳锛屽紑鏀捐澶囨潈闄愶紒'
-              });
+                message: '娑堟伅',
+                description: '璇疯仈绯荤鐞嗗憳锛屽紑鏀捐澶囨潈闄愶紒'
+              })
             }
-          }else{
+          } else {
             // this.$message.warning(res.message)
             _this.$notification.warning({
-              message:'娑堟伅',
-              description:res.message
-            });
+              message: '娑堟伅',
+              description: res.message
+            })
           }
         })
       },
@@ -426,16 +437,16 @@
               this.equipment = {}
               // _this.$message.warning('璇疯仈绯荤鐞嗗憳锛屽紑鏀捐澶囨潈闄愶紒')
               _this.$notification.warning({
-                message:'娑堟伅',
-                description:'璇疯仈绯荤鐞嗗憳锛屽紑鏀捐澶囨潈闄愶紒'
-              });
+                message: '娑堟伅',
+                description: '璇疯仈绯荤鐞嗗憳锛屽紑鏀捐澶囨潈闄愶紒'
+              })
             }
-          }else{
+          } else {
             // this.$message.warning(res.message)
             _this.$notification.warning({
-              message:'娑堟伅',
-              description:res.message
-            });
+              message: '娑堟伅',
+              description: res.message
+            })
           }
         })
       }
@@ -445,68 +456,75 @@
       this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
       this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
       this.queryParam.startTime = '00:00'
-      this.queryParam.endTime = "08:00"
-      this.queryParams.typeTree = "1";
-
+      this.queryParam.endTime = '08:00'
+      this.queryParams.typeTree = '1'
 
     },
     mounted() {
       this.initEquipment()
-    },
+    }
   }
 </script>
 
 <style lang="less" scoped>
   /*@import '~@assets/less/common.less';*/
 
-  @media screen and (min-width: 1920px){
-    .device_list{
-      height: 811px!important;
+  @media screen and (min-width: 1920px) {
+    .device_list {
+      height: 811px !important;
       overflow: scroll;
     }
   }
-  @media screen and (min-width: 1680px) and (max-width: 1920px){
-    .device_list{
-      height: 811px!important;
+
+  @media screen and (min-width: 1680px) and (max-width: 1920px) {
+    .device_list {
+      height: 811px !important;
       overflow: scroll;
     }
   }
-  @media screen and (min-width: 1400px) and (max-width: 1680px){
-    .device_list{
-      height: 663px!important;
+
+  @media screen and (min-width: 1400px) and (max-width: 1680px) {
+    .device_list {
+      height: 663px !important;
       overflow: scroll;
     }
   }
-  @media screen and (min-width: 1280px) and (max-width: 1400px){
-    .device_list{
-      height: 564px!important;
+
+  @media screen and (min-width: 1280px) and (max-width: 1400px) {
+    .device_list {
+      height: 564px !important;
       overflow: scroll;
     }
   }
-  @media screen and (max-width: 1280px){
-    .device_list{
-      height: 564px!important;
+
+  @media screen and (max-width: 1280px) {
+    .device_list {
+      height: 564px !important;
       overflow: scroll;
     }
   }
+
   /*.device_list{*/
   /*display: flex;*/
   /*}*/
   /*.device_list .table-page-search-wrapper{*/
   /**/
   /*}*/
-  /deep/ .ant-card-body{
-    height: 100%!important;
+  /deep/ .ant-card-body {
+    height: 100% !important;
   }
-  .device_list .com_box{
-    display: flex!important;
-    height: 100%!important;
-    flex-direction: column!important;
+
+  .device_list .com_box {
+    display: flex !important;
+    height: 100% !important;
+    flex-direction: column !important;
   }
-  .device_list .table-page-search-wrapper{
-    height: 6%!important;
+
+  .device_list .table-page-search-wrapper {
+    height: 6% !important;
   }
-  .device_list #DeviceList{
-    height: 90%!important;
+
+  .device_list #DeviceList {
+    height: 90% !important;
   }
 </style>

--
Gitblit v1.9.3