Parcourir la source

'批量绑定'

zhangyu il y a 4 ans
Parent
commit
77bff498d1
1 fichiers modifiés avec 96 ajouts et 27 suppressions
  1. 96 27
      src/components/edit/edit-dialog.vue

+ 96 - 27
src/components/edit/edit-dialog.vue

@@ -95,9 +95,9 @@
 
         <a-modal v-model="visibleBind" title="是否批量绑定图例" width="840px" class="edit-dialog" @cancel="handleClickCancel">
             <template slot="footer">
-                <a-checkbox @change="onChangeRemember" :checked="isRem" style="margin-top: 5px;margin-right: 10px;">
+                <!-- <a-checkbox @change="onChangeRemember" :checked="isRem" style="margin-top: 5px;margin-right: 10px;">
                     记住操作,不再提醒
-                </a-checkbox>
+                </a-checkbox> -->
                 <a-button key="back" @click="handleClickUntreated">
                     暂不处理
                 </a-button>
@@ -121,7 +121,14 @@
                                 <el-link :underline="false" type="primary" style="vertical-align: baseline;margin-left: 5px;">查看</el-link>
                             </div>
                             <div class="bind-equip-list">
-                                <el-tag v-for="floor in data.floor.FloorName" :key="floor" size="small" type="info" closable>{{floor}}</el-tag>
+                                <el-tag
+                                    v-for="floor in data.floor.FloorName" 
+                                    :key="floor.Id" 
+                                    size="small" 
+                                    type="info" 
+                                    closable 
+                                    @close="handleClose(data.floor.FloorName, floor)"
+                                >{{floor.Name}}</el-tag>
                             </div>
                         </div>
                         <div class="bind-equip" v-if="data.equip && data.equip.length">
@@ -132,7 +139,14 @@
                                     <el-link :underline="false" type="primary" style="vertical-align: baseline;margin-left: 5px;">查看</el-link>
                                 </div>
                                 <div class="bind-equip-list">
-                                    <el-tag v-for="floor in equip.FloorName" :key="floor" size="small" type="info" closable>{{floor}}</el-tag>
+                                    <el-tag
+                                        v-for="floor in equip.FloorName" 
+                                        :key="floor.Id" 
+                                        size="small" 
+                                        type="info" 
+                                        closable
+                                        @close="handleClose(equip.FloorName, floor)"
+                                    >{{floor.Name}}</el-tag>
                                 </div>
                             </div>
                         </div>
@@ -144,7 +158,14 @@
                                     <el-link :underline="false" type="primary" style="vertical-align: baseline;margin-left: 5px;">查看</el-link>
                                 </div>
                                 <div class="bind-equip-list">
-                                    <el-tag v-for="floor in system.FloorName" :key="floor" size="small" type="info" closable>{{floor}}</el-tag>
+                                    <el-tag
+                                        v-for="floor in system.FloorName" 
+                                        :key="floor.Id" 
+                                        size="small" 
+                                        type="info" 
+                                        closable
+                                        @close="handleClose(system.FloorName, floor)"
+                                    >{{floor.Name}}</el-tag>
                                 </div>
                             </div>
                         </div>
@@ -152,6 +173,8 @@
                 </div>
             </div>
         </a-modal>
+
+        <a-modal v-model="visibleMap" title="标题" width="1200px"></a-modal>
     </div>
 </template>
 
@@ -345,16 +368,33 @@
                     el.model = check
                 })
             },
-
             // 复选框
             handleCheckChange(key, check) {
-                // if (check) {
-                //     if (this.$refs[`${key}check`].find(el => {return el.model == false}) != -1) {
-                //         this.checkAll[key] = check;
-                //     }
-                // } else {
-                //     this.checkAll[key] = check;
-                // }
+                if (check) {
+                    let flag = true;
+                    Object.keys(this.bindData[key]).forEach(type => {
+                        if (type == "floor") {
+                            if (this.bindData[key][type].Checked == false) {
+                                flag = false;
+                            }
+                        } else {
+                            if (this.bindData[key][type].findIndex(item => {return item.Checked == false}) != -1) {
+                                flag = false;
+                            }
+                        }
+                    })
+                    if (flag) {
+                        this.checkAll[key] = check;
+                    }
+                } else {
+                    this.checkAll[key] = check;
+                }
+                this.$forceUpdate();
+            },
+            // 删除tag
+            handleClose(floorList, floor) {
+                floorList.splice(floorList.findIndex(item => {return item.Id == floor.Id}), 1);
+                this.$forceUpdate();
             },
             handleOk(e) {
                 // this.loading = true;
@@ -396,10 +436,11 @@
                     bus.$emit('changeAttachObjectIds', lists, true)
                     bus.$emit('updateAttachMsg', lists)
                 }, 1000);
