Browse Source

'批量绑定'

zhangyu 4 years ago
parent
commit
e8e39455c8
2 changed files with 203 additions and 80 deletions
  1. 10 0
      src/api/editer.js
  2. 193 80
      src/components/edit/edit-dialog.vue

+ 10 - 0
src/api/editer.js

@@ -112,4 +112,14 @@ export function deleteByCategory(params){
 // 推荐
 export function graphElementOrderInfoLocal(params){
     return httputils.getJson(`${testApi}/graphElement/orderInfoLocal`, params)
+}
+
+// 查询图例绑定的楼层
+export function queryFloorByNode(params) {
+    return httputils.getJson(`${testApi}/node/qfloor`, params)
+}
+
+// 批量绑定工程信息化数据
+export function bindAttachObject(params){
+    return httputils.postJson(`${testApi}/node/bindAttachObject`, params)
 }

+ 193 - 80
src/components/edit/edit-dialog.vue

@@ -101,15 +101,32 @@
                 <a-button key="back" @click="handleClickUntreated">
                     暂不处理
                 </a-button>
-                <a-button key="submit" type="primary" :loading="loading" @click="handleClickBind">
+                <a-button key="submit" type="primary" :loading="loading" @click="handleClickBind(true)">
                     批量绑定
                 </a-button>
             </template>
-            <div>
-                <p>{{`系统自动将其他平面图中的“${lengedName}”绑定相同台账,涉及以下平面图:`}}</p>
-
-                <p>Bla bla ...</p>
-                <p>Bla bla ...</p>
+            <div class="bind-content">
+                <p>{{`系统自动将其他平面图中的“${GraphElementName?GraphElementName:"图例"}”绑定相同台账,涉及以下平面图:`}}</p>
+                <div class="bind-box" v-for="(data, key) in bindData" :key="key" v-show="Object.keys(data).length">
+                    <h3 class="bind-title" v-if="Object.keys(data).length">{{key == "HasPub"?"已发布的平面图":"草稿箱中的平面图"}}</h3>
+                    <p v-if="data.floor">{{`${data.floor.Name}—${data.floor.FloorName.join('、')}`}}</p>
+                    <div class="bind-equip" v-if="data.equip && data.equip.length">
+                        <div class="bind-equip-title">设备设施—</div>
+                        <div class="bind-equip-list">
+                            <p class="bind-equip-item" v-for="equip in data.equip" :key="equip.Id" :title="`${equip.Name}—${equip.FloorName.join('、')}`">
+                                {{`${equip.Name}—${equip.FloorName.join('、')}`}}
+                            </p>
+                        </div>
+                    </div>
+                    <div class="bind-equip" v-if="data.system && data.system.length">
+                        <div class="bind-equip-title">系统原理图—</div>
+                        <div class="bind-equip-list">
+                            <p class="bind-equip-item" v-for="system in data.system" :key="system.Id" :title="`${system.Name}—${system.FloorName.join('、')}`">
+                                {{`${system.Name}—${system.FloorName.join('、')}`}}
+                            </p>
+                        </div>
+                    </div>
+                </div>
             </div>
         </a-modal>
     </div>
@@ -125,7 +142,9 @@
         queryWzfldl,
         queryWzflByDl,
         queryGlsmsLocation,
-        graphElementOrderInfoLocal
+        graphElementOrderInfoLocal,
+        queryFloorByNode,
+        bindAttachObject
     } from "@/api/editer";
     import bus from "@/bus";
     import {getUrlMsg} from '@/components/urlMsg.js';
@@ -156,6 +175,7 @@
                 model: 'test1',
                 searchName: '',
                 floorId: "",//所属楼层
+                projectId: "",//所属项目
                 dataFloor: [],
                 plainOptions: ['福建三明万达-供电系统-6楼-工程信息化中的区域编码ND182472e83742', '福建三明万达-供电系统-6楼-工程信息化中的区域编码ND18247283742'],
                 majorList: [],
@@ -222,9 +242,14 @@
                 selectVal:'',
                 sysId:'',
                 majorId:'#',
+                GraphElementName: "",
                 visibleBind: false, // 是否显示批量绑定弹窗
                 isRem: false, // 是否记住操作
