dedsudiyu 1 month ago
parent
commit
30b3270c43

+ 2 - 0
src/utils/request.js

@@ -79,6 +79,8 @@ service.interceptors.response.use(res => {
         },1000);
       }
       return res.data
+    }else if(code == 5007){
+      return res.data
     }else if(code == 5002){
       // autoLogin();
       if(getToken()){

+ 243 - 143
src/views/components/facilityUtilizationRate.vue

@@ -30,48 +30,13 @@
           // text: 'Facility utilization rate and status statistics'
           text: ''
         },
-        data1: {
-          name: '温室',
-          value: 0,
-          color1: '#FF3131',
-          color2: 'rgba(221, 111, 114, 1)',
-          color3: 'rgba(221, 111, 114, 0.2)'
-        },
-        data2: {
-          name: '温室附属房',
-          value: 0,
-          color1: '#FF8D12',
-          color2: 'rgba(255, 132, 0, 1)',
-          color3: 'rgba(255, 132, 0, 0.2)'
-        },
-        data3: {
-          name: '顶置光型人工气候室',
-          value: 0,
-          color1: '#17C700',
-          color2: 'rgba(104, 231, 88, 1)',
-          color3: 'rgba(104, 231, 88, 0.2)'
-        },
-        data4: {
-          name: '冷库',
-          value: 0,
-          color1: '#0B94F4',
-          color2: 'rgba(65, 177, 255, 1)',
-          color3: 'rgba(65, 177, 255, 0.2)'
-        },
-        data5: {
-          name: '种质资源库',
-          value: 0,
-          color1: '#AE7CF9',
-          color2: 'rgba(180, 130, 255, 1)',
-          color3: 'rgba(180, 130, 255, 0.2)'
-        },
-        data6: {
-          name: '培养架型人工气候室',
-          value: 0,
-          color1: '#00FFFF',
-          color2: 'rgba(68, 255, 255, 1)',
-          color3: 'rgba(68, 255, 255, 0.2)'
-        },
+        data1: {},
+        data2: {},
+        data3: {},
+        data4: {},
+        data5: {},
+        data6: {},
+        color:[],
         //学院统计数据
         newData: {
           deptName: ['暂无数据'],
@@ -102,7 +67,6 @@
       }
     },
     created() {
-
     },
     mounted() {
       this.getDataTimerFunction();
@@ -121,6 +85,9 @@
         dashboardsFacilitiesUsageStats().then(res => {
           this.$set(this,'eChartsCarouselIndex',0);
           this.$set(this,'eChartsCarouselMaxIndex',0);
+          let dataList = [];
+          let color = [];
+          //六个饼
           if(!res.data.monthlyUsage[0]){
             this.eChartsMethod(this.eChartsData1, this.data1, 'facilityUtilizationRate-eCharts-1')
             this.eChartsMethod(this.eChartsData2, this.data2, 'facilityUtilizationRate-eCharts-2')
@@ -135,31 +102,158 @@
             max = self.precisionAdd(max,res.data.monthlyUsage[i].equCount)
           }
           for (let i = 0; i < res.data.monthlyUsage.length; i++) {
-            if (res.data.monthlyUsage[i].equTypeName == '温室') {
-              self.$set(self.data1, 'value', self.calculatePercentage(res.data.monthlyUsage[i].equCount,max,0))
-            } else if (res.data.monthlyUsage[i].equTypeName == '温室附属房') {
-              self.$set(self.data2, 'value', self.calculatePercentage(res.data.monthlyUsage[i].equCount,max,0))
-            } else if (res.data.monthlyUsage[i].equTypeName == '顶置光型人工气候室') {
-              self.$set(self.data3, 'value', self.calculatePercentage(res.data.monthlyUsage[i].equCount,max,0))
-            } else if (res.data.monthlyUsage[i].equTypeName == '冷库') {
-              self.$set(self.data4, 'value', self.calculatePercentage(res.data.monthlyUsage[i].equCount,max,0))
-            } else if (res.data.monthlyUsage[i].equTypeName == '种质资源库') {
-              self.$set(self.data5, 'value', self.calculatePercentage(res.data.monthlyUsage[i].equCount,max,0))
-            } else if (res.data.monthlyUsage[i].equTypeName == '培养架型人工气候室') {
-              self.$set(self.data6, 'value', self.calculatePercentage(res.data.monthlyUsage[i].equCount,max,0))
+            if(i==0){
+              dataList.push(res.data.monthlyUsage[i].equTypeName)
+              color.push({
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [{
+                  offset: 0,
+                  color: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)'
+                }, {
+                  offset: 1,
+                  color: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)'
+                }]
+              })
+              this.$set(this,'data1',{
+                name: res.data.monthlyUsage[i].equTypeName,
+                value: this.accMul(res.data.monthlyUsage[i].rentingMonthFromYearRate,100).toFixed(0),
+                color1: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'#ffffff',
+                color2: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)',
+                color3: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)',
+              });
+            }else if(i==1){
+              dataList.push(res.data.monthlyUsage[i].equTypeName)
+              color.push({
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [{
+                  offset: 0,
+                  color: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)'
+                }, {
+                  offset: 1,
+                  color: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)'
+                }]
+              })
+              this.$set(this,'data2',{
+                name: res.data.monthlyUsage[i].equTypeName,
+                value: this.accMul(res.data.monthlyUsage[i].rentingMonthFromYearRate,100).toFixed(0),
+                color1: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'#ffffff',
+                color2: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)',
+                color3: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)',
+              });
+            }else if(i==2){
+              dataList.push(res.data.monthlyUsage[i].equTypeName)
+              color.push({
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [{
+                  offset: 0,
+                  color: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)'
+                }, {
+                  offset: 1,
+                  color: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)'
+                }]
+              })
+              this.$set(this,'data3',{
+                name: res.data.monthlyUsage[i].equTypeName,
+                value: this.accMul(res.data.monthlyUsage[i].rentingMonthFromYearRate,100).toFixed(0),
+                color1: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'#ffffff',
+                color2: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)',
+                color3: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)',
+              });
+            }else if(i==3){
+              dataList.push(res.data.monthlyUsage[i].equTypeName)
+              color.push({
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [{
+                  offset: 0,
+                  color: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)'
+                }, {
+                  offset: 1,
+                  color: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)'
+                }]
+              })
+              this.$set(this,'data4',{
+                name: res.data.monthlyUsage[i].equTypeName,
+                value: this.accMul(res.data.monthlyUsage[i].rentingMonthFromYearRate,100).toFixed(0),
+                color1: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'#ffffff',
+                color2: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)',
+                color3: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)',
+              });
+            }else if(i==4){
+              dataList.push(res.data.monthlyUsage[i].equTypeName)
+              color.push({
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [{
+                  offset: 0,
+                  color: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)'
+                }, {
+                  offset: 1,
+                  color: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)'
+                }]
+              })
+              this.$set(this,'data5',{
+                name: res.data.monthlyUsage[i].equTypeName,
+                value: this.accMul(res.data.monthlyUsage[i].rentingMonthFromYearRate,100).toFixed(0),
+                color1: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'#ffffff',
+                color2: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)',
+                color3: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)',
+              });
+            }else if(i==5){
+              dataList.push(res.data.monthlyUsage[i].equTypeName)
+              color.push({
+                type: 'linear',
+                x: 0,
+                y: 0,
+                x2: 0,
+                y2: 1,
+                colorStops: [{
+                  offset: 0,
+                  color: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)'
+                }, {
+                  offset: 1,
+                  color: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)'
+                }]
+              })
+              this.$set(this,'data6',{
+                name: res.data.monthlyUsage[i].equTypeName,
+                value: this.accMul(res.data.monthlyUsage[i].rentingMonthFromYearRate,100).toFixed(0),
+                color1: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'#ffffff',
+                color2: res.data.monthlyUsage[i].color?res.data.monthlyUsage[i].color:'rgba(255, 255, 255, 1)',
+                color3: res.data.monthlyUsage[i].color?this.changeAlpha(res.data.monthlyUsage[i].color,'0.2'):'rgba(255, 255, 255, 0.2)',
+              });
             }
           }