-                if (this.isRem && this.rememberBtn == "bind" && this.GraphElementName) { // 记住批量绑定并且图例名不为空
-                    // 直接绑定接口
-                    this.handleClickBind(false);
-                } else if (!this.isRem && this.GraphElementName) { // 没有记住操作并且图例名不为空
+                // if (this.isRem && this.rememberBtn == "bind" && this.GraphElementName) { // 记住批量绑定并且图例名不为空
+                //     // 直接绑定接口
+                //     this.handleClickBind(false);
+                // } else 
+                if (!this.isRem && this.GraphElementName) { // 没有记住操作并且图例名不为空
                     // 打开批量绑定弹窗并查询相关楼层
                     this.getBindGraphs();
                 } else {
@@ -410,8 +451,8 @@
             getBindGraphs() {
                 // 初始化数据
                 this.bindData = {HasPub: {}, NotPub: {}};
-                this.bindTreeData = {HasPub: [], NotPub: []};
-                this.GraphsIdList = [];
+                this.checkAll = {HasPub: true, NotPub: true};
+                // this.GraphsIdList = [];
                 queryFloorByNode({graphElementId: this.GraphElementId,graphElementName: this.GraphElementName,projectId: this.projectId}).then(res => {
                     if (res.Data && ((res.Data.HasPub && res.Data.HasPub.length) || (res.Data.NotPub && res.Data.NotPub.length))) {
                         const data = res.Data;
@@ -428,8 +469,11 @@
                                         const floor = this.bindData[key].floor;
                                         if (item.Graphs.length) {
                                             item.Graphs.forEach(graph => {
-                                                floor.FloorName.push(graph.Floor.Code);
-                                                this.GraphsIdList.push(graph.Id);
+                                                floor.FloorName.push({
+                                                    Id: graph.Id,
+                                                    Name: graph.Floor.Code
+                                                });
+                                                // this.GraphsIdList.push(graph.Id);
                                             })
                                         }
                                     } else if (item.Id == "XFBFYCFL" || item.Id == "FZQZL") { // 系统原理图
@@ -451,8 +495,11 @@
                                         const systemLast = this.bindData[key].system[this.bindData[key].system.length - 1];
                                         if (item.Graphs.length) {
                                             item.Graphs.forEach(graph => {
-                                                systemLast.FloorName.push(graph.Floor.Code);
-                                                this.GraphsIdList.push(graph.Id);
+                                                systemLast.FloorName.push({
+                                                    Id: graph.Id,
+                                                    Name: graph.Floor.Code
+                                                });
+                                                // this.GraphsIdList.push(graph.Id);
                                             })
                                         }
                                     } else { // 设备设施
@@ -474,8 +521,11 @@
                                         const equipLast = this.bindData[key].equip[this.bindData[key].equip.length - 1];
                                         if (item.Graphs.length) {
                                             item.Graphs.forEach(graph => {
-                                                equipLast.FloorName.push(graph.Floor.Code);
-                                                this.GraphsIdList.push(graph.Id);
+                                                equipLast.FloorName.push({
+                                                    Id: graph.Id,
+                                                    Name: graph.Floor.Code
+                                                });
+                                                // this.GraphsIdList.push(graph.Id);
                                             })
                                         }
                                     }
@@ -488,8 +538,6 @@
                     }
                 })
                 console.log("bindData+++++++++++++++++++++++",this.bindData);
-                console.log("bindTreeData+++++++++++++++++++++++",this.bindTreeData);
-                console.log("GraphsIdList++++++++++++++++++++",this.GraphsIdList);
             },
             handleCancel(e) {
                 this.visible = false;
@@ -544,6 +592,27 @@
                         })
                     }
                 })
+                this.GraphsIdList = [];
+                Object.keys(this.bindData).forEach(key => {
+                    Object.keys(this.bindData[key]).forEach(type => {
+                        if (type == "floor") {
+                            if (this.bindData[key][type].Checked == true) {
+                                this.bindData[key][type].FloorName.forEach(floor => {
+                                    this.GraphsIdList.push(floor.Id);
+                                })
+                            }
+                        } else {
+                            this.bindData[key][type].forEach(item => {
+                                if (item.Checked == true) {
+                                    item.FloorName.forEach(floor => {
+                                        this.GraphsIdList.push(floor.Id);
+                                    })
+                                }
+                            })
+                        }
+                    })
+                })
+                console.log(this.GraphsIdList)
                 if (Marked) {
                     this.$store.commit("setRememberBtn", "bind");
                     params = {