Browse Source

业务空间

haojianlong 4 years ago
parent
commit
ae660b8fe6
2 changed files with 203 additions and 148 deletions
  1. 7 2
      src/views/maintain/space/components/spaceGraph.vue
  2. 196 146
      src/views/maintain/space/index.vue

+ 7 - 2
src/views/maintain/space/components/spaceGraph.vue

@@ -125,8 +125,13 @@ export default class spaceGraph extends Vue {
         this.canvasLoading = true;
         if (floor.infos && floor.infos.floorMap) {
             this.floor = floor;
-            this.floorKey = this.mapBaseUrl + floor.infos.floorMap;
-            this.init(1);
+            const url = this.mapBaseUrl + floor.infos.floorMap
+            if (url == this.floorKey) {
+                this.init(2)
+            } else {
+                this.floorKey = this.mapBaseUrl + floor.infos.floorMap;
+                this.init(1);
+            }
         } else {
             this.noMap();
         }

+ 196 - 146
src/views/maintain/space/index.vue

@@ -10,10 +10,14 @@
             <div class="tab-content">
                 <div class="search" :class="{ 'borderBottom': activeName==='picture' }">
                     <el-cascader clearable ref="floorCascader" placeholder="请选择建筑楼层" :options="options" v-model="building" filterable size="small"
-                        @change="changeCascader" style="margin-right: 12px"></el-cascader>
+                        @change="changeCascader" style="margin-right: 12px" v-if="activeName==='table'"></el-cascader>
+                    <admSearch @SearchValue="searchValue" class="item" v-if="activeName==='table'" />
+
+                    <el-cascader clearable ref="floorCascader" placeholder="请选择建筑楼层" :options="graphOptions" v-model="graphBuilding" filterable
+                        size="small" @change="changeGraphCascader" style="margin-right: 12px" v-if="activeName==='picture'" :props="graphProps">
+                    </el-cascader>
                     <el-cascader v-model="zoneTypeVal" :options="zoneTypeOption" @change="changeZoneType" placeholder="请选择分区" class="item"
                         v-if="activeName==='picture'"></el-cascader>
-                    <admSearch @SearchValue="searchValue" class="item" v-if="activeName==='table'" />
                 </div>
                 <div v-if="activeName==='table'" v-loading="loading" style="height: calc(100% - 100px);padding: 0 12px">
                     <template style="height: 100%;" v-if="building.length > 0">
@@ -37,9 +41,20 @@
 
 <script lang="ts">
 import { Component, Vue } from "vue-property-decorator";
-import { AdmMultiTable, AdmSearch, Pagination, Statistics, } from "../components/index";
+import {
+    AdmMultiTable,
+    AdmSearch,
+    Pagination,
+    Statistics,
+} from "../components/index";
 import spaceGraph from "./components/spaceGraph.vue";
-import { buildingQuery, dictQuery, floorQuery, queryCountSpace, queryZone, } from "@/api/datacenter";
+import {
+    buildingQuery,
+    dictQuery,
+    floorQuery,
+    queryCountSpace,
+    queryZone,
+} from "@/api/datacenter";
 import tools from "@/utils/maintain";
 import { BeatchQueryParam } from "@/api/equipComponent";
 import { UserModule } from "@/store/modules/user";
@@ -65,7 +80,7 @@ export default class spaceIndex extends Vue {
     activeName = "table";
     building = ["all"];
 
-    zoneTypeVal = ['GeneralZone'];
+    zoneTypeVal = ["GeneralZone"];
     // 分页
     private paginationList = {
         page: 1,
@@ -74,6 +89,7 @@ export default class spaceIndex extends Vue {
         total: 0,
     };
     options = [];
+    graphOptions = [];
     zoneTypeOption = [
         {
             value: "GeneralZone",
@@ -106,6 +122,12 @@ export default class spaceIndex extends Vue {
     // 楼层映射
     floorToMap = {};
     //
+    graphProps = {
+        label: "localName",
+        value: "id",
+        children: "floor",
+    };
+    //
     // 项目id
     private get projectId(): string {
         return UserModule.projectId;
@@ -152,7 +174,7 @@ export default class spaceIndex extends Vue {
         Promise.all([promise1, promise2]).then((values) => {
             let buildData = values[0].content,
                 floorData = values[1].content;
-                this.floorToMap = {};
+            this.floorToMap = {};
             data = buildData.map((build) => {
                 return {
                     value: build.id,
@@ -210,6 +232,32 @@ export default class spaceIndex extends Vue {
             });
             this.options = data;
         });
+
+        const pa = {
+            pageSize: 1000,
+            orders: "localName asc",
+            cascade: [{ name: "floor", orders: "floorSequenceId desc" }],
+        };
+        buildingQuery(pa).then((res) => {
+            try {
+                this.graphOptions = res.content.map((t) => {
+                    if (!t.floor) {
+                        t.floor = [];
+                    }
+                    return t;
+                });
+            } catch (err) {
+                this.graphOptions = [];
+            }
+            if (this.graphOptions.length) {
+                if (this.graphOptions[0].floor.length) {
+                    this.graphBuilding = [
+                        this.graphOptions[0].id,
+                        this.graphOptions[0].floor[0].id,
+                    ];
+                }
+            }
+        });
     }
 
     //改变楼层
@@ -218,150 +266,149 @@ export default class spaceIndex extends Vue {
         // if (value && value.length > 0  && this.building[0] != 'all') {
         //     this.buildingLabel = this.$refs['floorCascader'].getCheckedNodes()[0].pathLabels
         // }
-        if (this.activeName == 'table') {
-            if (this.building.length > 0) {
-                this.loading = true;
-                let param = {
-                    type: "FunctionZone",
-                    orders: "sort asc, name desc",
-                    pageNumber: 1,
-                    pageSize: 1000,
-                };
-                let param2 = {
-                    // 级联查建筑楼层信息
-                    cascade: [
-                        { name: "building" },
-                        { name: "floor", orders: "floorSequenceId desc" },
-                    ],
-                    zoneType: "FunctionZone",
-                    pageNumber: this.paginationList.page,
-                    pageSize: this.paginationList.size,
-                    orders: "createTime desc, localName desc, localId desc, id asc",
-                };
+        if (this.building.length > 0) {
+            this.loading = true;
+            let param = {
+                type: "FunctionZone",
+                orders: "sort asc, name desc",
+                pageNumber: 1,
+                pageSize: 1000,
+            };
+            let param2 = {
+                // 级联查建筑楼层信息
+                cascade: [
+                    { name: "building" },
+                    { name: "floor", orders: "floorSequenceId desc" },
+                ],
+                zoneType: "FunctionZone",
+                pageNumber: this.paginationList.page,
+                pageSize: this.paginationList.size,
+                orders: "createTime desc, localName desc, localId desc, id asc",
+            };
 
-                if (this.building.length === 1) {
-                    param2.filters = "";
-                    switch (this.building[0]) {
-                        case "noKnow":
-                            param2.filters = `buildingId='isnull'`;
-                            break;
-                        case "all":
-                            delete param2.filters;
+            if (this.building.length === 1) {
+                param2.filters = "";
+                switch (this.building[0]) {
+                    case "noKnow":
+                        param2.filters = `buildingId='isnull'`;
+                        break;
+                    case "all":
+                        delete param2.filters;
 
-                            break;
-                    }
-                } else if (this.building.length === 2) {
-                    switch (this.building[1]) {
-                        case "noKnow":
-                            param2.filters = `buildingId='${this.building[0]}';floorId='isnull'`;
+                        break;
+                }
+            } else if (this.building.length === 2) {
+                switch (this.building[1]) {
+                    case "noKnow":
+                        param2.filters = `buildingId='${this.building[0]}';floorId='isnull'`;
 
-                            break;
-                        case "all":
-                            param2.filters = `buildingId='${this.building[0]}'`;
-                            break;
-                        default:
-                            param2.filters = `buildingId='${this.building[0]}';floorId='${this.building[1]}'`;
-                    }
+                        break;
+                    case "all":
+                        param2.filters = `buildingId='${this.building[0]}'`;
+                        break;
+                    default:
+                        param2.filters = `buildingId='${this.building[0]}';floorId='${this.building[1]}'`;
                 }
+            }
 
-                let promise = new Promise((resolve) => {
-                    dictQuery(param).then((res) => {
-                        resolve(res);
-                    });
+            let promise = new Promise((resolve) => {
+                dictQuery(param).then((res) => {
+                    resolve(res);
                 });
-                let promise2 = new Promise((resolve) => {
-                    queryZone(param2).then((res) => {
-                        resolve(res);
-                    });
+            });
+            let promise2 = new Promise((resolve) => {
+                queryZone(param2).then((res) => {
+                    resolve(res);
+                });
+            });
+            Promise.all([promise, promise2]).then((res) => {
+                let tableData = [];
+                this.loading = false;
+                // 类型下信息点,重组数据
+                let basicInfos = [],
+                    dictStages = [];
+                this.all = res[0].content;
+                res[0].content.forEach((item) => {
+                    let i = ["localName", "localId", "building", "floor"];
+                    if (i.includes(item.path)) {
+                        basicInfos.push(item);
+                    } else {
+                        dictStages.push(item);
+                    }
+                });
+                dictStages.map((val, index) => {
+                    val.name = val.unit ? `${val.name}(${val.unit})` : val.name;
+                    if (val.path == "outline") {
+                        dictStages.splice(index, 1);
+                    }
+                    return val;
+                });
+                basicInfos.map((item) => {
+                    if (item.path == "building") {
+                        item.path = "buildingSign";
+                    }
+                    if (item.path == "floor") {
+                        item.path = "floorSign";
+                    }
+                    return item;
                 });
-                Promise.all([promise, promise2]).then((res) => {
-                    let tableData = [];
-                    this.loading = false;
-                    // 类型下信息点,重组数据
-                    let basicInfos = [],
-                        dictStages = [];
-                    this.all = res[0].content;
-                    res[0].content.forEach((item) => {
-                        let i = ["localName", "localId", "building", "floor"];
-                        if (i.includes(item.path)) {
-                            basicInfos.push(item);
-                        } else {
-                            dictStages.push(item);
-                        }
-                    });
-                    dictStages.map((val,index) => {
-                        val.name = val.unit ? `${ val.name }(${ val.unit })` : val.name
-                        if (val.path == 'outline') {
-                            dictStages.splice(index,1)
-                        }
-                        return val
-                    })
-                    basicInfos.map((item) => {
-                        if (item.path == "building") {
-                            item.path = "buildingSign";
-                        }
-                        if (item.path == "floor") {
-                            item.path = "floorSign";
-                        }
-                        return item;
-                    });
 
-                    this.headersStage = {
-                        basicInfos: {
-                            name: "模型解析",
-                            data: basicInfos,
-                        },
-                        dictStages: {
-                            name: "租赁系统",
-                            data: dictStages,
-                        },
-                    };
-                    this.paginationList.total = res[1].total;
-                    tableData = res[1].content; // 主体数据
-                    // 处理 outline BIM模型中轮廓坐标 展示
-                    // 添加建筑,楼层展示(从下拉框获取)
-                    this.tableData = tableData.map((item) => {
-                        if (item.building) {
-                            item.buildingSign = item.building.localName;
-                        }
-                        if (item.floor) {
-                            item.floorSign = item.floor.localName;
-                        }
-                        // 删除轮廓线
-                        if (item.outline) {
-                            delete item.outline
-                        }
-                        // item = {
-                        //     ...item,
-                        //     outline: JSON.stringify(item.outline),
-                        // };
-                        return item;
-                    });
-                    //  列表信息展示,获取动态数据
-                    this.codeToDataSource = {};
-                    this.all.forEach((item) => {
-                        if (item.dataSource) {
-                            try {
-                                this.codeToDataSource[item.code] = {};
-                                item.dataSource.forEach((dic) => {
-                                    this.codeToDataSource[item.code][dic.code] =
-                                        dic.name;
-                                });
-                            } catch (e) {
-                                console.log(e);
-                            }
+                this.headersStage = {
+                    basicInfos: {
+                        name: "模型解析",
+                        data: basicInfos,
+                    },
+                    dictStages: {
+                        name: "租赁系统",
+                        data: dictStages,
+                    },
+                };
+                this.paginationList.total = res[1].total;
+                tableData = res[1].content; // 主体数据
+                // 处理 outline BIM模型中轮廓坐标 展示
+                // 添加建筑,楼层展示(从下拉框获取)
+                this.tableData = tableData.map((item) => {
+                    if (item.building) {
+                        item.buildingSign = item.building.localName;
+                    }
+                    if (item.floor) {
+                        item.floorSign = item.floor.localName;
+                    }
+                    // 删除轮廓线
+                    if (item.outline) {
+                        delete item.outline;
+                    }
+                    // item = {
+                    //     ...item,
+                    //     outline: JSON.stringify(item.outline),
+                    // };
+                    return item;
+                });
+                //  列表信息展示,获取动态数据
+                this.codeToDataSource = {};
+                this.all.forEach((item) => {
+                    if (item.dataSource) {
+                        try {
+                            this.codeToDataSource[item.code] = {};
+                            item.dataSource.forEach((dic) => {
+                                this.codeToDataSource[item.code][dic.code] =
+                                    dic.name;
+                            });
+                        } catch (e) {
+                            console.log(e);
                         }
-                    });
-                    this.getBatch(this.tableData);
+                    }
                 });
-            } else {
-                console.log("void");
-            }
-        } else if (this.activeName == 'picture') {
-            this.toGraph()
+                this.getBatch(this.tableData);
+            });
+        } else {
+            console.log("void");
         }
     }
-
+    // 图建筑楼层修改
+    changeGraphCascader(value) {
+        this.toGraph();
+    }
     // 动态信息点
     getBatch(data) {
         let param = {
@@ -426,9 +473,9 @@ export default class spaceIndex extends Vue {
             });
         }
     }
-
+    // 修改分区类型
     changeZoneType(val) {
-        console.log(val);
+        this.toGraph()
     }
 
     // 当前分页
@@ -452,19 +499,22 @@ export default class spaceIndex extends Vue {
     tabChange() {
         if (this.activeName == "picture") {
             this.$nextTick(() => {
-                this.toGraph()
+                this.toGraph();
             });
         }
     }
 
     // 切换至图
     toGraph() {
-        if (this.building.length) {
+        if (this.graphBuilding.length) {
             if (
-                this.building.indexOf("noKnow") < 0 &&
-                this.building.indexOf("all") < 0
+                this.graphBuilding.indexOf("noKnow") < 0 &&
+                this.graphBuilding.indexOf("all") < 0
             ) {
-                this.$refs.spaceGraph.getData(this.floorToMap[this.building[1]], this.zoneTypeVal);
+                this.$refs.spaceGraph.getData(
+                    this.floorToMap[this.graphBuilding[1]],
+                    this.zoneTypeVal
+                );
             } else {
                 this.$refs.spaceGraph.noMap();
             }
@@ -518,7 +568,7 @@ export default class spaceIndex extends Vue {
                     margin-left: 16px;
                 }
             }
-            .borderBottom{
+            .borderBottom {
                 border-bottom: 1px solid #e1e7ea;
             }
             .graph {