index.js 7.8 KB

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