noModelDialog.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <el-dialog
  3. :visible.sync="isShow.dialogVisible"
  4. :close-on-click-modal="false"
  5. :close-on-press-escape="false"
  6. :show-close="false"
  7. :width="width"
  8. >
  9. <span slot="title">{{title}}</span>
  10. <!-- <slot name="body"></slot> -->
  11. <el-tree :props="treeArr" :data="data" @node-click="floorClick" :highlight-current="true"></el-tree>
  12. <span slot="footer" class="dialog-footer my">
  13. <el-button @click="close">取 消</el-button>
  14. <el-button type="primary" @click="confirm">确 定</el-button>
  15. </span>
  16. </el-dialog>
  17. </template>
  18. <script>
  19. import {
  20. getBuildSelect, //根据项目ID获得建筑列表
  21. getSpaceFloor //根据建筑id获取楼层id
  22. } from "@/api/scan/request";
  23. import tools from '@/utils/scan/tools'
  24. import {
  25. mapGetters,
  26. mapActions
  27. } from "vuex";
  28. export default {
  29. props: {
  30. width: {
  31. type: String,
  32. default: "40%"
  33. },
  34. title: {
  35. type: String,
  36. default: "头部信息"
  37. },
  38. isShow: {
  39. type: Object
  40. },
  41. param: {
  42. type: Object
  43. }
  44. },
  45. computed: {
  46. ...mapGetters("peojMess", [
  47. "projectId",
  48. "secret",
  49. "userId"
  50. ])
  51. },
  52. data() {
  53. return {
  54. treeArr: {
  55. label: "name", //label的名字
  56. children: "children", //如果有下一级children和isLeaf存在
  57. },
  58. data: null,
  59. proj: null,
  60. mess: null
  61. };
  62. },
  63. created() {
  64. this.getNodes()
  65. },
  66. methods: {
  67. //确定
  68. confirm() {
  69. if (!!this.mess) {
  70. this.isShow.dialogVisible = false;
  71. this.$emit("close", this.mess);
  72. } else {
  73. this.$message("请选择楼层");
  74. }
  75. },
  76. //取消
  77. close() {
  78. if (!!this.mess) {
  79. this.isShow.dialogVisible = false;
  80. } else {
  81. this.$message("请选择楼层");
  82. }
  83. },
  84. changeArr(arr) {
  85. return arr.map(item => {
  86. if (item.floors && item.floors.length) {
  87. return {
  88. code: item.id,
  89. name: item.infos.BuildLocalName,
  90. children: item.floors.map(i => {
  91. return {
  92. code: i.id,
  93. name: (i.infos.FloorLocalName || i.infos.FloorName || "未知") + this.myMess(i),
  94. map: i.infos.FloorMap || null,
  95. affected: i.affected,
  96. isChilren: 2,
  97. buildCode: item.id,
  98. buildName: item.infos.BuildLocalName,
  99. shunxu: i.infos.FloorSequenceID || 0
  100. }
  101. })
  102. }
  103. } else {
  104. return {
  105. code: item.id,
  106. name: item.infos.BuildLocalName,
  107. children: null,
  108. isChilren: 1,
  109. }
  110. }
  111. })
  112. },
  113. myMess(i) {
  114. if (i.affected) {
  115. return "(该业务空间受元空间变化影响)"
  116. } else {
  117. if (i.infos.FloorMap) {
  118. return ''
  119. } else {
  120. return "(请初始化平面图)"
  121. }
  122. }
  123. },
  124. //点击节点懒加载
  125. getNodes() {
  126. let param = {
  127. ProjId: this.projectId,
  128. UserId: this.UserId,
  129. secret: this.secret
  130. };
  131. getSpaceFloor(param).then(res => {
  132. if (res.data.Result == 'success') {
  133. let data = this.changeArr(res.data.Content).map(item => {
  134. if (item.children && item.children.length) {
  135. item.children = tools.sortArr(item.children, "shunxu", false)
  136. }
  137. return item
  138. })
  139. this.data = data
  140. } else {
  141. this.$message.error(res.data.ResultMsg)
  142. }
  143. }).catch(() => {
  144. this.$message.error("请求出错")
  145. })
  146. },
  147. //子节点被点击
  148. floorClick(data) {
  149. if (data.isChilren == 2) {
  150. this.mess = data
  151. } else { }
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. </style>