repetitionGraphy.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. <template v-if="!hasGraph">
  7. <el-button size='mini' @click='changeGraphy'>{{hasModel?'关联模型文件':'上传平面图图片'}}</el-button>
  8. </template>
  9. <template v-else>
  10. <el-button v-if='!isEdit' size='mini' @click='changeGraphy'>替换平面图</el-button>
  11. <el-button v-if='(sign||otherSign)&&!isEdit' size='mini' @click='editGraphy'>编辑平面图</el-button>
  12. <el-button v-if='isEdit' size='mini' @click='cancel'>取消</el-button>
  13. <el-button v-if='isEdit' size='mini' @click='confirm' type='primary'>确认</el-button>
  14. </template>
  15. <span style='float:right;' v-if='file.FolderName'>当前对应的模型文件:{{file.FolderName}} - {{file.FloorName}}</span>
  16. </div>
  17. <!-- 展示图片 -->
  18. <div class='drawImg'>
  19. <div style="width: 100%;height: 100%" v-if="hasGraph">
  20. <drawFloor ref='drawFloor' :isEdit='isEdit' :showTools='true' :id='1' @changeSign='changeSign'></drawFloor>
  21. </div>
  22. <div style="width: 100%;height: 100%" v-else>
  23. <div class="center" style="padding-top: 300px">
  24. <i class="icon-wushuju iconfont"></i>暂无平面图
  25. </div>
  26. </div>
  27. </div>
  28. <!-- 查看图片弹窗 -->
  29. <checkGraphy ref='checkGraphy' @refresh='refresh' :alreadyRelatedModel='alreadyRelatedModel' @hasModel="getCount"></checkGraphy>
  30. </div>
  31. </template>
  32. <script>
  33. import drawFloor from './drawGraphy/drawFloor'
  34. import checkGraphy from './drawGraphy/checkGraphy' //查看图片
  35. import { floorUpdateOutline, floorQueryAndSign } from '@/api/scan/request'
  36. import { getFileNameById } from '@/api/model/file'
  37. export default {
  38. components: {
  39. drawFloor,
  40. checkGraphy,
  41. },
  42. data() {
  43. return {
  44. modelId: '', //
  45. isEdit: false, // 是否编辑模式
  46. file: {},
  47. alreadyRelatedModel: [],
  48. sign: false,
  49. otherSign: false,
  50. hasGraph: false, // 当前楼层是否有平面图
  51. hasModel: false, // 项目中时候有模型文件
  52. }
  53. },
  54. created() {
  55. this.modelId = this.$route.query.modelId
  56. this.FloorID = this.$route.query.FloorID
  57. this.BuildID = this.$route.query.BuildID
  58. this.BuildName = this.$route.query.BuildName
  59. if (this.modelId != '') {
  60. this.hasGraph = true;
  61. const temp = this.modelId.split('.');
  62. if (temp.length > 1 && (temp[1] == 'png' || temp[1] == 'jpg')) {
  63. return
  64. } else {
  65. this.init()
  66. }
  67. } else {
  68. this.hasGraph = false;
  69. }
  70. },
  71. mounted() {},
  72. methods: {
  73. init() {
  74. this.getFileName(this.modelId)
  75. this.getFloorData()
  76. },
  77. // 返回路由
  78. backRouter() {
  79. this.$router.push({ name: 'buildFloor' })
  80. },
  81. // 替换模型文件
  82. changeGraphy() {
  83. this.$refs.checkGraphy.showDialog({ FloorID: this.FloorID, BuildID: this.BuildID })
  84. },
  85. // 确认保存
  86. confirm() {
  87. let sceneMark = this.$refs.drawFloor.drawMainScene.sceneMark,
  88. Outline = null
  89. if (sceneMark) {
  90. if (sceneMark.outLine.length < 3) {
  91. this.$message.warning('请添加轮廓线')
  92. return
  93. }
  94. if (!sceneMark.closeFlag) {
  95. this.$message.warning('请按回车闭合轮廓线')
  96. this.$refs.drawFloor.focus()
  97. return
  98. }
  99. Outline = this.$refs.drawFloor.drawMainScene.sceneMark.outLine
  100. Outline = Outline.map((t) => {
  101. return {
  102. x: t.x.toFixed(2),
  103. y: -t.y.toFixed(2),
  104. }
  105. })
  106. }
  107. let pa = {
  108. Content: [{ FloorID: this.FloorID, Outline: Outline }],
  109. Projection: ['Outline'],
  110. }
  111. floorUpdateOutline(pa, (res) => {
  112. this.isEdit = false
  113. this.$message.success('更新成功')
  114. })
  115. },
  116. // 取消
  117. cancel() {
  118. this.isEdit = false
  119. this.$refs.drawFloor.init()
  120. },
  121. // 编辑平面图
  122. editGraphy() {
  123. this.isEdit = true
  124. },
  125. // 替换模型文件成功
  126. refresh(modelId) {
  127. this.modelId = modelId
  128. this.hasGraph = true;
  129. const temp = this.modelId.split('.');
  130. if (temp[1] && temp[1] != 'png' && temp[1] != 'jpg') {
  131. this.getFileName(this.modelId)
  132. }
  133. },
  134. // 获取文件夹名称
  135. getFileName(modelId) {
  136. if (!modelId) return
  137. let pa = {
  138. Id: modelId,
  139. }
  140. getFileNameById(pa, (res) => {
  141. this.file = res
  142. })
  143. },
  144. // 获取楼层
  145. getFloorData() {
  146. let floorParam = {
  147. PageSize: 1000,
  148. Filters: `BuildID='${this.BuildID}'`,
  149. }
  150. floorQueryAndSign(floorParam, (res) => {
  151. this.alreadyRelatedModel = res.Content.map((t) => {
  152. if (t.FloorID != this.FloorID) return t.ModelId
  153. this.sign = t.Sign > 0
  154. this.FloorName = t.FloorLocalName || t.FloorName
  155. this.$refs.drawFloor.buildFloorName = `${this.BuildName}-${this.FloorName}`
  156. }).filter((t) => t)
  157. })
  158. },
  159. changeSign(flag) {
  160. this.otherSign = flag
  161. },
  162. // 当前项目中是否有模型文件
  163. getCount(flag) {
  164. this.hasModel = flag;
  165. }
  166. },
  167. watch: {
  168. modelId(n, o) {
  169. if (n != o) {
  170. if (n) {
  171. if (n.split('.')[1].toString() == 'png' || n.split('.')[1].toString() == 'jpg') {
  172. this.$refs.drawFloor.initGraphy(n, 3)
  173. } else {
  174. this.$refs.drawFloor.initGraphy(n, 1)
  175. }
  176. }
  177. }
  178. },
  179. },
  180. }
  181. </script>
  182. <style lang="less">
  183. #repetitionGraphy {
  184. width: 100%;
  185. height: 100%;
  186. background: #fff;
  187. position: relative;
  188. padding: 10px;
  189. box-sizing: border-box;
  190. .drawImg {
  191. width: 100%;
  192. margin-top: 10px;
  193. height: calc(100% - 40px);
  194. }
  195. }
  196. </style>