Pārlūkot izejas kodu

资产支持编辑建筑楼层及相关优化

zhangyu 5 gadi atpakaļ
vecāks
revīzija
179ff9fd3e

+ 6 - 0
src/api/scan/request.js

@@ -927,6 +927,12 @@ export function queryProperty(param, success) {
     http.postJson(url, param, success)
 }
 
+//根据条件查询统计数量
+export function countProperty(param, success) {
+    let url = `${baseUrl}/datacenter/property/count`;
+    http.postJson(url, param, success)
+}
+
 //根据id删除资产信息
 export function deleteProperty(param, success) {
     let url = `${baseUrl}/datacenter/property/delete`;

+ 0 - 1
src/components/dialogs/addDialog/dialogAssets.vue

@@ -472,7 +472,6 @@ export default {
           renderer: tools.customDropdownRenderer,
           editor: "chosen",
           chosenOptions: {
-            // multiple: true,//多选
             data: this.floorData
           }
         }

+ 125 - 59
src/components/ledger/handsontables/assets.vue

@@ -3,7 +3,7 @@
     <div class="hanson-bar">
       <div style="float:right;overflow:hidden;">
         <span style="width:20px;float:left;display:block;height:20px;cursor: pointer;" @click="changeAssetsFalg">
-          <i v-show="!onlyRead" class="el-icon-fa  el-icon-fa-compass"></i>
+          <i v-show="!onlyRead" class="el-icon-fa  el-icon-fa-eye"></i>
         </span>
         <span>当前筛选条件下共{{page.total || '--'}}设备</span>
       </div>
@@ -55,6 +55,7 @@ import tools from "@/utils/scan/tools"
 import handsonUtils from "@/utils/scan/hasontableUtils"
 import showTools from "@/utils/handsontable/notShow"
 import text from "@/utils/handsontable/mainText"
+import buildFloorData from '@/utils/handsontable/buildFloorData'
 
 import qrcode from "@/components/business_space/lib/qrcode"
 import firm from "@/components/business_space/dialogs/list/firm"
@@ -160,6 +161,7 @@ export default {
       floorData: [],
       curDevice: '',//当前点击的资产id
       addData: {}, //添加资产选择的资产类型
+      showFlowBuild: false //是否显示建筑楼层
     };
   },
   methods: {
@@ -205,18 +207,25 @@ export default {
         }
         queryProperty(param, res => {
           this.loading = false
-          this.tableData = res.Content
-          this.copyMain = tools.deepCopy(res.Content)
+          this.tableData = res.Content.map((item) => {
+            if (item.hasOwnProperty("BuildingId") && item.hasOwnProperty("FloorId")) {
+              item.flowBuild = item.BuildingId + "-" + item.FloorId
+            } else if (item.hasOwnProperty("BuildingId") && !item.hasOwnProperty("FloorId")) {
+              item.flowBuild = item.BuildingId
+            }
+            return item
+          })
+          this.copyMain = tools.deepCopy(this.tableData)
           this.page.total = res.Total
           if (this.hot) {
             this.hot.destroy()
             this.hot = null
           }
-          if (res.Content && res.Content.length) {
+          if (this.tableData && this.tableData.length) {
             if (this.onlyRead) {
-              this.getBatch(res.Content)
+              this.getBatch(this.tableData)
             }
-            this.initTable();
+            this.initTable()
           }
         })
       }
@@ -229,53 +238,74 @@ export default {
         data: {
           criterias: []
         }
-      }
-      if (!!data && data.length) {
-        //一级遍历list
-        data.map(item => {
-          if (!!item.infos) {
-            // 二级遍历对象infos
-            for (let key in item.infos) {
-              //判断是否是设定参数和动态参数
-              if (!!item.infos[key]) {
-                this.tableHeader.map(child => {
-                  //如果一级标签为动态参数或者设定参数放入数据等待请求
-                  if (key == child.InfoPointCode && (child.InputMode == "L" || child.InputMode == "L1" || child.InputMode == "L2" || child.InputMode == "M")) {
-                    param.data.criterias.push({
-                      id: item.id,
-                      code: key
-                    })
-                  }
-                })
-              }
-            }
-          }
-        })
-        if (param.data.criterias.length) {
-          BeatchQueryParam(param, res => {
-            if (!this.onlyRead) {
-              return false
+      };
+      this.tableHeader.map(head => {
+        if (
+          head.InputMode == "L" ||
+          head.InputMode == "L1" ||
+          head.InputMode == "L2" ||
+          head.InputMode == "M"
+        ) {
+          data.map(item => {
+            let cur = tools.dataForKey(item, head.Path);
+            if (cur) {
+              param.data.criterias.push({
+                id: item.EquipID,
+                code: head.InfoPointCode
+              });
             }
-            this.tableData = data.map(item => {
-              res.Content.map(child => {
-                if (item.id == child.id) {
-                  if (!!child.data || child.data == 0) {
-                    item.infos[child.code] = child.data
-                  } else {
-                    item.infos[child.code] = child.error ? "表号功能号格式错误" : "表号功能号不存在"
-                  }
-                }
-              })
-              return item
-            })
-            this.hot.loadData(this.tableData)
-          })
+          });
         }
+      });
+      if (param.data.criterias.length) {
+        BeatchQueryParam(param, res => {
+          this.tableData = data.map(item => {
+            res.Content.map(child => {
+              if (item.EquipID == child.id) {
+                if (child.data || child.data == 0) {
+                  this.tableHeader.map(head => {
+                    if (head.InfoPointCode == child.code) {
+                      tools.setDataForKey(item, head.Path, child.data);
+                    }
+                  });
+                } else {
+                  this.tableHeader.map(head => {
+                    if (head.InfoPointCode == child.code) {
+                      tools.setDataForKey(
+                        item,
+                        head.Path,
+                        child.error ? "表号功能号格式错误" : "表号功能号不存在"
+                      );
+                    }
+                  });
+                }
+              }
+            });
+            return item;
+          });
+          this.hot.loadData(this.tableData);
+        });
       }
     },
     //显示楼层信息
     changeAssetsFalg() {
-      
+      if (this.showFlowBuild) {
+        this.showFlowBuild = false
+        this.getTableData()
+      } else {
+        this.$confirm('<p>维护资产所在建筑楼层后,对后续数据影响较大,如业务空间中的所在关系or其他?暂未梳理明白……</p><p>后续要修改设备所属建筑楼层,只能通过模型中的待建模清单操作</p>', '提示', {
+          dangerouslyUseHTMLString: true,
+          confirmButtonText: '就要维护资产所属建筑楼层',
+          cancelButtonText: '暂时不搞了',
+          confirmButtonClass: 'confirmButtonClass',
+          cancelButtonClass: 'cancelButtonClass'
+        }).then(_ => {
+          this.showFlowBuild = true
+          this.initTable()
+        }).catch(_ => {
+          this.$message("取消")
+        })
+      }
     },
     //撤回
     undo() {
@@ -326,6 +356,9 @@ export default {
       let arr = tools.copyArr(list)
       let data = showTools.headerTextFilter(arr, 'property', this.onlyRead, this.showType, true)
       data.unshift("操作", "当前关联的设备")
+      if (this.showFlowBuild) {
+        data.splice(2, 0, "所属建筑楼层")
+      }
       return data
     },
     //格式化表内容
@@ -341,7 +374,17 @@ export default {
           readOnly: true
         }
       )
-      return data;
+      if (this.showFlowBuild) {
+        data.splice(2, 0, {
+          data: "flowBuild",
+          renderer: tools.customDropdownRenderer,
+          editor: "chosen",
+          chosenOptions: {
+            data: buildFloorData.data
+          }
+        })
+      }
+      return data
     },
     //初始化插件
     initTable() {
@@ -349,7 +392,7 @@ export default {
       let winHeight = document.documentElement.clientHeight;
       this.hot = new Handsontable(container, {
         data: this.tableData,
-        fixedColumnsLeft: 4,
+        fixedColumnsLeft: this.showFlowBuild?5:4,
         colHeaders: this.formatHeaderData(this.tableHeader), //表头文案
         columns: this.formatHeaderType(this.tableHeader), //数据显示格式
         filters: true,
@@ -432,7 +475,7 @@ export default {
 
           //存在data进行修改请求
           if (data && data.length) {
-            this.updateBusiness(data, changeData);
+            this.updateProperty(data, changeData);
           }
         }
       }
@@ -468,26 +511,49 @@ export default {
       })
     },
     // 更新
-    updateBusiness(data, change) {
+    updateProperty(data, change) {
       let param = {
         Content: [],
         Projection: []
-      };
+      }
       //生成要修改字段列表
       change.map(item => {
         if (item[1] && param.Projection.indexOf(item[1]) == -1) {
-          param.Projection.push(item[1].split(".")[0]);
+          if (item[1].split(".")[0] == "flowBuild") {
+            param.Projection.push("BuildingId","FloorId")
+          } else {
+            param.Projection.push(item[1].split(".")[0])
+          }
         }
-      });
+      })
       //生成对应修改数据
       data.map((item, index) => {
         param.Projection.map(value => {
-          let itemData = tools.dataForKey(item, value);
-          tools.setDataForKey(item, value, itemData == "" ? null : itemData);
+          if (value == "BuildingId") {
+            let itemData = tools.dataForKey(item, "flowBuild")
+            if (itemData == "") {
+              tools.setDataForKey(item, "BuildingId", null)
+              tools.setDataForKey(item, "FloorId", null)
+            } else {
+              let BuildingId = itemData.split("-")[0]
+              let FloorId = itemData.split("-")[1]
+              if (BuildingId && FloorId) {
+                tools.setDataForKey(item, "BuildingId", BuildingId)
+                tools.setDataForKey(item, "FloorId", FloorId)
+              } else if (BuildingId && !FloorId) {
+                tools.setDataForKey(item, "BuildingId", BuildingId)
+                tools.setDataForKey(item, "FloorId", null)
+              }
+            }
+          } else {
+            let itemData = tools.dataForKey(item, value)
+            tools.setDataForKey(item, value, itemData == "" ? null : itemData)
+          }
+          
         });
-        param.Content.push(item);
-      });
-      updateEquip(param, res => { });
+        param.Content.push(item)
+      })
+      updateProperty(param, res => { })
     },
     //修改资产类型
     // changeCader() {

