repetitionGraphy.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. },
  39. mounted() { },
  40. methods: {
  41. // 返回路由
  42. backRouter() {
  43. this.$router.push({ name: 'buildFloor' })
  44. },
  45. // 替换模型文件
  46. changeGraphy() {
  47. this.$refs.checkGraphy.showDialog({ FloorID: this.FloorID, BuildID: this.BuildID })
  48. },
  49. // 确认保存
  50. confirm() {
  51. let sceneMark = this.$refs.drawFloor.drawMainScene.sceneMark, Outline = null;
  52. if (sceneMark) {
  53. if (sceneMark.outLine.length < 3) {
  54. this.$message.warning('请添加轮廓线');
  55. return;
  56. }
  57. if (!sceneMark.closeFlag) {
  58. this.$message.warning('请按回车闭合轮廓线');
  59. this.$refs.drawFloor.focus();
  60. return;
  61. }
  62. Outline = this.$refs.drawFloor.drawMainScene.sceneMark.outLine
  63. Outline = Outline.map(t => {
  64. return {
  65. x: t.x.toFixed(2),
  66. y: -t.y.toFixed(2),
  67. }
  68. })
  69. }
  70. let pa = {
  71. Content: [{ FloorID: this.FloorID, Outline: Outline }],
  72. Projection: ['Outline']
  73. }
  74. floorUpdate(pa, res => {
  75. this.isEdit = false;
  76. this.$message.success("更新成功");
  77. })
  78. },
  79. // 取消
  80. cancel() {
  81. this.isEdit = false;
  82. this.$refs.drawFloor.init();
  83. },
  84. // 编辑平面图
  85. editGraphy() {
  86. this.isEdit = true;
  87. },
  88. // 替换模型文件成功
  89. refresh(modelId) {
  90. this.modelId = modelId
  91. }
  92. },
  93. watch: {
  94. modelId(n, o) {
  95. if (o && n != o) {
  96. this.$refs.drawFloor.initGraphy(n, 1)
  97. }
  98. }
  99. }
  100. };
  101. </script>
  102. <style lang="less">
  103. #repetitionGraphy {
  104. width: 100%;
  105. height: 100%;
  106. background: #fff;
  107. position: relative;
  108. padding: 10px;
  109. box-sizing: border-box;
  110. .drawImg {
  111. width: 100%;
  112. margin-top: 10px;
  113. height: calc(100% - 40px);
  114. }
  115. }
  116. </style>