repetitionGraphy.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <!-- 查看平面图页面 -->
  3. <div id="repetitionGraphy">
  4. <div class="buttons">
  5. <el-button icon="el-icon-back" size="mini" @click="backRouter"></el-button>
  6. <el-button v-if="!isEdit" size="mini" @click="changeGraphy">替换平面图</el-button>
  7. <el-button v-if="!isEdit" size="mini" @click="editGraphy">编辑平面图</el-button>
  8. <el-button v-if="isEdit" size="mini" @click="cancel">取消</el-button>
  9. <el-button v-if="isEdit" size="mini" @click="confirm" type="primary">确认</el-button>
  10. <span style="float:right;" v-if="file.FolderName">当前对应的模型文件:{{file.FolderName}}{{file.FloorName}}</span>
  11. </div>
  12. <!-- 展示图片 -->
  13. <div class="drawImg">
  14. <drawFloor ref="drawFloor" :isEdit="isEdit" :showTools="true" :id="1"></drawFloor>
  15. </div>
  16. <!-- 查看图片弹窗 -->
  17. <checkGraphy ref="checkGraphy" @refresh="refresh"></checkGraphy>
  18. </div>
  19. </template>
  20. <script>
  21. import drawFloor from "./drawGraphy/drawFloor";
  22. import checkGraphy from "./drawGraphy/checkGraphy"; //查看图片
  23. import { floorUpdate } from "@/api/scan/request";
  24. import { getFileNameById } from "@/api/model/file";
  25. export default {
  26. components: {
  27. drawFloor,
  28. checkGraphy
  29. },
  30. data() {
  31. return {
  32. // modelId: "", //
  33. isEdit: false, // 是否编辑模式
  34. };
  35. },
  36. created() {
  37. // this.modelId = this.$route.query.modelId;
  38. this.FloorID = this.$route.query.FloorID;
  39. this.BuildID = this.$route.query.BuildID;
  40. this.getFileName(this.modelId)
  41. },
  42. mounted() { },
  43. methods: {
  44. // 返回路由
  45. backRouter() {
  46. this.$router.push({ name: 'buildFloor' })
  47. },
  48. // 替换模型文件
  49. changeGraphy() {
  50. this.$refs.checkGraphy.showDialog({ FloorID: this.FloorID, BuildID: this.BuildID })
  51. },
  52. // 确认保存
  53. confirm() {
  54. let sceneMark = this.$refs.drawFloor.drawMainScene.sceneMark, Outline = null;
  55. if (sceneMark) {
  56. if (sceneMark.outLine.length < 3) {
  57. this.$message.warning('请添加轮廓线');
  58. return;
  59. }
  60. if (!sceneMark.closeFlag) {
  61. this.$message.warning('请按回车闭合轮廓线');
  62. this.$refs.drawFloor.focus();
  63. return;
  64. }
  65. Outline = this.$refs.drawFloor.drawMainScene.sceneMark.outLine
  66. Outline = Outline.map(t => {
  67. return {
  68. x: t.x.toFixed(2),
  69. y: -t.y.toFixed(2),
  70. }
  71. })
  72. }
  73. let pa = {
  74. Content: [{ FloorID: this.FloorID, Outline: Outline }],
  75. Projection: ['Outline']
  76. }
  77. floorUpdate(pa, res => {
  78. this.isEdit = false;
  79. this.$message.success("更新成功");
  80. })
  81. },
  82. // 取消
  83. cancel() {
  84. this.isEdit = false;
  85. this.$refs.drawFloor.init();
  86. },
  87. // 编辑平面图
  88. editGraphy() {
  89. this.isEdit = true;
  90. },
  91. // 替换模型文件成功
  92. refresh(modelId) {
  93. this.modelId = modelId;
  94. this.getFileName(this.modelId)
  95. },
  96. // 获取文件夹名称
  97. getFileName(modelId) {
  98. if (!modelId) return
  99. let pa = {
  100. Id: modelId
  101. }
  102. getFileNameById(pa, res => {
  103. this.file = res;
  104. })
  105. }
  106. },
  107. watch: {
  108. modelId(n, o) {
  109. if (o && n != o) {
  110. this.$refs.drawFloor.initGraphy(n, 1)
  111. }
  112. }
  113. }
  114. };
  115. </script>
  116. <style lang="less">
  117. #repetitionGraphy {
  118. width: 100%;
  119. height: 100%;
  120. background: #fff;
  121. position: relative;
  122. padding: 10px;
  123. box-sizing: border-box;
  124. .drawImg {
  125. width: 100%;
  126. margin-top: 10px;
  127. height: calc(100% - 40px);
  128. }
  129. }
  130. </style>