xushiting 4 年之前
父節點
當前提交
9c6e6c069f
共有 1 個文件被更改,包括 197 次插入0 次删除
  1. 197 0
      components/upload-pointClound/index.js

+ 197 - 0
components/upload-pointClound/index.js

@@ -0,0 +1,197 @@
+(() => {
+    Vue.component('uploadPointclound', {
+        props: [],
+        name: 'uploadPointclound',
+        template: `<div id="uploadBox" >
+                    <div class="headerBack">
+                        <div class="topBox">
+                            <i class="backIcon" @click="back"></i>
+                            <p class="headerTitle">添加数据集</p>
+                        </div>
+                    </div>
+                    
+                    <div class="selectBox">
+                        <el-select v-model="value" filterable @click.native="options = dataList" :filter-method="searchScene" placeholder="请选择">
+                            <el-option v-for="item in options" :key="item.id" :label="item.title" :value="item.id">
+                                <div class="sceneName">
+                                    <p class="code">{{item.title}}</p>
+                                    <span class="name">数据集:{{item.id}}</span>
+                                </div>
+
+                            </el-option>
+                        </el-select>
+
+                    </div>
+                    <div class="uploadBtn" @click="openUpload" :class="{disabled:value==''}">
+                        <i class="fa fa-plus ng-scope"></i>&nbsp;&nbsp;添加到场景
+                    </div>
+
+                    <p class="itemTitle">已添加的数据集 </p>
+                    <div class="listBox">
+                        <ul class="sceneList">
+                            <li class="sceneItem" v-for="i in hasList">
+                                <div class="sceneName">
+                                    <p class="code">{{i.sceneNum}}</p>
+                                    <span class="name">来自场景:{{i.title}}</span>
+                                </div>
+                                <div class="scene_control">
+                                   
+
+                                    <el-popconfirm placement="top" title="是否要删除该数据集?" :hide-icon="true" @confirm="delConfirm(i.id)">
+                                        <el-button class="delBtn" title="删除" slot="reference"></el-button>
+                                    </el-popconfirm>
+                                    <!-- <div class="delBtn" title="删除"></div> -->
+                                </div>
+                            </li>
+                        </ul>
+                    </div>
+
+                </div>`,
+        data() {
+            return {
+                dataList: [],
+                options: [],
+                hasList: [],
+                value: '',
+            }
+        },
+        methods: {
+
+            getSceneData() {
+                let params = {
+                    "pageNum": 0,
+                    "pageSize": 999,
+                    "searchKey": "",
+                }
+
+                axios({
+                    url: '/indoor/scene/list',
+                    method: 'post',
+                    data: params
+                }).then(res => {
+                    console.log(res)
+                    this.dataList = res.data.data.content
+                    this.options = res.data.data.content
+                }).catch(err => {
+
+                })
+            },
+            getHasSceneList() {
+                axios({
+                    url: `/indoor/${sceneNum}/api/merge/exist`,
+                    method: 'get',
+                }).then(res => {
+                    if (res.data.code == 0) {
+                        this.hasList = res.data.data
+                    }
+                }).catch(err => {
+
+                })
+            },
+            searchScene(e) {
+                console.log(e)
+                let res = this.dataList.filter(i => {
+                    if (i.id.indexOf(e) != -1 || i.title.indexOf(e) != -1) {
+                        return i
+                    }
+                })
+                console.log(res)
+                this.options = res
+
+            },
+            openUpload() {
+                // 
+
+                this.$parent.showLoading('上传中...')
+                let res = this.hasList.filter(i => {
+                    console.log(i.sceneNum)
+                    if (this.value == i.sceneNum) {
+                        return i
+                    }
+                })
+                if (res.length > 0) {
+                    this.$parent.hideLoading()
+                    this.$message({
+                        message: '请勿重复添加数据集',
+                        type: 'error',
+                        duration: 2000,
+                    });
+                    return
+
+                }
+
+                axios.post(`/indoor/${sceneNum}/api/merge/${this.value}`).then(res => {
+                    this.$parent.hideLoading()
+                    this.value = ''
+                    if (res.data.code == 0) {
+                        this.getHasSceneList()
+                        this.$message({
+                            message: '数据集添加成功',
+                            type: 'success',
+                            duration: 2000,
+                        });
+                        IV.api.AuthenticationService.sendAuthenticationChanged()
+                    } else {
+                        this.$message({
+                            message: '数据集添加失败',
+                            type: 'error',
+                            duration: 2000,
+                        });
+                    }
+
+                }).catch(err => {
+                    this.value = ''
+                    this.$parent.hideLoading()
+                    this.$message({
+                        message: '数据集添加失败',
+                        type: 'error',
+                        duration: 2000,
+                    });
+
+                })
+
+
+            },
+            delConfirm(id) {
+                axios({
+                    // url: `/indoor/${sceneNum}/api/merge/exist`,
+                    url: `/indoor/${sceneNum}/api/merge/remove/${id}`,
+                    method: 'get',
+                }).then(res => {
+                    if (res.data.code == 0) {
+                        this.getHasSceneList()
+                        this.$message({
+                            message: '数据集删除成功',
+                            type: 'success',
+                            duration: 2000,
+                        });
+                        IV.api.AuthenticationService.sendAuthenticationChanged()
+                    }
+                }).catch(err => {
+
+                })
+            },
+            back() {
+                this.$parent.showType = 0
+            }
+
+        },
+        computed: {
+
+        },
+        destroyed() {
+
+        },
+        mounted() {
+            // window.eventBus.off('openMap', openMap);
+            // window.eventBus.on('openMap', openMap);
+
+            // function openMap() {
+            //     IV.swapScenes()
+            // }
+
+            this.getSceneData()
+            this.getHasSceneList()
+        },
+    })
+})();