index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. (() => {
  2. Vue.component('uploadTitlemap', {
  3. props: [],
  4. name: 'uploadTitlemap',
  5. template: ` <div id="planePic"">
  6. <div class="headerBack">
  7. <div class="topBox">
  8. <i class="backIcon" @click="back"></i>
  9. <p class="headerTitle">平面图</p>
  10. </div>
  11. <el-switch v-model="showMapPic" @change="changeDisplay" active-color="#15BEC8" inactive-color="#999">
  12. </el-switch>
  13. </div>
  14. <div class="defaultPic itemBox" :class="type==0 ?'active':''">
  15. <div class="ctrlBox">
  16. <div class="ctrlTitle">
  17. 默认平面图
  18. <div class="tipBox" title="修改点云或数据集后,请更新平面图"></div>
  19. </div>
  20. <!-- <p>默认平面图</p> -->
  21. <el-popconfirm placement="top" title="系统将创建新的平面图,您上传的平面图将被清除,是否继续?" :hide-icon="true" @confirm="refreshConfirm">
  22. <el-button slot="reference">
  23. <div class="ctrlBtn">
  24. <i class="ctrlIcon refreshIcon"></i>
  25. <p class="ctrlText">更新</p>
  26. </div>
  27. </el-button>
  28. </el-popconfirm>
  29. </div>
  30. </div>
  31. <div class="diyPic itemBox " :class=" type==1 ?'active':''">
  32. <div class="ctrlBox">
  33. <p class="ctrlTitle">自定义平面图</p>
  34. <div class="btnBox">
  35. <div class="ctrlBtn" @click="downloadMap">
  36. <i class="ctrlIcon downloadIcon"></i>
  37. <p class="ctrlText">下载</p>
  38. </div>
  39. <label class="ctrlBtn" for="files">
  40. <i class="ctrlIcon uploadIcon"></i>
  41. <p class="ctrlText">上传</p>
  42. </label>
  43. <input type="file" accept=".zip" ref="files" id="files" @change="uploadPic">
  44. </div>
  45. </div>
  46. </div>
  47. <div class="tipText">
  48. 操作说明<br /> 1. 下载默认平面图,支持.png文件下载;<br /> 2. 解压下载的压缩包,替换压缩包中的图片文件;<br /> (文件名,图片大小、格式需与原图保持一致)
  49. <br /> 3. 上传平面图<br />
  50. </div>
  51. </div>`,
  52. //删除
  53. // <el-popconfirm placement="top" title="确认删除?" :hide-icon="true" @confirm="delConfirm">
  54. // <el-button slot="reference">
  55. // <div class="ctrlBtn">
  56. // <i class="ctrlIcon disableIcon "></i>
  57. // <p class="ctrlText">删除</p>
  58. // </div>
  59. // </el-button>
  60. // </el-popconfirm>
  61. data() {
  62. return {
  63. showMapPic: false,
  64. info: {},
  65. type: -1,
  66. downloadUrl: 'https://laser.4dkankan.com/'
  67. }
  68. },
  69. methods: {
  70. downloadMap() {
  71. axios.get(`/indoor/${sceneNum}/api/tiled_maps/download`).then(res => {
  72. console.log(this.downloadUrl + res.data.msg)
  73. if (res.data.code == 0) {
  74. window.location.href = this.downloadUrl + res.data.msg
  75. } else {
  76. this.$message({
  77. message: res.data.msg,
  78. type: 'error',
  79. duration: 2000,
  80. });
  81. }
  82. }).catch(err => {
  83. this.$message({
  84. message: err.data.msg,
  85. type: 'error',
  86. duration: 2000,
  87. });
  88. })
  89. },
  90. refreshConfirm() {
  91. this.$parent.showLoading('更新中...')
  92. axios.get(`/indoor/${sceneNum}/api/tiled_maps/init`).then(res => {
  93. // this.$parent.hideLoading()
  94. if (res.data.code == 0) {
  95. this.getDetaile()
  96. IV.api.AuthenticationService.sendAuthenticationChanged()
  97. } else {
  98. this.$parent.hideLoading()
  99. this.$message({
  100. message: res.data.msg,
  101. type: 'error',
  102. duration: 2000,
  103. });
  104. }
  105. }).catch(err => {
  106. this.$parent.hideLoading()
  107. this.$message({
  108. message: err.data.msg,
  109. type: 'error',
  110. duration: 2000,
  111. });
  112. })
  113. },
  114. changeDisplay(val) {
  115. console.log(val)
  116. if (val) {
  117. this.info.display = 1
  118. } else {
  119. this.info.display = 0
  120. }
  121. this.$parent.showLoading('切换中...')
  122. axios.get(`/indoor/${sceneNum}/api/tiled_maps/updateDisplay/${this.info.display}`).then(res => {
  123. if (res.data.code == 0) {
  124. IV.api.AuthenticationService.sendAuthenticationChanged()
  125. } else {
  126. this.$parent.hideLoading()
  127. this.$message({
  128. message: res.data.msg,
  129. type: 'error',
  130. duration: 2000,
  131. });
  132. }
  133. }).catch(err => {
  134. this.$parent.hideLoading()
  135. this.$message({
  136. message: err.data.msg,
  137. type: 'error',
  138. duration: 2000,
  139. });
  140. })
  141. },
  142. delConfirm() {
  143. console.log('delConfirm')
  144. },
  145. isZip(file) {
  146. return /\.(zip)$/.test(file.name)
  147. },
  148. uploadPic(e) {
  149. let file = e.target.files[0]
  150. console.log(file)
  151. if (!this.isZip(file)) {
  152. this.$message({
  153. message: '请上传zip格式',
  154. type: 'error',
  155. duration: 2000,
  156. });
  157. return
  158. }
  159. let params = new FormData()
  160. params.append('file', file)
  161. this.$parent.showLoading('上传中...')
  162. axios.post(`/indoor/${sceneNum}/api/tiled_maps/upload`, params).then(res => {
  163. let file = this.$refs.files
  164. file.value = ''
  165. if (res.data.code == 0) {
  166. this.$message({
  167. message: '上传成功',
  168. type: 'success',
  169. duration: 2000,
  170. });
  171. this.getDetaile()
  172. IV.api.AuthenticationService.sendAuthenticationChanged()
  173. } else {
  174. this.$parent.hideLoading()
  175. this.$message({
  176. message: res.data.msg,
  177. type: 'error',
  178. duration: 2000,
  179. });
  180. }
  181. }).catch(err => {
  182. let file = this.$refs.file
  183. file.value = ''
  184. this.$parent.hideLoading()
  185. this.$message({
  186. message: err.data.msg,
  187. type: 'error',
  188. duration: 2000,
  189. });
  190. })
  191. },
  192. back() {
  193. this.$parent.showType = 0
  194. },
  195. getDetaile() {
  196. axios.get(`/indoor/${sceneNum}/api/tiled_maps/detail`).then(res => {
  197. if (res.data.code == 0) {
  198. console.log(res.data.data)
  199. this.info = res.data.data
  200. this.type = this.info.status || 0
  201. if (this.info.display) {
  202. this.showMapPic = true
  203. } else {
  204. this.showMapPic = false
  205. }
  206. } else {
  207. this.$message({
  208. message: res.data.msg,
  209. type: 'error',
  210. duration: 1000,
  211. });
  212. }
  213. }).catch(err => {
  214. this.$message({
  215. message: err.data.msg,
  216. type: 'error',
  217. duration: 1000,
  218. });
  219. })
  220. },
  221. openMap() {
  222. this.$parent.hideLoading()
  223. if (IV.getMainView().ViewService.primaryView != 'map') {
  224. IV.swapScenes()
  225. }
  226. }
  227. },
  228. computed: {
  229. },
  230. destroyed() {
  231. if (IV.getMainView().ViewService.primaryView == 'map') {
  232. IV.swapScenes()
  233. }
  234. },
  235. mounted() {
  236. this.openMap()
  237. window.eventBus.off('openMap', this.openMap);
  238. window.eventBus.on('openMap', this.openMap);
  239. // function openMap() {
  240. // this.$parent.hideLoading()
  241. // if (IV.getMainView().ViewService.primaryView != 'map') {
  242. // IV.swapScenes()
  243. // }
  244. // }
  245. this.getDetaile()
  246. },
  247. })
  248. })();