checkGraphy.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <el-dialog id="checkGraphy" title="添加平面图" :visible.sync="checkGraphyVisible" width="900px" @close="handleClose">
  3. <div class="bodys">
  4. <el-cascader :options="options" :show-all-levels="false" @change="handleChange" @active-item-change='handleItemChange' clearable
  5. placeholder="请选择模型文件" v-model="casVal"></el-cascader>
  6. <div>
  7. <el-button type="text">上传图片</el-button>
  8. </div>
  9. <!-- 展示框 -->
  10. <div class="showBox">
  11. <drawFloor ref="drawFloorDialog" :showTools="false" :id="0" :dialog="true"></drawFloor>
  12. </div>
  13. </div>
  14. <span slot="footer" class="dialog-footer">
  15. <el-button @click="handleClose">取 消</el-button>
  16. <el-button type="primary" @click="bindGraphy">确 定</el-button>
  17. </span>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. import drawFloor from "./drawFloor";
  22. import { mapGetters, mapActions } from "vuex";
  23. import request from "@/api/model/file.js";
  24. import { bindFloorModel } from "@/api/model/file";
  25. export default {
  26. components: {
  27. drawFloor
  28. },
  29. computed: {
  30. ...mapGetters("layout", ["projectId"])
  31. },
  32. props: {
  33. alreadyRelatedModel: {
  34. default: []
  35. }
  36. },
  37. data() {
  38. return {
  39. casVal: [],
  40. jsonKey: "", //map.josn
  41. checkGraphyVisible: false,
  42. options: [],
  43. floor: {}, // 当前选中的楼层数据
  44. modelIdToFloorId: {}
  45. };
  46. },
  47. methods: {
  48. // 弹窗显示
  49. showDialog(floor) {
  50. this.floor = floor;
  51. this.checkGraphyVisible = true;
  52. },
  53. // 关闭弹窗
  54. handleClose() {
  55. this.checkGraphyVisible = false;
  56. this.casVal = []
  57. this.$refs.drawFloorDialog.clearGraphy()
  58. },
  59. // 更新楼层 平面图文件
  60. bindGraphy() {
  61. if (!this.jsonKey) {
  62. this.$message.warning("请选择模型文件");
  63. return
  64. }
  65. if (this.alreadyRelatedModel.indexOf(this.jsonKey) > -1) {
  66. this.$message.warning('此模型已关联该建筑下的楼层');
  67. return;
  68. }
  69. let pa = {
  70. FloorId: this.floor.FloorID,
  71. Id: this.modelIdToFloorId[this.jsonKey],
  72. BuildingId: this.floor.BuildID,
  73. Cover: true
  74. };
  75. bindFloorModel(pa, res => {
  76. this.$message.success("更新成功");
  77. this.handleClose()
  78. this.$emit('refresh', this.jsonKey)
  79. });
  80. },
  81. // 点击多级联动
  82. handleChange(val) {
  83. this.$refs.drawFloorDialog.initGraphy(val[1], 1)
  84. this.jsonKey = val[1]
  85. },
  86. // 通过id查询文件夹下模型文件
  87. handleItemChange(val) {
  88. let data = {
  89. FolderId: val[0],
  90. Status: '4',
  91. ProjectId: this.projectId
  92. };
  93. request.queryFloorList(data, res => {
  94. let tempArr = res.Content.map(t => {
  95. this.modelIdToFloorId[t.CurrentModelId] = t.Id;
  96. return {
  97. value: t.CurrentModelId,
  98. label: t.FloorName
  99. }
  100. })
  101. this.pushChild(this.options, tempArr, val[0])
  102. })
  103. },
  104. // 将模型文件list填到相应的文件夹下
  105. pushChild(options, arr, Code) {
  106. options.map(option => {
  107. if (option.value == Code) {
  108. option.children = arr;
  109. } else {
  110. if (option.children) {
  111. this.pushChild(option.children, arr, Code)
  112. }
  113. }
  114. }) },
  115. init() {
  116. this.getDirectory()
  117. },
  118. // 获取文件夹
  119. getDirectory() {
  120. request.queryModel("", res => {
  121. this.options = res.Content.map(t => {
  122. return {
  123. value: t.Id,
  124. label: t.Name,
  125. children: []
  126. }
  127. })
  128. });
  129. },
  130. },
  131. created() {
  132. this.init()
  133. },
  134. watch: {
  135. projectId() {
  136. this.init()
  137. }
  138. }
  139. };
  140. </script>
  141. <style lang="less">
  142. #checkGraphy {
  143. .bodys {
  144. .showBox {
  145. box-sizing: border-box;
  146. width: 100%;
  147. height: 300px;
  148. border: 1px #ccc solid;
  149. padding: 10px;
  150. }
  151. }
  152. }
  153. </style>