index.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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.$message({
  99. message: res.data.msg,
  100. type: 'error',
  101. duration: 2000,
  102. });
  103. }
  104. }).catch(err => {
  105. this.$parent.hideLoading()
  106. this.$message({
  107. message: err.data.msg,
  108. type: 'error',
  109. duration: 2000,
  110. });
  111. })
  112. },
  113. changeDisplay(val) {
  114. console.log(val)
  115. if (val) {
  116. this.info.display = 1
  117. } else {
  118. this.info.display = 0
  119. }
  120. this.$parent.showLoading('切换中...')
  121. axios.get(`/indoor/${sceneNum}/api/tiled_maps/updateDisplay/${this.info.display}`).then(res => {
  122. this.$parent.hideLoading()
  123. if (res.data.code == 0) {
  124. IV.api.AuthenticationService.sendAuthenticationChanged()
  125. } else {
  126. this.$message({
  127. message: res.data.msg,
  128. type: 'error',
  129. duration: 2000,
  130. });
  131. }
  132. }).catch(err => {
  133. this.$parent.hideLoading()
  134. this.$message({
  135. message: err.data.msg,
  136. type: 'error',
  137. duration: 2000,
  138. });
  139. })
  140. },
  141. delConfirm() {
  142. console.log('delConfirm')
  143. },
  144. isZip(file) {
  145. return /\.(zip)$/.test(file.name)
  146. },
  147. uploadPic(e) {
  148. let file = e.target.files[0]
  149. console.log(file)
  150. if (!this.isZip(file)) {
  151. this.$message({
  152. message: '请上传zip格式',
  153. type: 'error',
  154. duration: 2000,
  155. });
  156. return
  157. }
  158. let params = new FormData()
  159. params.append('file', file)
  160. this.$parent.showLoading('上传中...')
  161. axios.post(`/indoor/${sceneNum}/api/tiled_maps/upload`, params).then(res => {
  162. this.$parent.hideLoading()
  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. },
  222. computed: {
  223. },
  224. destroyed() {
  225. },
  226. mounted() {
  227. this.getDetaile()
  228. },
  229. })
  230. })();