-
+                bindData: {
+                    HasPub: {},
+                    NotPub: {}
+                },
+                GraphsIdList: []
             }
         },
         watch: {
@@ -273,11 +298,14 @@
                 })
                 bus.$emit('changeAttachObjectIds', lists, true)
                 bus.$emit('updateAttachMsg', lists)
-                if (this.isRem && this.rememberBtn == "bind") {
+                if (this.isRem && this.rememberBtn == "bind" && this.GraphElementName) { // 记住批量绑定并且图例名不为空
                     // 直接绑定接口
-                } else if (!this.isRem) {
+                    this.handleClickBind(false);
+                } else if (!this.isRem && this.GraphElementName) { // 没有记住操作并且图例名不为空
                     // 打开批量绑定弹窗并查询相关楼层
-                    this.visibleBind = true;
+                    this.getBindGraphs();
+                } else {
+                    this.visible = false;
                 }
                 // setTimeout(() => {
                 //     this.visible = false;
@@ -305,73 +333,81 @@
             },
             // 查询相关图并打开批量绑定弹窗
             getBindGraphs() {
-                const data = {
-                    "Data":{
-                        "HasPub":[ ],
-                        "NotPub":[
-                            {
-                                "Graphs":[
-                                    {
-                                        "BuildingId":"1",
-                                        "CategoryId":"LCGN",
-                                        "Floor":{
-                                            "Code":"B1",
-                                            "Gcode":"B1",
-                                            "Gname":"b1",
-                                            "Name":"地下1层",
-                                            "Seq":-100
-                                        },
-                                        "FloorId":"b1",
-                                        "Id":"3e3f48bf970a4a9b9d51cb32abe2747b",
-                                        "IsPub":false,
-                                        "ProjectId":"1000423"
-                                    },
-                                    {
-                                        "BuildingId":"1",
-                                        "CategoryId":"LCGN",
-                                        "Floor":{
-                                            "Code":"F5",
-                                            "Gcode":"5F",
-                                            "Gname":"f5",
-                                            "Name":"第5层",
-                                            "Seq":500
-                                        },
-                                        "FloorId":"f5",
-                                        "Id":"49a886cb00df4d72ade2786d6536dc5a",
-                                        "IsPub":false,
-                                        "ProjectId":"1000423"
-                                    }
-                                ],
-                                "Id":"LCGN",
-                                "Name":"楼层功能"
-                            },
-                            {
-                                "Graphs":[
-                                    {
-                                        "BuildingId":"1",
-                                        "CategoryId":"XFXT",
-                                        "Floor":{
-                                            "Code":"F6",
-                                            "Gcode":"6F",
-                                            "Gname":"f6",
-                                            "Name":"第6层",
-                                            "Seq":600
-                                        },
-                                        "FloorId":"f6",
-                                        "Id":"4ae0893d48a249339f53883ac2cd1b36",
-                                        "IsPub":false,
-                                        "ProjectId":"1000423"
+                // 初始化数据
+                this.bindData = {HasPub: {}, NotPub: {}};
+                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;
+                        Object.keys(data).forEach(key => {
+                            if (data[key].length) {
+                                data[key].forEach(item => {
+                                    if (item.Id == "LCGN") { // 楼层功能
+                                        this.bindData[key].floor = {
+                                            Id: item.Id,
+                                            Name: item.Name,
+                                            FloorName: []
+                                        }
+                                        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);
+                                            })
+                                        }
+                                    } else if (item.Id == "XFBFYCFL" || item.Id == "FZQZL") { // 系统原理图
+                                        if (this.bindData[key].system) {
+                                            this.bindData[key].system.push({
+                                                Id: item.Id,
+                                                Name: item.Name,
+                                                FloorName: []
+                                            })
+                                        } else {
+                                            this.bindData[key].system = [{
+                                                Id: item.Id,
+                                                Name: item.Name,
+                                                FloorName: []
+                                            }]
+                                        }
+                                        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);
+                                            })
+                                        }
+                                    } else { // 设备设施
+                                        if (this.bindData[key].equip) {
+                                            this.bindData[key].equip.push({
+                                                Id: item.Id,
+                                                Name: item.Name,
+                                                FloorName: []
+                                            })
+                                        } else {
+                                            this.bindData[key].equip = [{
+                                                Id: item.Id,
+                                                Name: item.Name,
+                                                FloorName: []
+                                            }]
+                                        }
+                                        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);
+                                            })
+                                        }
                                     }
