Browse Source

位置标签更新业务空间

LXXXY 5 years ago
parent
commit
ad1f843e27

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

@@ -183,6 +183,12 @@ export function updateLocationPoint(param, success) {
     http.postJson(url, param, success)
 }
 
+//根据点位标签推荐业务空间
+export function zoneQueryByPoint(param, success) {
+    let url = `${baseUrl}/equip-component/space/in-bdfl-zonespacebase?X=${param.X}&Y=${param.Y}`;
+    http.postJson(url, param.data, success)
+}
+
 //扫楼作业-位置标签-删除图片
 export function deleteLocationImg(param, success) {
     let url = `${baseUrl}/datacenter/location-point/delete-image`;

+ 65 - 25
src/views/data_admin/buildGraphy/createPointZone.vue

@@ -3,16 +3,16 @@
     <div class="condition">
       <div class="header">
         <el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goBack"></el-button>
-        <el-button size="small" style="float:right" @click="createZone">创建</el-button>
+        <el-button size="small" style="float:right" @click="createZ">创建</el-button>
       </div>
       <el-scrollbar style="height:calc(100% - 43px)">
         <div class="item">
           <span>基本信息:</span>
           <div>
             <label><span style="color:red;">*</span>业务空间名称</label>
-            <el-input placeholder="请输入业务空间名称" v-model="zoneObj.RoomLocalName" clearable style="width:215px;margin-right:10px;"></el-input>
+            <el-input placeholder="请输入业务空间名称" v-model="RoomLocalName" clearable style="width:215px;margin-right:10px;"></el-input>
             <label>业务空间编码</label>
-            <el-input placeholder="请输入业务空间编码" v-model="zoneObj.RoomLocalID" clearable style="width:215px;margin-right:10px;"></el-input>
+            <el-input placeholder="请输入业务空间编码" v-model="RoomLocalID" clearable style="width:215px;margin-right:10px;"></el-input>
           </div>
           <div>
             <label><span style="color:red;">*</span>所属建筑楼层</label>
@@ -31,17 +31,18 @@
             @click="showEx = (showEx == 'el-icon-arrow-up' ? 'el-icon-arrow-down' : 'el-icon-arrow-up')"></i>
           <div v-show="showEx == 'el-icon-arrow-up'" v-loading="loadingOtherMsg">
             <div v-if="otherList.length">
-            <div class="suppMsg" v-for="(item, key) in otherList" :key="key" >
-              <label>{{item.InfoPointName}}:</label>
-              <el-input :placeholder="`请输入${item.InfoPointName}`" v-model="otherMsg[item.InfoPointCode]" clearable style="width:215px;margin-right:10px;"></el-input>
-            </div>
+              <div class="suppMsg" v-for="(item, key) in otherList" :key="key">
+                <label>{{item.InfoPointName}}:</label>
+                <el-input :placeholder="`请输入${item.InfoPointName}`" v-model="item.inputValue" clearable style="width:215px;margin-right:10px;">
+                </el-input>
+              </div>
             </div>
             <p v-else>请选择业务空间类型</p>
           </div>
         </div>
         <div class="item">
           <p>位置标签图片信息:</p>
-          <locationPointMsg :pointObj="$route.params.item"></locationPointMsg>
+          <locationPointMsg ref="pointMsg" :pointObj="$route.params.item"></locationPointMsg>
         </div>
       </el-scrollbar>
     </div>
@@ -50,7 +51,7 @@
 
 <script>
 import locationPointMsg from '@/views/data_admin/buildGraphy/locationPointMsg'
-import { queryDictionaryHead, getDataDictionary } from '@/api/scan/request';
+import { queryDictionaryHead, getDataDictionary, createZone } from '@/api/scan/request';
 import { mapGetters } from 'vuex'
 export default {
   data() {
@@ -67,15 +68,11 @@ export default {
       zoneName: '',//业务空间名称
       zoneLocalId: '',//业务空间编码
       showEx: 'el-icon-arrow-down',//下拉菜单
-      zoneObj: {
-        RoomLocalID: '',//业务空间本地编码
-        RoomLocalName:'',//业务空间名称
-      },
-      otherMsg:{//其他可补充信息
-
-      },
-      otherList:[],//可补充信息list
-      loadingOtherMsg:false,
+      RoomLocalID: '',//业务空间本地编码
+      RoomLocalName: '',//业务空间名称
+      otherList: [],//可补充信息list
+      loadingOtherMsg: false,
+      test: '1'
     }
   },
   computed: {
@@ -93,10 +90,52 @@ export default {
   },
   methods: {
     //创建
-    createZone() {
+    createZ() {
       let param = {
-
+        zone: '',
+        data: {
+          content: []
+        }
+      }
+      let reqData = {
+        Pic: {}
+      };
+      //图片信息
+      this.$refs.pointMsg.choImg.map((item,key) => {
+        reqData.Pic[`additionalProp${key + 1}`] = item;
+      })
+      //其他补充信息
+      this.otherList.map(item => {
+        if (item.inputValue) {
+          reqData[item.InfoPointCode] = item.inputValue;
+        }
+      });
+      if (this.RoomLocalName && this.buildFloor.length && this.space) {
+        reqData.RoomLocalName = this.RoomLocalName;
+        reqData.RoomLocalID = this.RoomLocalID;
+        reqData.BuildingId = this.buildFloor[0];
+        reqData.FloorId = this.buildFloor[1];
+        param.zone = this.space;
+        param.data.content = [reqData];
+        createZone(param, res => {
+          this.$message.success("创建成功");
+          this.RoomLocalName = ''
+          this.RoomLocalID = ''
+          this.buildFloor = []
+          this.space = ''
+          
+        })
+      }
+      else if (!this.RoomLocalName) {
+        this.$message("请输入业务空间名称");
       }
+      else if (!this.buildFloor.length) {
+        this.$message("请选择所属建筑楼层");
+      }
+      else {
+        this.$message("请选择业务空间类型");
+      }
+      console.log(param);
     },
     //获取空间列表
     getSpaceList() {
@@ -109,7 +148,7 @@ export default {
     },
     //选择楼层
     changeFloor(val) {
-
+      this.buildFloor = val;
     },
     //选择业务空间
     changeSpace(val) {
@@ -123,11 +162,12 @@ export default {
       this.loadingOtherMsg = true;
       getDataDictionary(pa, res => {
         this.loadingOtherMsg = false;
-        this.otherMsg = {}
+        let filterCode = ["RoomLocalID", "RoomLocalName"]
+        res.Content = res.Content.filter(item => {
+          item.inputValue = null;
+          return filterCode.indexOf(item.InfoPointCode) == -1
+        });
         this.otherList = res.Content;
-        res.Content.map(item => {
-          this.otherMsg[item.InfoPointCode] = '';
-        })
       })
     },
     //返回

+ 1 - 1
src/views/data_admin/buildGraphy/graphyTabs.vue

@@ -262,7 +262,7 @@ export default {
       }).then(() => {
         this.$emit("closeCanvas")
         this.$router.push({
-          name: 'updateLocationPointZone',
+          name: 'updatePointZone',
           params: { item: item, floorData: this.floorOption, nowBuildFloor: this.buildingData }
         })
       }).catch(action => {

+ 2 - 8
src/views/data_admin/buildGraphy/locationPointMsg.vue

@@ -23,7 +23,6 @@
 </template>
 
 <script>
-const cityOptions = ['上海', '北京', '广州', '深圳'];
 export default {
   data() {
     return {
@@ -43,18 +42,13 @@ export default {
     handleCheckAllChange(val) {
       this.choImg = val ? this.pointObj.ImageList : [];
       this.isIndeterminate = false;
-
     },
     //选中
     handleCheckedCitiesChange(value) {
       let checkedCount = value.length;
-      this.checkAll = checkedCount === this.pointObj.ImageList.length && this.pointObj.ImageList;
-      this.isIndeterminate = checkedCount > 0 && checkedCount < this.pointObj.ImageList.length && this.pointObj.ImageList;
+      this.checkAll = checkedCount === this.pointObj.ImageList.length;
+      this.isIndeterminate = checkedCount > 0 && checkedCount < this.pointObj.ImageList.length;
     },
-    //获取选中的图片
-    getChoImg(){
-      return this.choImg;
-    }
   }
 }
 </script>

+ 143 - 36
src/views/data_admin/buildGraphy/updatePointZone.vue

@@ -3,17 +3,27 @@
     <div class="condition">
       <div class="header">
         <el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goBack"></el-button>
-        <el-button size="small" style="float:right" @click="createZone">更新</el-button>
+        <el-button size="small" style="float:right" @click="updateZ">更新</el-button>
       </div>
       <el-scrollbar style="height:calc(100% - 43px)">
         <div class="item">
-          <span>将位置标签图片批量补充到业务空间:</span>
-          <div>
+          <p>将位置标签图片批量补充到业务空间:</p>
+          <div v-for="item in zoneList" :key="item.objid" class="zone-item">
+            <el-tooltip class="item" effect="light" :content="item.RoomLocalName || item.RoomName" placement="top">
+              <p style="width:215px;float:left;height:32px;overflow:hidden;text-overflow: ellipsis;padding: 0 0;">
+                {{item.RoomLocalName || item.RoomName}}</p>
+            </el-tooltip>
+            <el-button type="info" icon="el-icon-delete" circle style="float:right;" size="mini" @click="deleteZone(item.RoomID)"></el-button>
+          </div>
+          <div class="zone-item" style="border:none;">
+            <el-cascader :props="zoneCascader" :show-all-levels="false" v-model="zoneCa" @change="changeCascader" filterable style="float:left;">
+            </el-cascader>
+            <el-button type="primary" icon="el-icon-plus" circle style="float:right;" size="mini" @click="addZone"></el-button>
           </div>
         </div>
         <div class="item">
           <p>位置标签图片信息:</p>
-          <locationPointMsg :pointObj="$route.params.item"></locationPointMsg>
+          <locationPointMsg :pointObj="$route.params.item" ref="pointMsg"></locationPointMsg>
         </div>
       </el-scrollbar>
     </div>
@@ -22,65 +32,158 @@
 
 <script>
 import locationPointMsg from '@/views/data_admin/buildGraphy/locationPointMsg'
-import { queryDictionaryHead } from '@/api/scan/request';
+import { queryDictionaryHead, zoneQueryByPoint, queryZone } from '@/api/scan/request';
 import { mapGetters } from 'vuex'
 export default {
   data() {
+    let that = this;
     return {
-      floorProps: {
-        value: 'BuildID',
-        label: 'BuildLocalName',
-        children: 'Floor'
+      zoneList: [],//业务空间列表
+      pointItem: {},//点位标签对象
+      zoneTypeList: [],//业务空间类型
+      zoneCascader: {//业务空间忌廉器
+        lazy: true,
+        lazyLoad(node, resolve) {
+          const { level } = node;
+          that.getCascaderNode(level, node, resolve);
+        }
       },
-      options: [],//建筑楼层
-      spaceList: [],//空间列表
-      space: '',//当前空间
-      buildFloor: [],//建筑楼层信息
-      zoneName: '',//业务空间名称
-      zoneLocalId: '',//业务空间编码
-      showEx: 'el-icon-arrow-down',//下拉菜单
+      newZoneObj: {},//当前新建业务空间
+      zoneCa: []
     }
   },
   computed: {
     ...mapGetters("layout", ["projectId"])
   },
-  props: {
-
-  },
   components: {
     locationPointMsg
   },
   created() {
-    this.options = this.$route.params.floorData
+    this.pointItem = this.$route.params.item
     this.getSpaceList();
-    console.log(this.$route.params.item)
-    console.log(this.$route.params.floorData)
   },
   methods: {
     //创建
-    createZone(){
-      let param = {
-
+    updateZ() {
+      console.log(this.zoneList);
+      if (this.$refs.pointMsg.choImg.length && this.zoneList.length) {
+        let imgs = {};
+        this.$refs.pointMsg.choImg.map((item, key) => {
+          imgs[`additionalProp${key + 1}`] = item;
+        })
+        this.zoneList.map(item => {
+          item.Pic = imgs;
+        })
+        let param = {
+          data: {
+            content: this.zoneList
+          }
+        }
+      }
+      else if (!this.$refs.pointMsg.choImg.length) {
+        this.$message("请至少选择一张图片");
       }
+      else {
+        this.$message("请至少添加一个业务空间");
+      }
+
     },
     //获取空间列表
     getSpaceList() {
       let pa = {
-        Filters: `parentId='Space'`
+        X: this.pointItem.X,
+        Y: this.pointItem.Y,
+        data: { Filters: `buildingId = '${this.pointItem.BuildId}' and floorId = '${this.pointItem.FloorId}'` }
       }
-      queryDictionaryHead(pa, res => {
-        this.spaceList = res.Content.filter((item => { return item.Name != '元空间' }));
+      zoneQueryByPoint(pa, res => {
+        this.zoneList = res.Content;
       });
     },
-    //选择楼层
-    changeFloor(val) {
-
+    //级联node
+    getCascaderNode(level, node, resolve) {
+      let id = (level + 1) * 10;
+      //建筑
+      if (level == 0) {
+        let nodes = this.$route.params.floorData.map(item => ({
+          value: item.BuildID,
+          label: item.BuildLocalName || item.BuildName,
+          leaf: level >= 3
+        }))
+        resolve(nodes)
+      }
+      //楼层
+      else if (level == 1) {
+        let floors = this.$route.params.floorData.filter(item => { return item.BuildID == node.value })
+        let nodes = floors[0].Floor.map(item => ({
+          value: item.FloorID,
+          label: item.FloorLocalName || item.FloorName,
+          leaf: level >= 3
+        }))
+        resolve(nodes)
+      }
+      //空间类型
+      else if (level == 2) {
+        if (this.zoneTypeList && this.zoneTypeList.length) {
+          resolve(this.zoneTypeList)
+        }
+        else {
+          let pa = {
+            Filters: `parentId='Space'`
+          }
+          queryDictionaryHead(pa, res => {
+            this.zoneTypeList = res.Content.filter((item => { return item.Name != '元空间' })).map(item => ({
+              value: item.Code,
+              label: item.Name,
+              leaf: level >= 3
+            }))
+            resolve(this.zoneTypeList)
+          });
+        }
+      }
+      //业务空间
+      else {
+        let pa = {
+          zone: node.value,
+          data: {
+            "Filters": `buildingId='${node.parent.parent.value}';floorId='${node.parent.value}'`,
+            "Orders": "createTime desc, RoomID asc",
+            "PageNumber": 1,
+            "PageSize": 999
+          }
+        }
+        queryZone(pa, res => {
+          let nodes = res.Content.map(item => ({
+            value: item,
+            label: item.RoomLocalName || item.RoomName,
+            leaf: level >= 3
+          }))
+          resolve(nodes)
+        })
+      }
+    },
+    //删除业务空间
+    deleteZone(zoneid) {
+      this.zoneList = this.zoneList.filter(item => { return item.RoomID != zoneid });
+    },
+    //添加业务空间
+    addZone() {
+      if (this.newZoneObj.RoomID && this.zoneList.indexOf(this.newZoneObj.RoomID) == -1) {
+        this.zoneList.push(this.newZoneObj)
+        this.zoneCa = [];
+      }
+      else {
+        this.$message("请选择业务空间后添加")
+      }
+    },
+    //选择业务空间
+    changeCascader(val) {
+      this.newZoneObj = val[3]
     },
     //返回
     goBack() {
       this.$router.push({
         name: "buildGraphy",
-        params:{nowBuildFloor: this.$route.params.nowBuildFloor}
+        params: { nowBuildFloor: this.$route.params.nowBuildFloor }
       })
     }
   },
@@ -123,11 +226,15 @@ export default {
   label {
     display: inline-block;
     padding: 5px 10px;
-    width:100px;
+    width: 130px;
   }
 }
-.suppMsg{
-  display:inline-block;
-  position:relative;
+.zone-item {
+  display: inline-block;
+  position: relative;
+  width: 245px;
+  padding: 5px 10px;
+  border: 1px solid rgba(0, 0, 0, 0.5);
+  margin: 0 5px 5px 0;
 }
 </style>