Explorar el Código

'树形数据处理'

zhangyu hace 4 años
padre
commit
82428b48e1
Se han modificado 1 ficheros con 112 adiciones y 0 borrados
  1. 112 0
      src/components/edit/edit-dialog.vue

+ 112 - 0
src/components/edit/edit-dialog.vue

@@ -249,6 +249,10 @@
                     HasPub: {},
                     NotPub: {}
                 },
+                bindTreeData: {
+                    HasPub: [],
+                    NotPub: []
+                },
                 GraphsIdList: []
             }
         },
@@ -335,6 +339,7 @@
             getBindGraphs() {
                 // 初始化数据
                 this.bindData = {HasPub: {}, NotPub: {}};
+                this.bindTreeData = {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))) {
@@ -343,19 +348,64 @@
                             if (data[key].length) {
                                 data[key].forEach(item => {
                                     if (item.Id == "LCGN") { // 楼层功能
+                                        /******************** */
+                                        this.bindTreeData[key].push({
+                                            id: item.Id,
+                                            label: item.Name,
+                                            children: []
+                                        })
+                                        /******************** */
+
+
                                         this.bindData[key].floor = {
                                             Id: item.Id,
                                             Name: item.Name,
                                             FloorName: []
                                         }
+                                        /*********************************** */
+                                        const floorTreeLast = this.bindTreeData[key][this.bindTreeData[key].length - 1];
+                                        /*********************************** */
                                         const floor = this.bindData[key].floor;
                                         if (item.Graphs.length) {
                                             item.Graphs.forEach(graph => {
+                                                /*********************** */
+                                                graph.label = graph.Floor.Code;
+                                                graph.id = graph.Id;
+                                                floorTreeLast.children.push(graph);
+                                                /*********************** */
+
+
+
                                                 floor.FloorName.push(graph.Floor.Code);
                                                 this.GraphsIdList.push(graph.Id);
                                             })
                                         }
                                     } else if (item.Id == "XFBFYCFL" || item.Id == "FZQZL") { // 系统原理图
+                                        /********************************** */
+                                        const index = this.bindTreeData[key].findIndex(item => {
+                                            return item.id == "XTYLT"
+                                        })
+                                        if (index != -1) {
+                                            this.bindTreeData[key][index].children.push({
+                                                id: item.Id,
+                                                label: item.Name,
+                                                children: []
+                                            })
+                                        } else {
+                                            this.bindTreeData[key].push({
+                                                id: "XTYLT",
+                                                label: "系统原理图",
+                                                children: [{
+                                                    id: item.Id,
+                                                    label: item.Name,
+                                                    children: []
+                                                }]
+                                            })
+                                        }
+                                        /*********************************** */
+
+
+
                                         if (this.bindData[key].system) {
                                             this.bindData[key].system.push({
                                                 Id: item.Id,
@@ -369,14 +419,57 @@
                                                 FloorName: []
                                             }]
                                         }
+                                        /*********************************** */
+                                        let system;
+                                        if (index != -1) {
+                                            system = this.bindTreeData[key][index];
+                                        } else {
+                                            system = this.bindTreeData[key][this.bindTreeData[key].length - 1];
+                                        }
+                                        const systemTreeLast = system.children[system.children.length - 1];
+                                        /*********************************** */
                                         const systemLast = this.bindData[key].system[this.bindData[key].system.length - 1];
                                         if (item.Graphs.length) {
                                             item.Graphs.forEach(graph => {
+                                                /*********************** */
+                                                graph.label = graph.Floor.Code;
+                                                graph.id = graph.Id;
+                                                systemTreeLast.children.push(graph);
+                                                /*********************** */
+                                                
+
+
                                                 systemLast.FloorName.push(graph.Floor.Code);
                                                 this.GraphsIdList.push(graph.Id);
                                             })
                                         }
                                     } else { // 设备设施
+                                        /********************************** */
+                                        const index = this.bindTreeData[key].findIndex(item => {
+                                            return item.id == "SBSS"
+                                        })
+                                        if (index != -1) {
+                                            this.bindTreeData[key][index].children.push({
+                                                id: item.Id,
+                                                label: item.Name,
+                                                children: []
+                                            })
+                                        } else {
+                                            this.bindTreeData[key].push({
+                                                id: "SBSS",
+                                                label: "设备设施",
+                                                children: [{
+                                                    id: item.Id,
+                                                    label: item.Name,
+                                                    children: []
+                                                }]
+                                            })
+                                        }
+                                        /*********************************** */
+
+
+
+
                                         if (this.bindData[key].equip) {
                                             this.bindData[key].equip.push({
                                                 Id: item.Id,
@@ -390,9 +483,27 @@
                                                 FloorName: []
                                             }]
                                         }
+                                        /*********************************** */
+                                        let equip;
+                                        if (index != -1) {
+                                            equip = this.bindTreeData[key][index];
+                                        } else {
+                                            equip = this.bindTreeData[key][this.bindTreeData[key].length - 1];
+                                        }
+                                        const equipTreeLast = equip.children[equip.children.length - 1];
+                                        /*********************************** */
                                         const equipLast = this.bindData[key].equip[this.bindData[key].equip.length - 1];
                                         if (item.Graphs.length) {
                                             item.Graphs.forEach(graph => {
+                                                /*********************** */
+                                                graph.label = graph.Floor.Code;
+                                                graph.id = graph.Id;
+                                                equipTreeLast.children.push(graph);
+                                                /*********************** */
+
+
+
+
                                                 equipLast.FloorName.push(graph.Floor.Code);
                                                 this.GraphsIdList.push(graph.Id);
                                             })
@@ -407,6 +518,7 @@
                     }
                 })
                 console.log("bindData+++++++++++++++++++++++",this.bindData);
+                console.log("bindTreeData+++++++++++++++++++++++",this.bindTreeData);
                 console.log("GraphsIdList++++++++++++++++++++",this.GraphsIdList);
             },
             handleCancel(e) {