123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <el-dialog
- :visible.sync="isShow.dialogVisible"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :show-close="false"
- :width="width"
- >
- <span slot="title">{{title}}</span>
- <!-- <slot name="body"></slot> -->
- <el-tree :props="treeArr" :data="data" @node-click="floorClick" :highlight-current="true"></el-tree>
- <span slot="footer" class="dialog-footer my">
- <el-button @click="close">取 消</el-button>
- <el-button type="primary" @click="confirm">确 定</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import {
- getBuildSelect, //根据项目ID获得建筑列表
- getSpaceFloor //根据建筑id获取楼层id
- } from "@/api/scan/request";
- import tools from '@/utils/scan/tools'
- import {
- mapGetters,
- mapActions
- } from "vuex";
- export default {
- props: {
- width: {
- type: String,
- default: "40%"
- },
- title: {
- type: String,
- default: "头部信息"
- },
- isShow: {
- type: Object
- },
- param: {
- type: Object
- }
- },
- computed: {
- ...mapGetters("peojMess", [
- "projectId",
- "secret",
- "userId"
- ])
- },
- data() {
- return {
- treeArr: {
- label: "name", //label的名字
- children: "children", //如果有下一级children和isLeaf存在
- },
- data: null,
- proj: null,
- mess: null
- };
- },
- created() {
- this.getNodes()
- },
- methods: {
- //确定
- confirm() {
- if (!!this.mess) {
- this.isShow.dialogVisible = false;
- this.$emit("close", this.mess);
- } else {
- this.$message("请选择楼层");
- }
- },
- //取消
- close() {
- if (!!this.mess) {
- this.isShow.dialogVisible = false;
- } else {
- this.$message("请选择楼层");
- }
- },
- changeArr(arr) {
- return arr.map(item => {
- if (item.floors && item.floors.length) {
- return {
- code: item.id,
- name: item.infos.BuildLocalName,
- children: item.floors.map(i => {
- return {
- code: i.id,
- name: (i.infos.FloorLocalName || i.infos.FloorName || "未知") + this.myMess(i),
- map: i.infos.FloorMap || null,
- affected: i.affected,
- isChilren: 2,
- buildCode: item.id,
- buildName: item.infos.BuildLocalName,
- shunxu: i.infos.FloorSequenceID || 0
- }
- })
- }
- } else {
- return {
- code: item.id,
- name: item.infos.BuildLocalName,
- children: null,
- isChilren: 1,
- }
- }
- })
- },
- myMess(i) {
- if (i.affected) {
- return "(该业务空间受元空间变化影响)"
- } else {
- if (i.infos.FloorMap) {
- return ''
- } else {
- return "(请初始化平面图)"
- }
- }
- },
- //点击节点懒加载
- getNodes() {
- let param = {
- ProjId: this.projectId,
- UserId: this.UserId,
- secret: this.secret
- };
- getSpaceFloor(param).then(res => {
- if (res.data.Result == 'success') {
- let data = this.changeArr(res.data.Content).map(item => {
- if (item.children && item.children.length) {
- item.children = tools.sortArr(item.children, "shunxu", false)
- }
- return item
- })
- this.data = data
- } else {
- this.$message.error(res.data.ResultMsg)
- }
- }).catch(() => {
- this.$message.error("请求出错")
- })
- },
- //子节点被点击
- floorClick(data) {
- if (data.isChilren == 2) {
- this.mess = data
- } else { }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
|