+ 79 - 0
src/utils/handsontable/buildFloorData.js

@@ -0,0 +1,79 @@
+import { floorQuery, buildingQuery } from '@/api/scan/request'
+
+const buildFloorData = {
+  data: []
+}
+
+function getData () {
+  let data, buildParams = {
+      PageNumber: 1,
+      PageSize: 500,
+      Projection: [
+          "BuildID",
+          "BuildLocalName"
+      ]
+  }, floorParams = {
+      Orders: "FloorSequenceID desc",
+      PageNumber: 1,
+      PageSize: 500,
+      Projection: [
+          "BuildID",
+          "FloorID",
+          "FloorLocalName",
+          "FloorSequenceID"
+      ]
+  }
+  buildingQuery(buildParams, res => {
+      let builData = res.Content
+      data = builData.map(build => {
+          return {
+              value: build.BuildID,
+              label: build.BuildLocalName
+          }
+      })
+      data.unshift({
+        value: "",
+        label: "未明确建筑的设备"
+      })
+      floorQuery(floorParams, res => {
+          let floorData = res.Content
+          data.forEach(build => {
+              floorData.forEach(floor => {
+                  if (build.value == floor.BuildID && floor.FloorID && floor.FloorLocalName) {
+                      if (build.children) {
+                          build.children.push({
+                              value: floor.FloorID,
+                              label: floor.FloorLocalName
+                          })
+                      } else {
+                          build.children = []
+                          build.children.push({
+                              value: "",
+                              label: "未明确楼层的设备"
+                          })
+                      }
+                  }
+              })
+          })
+          data.forEach(item => {
+            if (item.children && item.children.length) {
+              item.children.forEach(child => {
+                buildFloorData.data.push({
+                  Code: item.value + "-" + child.value,
+                  Name: item.label + "-" + child.label
+                })
+              })
+            } else {
+              buildFloorData.data.push({
+                Code: item.value,
+                Name: item.label
+              })
+            }
+          })
+      })
+  })
+}
+
+getData()
+
+export default buildFloorData

