shaun-sheep 5 years ago
parent
commit
fdbd575a4a
1 changed files with 173 additions and 151 deletions
  1. 173 151
      src/components/business_space/business/handsontable.vue

+ 173 - 151
src/components/business_space/business/handsontable.vue

@@ -44,46 +44,43 @@
   </div>
 </template>
 <script>
-// 引用handsontable插件
-import "@/assets/js/chosen.jquery.min";
-import tools from "@/utils/scan/tools";
-import "@/assets/js/handsontable-chosen-editor";
-import lStorage from '@/utils/localStorage'
-import myPagination from "@/components/common/myPagination";
-import addBusiness from "@/components/business_space/dialogs/addDialog/businessDialog"
-import showTools from "@/utils/handsontable/notShow"
-import handsonUtils from "@/utils/hasontableUtils"
-import Handsontable from "handsontable-pro"
-import buildFloor from '@/utils/handsontable/buildFloorData'
-import 'handsontable-pro/dist/handsontable.full.css'
-import zhCN from 'handsontable-pro/languages/zh-CN';
-import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
-import qrcode from "@/components/ledger/lib/qrcode";
-import {
-  queryZone,
-  updateZone,
-  deleteZone,
-  createZone,
-  BeatchQueryParam,
-  updateRelateInSpAndBuild,
-  queryAllZoneType,
-  searchZoneQuery
-} from "@/api/scan/request";
-import { mapGetters, mapActions } from "vuex";
-import dialogZone from "../../ledger/addDialog/dialogZone";
-import { getZoneQuery } from "../../../api/scan/request";
+  // 引用handsontable插件
+  import "@/assets/js/chosen.jquery.min";
+  import tools from "@/utils/scan/tools";
+  import "@/assets/js/handsontable-chosen-editor";
+  import lStorage from '@/utils/localStorage'
+  import myPagination from "@/components/common/myPagination";
+  import addBusiness from "@/components/business_space/dialogs/addDialog/businessDialog"
+  import showTools from "@/utils/handsontable/notShow"
+  import handsonUtils from "@/utils/hasontableUtils"
+  import Handsontable from "handsontable-pro"
+  import buildFloor from '@/utils/handsontable/buildFloorData'
+  import 'handsontable-pro/dist/handsontable.full.css'
+  import uploadImgDialog from "@/components/business_space/dialogs/list/uploadImgDialog"
+  import qrcode from "@/components/ledger/lib/qrcode";
+  import {
+    BeatchQueryParam,
+    deleteZone,
+    queryAllZoneType,
+    searchZoneQuery,
+    updateRelateInSpAndBuild,
+    updateZone,
+    zoneCreate
+  } from "@/api/scan/request";
+  import {mapGetters} from "vuex";
+  import dialogZone from "../../ledger/addDialog/dialogZone";
 
