Browse Source

modify add device and add system back to listpage

haojianlong 5 years ago
parent
commit
bbadc28a56

+ 3 - 40
src/views/ledger/facility/addfacility.vue

@@ -125,7 +125,7 @@ export default {
       filesArr: [], //保存临时的文件key
       imgsArr: [], //临时保存的图片key数组
       picsArr: [], //临时设备图片keys数组
-      systemList:[], //关联的系统
+      systemList: [], //关联的系统
       systemId: null,
       graphyId: null,
       id: 0,
@@ -140,7 +140,6 @@ export default {
   created() {
     this.category = this.$route.query;
     this.getBelongs();
-    this.getFloorData();
     this.getTableHeader();
   },
   methods: {
@@ -176,42 +175,6 @@ export default {
         })
       }
     },
-    //获取楼层数据
-    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 => {
@@ -330,8 +293,8 @@ export default {
         this.$message.success('创建成功')
         session.remove("deviceAddData")
         this.$router.push({
-          path: "/ledger/facility",
-          query: { deviceId: this.category.deviceId }
+          name: "facilityLedger",
+          params: { deviceId: this.category.deviceId }
         });
       })
     },

+ 1 - 1
src/views/ledger/facility/index.vue

@@ -75,7 +75,7 @@ export default {
     this.param.secret = this.secret
     this.getProjName()
     this.getCount()
-    let deviceId = this.$route.query.deviceId;
+    let deviceId = this.$route.params.deviceId;
     if (deviceId) {
       this.$nextTick(() => {
         this.$refs.cascader.changeVal([deviceId])

+ 21 - 48
src/views/ledger/system/addsystem.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="deviceList">
-    <el-row class="right"> 
+    <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>
@@ -41,7 +41,7 @@ import handsonTable from "@/components/common/handsontable";
 import {
   getDataDictionary,
   createGeneralSys,
-  getSpaceFloor
+  buildingQuery
 } from "@/api/scan/request";
 import { mapGetters, mapActions } from "vuex";
 
@@ -95,7 +95,7 @@ export default {
   },
   created() {
     this.category = this.$route.query;
-    this.getFloorData();
+    this.getBuildData();
     this.getTableHeader();
   },
   methods: {
@@ -118,52 +118,25 @@ export default {
         })
       }
     },
-    //获取楼层数据
-    getFloorData() {
+    //获取建筑数据
+    getBuildData() {
       let param = {
-        ProjId: this.projectId,
-        secret: this.secret
+        PageNumber: 1,
+        PageSize: 500,
+        Projection: [
+          "BuildID",
+          "BuildLocalName"
+        ]
       }
-      getSpaceFloor(param).then(res => {
-        if (res.data.Result == 'success') {
-          let data = this.changeArr(res.data.Content), floorData = []
-          data.map(item => {
-            floorData.push({
-              Code: item.value,
-              Name: item.label
-            })
-          })
-          this.floorData = floorData
-          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) {
+      buildingQuery(param, res => {
+        let data = res.Content.map(t => {
           return {
-            value: item.id,
-            label: item.infos.BuildLocalName,
-            children: item.floors.map(i => {
-              return {
-                value: i.id,
-                label: i.infos.FloorLocalName || "未知",
-              }
-            })
+            Code: t.BuildID,
+            Name: t.BuildLocalName,
           }
-        } else {
-          return {
-            value: item.id,
-            label: item.infos.BuildLocalName,
-            children: null,
-            isChilren: 1,
-          }
-        }
+        })
+        data.unshift({ Code: '', Name: '未明确建筑' })
+        this.buildingData = data;
       })
     },
     // 获取表头数据(初始化表格)
@@ -218,8 +191,8 @@ export default {
         this.$message.success('创建成功')
         session.remove("systemAddData")
         this.$router.push({
-          path: "/system/list",
-          query: { deviceId: this.category.Category }
+          name: "systemlist",
+          params: { deviceId: this.category.Category }
         });
       })
     },
@@ -276,7 +249,7 @@ export default {
         editor: "chosen",
         chosenOptions: {
           // multiple: true,//多选
-          data: this.floorData
+          data: this.buildingData
         }
       });
       return data;

+ 1 - 1
src/views/ledger/system/index.vue

@@ -65,7 +65,7 @@ export default {
     this.param.secret = this.secret
     this.countGeneralSys()
 
-    let deviceId = this.$route.query.deviceId;
+    let deviceId = this.$route.params.deviceId;
     if (deviceId) {
       this.$nextTick(() => {
         this.$refs.cascader.changeVal([deviceId])