-                                ],
-                                "Id":"XFXT",
-                                "Name":"消防系统"
+                                })
                             }
-                        ]
-                    },
-                    "Message":"",
-                    "Result":"success"
-                }
-
+                        })
+                        this.visibleBind = true;
+                    } else {
+                        this.visible = false;
+                    }
+                })
+                console.log("bindData+++++++++++++++++++++++",this.bindData);
+                console.log("GraphsIdList++++++++++++++++++++",this.GraphsIdList);
             },
             handleCancel(e) {
                 this.visible = false;
@@ -391,7 +427,7 @@
                 console.log(lists);
                 bus.$emit('changeAttachObjectIds', lists, false)
             },
-            // 关闭批量绑定弹窗
+            // 关闭批量绑定弹窗(疑问,点击取消按钮是否要关闭第一个弹窗)
             handleClickCancel() {
                 this.visibleBind = false;
                 this.isRem = false;
@@ -406,11 +442,49 @@
             handleClickUntreated() {
                 this.$store.commit("setRememberBtn", "untreated");
                 this.visibleBind = false;
+                this.visible = false;
             },
             // 点击批量绑定按钮
-            handleClickBind() {
-                this.$store.commit("setRememberBtn", "bind");
-                this.visibleBind = false;
+            handleClickBind(Marked) {
+                const lists = [];
+                let params = {};
+                let arr = [];
+                arr = JSON.parse(JSON.stringify(this.arrList))
+                arr.map(item => {
+                    if (item.type=='Zone') {
+                        lists.push({id: item.location, name: item.wzjc , type: 'Zone'})
+                    }
+                    if (item.type=='Image') {
+                        lists.push({
+                            id: item.assetnum,
+                            name: item.sbjc,
+                            type: 'Image'
+                        })
+                    }
+                })
+                if (Marked) {
+                    this.$store.commit("setRememberBtn", "bind");
+                    params = {
+                        ProjectId: this.projectId,
+                        Marked: true, // Marked为true时传GraphIds字段,
+                        GraphIds: this.GraphsIdList,
+                        GraphElementName: this.GraphElementName,
+                        AttachObject: lists
+                    }
+                } else {
+                    params = {
+                        ProjectId: this.projectId,
+                        Marked: false, // Marked为false时不传GraphIds字段,
+                        GraphElementName: this.GraphElementName,
+                        AttachObject: lists
+                    }
+                }
+
+                bindAttachObject(params).then(res => {
+                    this.visibleBind = false;
+                    this.visible = false;
+                    this.$message.success("绑定成功!");
+                })
             },
             onSearch(value) {
                 this.queryGlsmsasset()
@@ -811,8 +885,10 @@
         created() {
             // 取gcname
             this.floorId = getUrlMsg().FloorID;
+            this.projectId = getUrlMsg().projectId;
             // 获取vuex的isRemember赋值给isRem
             this.isRem = this.isRemember;
+            this.GraphElementName = this.lengedName;
             //如果有专业就带过来
             if (this.GraphElementId) {
               this.tuijian();
@@ -950,6 +1026,43 @@
             }
         }
 
+        .bind-content {
+            max-height: 250px;
+            overflow-y: auto;
+            overflow-x: hidden;
+            .bind-box {
+                margin-top: 20px;
+                .bind-title {
+                    padding: 0 8px;
+                    height: 16px;
+                    line-height: 16px;
+                    border-left: 3px solid #0091FF;
+                    margin-bottom: 8px;
+                    font-size: 16px;
+                    font-family: MicrosoftYaHeiSemibold;
+                    color: #1f2429;
+                    font-weight: bold;
+                }
+                .bind-equip{
+                    display: flex;
+                    .bind-equip-title {
+                        white-space: nowrap;
+                    }
+                    .bind-equip-list {
+                        flex: 1;
+                        overflow: hidden;
+                        .bind-equip-item {
+                            cursor: pointer;
+                            white-space: nowrap;
+                            overflow: hidden;
+                            text-overflow: ellipsis;
+                        }
+                    }
+
+                }
+            }
+        }
+
         /deep/ .ant-input-affix-wrapper .ant-input-suffix {
             /*left: 12px;*/
             /*padding-right: 12px;*/