Browse Source

6-11上传

yangxiao 3 years ago
parent
commit
61c69aaed1

+ 1 - 1
public/static/config/modeConfig.js

@@ -1,6 +1,6 @@
 
 // 本地联调开关
-const localTest = 0;
+const localTest = 1;
 
 // 服务器地址
 let baseURL = null;

+ 1 - 1
src/api/axios.js

@@ -48,7 +48,7 @@ export function requestData (options) {
       headers,
       withCredentials: true,
       crossDomain: true,
-      baseURL: window.__MODE__.baseURL || '/api/',
+      baseURL: options.baseURL || window.__MODE__.baseURL || '/api/',
       timeout: options.timeout || 3000, // 请求超时时间 - 3s
     });
 

+ 2 - 2
src/store/index.js

@@ -20,7 +20,7 @@ const mutations = {
     state.themeName = tag;
   },
   update (state, newData) {
-    state.windturbineMap = newData
+    state.windturbineMap = newData.data
   }
 };
 
@@ -38,7 +38,7 @@ const getters = {
   themeName: state => state.themeName,
   asidez: state => state.z,
   mainy: state => state.y,
-  login: state => state.login,
+  login: state => state.login
 }
 
 export default createStore({

+ 1 - 1
src/tools/websocket.js

@@ -42,7 +42,7 @@ function connectCallBackSubscribe (adpClient, topic) {
 function reflexWindturbineBasicInformation (stompMessage) {
   var newdata = JSON.parse(stompMessage.body);
   store.dispatch('getupdate', newdata);
-  // console.log("newdata", newdata)
+  // console.log("newdata", newdata);
 
 }
 // ============================  其他  ============================

+ 64 - 33
src/views/LightMatrix/LightMatrix.vue

@@ -15,7 +15,7 @@
           </div>
           <div class="panel-item-gf-right">
             <div class="panel-item-gf-up">{{ panelData.first.text }}</div>
-            <div class="panel-item-gf-down">{{ panelData.first.num }}</div>
+            <div class="panel-item-gf-down">{{ sourceMap[panelData.first.key] || '---' }}</div>
           </div>
         </div>
         </Col>
@@ -29,7 +29,7 @@
               </span>
             </div>
             <div class="panel-item-li">
-              <span>{{ data.num }}</span>
+              <span>{{ sourceMap[data.key] || '---'}}</span>
               <span class="svg-icon svg-icon-sm" :class="'svg-icon-' + data.color">
                 <SvgIcon :svgid="data.numIcon"></SvgIcon>
               </span>
@@ -108,6 +108,9 @@ import Col from "@com/coms/grid/col.vue";
 import SvgIcon from "@com/coms/icon/svg-icon.vue";
 import util from "@/helper/util.js";
 
+import { datainit, webtest } from "@tools/websocket.js";
+import store from "@store/index.js";
+
 export default {
   // 名称
   name: "LightMatrix",
@@ -120,78 +123,81 @@ export default {
   // 数据
   data () {
     return {
+      loadingFlg: false, // 遮罩开关
+      websocketServe: null, // websocket 服务实例
+      sourceMap: {}, // 核心数据
       panelData: {
         first: {
           icon: "svg-photovoltaic",
           text: "接入光伏",
-          num: 256,
+          key: "fcjrnum",
         },
         datas: [
           {
             color: "green",
             name: "待机",
             nameIcon: "svg-standby",
-            num: 50,
+            key: "fcdjnum",
             numIcon: "svg-manual",
             text1: "待风",
-            num1: 30,
+            key1: "fcddfum",
             text2: "手动停机",
-            num2: 30,
+            key2: "fcsdtjnum",
           },
           {
             color: "blue",
             name: "运行",
             nameIcon: "svg-normal-power",
-            num: 50,
+            key: "fcyxnum",
             numIcon: "svg-drop-output",
             text1: "正常发电",
-            num1: 30,
+            key1: "fczcfdnum",
             text2: "降出力",
-            num2: 30,
+            key2: "fcjclnum",
           },
           {
             color: "purple",
             name: "限电",
             nameIcon: "svg-limit-power",
-            num: 50,
+            key: "fcxdnum",
             numIcon: "svg-downtime",
             text1: "降出力",
-            num1: 30,
+            key1: "fcjclum",
             text2: "停机",
-            num2: 30,
+            key2: "fctjnum",
           },
           {
             color: "red",
             name: "故障",
             nameIcon: "svg-gz-downtime",
-            num: 50,
+            key: "fcgznum",
             numIcon: "svg-field-involved",
             text1: "故障停机",
-            num1: 30,
+            key1: "fcgztjnum",
             text2: "场内受累",
-            num2: 30,
+            key2: "fccnslnum",
           },
           {
             color: "orange",
             name: "检测",
             nameIcon: "svg-jx-downtime",
-            num: 50,
+            key: "fcjcnum",
             numIcon: "svg-field-involved",
             text1: "检修停机",
-            num1: 30,
+            key1: "fcjxtjnum",
             text2: "产内受累",
-            num2: 30,
+            key2: "fccnslnum",
           },
           {
             color: "gray",
             name: "离线",
             nameIcon: "svg-offline",
-            num: 50,
+            key: "fclxnum",
             numIcon: "svg-unknown",
             text1: "离线",
-            num1: 30,
+            key1: "asd",
             text2: "未知",
-            num2: 30,
+            key2: "fcwznum",
           },
           {
             color: "write",
@@ -322,10 +328,7 @@ export default {
       }
     },
   },
-  // 生命周期钩子
-  beforeCreate () {
-    // 创建前
-  },
+
   created () {
     // 创建后
     let tempData = [];
@@ -356,18 +359,46 @@ export default {
       this.tables.push(util.copy(this.tables[0]));
     }
   },
-  beforeMount () {
-    // 渲染前
-  },
+
   mounted () {
     let that = this;
-    that.$nextTick(() => { });
+    that.loadingFlg = true;
+    that.BASE.showLoading();
+    that.$nextTick(() => {
+      that.websocketServe && that.websocketServe.disconnect();
+      that.API.requestData({
+        method: "POST",
+        subUrl: "admin/websocketdisconnect",
+        success () {
+          that.websocketServe = datainit("/topic/matrixdetialpushtask");
+        }
+      });
+    });
   },
-  beforeUpdate () {
-    // 数据更新前
+
+  beforeDestroy () {
+    // 离开页面,销毁 websocket 实例
+    this.websocketServe && this.websocketServe.disconnect();
   },
-  updated () {
-    // 数据更新后
+
+  watch: {
+    // 监听 websocket 回调并包装数据用于展示
+    '$store.state.windturbineMap': function (res) {
+      this.loadingFlg && this.BASE.closeLoading();
+      this.loadingFlg = false;
+      if (res) {
+        let sourceMap = JSON.parse(res);
+        for (let key in sourceMap) {
+          if (key !== 'fczbmap' && key !== 'jmap') {
+            sourceMap[key] += '';
+          }
+        }
+        this.sourceMap = sourceMap;
+      } else {
+        this.sourceMap = {};
+      }
+      console.log(222, JSON.parse(res));
+    }
   }
 };
 </script>

+ 16 - 12
src/views/LightMatrix1/LightMatrix1.vue

@@ -268,10 +268,10 @@ export default {
             if (isNumber(fjzt)) {
               cEle.fjzt === fjzt ? (cEle.isShow = true) : (cEle.isShow = false);
             } else {
-              cEle.isShow = true
+              cEle.isShow = true;
             }
           } else {
-            cEle.isShow = false;
+            cEle.isShow = true;
           }
         });
       });
@@ -284,26 +284,30 @@ export default {
     that.loadingFlg = true;
     that.BASE.showLoading();
     that.$nextTick(() => {
-      that.websocketServe = datainit("/topic/matrixpushtask");
+      that.websocketServe && that.websocketServe.disconnect();
+      that.API.requestData({
+        method: "POST",
+        subUrl: "admin/websocketdisconnect",
+        success () {
+          that.websocketServe = datainit("/topic/matrixdetialpushtask");
+        }
+      });
     });
   },
 
-  destroyed () {
+  beforeDestroy () {
     // 离开页面,销毁 websocket 实例
-    this.websocketServe && this.websocketServe.disconnect(() => {
-      this.API.requeestData({
-        subUrl: "admin/websocketdisconnect"
-      });
-    });
+    this.websocketServe && this.websocketServe.disconnect();
   },
 
   watch: {
     // 监听 websocket 回调并包装数据用于展示
     '$store.state.windturbineMap': function (res) {
+
       this.loadingFlg && this.BASE.closeLoading();
       this.loadingFlg = false;
-      if (res.data) {
-        let sourceMap = JSON.parse(res.data);
+      if (res) {
+        let sourceMap = JSON.parse(res);
         let fjmap = [];
         for (let key in sourceMap) {
           if (key !== 'fczbmap' && key !== 'fjmap') {
@@ -324,7 +328,7 @@ export default {
       } else {
         this.sourceMap = {};
       }
-      console.log("sourceMap", this.sourceMap)
+      console.log(333, JSON.parse(res));
     }
   }
 }

+ 17 - 17
vue.config.js

@@ -147,21 +147,21 @@ module.exports = {
 
   },
 
-  // devServer: {
-  //   //代理配置
-  //   proxy: {
-  //     '/lightmatrix': {
-  //       target: 'https://h5.caibeike.com.cn/', // 请求地址
-
-  //       changeOrigin: true, // 在vue-cli3中,默认changeOrigin的值是true,意味着服务器host设置成target,这与vue-cli2不一致,vue-cli2这个默认值是false
-  //       // changeOrigin的值是true,target是host, request URL是http://baidu.com
-  //       // 如果设置changeOrigin: false,host就是浏览器发送过来的host,也就是localhost:8082。
-
-  //       pathRewrite: {  // 路径重写,eg:把api接口替换为''
-  //         '^/h5.caibeike.com.cn/': 'localhost:8888/'
-  //       }
-  //     }
-  //   },
-  //   open: false, // 是否打开浏览器
-  // }
+  devServer: {
+    //代理配置
+    proxy: {
+      '/cbk': {
+        target: 'https://h5.caibeike.com.cn/', // 请求地址
+
+        changeOrigin: true, // 在vue-cli3中,默认changeOrigin的值是true,意味着服务器host设置成target,这与vue-cli2不一致,vue-cli2这个默认值是false
+        // changeOrigin的值是true,target是host, request URL是http://baidu.com
+        // 如果设置changeOrigin: false,host就是浏览器发送过来的host,也就是localhost:8082。
+
+        pathRewrite: {  // 路径重写,eg:把api接口替换为''
+          '^/cbk': ''
+        }
+      }
+    },
+    open: false, // 是否打开浏览器
+  }
 }