+          this.$set(this,'color',color);
           this.eChartsMethod(this.eChartsData1, this.data1, 'facilityUtilizationRate-eCharts-1')
           this.eChartsMethod(this.eChartsData2, this.data2, 'facilityUtilizationRate-eCharts-2')
           this.eChartsMethod(this.eChartsData3, this.data3, 'facilityUtilizationRate-eCharts-3')
           this.eChartsMethod(this.eChartsData4, this.data4, 'facilityUtilizationRate-eCharts-4')
           this.eChartsMethod(this.eChartsData5, this.data5, 'facilityUtilizationRate-eCharts-5')
           this.eChartsMethod(this.eChartsData6, this.data6, 'facilityUtilizationRate-eCharts-6')
+          //学院
           if(!res.data.unitStats[0]){
             this.eChartsListMethod()
             return
           }
-          let dataList = ['温室','温室附属房','顶置光型人工气候室','冷库','种质资源库','培养架型人工气候室',];
           let newData = {
             deptName: [],
             list1: [],
@@ -261,7 +355,6 @@
           this.$set(this,'newList',list);
           this.$set(this,'newData',list[0]);
           this.eChartsListMethod()
-
         })
       },
       eChartsMethod(eChartsData, item, boxId) {
@@ -351,92 +444,85 @@
           legend: {
             show: false
           },
-          color: [
-            {
-              type: 'linear',
-              x: 0,
-              y: 0,
-              x2: 0,
-              y2: 1,
-              colorStops: [{
-                offset: 0,
-                color: 'rgba(221, 111, 114, 1)'
-              }, {
-                offset: 1,
-                color: 'rgba(221, 111, 114, 0.2)'
-              }]
-            },
-            {
-              type: 'linear',
-              x: 0,
-              y: 0,
-              x2: 0,
-              y2: 1,
-              colorStops: [{
-                offset: 0,
-                color: 'rgba(255, 132, 0, 1)'
-              }, {
-                offset: 1,
-                color: 'rgba(255, 132, 0, 0.2)'
-              }]
-            },
-            {
-              type: 'linear',
-              x: 0,
-              y: 0,
-              x2: 0,
-              y2: 1,
-              colorStops: [{
-                offset: 0,
-                color: 'rgba(104, 231, 88, 1)'
-              }, {
-                offset: 1,
-                color: 'rgba(104, 231, 88, 0.2)'
-              }]
-            },
-            {
-              type: 'linear',
-              x: 0,
-              y: 0,
-              x2: 0,
-              y2: 1,
-              colorStops: [{
-                offset: 0,
-                color: 'rgba(65, 177, 255, 1)'
-              }, {
-                offset: 1,
-                color: 'rgba(65, 177, 255, 0.2)'
-              }]
-            },
-            {
-              type: 'linear',
-              x: 0,
-              y: 0,
-              x2: 0,
-              y2: 1,
-              colorStops: [{
-                offset: 0,
-                color: 'rgba(180, 130, 255, 1)'
-              }, {
-                offset: 1,
-                color: 'rgba(180, 130, 255, 0.2)'
-              }]
-            },
-            {
-              type: 'linear',
-              x: 0,
-              y: 0,
-              x2: 0,
-              y2: 1,
-              colorStops: [{
-                offset: 0,
-                color: 'rgba(68, 255, 255, 1)'
-              }, {
-                offset: 1,
-                color: 'rgba(68, 255, 255, 0.2)'
-              }]
-            }
-          ],
+          color: this.color[0]?this.color:[{
+            type: 'linear',
+            x: 0,
+            y: 0,
+            x2: 0,
+            y2: 1,
+            colorStops: [{
+              offset: 0,
+              color: 'rgba(255, 255, 255, 1)'
+            }, {
+              offset: 1,
+              color: 'rgba(255, 255, 255, 0.2)'
+            }]
+          }, {
+            type: 'linear',
+            x: 0,
+            y: 0,
+            x2: 0,
+            y2: 1,
+            colorStops: [{
+              offset: 0,
+              color: 'rgba(255, 255, 255, 1)'
+            }, {
+              offset: 1,
+              color: 'rgba(255, 255, 255, 0.2)'
+            }]
+          }, {
+            type: 'linear',
+            x: 0,
+            y: 0,
+            x2: 0,
+            y2: 1,
+            colorStops: [{
+              offset: 0,
+              color: 'rgba(255, 255, 255, 1)'
+            }, {
+              offset: 1,
+              color: 'rgba(255, 255, 255, 0.2)'
+            }]
+          }, {
+            type: 'linear',
+            x: 0,
+            y: 0,
+            x2: 0,
+            y2: 1,
+            colorStops: [{
+              offset: 0,
+              color: 'rgba(255, 255, 255, 1)'
+            }, {
+              offset: 1,
+              color: 'rgba(255, 255, 255, 0.2)'
+            }]
+          }, {
+            type: 'linear',
+            x: 0,
+            y: 0,
+            x2: 0,
+            y2: 1,
+            colorStops: [{
+              offset: 0,
+              color: 'rgba(255, 255, 255, 1)'
+            }, {
+              offset: 1,
+              color: 'rgba(255, 255, 255, 0.2)'
+            }]
+          }, {
+            type: 'linear',
+            x: 0,
+            y: 0,
+            x2: 0,
+            y2: 1,
+            colorStops: [{
+              offset: 0,
+              color: 'rgba(255, 255, 255, 1)'
+            }, {
+              offset: 1,
+              color: 'rgba(255, 255, 255, 0.2)'
+            }]
+          }],
           //浮窗
           tooltip: {
             trigger: 'axis',
@@ -700,6 +786,20 @@
         const decimalIndex = str.indexOf('.');
         return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1;
       },
+      changeAlpha(rgba, alpha){
+        // 使用正则表达式匹配 RGBA 值
+        const rgbaRegex = /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/;
+        const matches = rgba.match(rgbaRegex);
+        if (!matches) {
+          return '无效的 RGBA 格式';
+        }
+        // 提取 R, G, B 值
+        const r = matches[1];
+        const g = matches[2];
+        const b = matches[3];
+        // 返回新的 RGBA 字符串
+        return `rgba(${r}, ${g}, ${b}, ${alpha})`;
+      },
     },
     beforeDestroy() {
       //清除定时器

+ 9 - 48
src/views/components/overviewOfFacilityData.vue

@@ -50,56 +50,17 @@
     },
     methods: {
       dashboardsFacilitiesTypeOverview(){
-        let list = [
-          {
-            name: '温室',
-            value: 0,
-            itemStyle: {
-              color: 'rgba(221, 111, 114, 1)'
-            }
-          },
-          {
-            name: '温室附属房',
-            value: 0,
-            itemStyle: {
-              color: 'rgba(255, 132, 0, 1)'
-            }
-          },
-          {
-            name: '顶置光型人工气候室',
-            value: 0,
-            itemStyle: {
-              color: 'rgba(104, 231, 88, 1)'
-            }
-          },
-          {
-            name: '冷库',
-            value: 0,
-            itemStyle: {
-              color: 'rgba(65, 177, 255, 1)'
-            }
-          },
-          {
-            name: '种质资源库',
-            value: 0,
-            itemStyle: {
-              color: 'rgba(180, 130, 255, 1)'
-            }
-          },
-          {
-            name: '培养架型人工气候室',
-            value: 0,
-            itemStyle: {
-              color: 'rgba(68, 255, 255, 1)'
-            }
-          }
-        ];
+        let list = [];
         dashboardsFacilitiesTypeOverview().then(res => {
           for(let i=0;i<res.data.types.length;i++){
-            for(let o=0;o<list.length;o++){
-              if(res.data.types[i].type == list[o].name){
-                list[o].value = res.data.types[i].count
-              }
+            if(i<6){
+              list.push({
+                name: res.data.types[i].type,
+                value: res.data.types[i].count,
+                itemStyle: {
+                  color: res.data.types[i].color?res.data.types[i].color:'rgba(255,255,255,1)'
+                }
+              })
             }
           }
           this.$set(this,'maxNum',res.data.total);

+ 1 - 2
src/views/login.vue

@@ -196,10 +196,10 @@
         const uuid = userInfo.uuid
         const userType = userInfo.userType
         login(account, password, code, uuid, userType).then(res => {
+          this.loading = false;
           if(res.code == 200){
             if(res.data.userType != 3){
               this.text = "* 非院级大屏账号,无权登录本系统.";
-              this.loading = false;
               this.getCode();
             }else{
               setToken(res.data.token)
@@ -220,7 +220,6 @@
               this.userTypeCode = "5";
             }
             this.text = res.message;
-            this.loading = false;
             this.getCode();
           }
         });