Kaynağa Gözat

modify create device

haojianlong 5 yıl önce
ebeveyn
işleme
1d82d9ae4f
1 değiştirilmiş dosya ile 115 ekleme ve 5 silme
  1. 115 5
      src/views/ledger/facility/addfacility.vue

+ 115 - 5
src/views/ledger/facility/addfacility.vue

@@ -1,6 +1,9 @@
 <template>
   <div id="deviceList">
     <el-row class="right">
+      <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
+        <i class="el-icon-fa  el-icon-fa-compass"></i>
+      </span>
       <span style="float:left;">当前选择的设备类型:{{category.name}}</span>
       <div style="width:200px;display:inline-block;text-align:left;color:gray;">
         <span>隐藏自动填充的信息</span>
@@ -55,7 +58,8 @@ import {
   getDataDictionary,
   createEquip,
   createPropertyData,
-  getEquipBelongs
+  getEquipBelongs,
+  getSpaceFloor
 } from "@/api/scan/request";
 import { mapGetters, mapActions } from "vuex";
 
@@ -147,6 +151,7 @@ export default {
   created() {
     this.category = this.$route.query;
     this.getBelongs();
+    this.getFloorData();
     this.getTableHeader();
   },
   methods: {
@@ -163,6 +168,85 @@ export default {
         this.firmId = res.Content[0].Family;
       })
     },
+    //维护建筑
+    changeAssetsFalg() {
+      if (this.floorFlag) {
+        this.floorFlag = false
+      } else {
+        this.$confirm('<p>维护设备所在建筑楼层后,对后续数据影响较大,如业务空间中的所在关系or其他?暂未梳理明白……</p><p>后续要修改设备所属建筑楼层,只能通过模型中的待建模清单操作</p>', '提示', {
+          dangerouslyUseHTMLString: true,
+          confirmButtonText: '就要维护设备所属建筑楼层',
+          cancelButtonText: '暂时不搞了',
+          confirmButtonClass: 'confirmButtonClass',
+          cancelButtonClass: 'cancelButtonClass'
+        }).then(_ => {
+          this.floorFlag = true
+          this.getTableHeader()
+        }).catch(_ => {
+          this.$message("取消")
+        })
+      }
+    },
+    //获取楼层数据
+    getFloorData() {
+      let param = {
+        ProjId: this.projectId,
+        secret: this.secret
+      }
+      getSpaceFloor(param).then(res => {
+        if (res.data.Result == 'success') {
+          let data = this.changeArr(res.data.Content), floorData = []
+          data.map(item => {
+            if (!!item.children) {
+              item.children.unshift({
+                value: '',
+                label: "未明确楼层"
+              })
+            }
+            return item
+          })
+          data.map(item => {
+            if (!!item.children && item.children.length) {
+              item.children.map(child => {
+                floorData.push({
+                  Code: item.value + "-" + child.value,
+                  Name: item.label + "-" + child.label
+                })
+              })
+            }
+          })
+          this.floorData = floorData
+        } else {
+          this.$message.error(res.data.ResultMsg)
+        }
+      }).catch(() => {
+        this.$message.error("请求出错")
+      })
+    },
+    //将数组转换成optiosn格式
+    changeArr(arr) {
+      return arr.map(item => {
+        if (item.floors && item.floors.length) {
+          return {
+            value: item.id,
+            label: item.infos.BuildLocalName,
+            children: item.floors.map(i => {
+              return {
+                value: i.id,
+                label: i.infos.FloorLocalName || "未知",
+              }
+            })
+          }
+        } else {
+          return {
+            value: item.id,
+            label: item.infos.BuildLocalName,
+            children: null,
+            isChilren: 1,
+          }
+        }
+      })
+    },
     // 获取表头数据(初始化表格)
     async getTableHeader() {
       let params = {
@@ -199,6 +283,18 @@ export default {
         if (item.Checked && !item.EquipLocalName) {
           flag = true;
         }
+        // 处理建筑-楼层
+        if (item.flowBuild) {
+          item.BuildingId = item.flowBuild.split("-")[0]
+          item.FloorId = item.flowBuild.split("-")[1]
+        }
+        //处理管理的系统
+        if (item.LinkSystem.length) {
+          item.SystemList = []
+          item.LinkSystem.map(t => {
+            item.SystemList.push(t.id)
+          })
+        }
       })
       if (flag) {
         this.$message.info("存在设备的本地名称为空,请检查")
@@ -286,6 +382,9 @@ export default {
         false
       );
       data.unshift("同时创建资产", "所属系统实例");
+      if (this.floorFlag) {
+        data.splice(1, 0, "所属建筑楼层")
+      }
       return data;
     },
     formatHeaderType(list) {
@@ -307,10 +406,21 @@ export default {
           position: "after"
         }
       }, {
-          data: "linkSystem",
+          data: "LinkSystem",
           renderer: text.systemList,
           readOnly: true
         });
+      if (this.floorFlag) {
+        data.splice(1, 0, {
+          data: "flowBuild",
+          renderer: tools.customDropdownRenderer,
+          editor: "chosen",
+          chosenOptions: {
+            // multiple: true,//多选
+            data: this.floorData
+          }
+        })
+      }
       return data;
     },
     initTable() {
@@ -438,7 +548,7 @@ export default {
     },
     //关联系统变更
     changeSystemType(data) {
-      tools.setDataForKey(this.tableData[this.row], "linkSystem", data)
+      tools.setDataForKey(this.tableData[this.row], "LinkSystem", data)
     },
     //表格点击事件
     handleTdClick(el, rowArr) {
@@ -493,8 +603,8 @@ export default {
         this.$refs.qrcode.getCanvas(1111);
       }
       //关联系统
-      if (val == "linkSystem") {
-        this.systemList = this.tableData[row.row].linkSystem || [];
+      if (val == "LinkSystem") {
+        this.systemList = this.tableData[row.row].LinkSystem || [];
         this.myDialog.systemType = true;
       }
       //品牌型号弹窗