index.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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" 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. window.location.href = this.downloadUrl + res.data.msg
  74. }).catch(err => {
  75. this.$message({
  76. message: err.data.msg,
  77. type: 'error',
  78. duration: 2000,
  79. });
  80. })
  81. },
  82. refreshConfirm() {
  83. this.$parent.showLoading('更新中...')
  84. axios.get(`/indoor/${sceneNum}/api/tiled_maps/init`).then(res => {
  85. this.$parent.hideLoading()
  86. this.getDetaile()
  87. IV.api.AuthenticationService.sendAuthenticationChanged()
  88. }).catch(err => {
  89. this.$parent.hideLoading()
  90. this.$message({
  91. message: err.data.msg,
  92. type: 'error',
  93. duration: 2000,
  94. });
  95. })
  96. },
  97. changeDisplay(val) {
  98. console.log(val)
  99. if (val) {
  100. this.info.display = 1
  101. } else {
  102. this.info.display = 0
  103. }
  104. this.$parent.showLoading('切换中...')
  105. axios.get(`/indoor/${sceneNum}/api/tiled_maps/updateDisplay/${this.info.display}`).then(res => {
  106. this.$parent.hideLoading()
  107. IV.api.AuthenticationService.sendAuthenticationChanged()
  108. }).catch(err => {
  109. this.$parent.hideLoading()
  110. this.$message({
  111. message: err.data.msg,
  112. type: 'error',
  113. duration: 2000,
  114. });
  115. })
  116. },
  117. delConfirm() {
  118. console.log('delConfirm')
  119. },
  120. isZip(file) {
  121. return /\.(zip)$/.test(file.name)
  122. },
  123. uploadPic(e) {
  124. let file = e.target.files[0]
  125. console.log(file)
  126. if (!this.isZip(file)) {
  127. this.$message({
  128. message: '请上传zip格式',
  129. type: 'error',
  130. duration: 2000,
  131. });
  132. return
  133. }
  134. let params = new FormData()
  135. params.append('file', file)
  136. this.$parent.showLoading('上传中...')
  137. axios.post(`/indoor/${sceneNum}/api/tiled_maps/upload`, params).then(res => {
  138. this.$message({
  139. message: '上传成功',
  140. type: 'success',
  141. duration: 2000,
  142. });
  143. this.$parent.hideLoading()
  144. this.getDetaile()
  145. IV.api.AuthenticationService.sendAuthenticationChanged()
  146. }).catch(err => {
  147. this.$parent.hideLoading()
  148. this.$message({
  149. message: '上传失败',
  150. type: 'error',
  151. duration: 2000,
  152. });
  153. })
  154. },
  155. back() {
  156. this.$parent.showType = 0
  157. },
  158. getDetaile() {
  159. axios.get(`/indoor/${sceneNum}/api/tiled_maps/detail`).then(res => {
  160. console.log(res.data.data)
  161. this.info = res.data.data
  162. this.type = this.info.status || 0
  163. if (this.info.display) {
  164. this.showMapPic = true
  165. } else {
  166. this.showMapPic = false
  167. }
  168. }).catch(err => {
  169. this.$message({
  170. message: err.data.msg,
  171. type: 'error',
  172. duration: 1000,
  173. });
  174. })
  175. }
  176. },
  177. computed: {
  178. },
  179. destroyed() {
  180. },
  181. mounted() {
  182. this.getDetaile()
  183. },
  184. })
  185. })();