index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. (() => {
  2. Vue.component('uploadPointclound', {
  3. props: [],
  4. name: 'uploadPointclound',
  5. template: `<div id="uploadBox" >
  6. <div class="headerBack">
  7. <div class="topBox">
  8. <i class="backIcon" @click="back"></i>
  9. <p class="headerTitle">添加数据集</p>
  10. </div>
  11. </div>
  12. <div class="selectBox">
  13. <el-select v-model="value" filterable @click.native="options = dataList" :filter-method="searchScene" placeholder="请选择">
  14. <el-option v-for="item in options" :key="item.id" :label="item.title" :value="item.id">
  15. <div class="sceneName">
  16. <p class="code">{{item.title}}</p>
  17. <span class="name">数据集:{{item.id}}</span>
  18. </div>
  19. </el-option>
  20. </el-select>
  21. </div>
  22. <div class="uploadBtn" @click="openUpload" :class="{disabled:value==''}">
  23. <i class="fa fa-plus ng-scope"></i>&nbsp;&nbsp;添加到场景
  24. </div>
  25. <p class="itemTitle">已添加的数据集 </p>
  26. <div class="listBox">
  27. <ul class="sceneList">
  28. <li class="sceneItem" v-for="i in hasList">
  29. <div class="sceneName">
  30. <p class="code">{{i.sceneNum}}</p>
  31. <span class="name">来自场景:{{i.title}}</span>
  32. </div>
  33. <div class="scene_control">
  34. <el-popconfirm placement="top" title="是否要删除该数据集?" :hide-icon="true" @confirm="delConfirm(i.id)">
  35. <el-button class="delBtn" title="删除" slot="reference"></el-button>
  36. </el-popconfirm>
  37. <!-- <div class="delBtn" title="删除"></div> -->
  38. </div>
  39. </li>
  40. </ul>
  41. </div>
  42. </div>`,
  43. data() {
  44. return {
  45. dataList: [],
  46. options: [],
  47. hasList: [],
  48. value: '',
  49. }
  50. },
  51. methods: {
  52. getSceneData() {
  53. let params = {
  54. "pageNum": 0,
  55. "pageSize": 999,
  56. "searchKey": "",
  57. }
  58. axios({
  59. url: '/indoor/scene/list',
  60. method: 'post',
  61. data: params
  62. }).then(res => {
  63. console.log(res)
  64. this.dataList = res.data.data.content
  65. this.options = res.data.data.content
  66. }).catch(err => {
  67. })
  68. },
  69. getHasSceneList() {
  70. axios({
  71. url: `/indoor/${sceneNum}/api/merge/exist`,
  72. method: 'get',
  73. }).then(res => {
  74. if (res.data.code == 0) {
  75. this.hasList = res.data.data
  76. }
  77. }).catch(err => {
  78. })
  79. },
  80. searchScene(e) {
  81. console.log(e)
  82. let res = this.dataList.filter(i => {
  83. if (i.id.indexOf(e) != -1 || i.title.indexOf(e) != -1) {
  84. return i
  85. }
  86. })
  87. console.log(res)
  88. this.options = res
  89. },
  90. openUpload() {
  91. //
  92. this.$parent.showLoading('上传中...')
  93. let res = this.hasList.filter(i => {
  94. console.log(i.sceneNum)
  95. if (this.value == i.sceneNum) {
  96. return i
  97. }
  98. })
  99. if (res.length > 0) {
  100. this.$parent.hideLoading()
  101. this.$message({
  102. message: '请勿重复添加数据集',
  103. type: 'error',
  104. duration: 2000,
  105. });
  106. return
  107. }
  108. axios.post(`/indoor/${sceneNum}/api/merge/${this.value}`).then(res => {
  109. this.$parent.hideLoading()
  110. this.value = ''
  111. if (res.data.code == 0) {
  112. this.getHasSceneList()
  113. this.$message({
  114. message: '数据集添加成功',
  115. type: 'success',
  116. duration: 2000,
  117. });
  118. IV.api.AuthenticationService.sendAuthenticationChanged()
  119. } else {
  120. this.$message({
  121. message: '数据集添加失败',
  122. type: 'error',
  123. duration: 2000,
  124. });
  125. }
  126. }).catch(err => {
  127. this.value = ''
  128. this.$parent.hideLoading()
  129. this.$message({
  130. message: '数据集添加失败',
  131. type: 'error',
  132. duration: 2000,
  133. });
  134. })
  135. },
  136. delConfirm(id) {
  137. axios({
  138. // url: `/indoor/${sceneNum}/api/merge/exist`,
  139. url: `/indoor/${sceneNum}/api/merge/remove/${id}`,
  140. method: 'get',
  141. }).then(res => {
  142. if (res.data.code == 0) {
  143. this.getHasSceneList()
  144. this.$message({
  145. message: '数据集删除成功',
  146. type: 'success',
  147. duration: 2000,
  148. });
  149. IV.api.AuthenticationService.sendAuthenticationChanged()
  150. }
  151. }).catch(err => {
  152. })
  153. },
  154. back() {
  155. this.$parent.showType = 0
  156. }
  157. },
  158. computed: {
  159. },
  160. destroyed() {
  161. },
  162. mounted() {
  163. // window.eventBus.off('openMap', openMap);
  164. // window.eventBus.on('openMap', openMap);
  165. // function openMap() {
  166. // IV.swapScenes()
  167. // }
  168. this.getSceneData()
  169. this.getHasSceneList()
  170. },
  171. })
  172. })();