xushining 3 年之前
父节点
当前提交
ccd5c415cc

+ 44 - 13
src/assets/script/BackgroundData.js

@@ -90,7 +90,8 @@ export default class BackgroundData {
     Accidents = new Array();
 
     /* 标记数据 */
-    Marks=[{title:"QG01_01",value:"温度过高"}];
+    Marks = [];
+    MarkIndex = 0;
 
     constructor() {
         this.refreshTPData = this.refreshTPData.bind(this);
@@ -104,8 +105,9 @@ export default class BackgroundData {
         this.refreshRecommendData = this.refreshRecommendData.bind(this);
         this.onRDMessage = this.onRDMessage.bind(this);
         this.showdialog = this.showdialog.bind(this);
-        this.windturbineControl=this.windturbineControl.bind(this);
-        this.marking=this.marking.bind(this);
+        this.windturbineControl = this.windturbineControl.bind(this);
+        this.marking = this.marking.bind(this);
+        this.removeMarked = this.removeMarked.bind(this);
 
         this.refreshTPData();
         this.refreshAlarmData();
@@ -270,13 +272,13 @@ export default class BackgroundData {
     }
 
     login(uname, psd, action) {
-        axios.get(`http://${config.calcUrl}/user/login?userName=${uname}&psd=${psd}`)
+        axios.get(`http://${config.calcUrl}/api/user/login?userName=${uname}&psd=${psd}`)
             .then(action)
-            .catch(err => action("登录出现错误:"+err.message));
+            .catch(err => action("登录出现错误:" + err.message));
     }
 
     /* 显示提示框 */
-    showdialog(title,message,detail) {
+    showdialog(title, message, detail) {
         const { remote } = require("electron");
         const { dialog } = remote;
         dialog.showMessageBox(remote.getCurrentWindow(), {
@@ -290,20 +292,49 @@ export default class BackgroundData {
     }
 
     /* 风机控制 */
-    windturbineControl(windturbines){
-        for(var ind in windturbines){
-            console.log(ind);
+    windturbineControl(windturbines) {
+        var pairs={};
+        for (var ind in windturbines) {
+            var wb = windturbines[ind];
+            var ct = {
+                windturbineId:wb.windturbineId,
+                stationId:wb.stationId,
+                projectId:wb.projectId,
+                modelId:wb.modelId,
+                controlType:wb.controlType,
+                lockType:wb.lockType,
+                userName:this.LoginUser.userName,
+                userId:this.LoginUser.id,
+            };
+            pairs[ct.windturbineId]=ct;
         }
+        var heads={
 
-        console.log(windturbines);
+        };
+        console.log(heads);
     }
 
-    marking(windturbines){
-        for(var v in windturbines){
-            this.Marks.push({title:windturbines[v].windturbineId});
+    /* 标记 */
+    marking(windturbines) {
+        for (var v in windturbines) {
+            ++this.MarkIndex;
+            this.Marks.push({ title: windturbines[v].windturbineId, id: this.MarkIndex });
         }
     }
 
+    /* 移除标记 */
+    removeMarked(mk) {
+        var indx = -1;
+        for (var id in this.Marks) {
+            if (this.Marks[id].id == mk.id) {
+                indx = id;
+                break;
+            }
+        }
+        if (indx < 0) return;
+        this.Marks.splice(indx, 1);
+    }
+
     /* 单例 */
     static getInstance() {
         if (!BackgroundData.instance) {

+ 1 - 1
src/components/area/ControlArea.vue

@@ -151,7 +151,7 @@ export default {
     menuClicked(msg) {
       var bd = BackgroundData.getInstance();
       if (!bd.LoginUser) {
-        bd.showdialog("提示", "控制出现错误:", "未登录");
+        bd.showdialog("提示", "请登录:", "在控制之前需要先登录!");
         return;
       }
       if (msg.type == "lock") {

+ 77 - 24
src/components/area/LabelArea.vue

@@ -1,36 +1,89 @@
 /* 标注区 */
 <template>
-    <gy-card title="标注区" area-style="label" circle-style="yellow" content-style="25">
-        <div v-for="mk in values" :key="mk" style="width:120px;margin-left:10px;margin-top:10px;">
-            <img src="../../assets/img/LabelArea/flag.png" style="float:left;margin-top:5px;margin-left:15px;"/>
-            <div style="text-align:center;">{{mk.title}}</div>
-            <input v-model="mk.value" style="border:none;background-color:#292929;height:30px;border-radius:6px;text-align:center;outline:none;width:120px;color:rgb(220,220,220);"/>
-        </div>
-    </gy-card>
+  <gy-card
+    title="标注区"
+    area-style="label"
+    circle-style="yellow"
+    content-style="25"
+  >
+    <div
+      v-for="mk in values"
+      :key="mk"
+      @contextmenu="contextmenu(mk)"
+      style="width: 120px; margin-left: 10px; margin-top: 10px"
+    >
+      <img
+        src="../../assets/img/LabelArea/flag.png"
+        style="float: left; margin-top: 5px; margin-left: 15px"
+      />
+      <div style="text-align: center">{{ mk.title }}</div>
+      <input
+        v-model="mk.value"
+        style="
+          border: none;
+          background-color: #292929;
+          height: 30px;
+          border-radius: 6px;
+          text-align: center;
+          outline: none;
+          width: 120px;
+          color: rgb(220, 220, 220);
+        "
+      />
+    </div>
+  </gy-card>
 </template>
 
 <script>
-import BackgroundData from '../../assets/script/BackgroundData'
+import BackgroundData from "../../assets/script/BackgroundData";
 
-export default{
-    name:'LabelArea',
-    data(){
-        return{
-            values:new Array(),
-        }
-    },
-    created(){
-        this.refreshTimer = setInterval(this.refreshData,1000);
+export default {
+  name: "LabelArea",
+  data() {
+    return {
+      values: new Array(),
+    };
+  },
+  created() {
+    this.refreshTimer = setInterval(this.refreshData, 1000);
+  },
+  methods: {
+    refreshData() {
+      this.values = new Array();
+      this.values = BackgroundData.getInstance().Marks;
     },
-    methods:{
-        refreshData(){
-            this.values=new Array();
-            this.values=BackgroundData.getInstance().Marks;
+
+    contextmenu(mk) {
+      const { remote } = require("electron");
+      var that = this;
+      const menuTemplate = [
+        {
+          label: "删除",
+          click() {
+            that.remove(mk);
+          },
         },
-    }
-}
+      ];
+      const menu = remote.Menu.buildFromTemplate(menuTemplate);
+
+      menu.popup(remote.getCurrentWindow());
+    },
+
+    remove(mk) {
+      var indx = -1;
+      for (var ind in this.values) {
+        if (this.values[ind].id == mk.id) {
+          indx = ind;
+          break;
+        }
+      }
+      if (indx < 0) return;
+      this.values.splice(indx, 1);
+      BackgroundData.getInstance().removeMarked(mk);
+    },
+  },
+};
 </script>
 
 <style scoped>
-
 </style>

+ 26 - 5
src/components/area/ProblemArea.vue

@@ -8,10 +8,10 @@
     @parentRun="run"
     @contextmenu="contextmenu"
   >
-    <ProblemMatrixCard title="故障" :type="5"></ProblemMatrixCard>
-    <ProblemMatrixCard title="维护" :type="6"></ProblemMatrixCard>
-    <ProblemMatrixCard title="离线" :type="7"></ProblemMatrixCard>
-    <ProblemMatrixCard title="挂牌" :type="-1"></ProblemMatrixCard>
+    <ProblemMatrixCard title="故障" :type="5" ref="malfunction"></ProblemMatrixCard>
+    <ProblemMatrixCard title="维护" :type="6" ref="maintain"></ProblemMatrixCard>
+    <ProblemMatrixCard title="离线" :type="7" ref="offline"></ProblemMatrixCard>
+    <ProblemMatrixCard title="挂牌" :type="-1" ref="lock"></ProblemMatrixCard>
   </gy-card>
 </template>
 
@@ -107,7 +107,7 @@ export default {
     menuClicked(msg) {
       var bd = BackgroundData.getInstance();
       if (!bd.LoginUser) {
-        bd.showdialog("提示", "控制出现错误:", "未登录");
+        bd.showdialog("提示", "请登录:", "在控制之前需要先登录!");
         return;
       }
       if (msg.type == "lock") {
@@ -116,7 +116,28 @@ export default {
         // 取消挂牌
       } else if (msg.type == "marking") {
         // 标注
+        var vs = this.getSelectedItems();
+        bd.marking(vs);
       }
+      this.clearSelected();
+    },
+
+    /* 获取选中的项目,isControl:是否是控制 */
+    getSelectedItems(){
+      var ls = new Array();
+      this.$refs.malfunction.outputSelectedItems(ls);
+      this.$refs.maintain.outputSelectedItems(ls);
+      this.$refs.offline.outputSelectedItems(ls);
+      this.$refs.lock.outputSelectedItems(ls);
+      return ls;
+    },
+    
+    /* 清除所有选择 */
+    clearSelected(){
+      this.$refs.malfunction.clearSelected();
+      this.$refs.maintain.clearSelected();
+      this.$refs.offline.clearSelected();
+      this.$refs.lock.clearSelected();
     },
   },
 };

+ 24 - 23
src/components/area/windturbine/control/ControlMatrixCard.vue

@@ -57,6 +57,30 @@ export default {
     onSelectHandler(item) {
       item.active = !item.active;
     },
+    
+    /* 获取选中的项目 */
+    getSelectedItems() {
+      var ls = new Array();
+      this.values.forEach((item) => {
+        if (item.active) {
+          ls.push(item);
+        }
+      });
+      return ls;
+    },
+    /* 将选中的项目填充到数组中 */
+    outputSelectedItems(ls) {
+      this.values.forEach((item) => {
+        if (item.active) {
+          ls.push(item);
+        }
+      });
+    },
+
+    /* 清除选中的项目 */
+    clearSelected() {
+      this.values.forEach((item) => (item.active = false));
+    },
   },
   watch: {
     "$store.getters.windturbinelist": {
@@ -86,29 +110,6 @@ export default {
         });
       },
     },
-    /* 获取选中的项目 */
-    getSelectedItems() {
-      var ls = new Array();
-      this.values.forEach((item) => {
-        if (item.active) {
-          ls.push(item);
-        }
-      });
-      return ls;
-    },
-    /* 将选中的项目填充到数组中 */
-    outputSelectedItems(ls) {
-      this.values.forEach((item) => {
-        if (item.active) {
-          ls.push(item);
-        }
-      });
-    },
-
-    /* 清除选中的项目 */
-    clearSelected() {
-      this.values.forEach((item) => (item.active = false));
-    },
   },
 };
 </script>

+ 32 - 0
src/components/area/windturbine/problem/ProblemMatrixCard.vue

@@ -83,6 +83,38 @@ export default {
         this.values.splice(array[1], 1, val);
       }
     },
+    /* 获取选中的项目 */
+    getSelectedItems() {
+      var ls = new Array();
+      this.values.forEach((item) => {
+        if (item.active) {
+          ls.push(item);
+        }
+      });
+      return ls;
+    },
+    /* 将选中的项目填充到数组中 */
+    outputSelectedItems(ls) {
+      this.values.forEach((item) => {
+        if (item.active&&!this.isHas(item,ls)) {
+          ls.push(item);
+        }
+      });
+    },
+
+    /* 清除选中的项目 */
+    clearSelected() {
+      this.values.forEach((item) => (item.active = false));
+    },
+
+    isHas(item,ls){
+      for(var id in ls){
+        if(ls[id].windturbineId==item.windturbineId){
+          return true;
+        }
+      }
+      return false;
+    }
   },
   watch: {
     "$store.getters.windturbinelist": {