Browse Source

替换业务空间表格相关接口

zhangyu 5 years ago
parent
commit
b47dde3cff

+ 48 - 63
src/components/business_space/business/handsontable.vue

@@ -41,7 +41,7 @@ import Handsontable from "handsontable-pro"
 import 'handsontable-pro/dist/handsontable.full.css'
 import zhCN from 'handsontable-pro/languages/zh-CN';
 import qrcode from "@/components/ledger/lib/qrcode";
-import { updateBusiness, queryZone, updateZone, deleteZone, createBusiness, createBusinessList, delManySpace, isSpaceBuss } from "@/api/scan/request";
+import { updateBusiness, queryZone, updateZone, deleteZone, createZone, createBusiness, createBusinessList, delManySpace, isSpaceBuss } from "@/api/scan/request";
 import { mapGetters, mapActions } from "vuex";
 export default {
   props: {
@@ -118,6 +118,7 @@ export default {
       this.activeType = activeTabType
     },
     getData(buildMess) {
+      this.isLoading = true
       if (buildMess) {
         this.buildMess = buildMess
 			}
@@ -142,13 +143,13 @@ export default {
 				this.main = res.Content
 				if (this.main && this.main.length && this.main[0].RoomID) {
 					this.copyMain = tools.deepCopy(this.main);
-				}
+        }
+        this.isLoading = false
 				this.getMain()
 			})
     },
     //获取表格主体内容
     getMain() {
-      this.isLoading = true;
       if (!!this.hot) {
         this.hot.destroy();
         this.hot = null;
@@ -198,7 +199,6 @@ export default {
       if (!!pro) {
         pro.parentNode.removeChild(pro);
       }
-      this.isLoading = false;
     },
     //表格中的查看详情
     eventClick(el, rowArr) {
@@ -249,7 +249,11 @@ export default {
           let param = handsonUtils.getParam(changeData, source, this.hot, trimmedArr);
           let data = []
           for (let i = 0; i < param.length; i++) {
-            data.push(param[i]);
+            if (param[i].RoomID) {
+              data.push(param[i])
+            } else {
+              this.handleCreateZone(param[i])
+            }
           }
           //如果data中包含/且data长度为1,将其转换成.
           if (changeData.length == 1 && changeData[0][1].indexOf("/") > 0) {
@@ -290,21 +294,31 @@ export default {
         this.$message("取消删除")
       })
     },
-    // 新建
-    createSq(param, change) {
-      let seedData = {
-        building_id: this.buildMess.buildCode,
-        floor_id: this.buildMess.code,
-        business_type: this.activeType.code == "GeneralZone" ? null : this.activeType.code,
-        infos: {}
-      };
-      for (let i = 0; i < change.length; i++) {
-        let arr = change[i][1].split(".");
-        seedData[arr[0]][arr[1]] = [{
-          value: change[i][3] != "" ? change[i][3] : null
-        }];
+    //创建业务空间
+    handleCreateZone(param) {
+      let keys = Object.keys(param)
+      keys.map((key) => { //将值为空字符串的属性删除
+        if(param[key] == "") {
+          delete param[key]
+        }
+      })
+      if (!Object.keys(param).length) {
+        this.$message("新添加业务空间内容不能为空!")
+        return
+      }
+      if (this.buildMess.selectd && this.buildMess.selectd[0] && this.buildMess.selectd[1]) {
+        param.BuildingId = this.buildMess.selectd[0]
+        param.FloorId = this.buildMess.selectd[1]
+			} else if (this.buildMess.selectd && this.buildMess.selectd[0] && !this.buildMess.selectd[1]) {
+				param.BuildingId = this.buildMess.selectd[0]
+			}
+      let params = {
+        zone: this.zoneObj.code,
+        data: [param]
       }
-      this.createSpace(seedData);
+      createZone(params,(res) => {
+        this.getData()
+      })
     },
     // 修改
     updateBusiness(data, change) {
@@ -331,32 +345,6 @@ export default {
 			})
 			updateZone(param, (res) => {})
     },
-    /**    请求部分 ------------------------------------ */
-    createSpace(data) {
-      let param = {
-        ProjId: this.param.ProjId,
-        secret: this.param.secret,
-        data: {
-          criterias: [data]
-        }
-      };
-      createBusinessList(param).then(res => {
-        if (res.data.Result == "success") {
-          console.log(this.main);
-          this.main.map(item => {
-            if (!item.id) {
-              item.id = res.data.id;
-              item.infos.RoomID = res.data.id;
-              item.infos.RoomName = res.data.RoomName;
-            }
-          });
-          this.hot.loadData(this.main);
-          this.reset()
-        } else {
-          this.$message.error("创建发生错误:" + res.data.ResultMsg);
-        }
-      });
-    },
     //获取被筛选掉的行号
     trimmedRows() {
       // var plugin = hot.getPlugin('trimRows').trimmedRows;//获取被筛选掉的行号
@@ -425,44 +413,41 @@ export default {
     },
     myRenderer(instance, td, row, col, prop, value, cellProperties) {
       if (value) {
-        td.innerHTML = "已关联";
+        td.innerHTML = "已关联"
       } else {
-        td.innerHTML = "未关联";
+        td.innerHTML = "未关联"
       }
       return td;
     },
     facilityRender(instance, td, row, col, prop, value, cellProperties) {
-      td.style.color = "#409EFF";
-      td.style.cursor = "pointer";
-      td.innerHTML = "点击查看";
+      td.style.color = "#409EFF"
+      td.style.cursor = "pointer"
+      td.innerHTML = "点击查看"
       return td;
     },
     /**  页面中的按钮事件--------------------------- */
     addSp() {
-      //   this.dialog.addDevice = true
-      //   this.hot.downloadFile()
-      //   this.hot.getPlugin('exportFile').downloadFile("csv", { columnHeaders: true, exportHiddenRows: true, exportHiddenColumns: true, rowHeaders: true })
-      if (this.main && this.main.length && !!this.main[0].RoomID) {
-        this.hot.destroy();
-        this.hot = null;
-        this.main.unshift([]);
-        this.getMain();
+      if (this.main && this.main.length && this.main[0].RoomID) {
+        this.hot.destroy()
+        this.hot = null
+        this.main.unshift({})
+        this.getMain()
       } else {
         if (this.main && this.main.length) {
-          this.$message.error("请添加完成后继续添加");
+          this.$message("请添加完成后继续添加")
         } else {
-          this.main.unshift([]);
-          this.getMain();
+          this.main.unshift({})
+          this.getMain()
         }
       }
     },
     //刷新
     reset() {
-      this.getData();
+      this.getData()
     },
     //撤回操作
     undo() {
-      this.hot.undo();
+      this.hot.undo()
     },
 		/**  分页事件------------------------ */
 		//切换每页显示多少条数据

+ 8 - 26
src/components/business_space/dialogs/detailsDialog.vue

@@ -45,9 +45,7 @@
 </template>
 
 <script>
-    import {
-        delManySpace
-    } from "@/api/scan/request";
+    import { deleteZone } from "@/api/scan/request";
     import equipTable from "@/components/business_space/table/equipTable";
     import addEquip from "@/components/business_space/table/addEquip";
     import {
@@ -154,29 +152,13 @@
                     })
                     .then(() => {
                         let param = {
-                            ProjId: this.projectId,
-                            secret: this.secret,
-                            data: {
-                                criteria: {
-                                    ids: [this.list.id]
-                                }
-                            }
-                        };
-                        delManySpace(param)
-                            .then(res => {
-                                if (res.data.Result == "success") {
-                                    this.$message({
-                                        type: "success",
-                                        message: "删除成功!"
-                                    });
-                                    this.$emit("del");
-                                } else {
-                                    this.$message.error(res.data.ResultMsg);
-                                }
-                            })
-                            .catch(() => {
-                                this.$message.error("请求发生错误");
-                            });
+                            zone: this.activeTabType.code,
+                            data: [{RoomID: this.list.id}]
+                        }
+                        deleteZone(param, res => {
+                            this.$message({ type: "success",  message: "删除成功!" })
+                            this.$emit("del")
+                        })
                     })
                     .catch(() => {
                         this.$message({

+ 3 - 6
src/components/business_space/table/businessTable.vue

@@ -49,10 +49,7 @@
 <script>
 import { getBussines2, createRelation } from "@/api/scan/request";
 import myPagination from "@/components/common/myPagination.vue";
-import {
-        mapGetters,
-        mapActions
-    } from "vuex";
+import { mapGetters, mapActions } from "vuex";
 export default {
   name: "equip-table",
   components: {
@@ -244,7 +241,7 @@ export default {
 };
 </script>
 <style>
-.el-table tr th {
+/* .el-table tr th { */
   /* background: #fafafa !important; */
-}
+/* } */
 </style>

+ 4 - 4
src/components/business_space/table/equipTable.vue

@@ -125,7 +125,7 @@
                             count: this.page.size // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
                         },
                         criteria: {
-                            space: this.data.RoomID, // 必填, 指定业务空间id
+                            space: this.data.id, // 必填, 指定业务空间id
                             type: ["Eq"] // 必填, 查询类型, 允许四位编码的详细设备类
                         }
                     },
@@ -192,7 +192,7 @@
                         criteria: {
                             graphType: this.activeRelation,
                             relType: this.relType,
-                            toId: this.data.RoomID,
+                            toId: this.data.id,
                             fromId: this.data.fromId,
                             type: ["Eq"]
                         }
@@ -214,7 +214,7 @@
                     data: {
                         criterias: [{
                             from_id: row.id, //选填
-                            to_id: this.data.RoomID, //选填
+                            to_id: this.data.id, //选填
                             graph_id: this.graphyId, //选填
                             rel_type: this.relType
                         }]
@@ -299,7 +299,7 @@
                             count: this.page.size // 查询跳过300条数据之后的50条 (默认按照创建时间从大-->小排序)
                         },
                         criteria: {
-                            space: this.data.RoomID, // 必填, 指定业务空间id
+                            space: this.data.id, // 必填, 指定业务空间id
                             type: ["Eq"] // 必填, 查询类型, 允许四位编码的详细设备类
                         }
                     },

+ 1 - 3
src/components/ledger/lib/qrcode.vue

@@ -36,9 +36,7 @@ export default {
   data() {
     return {};
   },
-  created() {
-    console.log(this.qrcodeUrl)
-   },
+  created() {},
   mounted() {
   },
   methods: {

+ 4 - 2
src/views/business_space/business_list/index.vue

@@ -308,8 +308,10 @@ export default {
       this.$refs.details.getData(list, this.buildMess);
     },
     lookEqu(infos) {
-      this.floor.facility = true;
-      this.$refs.facility.getData(infos, this.buildMess);
+      infos.id = infos.RoomID
+      infos.name = infos.RoomLocalName
+      this.floor.facility = true
+      this.$refs.facility.getData(infos, this.buildMess)
     },
     tabClick(num) {
       console.log(this.$refs)