Browse Source

修改替换租户接口

zhangyu 5 years ago
parent
commit
023b38dd43

+ 10 - 22
src/api/scan/request.js

@@ -768,46 +768,34 @@ export function saveCenoteRelateSpace(param, success) {
     http.postJson(url, param, success)
 }
 
-//获取租户表头信息
-export function getRentTableHeader(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/queryDic?projectId=${param.ProjId}&secret=${param.secret}`
-    let data = param.data
-    http.postJson(url, data, success)
-}
-
 //获取租户表格内容信息
 export function getRentTableData(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/queryWithCount?projectId=${param.ProjId}&secret=${param.secret}`
-    let data = param.data
-    http.postJson(url, data, success)
+    let url = `${baseUrl}/datacenter/tenant/query-with-count`
+    http.postJson(url, param, success)
 }
 
 //创建租户信息
 export function createRentTableData(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/batchCreate?projectId=${param.ProjId}&secret=${param.secret}`
-    let data = param.data
-    http.postJson(url, data, success)
+    let url = `${baseUrl}/datacenter/tenant/create`
+    http.postJson(url, param, success)
 }
 
 //修改租户信息
 export function updataRentTableData(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/update?projectId=${param.ProjId}&secret=${param.secret}`
-    let data = param.data
-    http.postJson(url, data, success)
+    let url = `${baseUrl}/datacenter/tenant/update`
+    http.postJson(url, param, success)
 }
 
 //删除租户信息
 export function deleteRentTableData(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/delete?projectId=${param.ProjId}&secret=${param.secret}`
-    let data = param.data
-    http.postJson(url, data, success)
+    let url = `${baseUrl}/datacenter/tenant/delete`
+    http.postJson(url, param, success)
 }
 
 //关联分区空间
 export function saveRentRelateSpace(param, success) {
-    let url = `${baseUrl}/datacenter/tenant/relateSpace?projectId=${param.ProjId}&secret=${param.secret}`
-    let data = param.data
-    http.postJson(url, data, success)
+    let url = `${baseUrl}/datacenter/tenant/relate-space`
+    http.postJson(url, param, success)
 }
 
 //扫楼创建资产

+ 54 - 18
src/utils/handsontable/notShow.js

@@ -68,6 +68,31 @@ let cantShow = [
     "ShaftID"
 ]
 
+//台账编辑页面不显示的厂商信息
+let firmArr = [
+    "Brand",//品牌
+    "Specification",//设备型号
+    "Manufacturer",//生产厂家
+    "Supplier",//供应商单位名称
+    "SupplierContactor",//供应商联系人
+    "SupplierPhone",//供应商联系电话
+    "SupplierEmail",//供应商电子邮件
+    "SupplierWeb",//供应商网址
+    "SupplierFax",//供应商传真
+    "Maintainer",//维修商单位名称
+    "MaintainerContactor",//维修商联系人
+    "MaintainerPhone",//维修商联系电话
+    "MaintainerEmail",//维修商电子邮件
+    "MaintainerWeb",//维修商网址
+    "MaintainerFax",//维修商传真
+    "Insurer",//保险公司名称
+    "InsurerContactor",//保险公司联系人
+    "InsurerPhone",//保险公司联系电话
+    'InsurerEmail',//保险公司电子邮件
+    "InsurerWeb",//保险公司网址
+    "InsurerFax"//保险公司传真
+]
+
 let cutArr = [{
     name: "品牌型号",
     code: "DPManufacturerID",
@@ -846,12 +871,6 @@ const showTools = {
                             readOnly: onlyRead,
                             correctFormat: true
                         };
-                    } else if (item.InputMode == "Own" && !onlyRead) {
-                        return {
-                            data: item.Path,
-                            renderer: text.idType,
-                            readOnly: onlyRead
-                        }
                     } else {
                         return {
                             data: item.Path,
@@ -877,9 +896,6 @@ const showTools = {
      * 
      */
     headerTextFilter (arr, type, onlyRead, showType, taizhang = false) {
-        if (taizhang && !onlyRead) {
-            arr = showTools.arrToArr(arr)
-        }
         let data = arr.map(item => {
             if (onlyRead) { //只读模式
                 if (showType == "Visible" && item.Visible) { //只看要采集的信息
@@ -890,6 +906,9 @@ const showTools = {
                     return undefined
                 }
             } else { //编辑模式
+                if (taizhang && !showTools.filterFirm(item.InfoPointCode)) {
+                    return undefined
+                }
                 if (!showTools.filterUnshow(onlyRead, type, item.InfoPointCode)) { //过滤固定不显示字段
                     return undefined
                 }
@@ -913,9 +932,6 @@ const showTools = {
         return data
     },
     headerTypeFilter (arr, type, onlyRead, showType, taizhang = false) {
-        if (taizhang && !onlyRead) {
-            arr = showTools.arrToArr(arr)
-        }
         let data = arr.map(item => {
             if (onlyRead) { //只读模式
                 if (showType == "Visible" && item.Visible) { //只看要采集的信息
@@ -926,6 +942,9 @@ const showTools = {
                     return undefined
                 }
             } else { //编辑模式
+                if (taizhang && !showTools.filterFirm(item.InfoPointCode)) {
+                    return undefined
+                }
                 if (!showTools.filterUnshow(onlyRead, type, item.InfoPointCode)) { //过滤固定不显示字段
                     return undefined
                 }
@@ -1030,6 +1049,20 @@ const showTools = {
             }
         }
 
+        //四大厂商
+        if (
+            item.InfoPointCode == "DPSupplierID" ||
+            item.InfoPointCode == "DPMaintainerID" ||
+            item.InfoPointCode == "DPInsurerID" ||
+            item.InfoPointCode == "insurer"
+        ) {
+            return {
+                data: item.Path,
+                renderer: text.idType,
+                readOnly: !item.Editable
+            }
+        }
+
         if (item.InputMode == "D1" || item.InputMode == "E1") { //单选输入
             return {
                 data: item.Path,
@@ -1082,12 +1115,6 @@ const showTools = {
                 data: item.Path,
                 readOnly: !item.Editable
             }
-        } else if (item.InputMode == "Own") { //四大厂商
-            return {
-                data: item.Path,
-                renderer: text.idType,
-                readOnly: !item.Editable
-            }
         } else { //不支持输入(暂定后台控制是否可编辑)
             return {
                 data: item.Path,
@@ -1113,6 +1140,15 @@ const showTools = {
             })
             return falg
         }
+    },
+    filterFirm: (code) => {
+        let falg = true
+        firmArr.map(item => {
+            if (item == code) {
+                falg = false
+            }
+        })
+        return falg
     }
 }
 

+ 2 - 2
src/utils/scan/tools.js

@@ -455,8 +455,8 @@ tools.formatDataSource = function (data) {
         if(options) {
             options.forEach((item) =>{
                 arr.push({
-                    Code: item.code,
-                    Name: item.name
+                    Code: item.Code,
+                    Name: item.Name
                 }) 
             })
             return arr

+ 64 - 3
src/views/ledger/cenotelist/index.vue

@@ -79,7 +79,7 @@ import text from "@/utils/handsontable/mainText"
 
 import cenoteType from "@/components/ledger/lib/cenoteType";
 import handsonTable from "@/components/common/handsontable";
-import { getDataDictionary, getCenoteTableData, updataCenoteTableData, deleteCenoteTableData, saveCenoteRelateSpace } from "@/api/scan/request"
+import { getDataDictionary, getCenoteTableData, updataCenoteTableData, deleteCenoteTableData, saveCenoteRelateSpace, BeatchQueryParam } from "@/api/scan/request"
 import { mapGetters, mapActions } from "vuex";
 export default {
   components: {
@@ -101,7 +101,7 @@ export default {
       }],
       onlyRead: true,
       showType: "",
-      allMess: true,
+      // allMess: true,
       tableHeader: [],
       page: {
         pageSize: 50,
@@ -160,6 +160,7 @@ export default {
     async getTableData() {//获取表格数据
       let params = {
         Filters: this.cenoteId? `ProjectId='${this.projectId}';structureInfo.ShaftFuncType='${this.cenoteId}'`: `ProjectId='${this.projectId}'`,
+        Orders: "createTime desc, ShaftID asc",
         PageNumber: this.page.pageNumber,
         PageSize: this.page.pageSize
       }
@@ -169,6 +170,9 @@ export default {
         this.page.pageNumber = res.PageNumber
         this.page.total = res.Total
         if(this.tableData && this.tableData.length){
+          if (this.onlyRead) {
+            this.getBatch(res.Content)
+          }
           this.initTable()
         }
       })
@@ -234,7 +238,7 @@ export default {
       }
       let param = []
       params.map(item => {
-        param.push({ShaftID:item.ShaftID})
+        param.push({ShaftID: item.ShaftID})
       })
       this.$confirm("此操作将删除竖井,是否继续?", "提示", {
         confirmButtonText: '确定',
@@ -406,6 +410,63 @@ export default {
         }
       }
       return a;
+    },
+    //获取动态参数
+    getBatch(data) {
+      let param = {
+        secret: this.secret,
+        ProjId: this.projectId,
+        data: {
+          criterias: []
+        }
+      };
+      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.ShaftID,
+                code: head.InfoPointCode
+              });
+            }
+          });
+        }
+      });
+      if (param.data.criterias.length) {
+        BeatchQueryParam(param, res => {
+          this.tableData = data.map(item => {
+            res.Content.map(child => {
+              if (item.ShaftID == 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.tableExample.loadData(this.tableData);
+        });
+      }
     }
   }
 };

+ 111 - 52
src/views/rent/rentlist/index.vue

@@ -3,8 +3,8 @@
     <!-- <div class="search-header">
       <floor-cascader @change="changeFloor"></floor-cascader>
     </div> -->
-    <el-row class="right">
-      <span style="float:left;">当前筛选条件下共{{page.total || '--'}}租户</span>
+    <el-row class="left">
+      <span style="float:right;">当前筛选条件下共{{page.total || '--'}}租户</span>
       <el-select v-model="onlyRead" @change="getTableHeader" style="width:100px;margin-right:10px;vertical-align:bottom;">
         <el-option
           v-for="item in options"
@@ -13,10 +13,18 @@
           :value="item.value">
         </el-option>
       </el-select>
-      <div v-show="onlyRead" style="width:200px;display:inline-block;text-align:left;color:gray;font-size:12px;">
+      <el-select v-model="showType" @change="initTable" style="width:100px;margin-right:10px;vertical-align:bottom;">
+        <el-option
+          v-for="item in showTypes"
+          :key="item.value"
+          :label="item.label"
+          :value="item.value">
+        </el-option>
+      </el-select>
+      <!-- <div v-show="onlyRead" style="width:200px;display:inline-block;text-align:left;color:gray;font-size:12px;">
         <span>只看要采集的信息</span>
         <el-checkbox v-model="allMess" @change="getTableHeader"></el-checkbox>
-      </div>
+      </div> -->
       <el-button @click="handleCreateTableData">添加租户</el-button>
       <el-button @click="getTableHeader">刷新</el-button>
       <el-button v-show="!onlyRead" @click="undo">撤销</el-button>
@@ -71,7 +79,7 @@ import text from "@/utils/handsontable/mainText"
 
 import floorCascader from "@/components/ledger/lib/floorCascader"
 import handsonTable from "@/components/common/handsontable"
-import { getDataDictionary, getRentTableHeader, getRentTableData, updataRentTableData, deleteRentTableData, saveRentRelateSpace } from "@/api/scan/request"
+import { getDataDictionary, getRentTableHeader, getRentTableData, updataRentTableData, deleteRentTableData, saveRentRelateSpace, BeatchQueryParam } from "@/api/scan/request"
 import { mapGetters, mapActions } from "vuex";
 export default {
   components: {
@@ -93,7 +101,8 @@ export default {
         label: '编辑模式'
       }],
       onlyRead: true,
-      allMess: true,
+      showType: "",
+      // allMess: true,
       tableHeader: [],
       page: {
         pageSize: 50,
@@ -110,7 +119,12 @@ export default {
         "projectId",
         "secret",
         "userId"
-    ])
+    ]),
+    showTypes () {
+      return this.onlyRead?
+        [{value: "all", label: '全部'}, {value: "Visible", label: '只看要采集的信息'}]: 
+        [{value: "all", label: '全部'}, {value: "Visible", label: '只看要采集的信息'}, {value: "partInfo", label: '隐藏自动填充的信息点'}]
+    }
   },
   created() {
     this.getTableHeader()
@@ -118,17 +132,28 @@ export default {
   watch: {
       projectId() {
         this.getTableHeader()
+      },
+      showTypes: {
+        handler(newName, oldName) {
+          if (newName && newName[0] && newName[0].value) {
+            this.showType = newName[0].value
+          } else {
+            this.showType = ""
+          }
+        },
+        immediate: true,
+        deep: true
       }
   },
   methods: {
     // 获取表头数据(初始化表格)
     async getTableHeader() {
       let param = {
-        // ProjId: this.projectId,
-        // secret: this.secret,
-        PageNumber: 1,
-        PageSize: 500,
-        Filters: `type='Tenant'`
+        data: {
+          PageNumber: 1,
+          PageSize: 500
+        },
+        type: 'Tenant'
       }
       await getDataDictionary(param, res => {
         this.tableHeader = res.Content;
@@ -136,22 +161,20 @@ export default {
       })
     },
     async getTableData() {//获取表格数据
-      let data = {
-        Filters: `ProjectId='${this.projectId}'`,
+      let params = {
+        Orders: "createTime desc, TenantID asc",
         PageNumber: this.page.pageNumber,
         PageSize: this.page.pageSize
       }
-      const params = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: data
-      }
       await getRentTableData(params, (res) => {
         this.tableData = res.Content
         this.copyTableData = tools.deepCopy(res.Content)
         this.page.pageNumber = res.PageNumber
         this.page.total = res.Total
         if(this.tableData && this.tableData.length){
+          if (this.onlyRead) {
+            this.getBatch(res.Content)
+          }
           this.initTable()
         }
       })
@@ -159,17 +182,13 @@ export default {
     // 修改表格内容
     async updateTableData(data, change) {
       let param = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: {
-          Content: [],
-          Projection: []
-        }
-      };
+        Content: [],
+        Projection: []
+      }
       //生成要修改字段列表
       change.map((item) => {
-        if(item[1] && param.data.Projection.indexOf(item[1]) == -1) {
-          param.data.Projection.push(item[1])
+        if(item[1] && param.Projection.indexOf(item[1]) == -1) {
+          param.Projection.push(item[1])
         }
       })
       //生成对应修改数据
@@ -180,7 +199,7 @@ export default {
         // } else {
         //   item[keyarr[0]] = item[keyarr[0]] != ""? item[keyarr[0]]: null
         // }
-        param.data.Content.push(item);
+        param.Content.push(item);
       });
 
       await updataRentTableData(param, (res) => {
@@ -189,15 +208,10 @@ export default {
     },
     //保存元空间关联
     async saveSpaceList() {
-      let data = {
-        TenantID: this.tenantID,
+      let params = {
+        Tenant: this.tenantID,
         RoomID: this.roomId
       }
-      const params = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: data
-      }
       await saveRentRelateSpace(params, (res) => {
         this.$message.success("关联成功!")
         this.getTableHeader()
@@ -220,13 +234,9 @@ export default {
       if (params.length < 1) {
         return
       }
-      let param = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: []
-      }
+      let param = []
       params.map(item => {
-        param.data.push(item.TenantID)
+        param.push({TenantID: item.TenantID})
       })
       this.$confirm("此操作将删除租户,是否继续?", "提示", {
         confirmButtonText: '确定',
@@ -293,21 +303,13 @@ export default {
     },
     formatHeaderData(list) {//格式化表头显示的数据
       let arr = tools.copyArr(list)
-      arr.map((item) => {
-        item.Visible = true
-      })
-      let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "F1", "F2", "L", "L1", "L2", "M"]
-      let data = showTools.changeHeader(arr, readArr, this.onlyRead, false, this.allMess)
+      let data = showTools.headerTextFilter(arr, "tenant", this.onlyRead, this.showType)
       data.unshift("操作","所属楼层","租赁空间");
       return data;
     },
     formatHeaderType(list) {//格式化表头头映射的数据
       let arr = tools.copyArr(list);
-      arr.map((item) => { //缺少信息点
-        item.Visible = true
-      })
-      let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "F1", "F2", "L", "L1", "L2", "M"]
-      let data = showTools.showHeaderTypes(arr, readArr, this.onlyRead, false, this.allMess)
+      let data = showTools.headerTypeFilter(arr, "tenant", this.onlyRead, this.showType)
       data.unshift({
         data: "caozuo",
         renderer: tools.lookDetails,
@@ -430,6 +432,63 @@ export default {
         }
       }
       return a;
+    },
+    //获取动态参数
+    getBatch(data) {
+      let param = {
+        secret: this.secret,
+        ProjId: this.projectId,
+        data: {
+          criterias: []
+        }
+      };
+      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.TenantID,
+                code: head.InfoPointCode
+              });
+            }
+          });
+        }
+      });
+      if (param.data.criterias.length) {
+        BeatchQueryParam(param, res => {
+          this.tableData = data.map(item => {
+            res.Content.map(child => {
+              if (item.TenantID == 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.tableExample.loadData(this.tableData);
+        });
+      }
     }
   }
 };

+ 9 - 22
src/views/rent/rentlist/rentadd/index.vue

@@ -43,7 +43,7 @@ export default {
       isTableRightShow: false,
       relationids: "",
       onlyRead: false,
-      allMess: true,
+      showType: "all",
       tableHeader: [],
       tableData: session.get("rentAddData")? session.get("rentAddData").length? session.get("rentAddData"): [{}]: [{}],
       copyTableData: []
@@ -66,11 +66,11 @@ export default {
     // 获取表头数据(初始化表格)
     async getTableHeader() {
       let param = {
-        // ProjId: this.projectId,
-        // secret: this.secret,
-        PageNumber: 1,
-        PageSize: 500,
-        Filters: `type='Tenant'`
+        data: {
+          PageNumber: 1,
+          PageSize: 500,
+        },
+        type: 'Tenant'
       }
       await getDataDictionary(param, res => {
         this.tableHeader = res.Content
@@ -94,12 +94,7 @@ export default {
         this.$message("创建信息为空,请录入信息后再创建!")
         return
       }
-      const params = {
-        ProjId: this.projectId,
-        secret: this.secret,
-        data: newData
-      }
-      await createRentTableData(params, (res) => {
+      await createRentTableData(newData, (res) => {
         this.$message.success("添加成功!")
         session.remove("rentAddData")
         this.$router.push({ name: 'rentlist'})
@@ -144,21 +139,13 @@ export default {
     },
     formatHeaderData(list) {//格式化表头显示的数据
       let arr = tools.copyArr(list)
-      arr.map((item) => {
-        item.Visible = true
-      })
-      let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "F1", "F2", "L", "L1", "L2", "M"]
-      let data = showTools.changeHeader(arr, readArr, this.onlyRead, false, this.allMess)
+      let data = showTools.headerTextFilter(arr, "tenant", this.onlyRead, this.showType)
       // data.unshift("关联的元空间");
       return data;
     },
     formatHeaderType(list) {//格式化表头头映射的数据
       let arr = tools.copyArr(list);
-      arr.map((item) => { //缺少信息点
-        item.Visible = true
-      })
-      let readArr = ["A1", "A2", "B1", "C5", "D1", "D2", "E1", "F1", "F2", "L", "L1", "L2", "M"]
-      let data = showTools.showHeaderTypes(arr, readArr, this.onlyRead, false, this.allMess)
+      let data = showTools.headerTypeFilter(arr, "tenant", this.onlyRead, this.showType)
       // data.unshift({
       //   data: "SpaceCount",
       //   readOnly: this.onlyRead