-export default {
-  props: {
-    id: {},
-    zoneCode: {}
-  },
-  components: {
-    qrcode, //二维码页面
-    myPagination,
-    addBusiness,
-    uploadImgDialog,
-    dialogZone,
+  export default {
+    props: {
+      id: {},
+      zoneCode: {}
+    },
+    components: {
+      qrcode, //二维码页面
+      myPagination,
+      addBusiness,
+      uploadImgDialog,
+      dialogZone,
 
   },
   computed: {
@@ -157,124 +154,135 @@ export default {
       this.page.pageNumber = 1
       this.getData()
     },
-    // getData(){
-    //   this.loading = true
-    //   let params = {
-    //     ZoneType: this.zoneCode,
-    //     PageNumber: 1,
-    //     PageSize: 50,
-    //     Orders: "createTime desc, RoomID asc"
-    //   }
-    //   if (this.buildFloorSelectd.length === 1) {
-    //     switch (this.buildFloorSelectd[0]) {
-    //       case 'noKnow':
-    //         params.BuildingId = 'isnull';
-    //         break;
-    //       case 'all':
-    //         // params.BuildingId = '';
-    //         break
-    //     }
-    //   } else if (this.buildFloorSelectd.length === 2) {
-    //     switch (this.buildFloorSelectd[1]) {
-    //       case 'noKnow':
-    //         params.BuildingId = this.buildFloorSelectd[0];
-    //         params.FloorId = 'isnull';
-    //         break;
-    //       case 'all' :
-    //         params.BuildingId = this.buildFloorSelectd[0];
-    //         // params.FloorId = '';
-    //         break;
-    //       default:
-    //         params.BuildingId = this.buildFloorSelectd[0];
-    //         params.FloorId = this.buildFloorSelectd[1]
-    //
-    //     }
-    //   }
-    //   searchZoneQuery(params, res => {
-    //     this.page.total = res.Total
-    //     this.main = res.Content && res.Content.length && 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
-    //     })
-    //     if (this.main && this.main.length && this.main[0].RoomID) {
-    //       this.copyMain = tools.deepCopy(this.main);
-    //       if (this.onlyRead) {
-    //         this.getBatch(this.main)
-    //       }
-    //     }
-    //     this.isLoading = false
-    //     this.getMain()
-    //     this.getOtherType();
-    //   })
-    // },
+
     getData() {
       if (this.zoneCode != 'OtherZone') {
         this.isLoading = true
-        let params = {
-          zone: this.zoneCode,
-          data: {
-            Filters: ``,
-            Orders: "createTime desc, RoomID asc",
-            PageNumber: this.page.pageNumber,
-            PageSize: this.page.pageSize
-          }
+        this.zoneParam = {
+          ZoneType: this.zoneCode,
+          PageNumber: 1,
+          PageSize: 50,
+          Orders: "createTime desc, RoomID asc"
         }
-        if (this.buildFloorSelectd[0] == "noKnow") {
-          params.data.Filters += `buildingId isNull`
-        } else if (this.buildFloorSelectd[0] && this.buildFloorSelectd[0] != "all") {
-          params.data.Filters += `buildingId='${this.buildFloorSelectd[0]}'`
-        }
-        if (this.buildFloorSelectd.length > 1) {
-          if (this.buildFloorSelectd[1] == "noKnow") {
-            params.data.Filters += `;floorId isNull`
-          } else if (this.buildFloorSelectd[1] && this.buildFloorSelectd[1] != "all") {
-            params.data.Filters += `;floorId='${this.buildFloorSelectd[1]}'`
+
+        if (this.buildFloorSelectd.length === 1) {
+          switch (this.buildFloorSelectd[0]) {
+            case 'noKnow':
+              this.zoneParam.BuildingId = 'isnull';
+              break;
+            case 'all':
+              // params.BuildingId = '';
+              break
           }
-        }
-        if (this.zoneItemID) {
-          params.data.Filters += `;RoomID='${this.zoneItemID}'`
-        }
-        if (!params.data.Filters) {
-          delete params.data.Filters
-        }
-        // if (this.buildFloorSelectd.length && this.buildFloorSelectd[0] && this.buildFloorSelectd[1]) {
-        //   params.data.Filters = `BuildingId='${this.buildFloorSelectd[0]}';FloorId='${this.buildFloorSelectd[1]}'`
-        // }
-        // else if (buildFloorSelectd.length && buildFloorSelectd[0] && !buildFloorSelectd[1]) {
-        //   params.data.Filters = `BuildingId='${buildFloorSelectd[0]}'`
-        // } else {
-        //   params.data.Filters = `BuildingId='';FloorId=''`
-        // }
+        } else if (this.buildFloorSelectd.length === 2) {
+          switch (this.buildFloorSelectd[1]) {
+            case 'noKnow':
+              this.zoneParam.BuildingId = this.buildFloorSelectd[0];
+              this.zoneParam.FloorId = 'isnull';
+              break;
+            case 'all' :
+              this.zoneParam.BuildingId = this.buildFloorSelectd[0];
+              // params.FloorId = '';
+              break;
+            default:
+              this.zoneParam.BuildingId = this.buildFloorSelectd[0];
+              this.zoneParam.FloorId = this.buildFloorSelectd[1]
 
-        queryZone(params, res => {
-          this.page.total = res.Total
-          this.main = 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
-          });
-          if (this.main && this.main.length && this.main[0].RoomID) {
-            this.copyMain = tools.deepCopy(this.main);
-            if (this.onlyRead) {
-              this.getBatch(this.main)
-            }
           }
-          this.isLoading = false
-          this.getMain()
-        })
+        }
+        this.getZoneMessage(this.zoneParam)
       } else {
         // 其他分区类型查询表数据接口
         this.isLoading = false
         this.getOtherType();
       }
     },
+    //查询空间信息
+    getZoneMessage(param) {
+      searchZoneQuery(param, res => {
+        this.page.total = res.Total;
+        this.main = 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
+        });
+        if (this.main && this.main.length && this.main[0].RoomID) {
+          this.copyMain = tools.deepCopy(this.main);
+          if (this.onlyRead) {
+            this.getBatch(this.main)
+          }
+        }
+        this.isLoading = false;
+        this.getMain()
+      })
+    },
+    // getData() {
+    //   if (this.zoneCode != 'OtherZone') {
+    //     this.isLoading = true
+    //     let params = {
+    //       zone: this.zoneCode,
+    //       data: {
+    //         Filters: ``,
+    //         Orders: "createTime desc, RoomID asc",
+    //         PageNumber: this.page.pageNumber,
+    //         PageSize: this.page.pageSize
+    //       }
+    //     }
+    //     if (this.buildFloorSelectd[0] == "noKnow") {
+    //       params.data.Filters += `buildingId isNull`
+    //     } else if (this.buildFloorSelectd[0] && this.buildFloorSelectd[0] != "all") {
+    //       params.data.Filters += `buildingId='${this.buildFloorSelectd[0]}'`
+    //     }
+    //     if (this.buildFloorSelectd.length > 1) {
+    //       if (this.buildFloorSelectd[1] == "noKnow") {
+    //         params.data.Filters += `;floorId isNull`
+    //       } else if (this.buildFloorSelectd[1] && this.buildFloorSelectd[1] != "all") {
+    //         params.data.Filters += `;floorId='${this.buildFloorSelectd[1]}'`
+    //       }
+    //     }
+    //     if (this.zoneItemID) {
+    //       params.data.Filters += `;RoomID='${this.zoneItemID}'`
+    //     }
+    //     if (!params.data.Filters) {
+    //       delete params.data.Filters
+    //     }
+    //     // if (this.buildFloorSelectd.length && this.buildFloorSelectd[0] && this.buildFloorSelectd[1]) {
+    //     //   params.data.Filters = `BuildingId='${this.buildFloorSelectd[0]}';FloorId='${this.buildFloorSelectd[1]}'`
+    //     // }
+    //     // else if (buildFloorSelectd.length && buildFloorSelectd[0] && !buildFloorSelectd[1]) {
+    //     //   params.data.Filters = `BuildingId='${buildFloorSelectd[0]}'`
+    //     // } else {
+    //     //   params.data.Filters = `BuildingId='';FloorId=''`
+    //     // }
+    //
+    //     queryZone(params, res => {
+    //       this.page.total = res.Total
+    //       this.main = 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
+    //       });
+    //       if (this.main && this.main.length && this.main[0].RoomID) {
+    //         this.copyMain = tools.deepCopy(this.main);
+    //         if (this.onlyRead) {
+    //           this.getBatch(this.main)
+    //         }
+    //       }
+    //       this.isLoading = false
+    //       this.getMain()
+    //     })
+    //   } else {
+    //     // 其他分区类型查询表数据接口
+    //     this.isLoading = false
+    //     this.getOtherType();
+    //   }
+    // },
     //获取表格主体内容
     getMain() {
       if (!!this.hot) {
@@ -335,7 +343,7 @@ export default {
       let trimmedArr = this.trimmedRows();
       //是否启用了排序
       let isSort = this.hot.getPlugin("columnSorting").isSorted();
-      // debugger
+      //
       if (trimmedArr.length && isSort) {
         let sortArr = this.myHotArr.getPlugin("columnSorting").rowsMapper
           .__arrayMap;
@@ -457,6 +465,7 @@ export default {
         return
       }
       if (param.flowBuild) {
+
         param.BuildingId = param.flowBuild.split('-')[0]
         param.FloorId = param.flowBuild.split('-')[1] || null
       } else {
@@ -469,13 +478,24 @@ export default {
           }
         }
       }
+
+      param.ObjectType = this.zoneParam.ZoneType ? this.zoneParam.ZoneType : this.zoneCode;
       let params = {
-        zone: this.zoneCode,
-        data: {
-          Content: [param]
-        }
-      }
-      createZone(params, res => {
+        Content: [param]
+      };
+
+      // let params = {
+      //   zone: this.zoneCode,
+      //   data: {
+      //     Content: [param]
+      //   }
+      // }
+      // createZone(params, res => {
+      //
+      //   this.$message.success("添加成功!")
+      //   this.getData()
+      // })
+      zoneCreate(params, res => {
         this.$message.success("添加成功!")
         this.getData()
       })
@@ -779,6 +799,8 @@ export default {
     },
     // 其他类型下拉change
     changeOtherZone(val) {
+      this.zoneParam.ZoneType = val;
+      this.getZoneMessage(this.zoneParam);
       console.log(val)
     },
   },