Browse Source

租户台账

haojianlong 5 years ago
parent
commit
913f137dc7

+ 1 - 1
package.json

@@ -28,7 +28,7 @@
         "@saga-web/base": "2.1.9",
         "@saga-web/draw": "2.1.61",
         "@saga-web/graphy": "2.1.34",
-        "@saga-web/cad-engine": "2.0.422"
+        "@saga-web/cad-engine": "2.0.423"
     },
     "devDependencies": {
         "ajv": "^6.9.1",

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

@@ -874,6 +874,24 @@ export function tnRelateZone(param, success) {
     http.postJson(url, param.data, success)
 }
 
+//租户关联业务空间,累加
+export function tnRelateOneZone(param, success) {
+    let url = `${baseUrl}/datacenter/tn-in-sp-base/link?type=${param.type}`
+    http.postJson(url, param.data, success)
+}
+
+//删除租户业务空间关系
+export function delTnRelateZone(param, success) {
+    let url = `${baseUrl}/datacenter/tn-in-sp-base/unlink?type=${param.type}`
+    http.postJson(url, param.data, success)
+}
+
+//查询租户关联的业务空间所在的建筑楼层
+export function queryTnRelateFloor(param, success) {
+    let url = `${baseUrl}/equip-component/tenant/tenant-building-floor?objectType=${param.objectType}&tenantId=${param.tenantId}`
+    http.postJson(url, {}, success)
+}
+
 //关联分区空间
 export function saveRentRelateSpace(param, success) {
     let url = `${baseUrl}/datacenter/tenant/relate-space`

+ 75 - 57
src/components/ledger/rentList/roomCountDrawer.vue

@@ -3,10 +3,10 @@
     <div class="drawer-body" :style="{height:drawerBodyHeight}">
       <div class="default-zone zone">
         <p>默认业务空间</p>
-        <div v-if="!(readonly&&!zoneList.default.length)">
-          <div v-for="(item,index) in zoneList.default" :key="item.RoomID" class="zoneItem">
+        <div v-if="!(readonly&&!zoneList.GeneralZone.length)">
+          <div v-for="(item,index) in zoneList.GeneralZone" :key="item.RoomID" class="zoneItem">
             {{item.BuildLocalName}}-{{item.FloorLocalName}}-{{item.RoomLocalName || item.RoomName}}
-            <i size="mini" class="el-icon-delete" title="删除" @click="deleteZoneItem('default',index)" v-if="!readonly"></i>
+            <i size="mini" class="el-icon-delete" title="删除" @click="deleteZoneItem('GeneralZone',index)" v-if="!readonly"></i>
           </div>
           <div class="zoneItem" style="border:none;padding:0;" v-if="!readonly">
             <el-cascader placeholder="请选择" v-model="GeneralVal" :options="option.GeneralZone" :props="props" filterable @expand-change="expandChange"
@@ -21,10 +21,10 @@
       </div>
       <div class="tenant-zone zone">
         <p>租户业务空间</p>
-        <div v-if="!(readonly&&!zoneList.tenant.length)">
-          <div v-for="(item,index) in zoneList.tenant" :key="item.RoomID" class="zoneItem">
+        <div v-if="!(readonly&&!zoneList.TenantZone.length)">
+          <div v-for="(item,index) in zoneList.TenantZone" :key="item.RoomID" class="zoneItem">
             {{item.BuildLocalName}}-{{item.FloorLocalName}}-{{item.RoomLocalName || item.RoomName}}
-            <i size="mini" class="el-icon-delete" title="删除" @click="deleteZoneItem('tenant',index)" v-if="!readonly"></i>
+            <i size="mini" class="el-icon-delete" title="删除" @click="deleteZoneItem('TenantZone',index)" v-if="!readonly"></i>
           </div>
           <div class="zoneItem" style="border:none;padding:0;" v-if="!readonly">
             <el-cascader placeholder="请选择" v-model="TenantVal" :options="option.TenantZone" :props="props" filterable
@@ -47,7 +47,8 @@
 import {
   tnRelateTenantZone, //关联租户空间
   tnRelateGeneralZone, //关联默认空间
-  tnRelateZone,// 关联业务空间
+  tnRelateOneZone,// 关联业务空间
+  delTnRelateZone, // 删除关系业务空间与租户
   buildingQuery, //建筑查询
   queryParentZone, //业务空间查询GeneralZone-TenantZone
 } from '@/api/scan/request'
@@ -58,8 +59,8 @@ export default {
       drawer: false,
       direction: 'rtl',
       zoneList: {
-        default: [],
-        tenant: []
+        GeneralZone: [],
+        TenantZone: []
       },
       option: {
         GeneralZone: [],
@@ -179,8 +180,9 @@ export default {
       if (zoneObj.BuildLocalName == '未明确建筑') {
         zoneObj.FloorLocalName = ''
       }
-      if (this.zoneList.default.findIndex((item) => (item.RoomID == zoneObj.RoomID)) == -1) {
-        this.zoneList.default.push(zoneObj);
+      if (this.zoneList.GeneralZone.findIndex((item) => (item.RoomID == zoneObj.RoomID)) == -1) {
+        this.zoneList.GeneralZone.push(zoneObj);
+        this.relateGeneral('GeneralZone', zoneObj.RoomID)
       } else {
         this.$message.warning('已有业务空间,请重新选择')
       }
@@ -191,8 +193,9 @@ export default {
       if (zoneObj.BuildLocalName == '未明确建筑') {
         zoneObj.FloorLocalName = ''
       }
-      if (this.zoneList.tenant.findIndex((item) => (item.RoomID == zoneObj.RoomID)) == -1) {
-        this.zoneList.tenant.push(zoneObj);
+      if (this.zoneList.TenantZone.findIndex((item) => (item.RoomID == zoneObj.RoomID)) == -1) {
+        this.zoneList.TenantZone.push(zoneObj);
+        this.relateGeneral('TenantZone', zoneObj.RoomID)
       } else {
         this.$message.warning('已有业务空间,请重新选择')
       }
@@ -201,70 +204,85 @@ export default {
     showDrawer(tenant) {
       this.curTenantId = tenant.TenantID;
       if (tenant.ZoneGeneraltList) {
-        this.zoneList.default = tenant.ZoneGeneraltList.map(t => {
-          t.BuildLocalName = t.Building.BuildLocalName || t.Building.BuildName;
-          t.FloorLocalName = t.Floor.FloorLocalName || t.Floor.FloorName;
+        this.zoneList.GeneralZone = tenant.ZoneGeneraltList.map(t => {
+          if (t.Building) {
+            t.BuildLocalName = t.Building.BuildLocalName || t.Building.BuildName;
+          } else {
+            t.BuildLocalName = '未明确建筑'
+          }
+          if (t.Floor) {
+            t.FloorLocalName = t.Floor.FloorLocalName || t.Floor.FloorName;
+          } else {
+            t.FloorLocalName = '未明确楼层'
+          }
+          if (t.BuildLocalName == '未明确建筑') {
+            t.FloorLocalName = ''
+          }
           return t;
         });
       } else {
-        this.zoneList.default = [];
+        this.zoneList.GeneralZone = [];
       }
       if (tenant.ZoneTenantList) {
-        this.zoneList.tenant = tenant.ZoneTenantList.map(t => {
-          t.BuildLocalName = t.Building.BuildLocalName || t.Building.BuildName;
-          t.FloorLocalName = t.Floor.FloorLocalName || t.Floor.FloorName;
+        this.zoneList.TenantZone = tenant.ZoneTenantList.map(t => {
+          if (t.Building) {
+            t.BuildLocalName = t.Building.BuildLocalName || t.Building.BuildName;
+          } else {
+            t.BuildLocalName = '未明确建筑'
+          }
+          if (t.Floor) {
+            t.FloorLocalName = t.Floor.FloorLocalName || t.Floor.FloorName;
+          } else {
+            t.FloorLocalName = '未明确楼层'
+          }
+          if (t.BuildLocalName == '未明确建筑') {
+            t.FloorLocalName = ''
+          }
           return t;
         });
       } else {
-        this.zoneList.tenant = [];
+        this.zoneList.TenantZone = [];
       }
       this.drawer = true;
     },
     handleClose(done) {
-      this.zoneList.default = [];
-      this.zoneList.tenant = [];
+      this.zoneList.GeneralZone = [];
+      this.zoneList.GeneralZone = [];
+      this.$emit('refresh');
       done();
     },
     // 删除
     deleteZoneItem(type, index) {
+      let pa = {
+        type: type,
+        data: [
+          {
+            SpaceID: this.zoneList[type][index].RoomID,
+            TenantID: this.curTenantId
+          }
+        ]
+      }
       this.zoneList[type].splice(index, 1);
+      delTnRelateZone(pa, res => { })
     },
-    save() {
-      let pa1 = {
-        data: {
-          SpaceIdList: [],
-          TenantId: this.curTenantId
-        },
-        type: 'GeneralZone'
-      }
-      pa1.data.SpaceIdList = this.zoneList.default.map(t => {
-        return t.RoomID;
-      })
-      let promise1 = new Promise((resolve) => {
-        tnRelateZone(pa1, res => {
-          resolve(res);
-        })
-      })
-      let pa2 = {
+    // 关联默认空间
+    relateGeneral(type, SpaceId) {
+      let pa = {
+        type: type,
         data: {
-          SpaceIdList: [],
-          TenantId: this.curTenantId
-        },
-        type: 'TenantZone'
+          Content: [
+            {
+              SpaceId: SpaceId,
+              TenantID: this.curTenantId
+            }
+          ]
+        }
       }
-      pa2.data.SpaceIdList = this.zoneList.tenant.map(t => {
-        return t.RoomID;
-      })
-      let promise2 = new Promise((resolve) => {
-        tnRelateZone(pa2, res => {
-          resolve(res);
-        })
-      })
-      Promise.all([promise1, promise2]).then(values => {
-        this.$message.success('关联成功');
-        this.$emit('refresh');
-        this.drawer = false;
-      })
+      tnRelateOneZone(pa, res => { })
+    },
+    save() {
+      this.$emit('refresh');
+      this.drawer = false;
     }
   }
 }

+ 111 - 40
src/views/ledger/rentlist/manageTenantZone.vue

@@ -5,7 +5,7 @@
       <el-button size="small" type="default" icon="el-icon-back" @click="goback"></el-button>
       <div style="display:inline-block;margin-left:10px;">
         <label style="margin-right:10px;">业务空间类型</label>
-        <el-select v-model="value" placeholder="请选择" @change="getBusinessSpace">
+        <el-select v-model="value" placeholder="请选择" @change="getTnRelatFloor">
           <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
           </el-option>
         </el-select>
@@ -45,7 +45,7 @@
           </div>
         </div>
         <div class="canvas-container" ref="graphy" v-loading="canvasLoading">
-          <div class="floor-container">
+          <div class="floor-container" v-show="hasMap">
             <div class="before" @click="toBefore">
               <div><i class="el-icon-caret-top"></i></div>
             </div>
@@ -53,7 +53,7 @@
               <div v-for="(fl,i) in floorList" :key="fl.id" :class="{'active':fl.active,'textParent':true}" @click="floorChange(i)">
                 <div class="text">
                   {{fl.FloorLocalID || fl.FloorLocalName}}
-                  <span>{{fl.count>9?'9+':fl.count}}</span>
+                  <span v-if="fl.Count">{{fl.Count>9?'9+':fl.Count}}</span>
                 </div>
               </div>
             </div>
@@ -83,7 +83,8 @@ import { mapGetters, mapActions } from "vuex";
 import { SColor, SPoint } from "@saga-web/draw/lib";
 import { DivideFloorScene, SpaceItem, ZoneItem, FloorView } from "@saga-web/cad-engine/lib";
 import { colorArr } from "@/utils/spaceColor"
-import { buildingQuery, queryZone, tnRelateZone, queryRentTableData } from '@/api/scan/request'
+import { buildingQuery, queryTnRelateFloor, queryRentTableData, tnRelateZone, queryZone } from '@/api/scan/request'
+import { resolve } from 'q';
 export default {
   data() {
     return {
@@ -108,6 +109,10 @@ export default {
       },
       hasMap: true,
       keyWord: '', // 查询租户名称
+      Cascade: {
+        GeneralZone: 'zoneGeneraltList',
+        TenantZone: 'zoneTenantList'
+      }
     }
   },
   components: {
@@ -127,7 +132,6 @@ export default {
   methods: {
     init() {
       this.getTenant();
-      this.getAllBuilding();
     },
     // 返回
     goback() {
@@ -200,7 +204,7 @@ export default {
     },
     // 租户更改引起的修改
     tenantChangeInflu(i) {
-      if (this.onlyRead) { // 只读模式-对空间类型处理
+      if (this.onlyRead === true || this.onlyRead === 'true') { // 只读模式-对空间类型处理
         let g = this.tenantList[i].ZoneGeneraltList;
         let t = this.tenantList[i].ZoneTenantList;
         let gFlag = g && g.length;
@@ -223,16 +227,15 @@ export default {
           }
         }
       }
+      this.getTnRelatFloor();
     },
     // 楼层修改
     floorChange(index) {
-      console.log(this.floorList)
       this.floorList.map(t => {
         t.active = false;
       })
       this.activeFloor = index;
       this.floorList[index].active = true;
-
       this.getGraphy(index)
     },
     // canvas点击事件
@@ -245,7 +248,10 @@ export default {
     editCanvas() {
       this.isEdit = true;
       this.config.isEdit = true;
-      // 将已关联选中
+      this.scene.zoneList.map(t => {
+        t.selected = t.highLightFlag;
+        t.highLightFlag = false;
+      })
     },
     // 取消
     cancel() {
@@ -261,7 +267,6 @@ export default {
       }
       this.view = new FloorView('floorCanvas')
     },
-    
     // 获取列表
     getTenant() {
       let pa = {
@@ -286,32 +291,11 @@ export default {
         }
       })
     },
-    // 编辑态获取所有建筑
-    getAllBuilding() {
-      let pa = {
-        Cascade: [{ name: 'floor', Orders: 'SequenceId desc' }],
-        Orders: "BuildLocalName asc",
-      }
-      buildingQuery(pa, res => {
-        this.allBuilding = res.Content.map(t => {
-          t.active = false;
-          if (t.Floor) {
-            t.Floor.map(item => {
-              item.active = false;
-              item.count = (20 * Math.random()).toFixed(0);
-            })
-          }
-          return t;
-        });
-        if (this.allBuilding.length) {
-          this.changeBuildSelect(0);
-        }
-      })
-    },
     // 获取业务空间
     getBusinessSpace() {
       let buildid = this.floorList[this.activeFloor].BuildID;
       let floorid = this.floorList[this.activeFloor].FloorID;
+      let TenantID = this.tenantList[this.activeTentanIndex].TenantID
       if (buildid && floorid && this.value) {
         this.canvasLoading = true
         let pa = {
@@ -322,12 +306,62 @@ export default {
             PageSize: 1000
           }
         }
-        queryZone(pa, res => {
-          // 所有业务空间
-          this.businessSpaceList = res.Content;
+        // queryZone(pa, res => {
+        //   // 所有业务空间
+        //   this.businessSpaceList = res.Content;
+        //   // 已关联元空间的业务空间
+        //   this.BSPRelaISPList = [];
+        //   res.Content.map(t => {
+        //     if (t.Outline && t.Outline.length) {
+        //       this.BSPRelaISPList.push(t)
+        //     }
+        //   })
+        //   let key = 'Z' + this.Cascade[this.value].substring(1)
+        //   let relationList = this.tenantList[this.activeTentanIndex][key] || []
+        //   // 绘制业务空间
+        //   let tempArr = this.BSPRelaISPList.map((t, i) => {
+        //     if (t.FloorId == this.floorList[this.activeFloor].FloorID && t.ObjectType == this.value) {
+        //       return {
+        //         RoomLocalName: t.RoomLocalName,
+        //         OutLine: t.Outline,
+        //         RoomID: t.RoomID,
+        //         Color: colorArr[i % colorArr.length],
+        //         HighLightFlag: relationList.findIndex((item) => (item.RoomID == t.RoomID)) > -1
+        //       }
+        //     } else {
+        //       return undefined;
+        //     }
+        //   }).filter(item => item)
+        //   this.scene.removeAllZone();
+        //   this.scene.addZoneList(tempArr);
+        //   this.scene.click(this, this.canvasClick);
+        // })
+        this.canvasLoading = false;
+        let promise1 = new Promise((resolve) => {
+          queryZone(pa, res => {
+            resolve(res);
+          })
+        })
+        let pa2 = {
+          Cascade: [
+            { Name: this.Cascade[this.value], Filters: `FloorId='${floorid}'` }
+          ],
+          Filters: `TenantID='${TenantID}'`
+        }
+        let promise2 = new Promise((resolve) => {
+          queryRentTableData(pa2, res => {
+            resolve(res);
+          })
+        })
+        Promise.all([promise1, promise2]).then(response => {
+          let res1 = response[0];
+          let res2 = response[1];
+          let key = 'Z' + this.Cascade[this.value].substring(1);
+          let relationList = res2.Content[0][key] || [];
+          this.businessSpaceList = res1.Content;
           // 已关联元空间的业务空间
           this.BSPRelaISPList = [];
-          res.Content.map(t => {
+          res1.Content.map(t => {
             if (t.Outline && t.Outline.length) {
               this.BSPRelaISPList.push(t)
             }
@@ -340,17 +374,15 @@ export default {
                 OutLine: t.Outline,
                 RoomID: t.RoomID,
                 Color: colorArr[i % colorArr.length],
+                HighLightFlag: relationList.findIndex((item) => (item.RoomID == t.RoomID)) > -1
               }
             } else {
-              console.log('internet slow')
               return undefined;
             }
           }).filter(item => item)
           this.scene.removeAllZone();
           this.scene.addZoneList(tempArr);
           this.scene.click(this, this.canvasClick);
-          // 将已关联的高亮
-          this.canvasLoading = false;
         })
       }
     },
@@ -383,21 +415,60 @@ export default {
         this.hasMap = false;
       }
     },
+    // 查询租户关联的业务空间所在建筑楼层,分区修改也会触发
+    getTnRelatFloor() {
+      if (this.value) {
+        let pa = {
+          objectType: this.value,
+          tenantId: this.curTenantId
+        }
+        queryTnRelateFloor(pa, res => {
+          this.allBuilding = res.Content.map(t => {
+            t.active = false;
+            if (t.Floor) {
+              t.Floor.map(item => {
+                item.active = false;
+              })
+            }
+            return t;
+          });
+          if (this.onlyRead === true || this.onlyRead === 'true') {
+            this.allBuilding = this.allBuilding.filter(item => item.Count > 0)
+            this.allBuilding.map(t => {
+              if (t.Floor) {
+                t.Floor = t.Floor.filter(item => item.Count > 0)
+              }
+            })
+          }
+          if (this.allBuilding.length) {
+            this.changeBuildSelect(this.buildSelect);
+          }
+        })
+      } else {
+        this.hasMap = false;
+        this.canvasLoading = false;
+        this.allBuilding = [];
+      }
+    },
     // 保存关系
     save() {
       let arr = this.scene.getSelectedZone();
       let pa = {
         data: {
           SpaceIdList: [],
+          FloorId: this.floorList[this.activeFloor].FloorID,
           TenantId: this.curTenantId
         },
         type: this.value
       }
-      pa.SpaceIdList = arr.map(t => {
+      pa.data.SpaceIdList = arr.map(t => {
         return t.data.RoomID;
       })
       tnRelateZone(pa, res => {
+        this.isEdit = false;
+        this.config.isEdit = false;
         this.$message.success('关联成功');
+        this.getTnRelatFloor();
       })
     },
   },