repetitionGraphy.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. </div>
  11. <!-- 展示图片 -->
  12. <div class="drawImg">
  13. <drawFloor ref="drawFloor" :isEdit="isEdit" :showTools="true" :id="1"></drawFloor>
  14. </div>
  15. <!-- 查看图片弹窗 -->
  16. <checkGraphy ref="checkGraphy" @refresh="refresh"></checkGraphy>
  17. </div>
  18. </template>
  19. <script>
  20. import drawFloor from "./drawGraphy/drawFloor";
  21. import checkGraphy from "./drawGraphy/checkGraphy"; //查看图片
  22. import { floorUpdate } from "@/api/scan/request";
  23. export default {
  24. components: {
  25. drawFloor,
  26. checkGraphy
  27. },
  28. data() {
  29. return {
  30. modelId: "", //
  31. isEdit: false, // 是否编辑模式
  32. };
  33. },
  34. created() {
  35. this.modelId = this.$route.query.modelId;
  36. this.FloorID = this.$route.query.FloorID;
  37. this.BuildID = this.$route.query.BuildID;
  38. this.OutlineFlag = this.$route.query.OutlineFlag;
  39. },
  40. mounted() {
  41. this.$refs.drawFloor.initGraphy(this.modelId)
  42. },
  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.initGraphy(this.modelId)
  86. },
  87. // 编辑平面图
  88. editGraphy() {
  89. this.isEdit = true;
  90. },
  91. // 替换模型文件成功
  92. refresh(modelId) {
  93. this.modelId = modelId
  94. }
  95. },
  96. watch: {
  97. modelId(n, o) {
  98. if (o && n != o) {
  99. this.$refs.drawFloor.initGraphy(n)
  100. }
  101. }
  102. }
  103. };
  104. </script>
  105. <style lang="less">
  106. #repetitionGraphy {
  107. width: 100%;
  108. height: 100%;
  109. background: #fff;
  110. position: relative;
  111. padding: 10px;
  112. box-sizing: border-box;
  113. .drawImg {
  114. width: 100%;
  115. margin-top: 10px;
  116. height: calc(100% - 40px);
  117. }
  118. }
  119. </style>