+ 11 - 23
src/views/ledger/property/index.vue

@@ -21,7 +21,7 @@ import {
     mapGetters,
     mapActions
 } from "vuex";
-import { getNumber, queryProperty, getSpaceName } from "@/api/scan/request"
+import { countProperty, queryProperty } from "@/api/scan/request"
 import "./../index.scss"
 export default {
   components: {
@@ -34,6 +34,7 @@ export default {
   computed: {
         ...mapGetters("layout", [
             "projectId",
+            "projects",
             "secret",
             "userId"
         ])
@@ -77,21 +78,11 @@ export default {
   },
   methods: {
     getProjName() {
-      let param = {
-        list: [{ id: this.param.ProjId }],
-        perjectId: this.param.ProjId,
-        secret: this.param.secret,
-      }
-      getSpaceName(param).then(res => {
-        if (res.data.Result == "success") {
-          this.mess.perjectName = res.data.Content[0].infos.ProjLocalName
-          this.getNumber()
-        } else {
-          this.$message.error("请求失败:" + res.data.ResultMsg)
-        }
-      }).catch(_ => {
-        this.$message.error("请求失败")
+      this.projects.forEach((item) => {
+        if(item.id == this.projectId) 
+        this.mess.perjectName = item.name
       })
+      this.getNumber()
     },
     getFamilyList() {
       let param = {
@@ -110,14 +101,11 @@ export default {
     },
     //获取header的list
     getNumber() {
-      let param = {
-        ProjId: this.param.ProjId,
-        secret: this.param.secret,
-        data: { type: "Pe" }
-      }
-      getNumber(param, res => {
-        this.mess.name[0].num = res.content.count
-        this.mess.name[1].num = res.content.bindingCount
+      countProperty({}, res => {
+        this.mess.name[0].num = res.Count
+      })
+      countProperty({"Filters": "not EquipId isNull"}, res => {
+        this.mess.name[1].num = res.Count
         this.getFamilyList()
       })
     },