2019-09-25 14:52:21 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2019-09-25 15:32:44 +08:00
|
|
|
<el-card v-loading="loading" class="map-list-main" header="已发布地图列表" :style="{height: heightUp+'px'}">
|
2019-09-25 14:52:21 +08:00
|
|
|
<filter-city ref="filerCity" filter-empty :query-function="queryFunction" @filterSelectChange="refresh" />
|
|
|
|
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
|
2019-09-26 15:51:22 +08:00
|
|
|
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: heightUp-173 +'px' }">
|
2019-09-25 14:52:21 +08:00
|
|
|
<el-tree
|
|
|
|
ref="tree"
|
|
|
|
:data="treeList"
|
|
|
|
node-key="id"
|
|
|
|
:props="defaultProps"
|
|
|
|
highlight-current
|
|
|
|
:span="22"
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
@node-click="clickEvent"
|
|
|
|
@node-contextmenu="showContextMenu"
|
|
|
|
>
|
|
|
|
<span slot-scope="{ node:tnode, data }">
|
|
|
|
<span
|
|
|
|
class="el-icon-tickets"
|
|
|
|
:style="{color: data.valid ? 'green':''}"
|
|
|
|
> {{ tnode.label }}</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
</el-scrollbar>
|
2019-09-26 15:51:22 +08:00
|
|
|
<div class="buttonList">
|
|
|
|
<el-button size="small" type="primary" class="eachButton uploadDemo ">
|
|
|
|
<input
|
|
|
|
ref="files"
|
|
|
|
type="file"
|
|
|
|
class="file_box"
|
|
|
|
accept=".json, application/json"
|
|
|
|
@change="importf"
|
|
|
|
>
|
|
|
|
{{ $t('map.importMap') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button size="small" type="primary" class="eachButton" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
|
|
|
|
|
|
|
|
<!-- <el-button type="text" style="float: right; padding: 3px 0" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
|
|
|
|
<el-button type="text" class="uploadDemo">
|
|
|
|
<input
|
|
|
|
ref="files"
|
|
|
|
type="file"
|
|
|
|
class="file_box"
|
|
|
|
accept=".json, application/json"
|
|
|
|
@change="importf"
|
|
|
|
>
|
|
|
|
{{ $t('map.importMap') }}
|
|
|
|
</el-button> -->
|
|
|
|
</div>
|
2019-09-25 14:52:21 +08:00
|
|
|
</el-card>
|
|
|
|
<drap-Up :height-up="heightUp" :width="width" @drapHeight="drapHeight" />
|
2019-09-25 15:32:44 +08:00
|
|
|
<el-card v-loading="loading" class="map-list-main" header="我的地图列表" :style="{height: (height-heightUp)+'px'}">
|
2019-09-25 14:52:21 +08:00
|
|
|
<filter-city ref="filerCity" filter-empty :query-function="queryFunction" @filterSelectChange="refresh" />
|
|
|
|
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
|
2019-09-26 15:51:22 +08:00
|
|
|
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-heightUp-173) +'px' }">
|
2019-09-25 14:52:21 +08:00
|
|
|
<el-tree
|
|
|
|
ref="tree"
|
|
|
|
:data="treeList"
|
|
|
|
node-key="id"
|
|
|
|
:props="defaultProps"
|
|
|
|
highlight-current
|
|
|
|
:span="22"
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
@node-click="clickEvent"
|
|
|
|
@node-contextmenu="showContextMenu"
|
|
|
|
>
|
|
|
|
<span slot-scope="{ node:tnode, data }">
|
|
|
|
<span
|
|
|
|
class="el-icon-tickets"
|
|
|
|
:style="{color: data.valid ? 'green':''}"
|
|
|
|
> {{ tnode.label }}</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
</el-scrollbar>
|
2019-09-26 15:51:22 +08:00
|
|
|
<div class="buttonList">
|
|
|
|
<el-button size="small" type="primary" class="eachButton uploadDemo ">
|
|
|
|
<input
|
|
|
|
ref="files"
|
|
|
|
type="file"
|
|
|
|
class="file_box"
|
|
|
|
accept=".json, application/json"
|
|
|
|
@change="importf"
|
|
|
|
>
|
|
|
|
{{ $t('map.importMap') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button size="small" type="primary" class="eachButton" @click="createMap">{{ $t('map.newConstruction') }}</el-button>
|
|
|
|
<!-- @click="" -->
|
|
|
|
</div>
|
2019-09-25 14:52:21 +08:00
|
|
|
</el-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-09-26 15:51:22 +08:00
|
|
|
import { postBuildMapImport } from '@/api/jmap/mapdraft';
|
2019-09-25 14:52:21 +08:00
|
|
|
import { getPublishMapTree } from '@/api/management/mapprd';
|
|
|
|
import { UrlConfig } from '@/router/index';
|
|
|
|
import { getSessionStorage, setSessionStorage, removeSessionStorage } from '@/utils/auth';
|
|
|
|
import FilterCity from '@/views/components/filterCity';
|
|
|
|
import drapUp from '@/views/components/drapUp/index';
|
|
|
|
import localStore from 'storejs';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ExamDetailList',
|
|
|
|
components: {
|
|
|
|
FilterCity,
|
2019-09-26 15:51:22 +08:00
|
|
|
drapUp,
|
2019-09-25 14:52:21 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
height: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
defaultShowKeys: [],
|
|
|
|
queryFunction: getPublishMapTree,
|
|
|
|
filterText: '',
|
|
|
|
treeData: [],
|
|
|
|
treeList: [],
|
|
|
|
selected: {},
|
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
|
|
|
label: 'name'
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
},
|
|
|
|
mapId: '',
|
2019-09-26 15:51:22 +08:00
|
|
|
heightUp: 450,
|
2019-09-25 14:52:21 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
role() {
|
|
|
|
return this.$store.state.user.roles.includes('04') ||
|
|
|
|
this.$store.state.user.roles.includes('05') ||
|
|
|
|
this.$store.state.user.roles.includes('01');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
filterText(val) {
|
|
|
|
this.treeList = this.treeData.filter((res) => {
|
|
|
|
return res.name.includes(val);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy () {
|
|
|
|
removeSessionStorage('demonList');
|
|
|
|
},
|
|
|
|
mounted() {
|
2019-09-25 15:32:44 +08:00
|
|
|
this.heightUp = Number(localStore.get('upHeight')?localStore.get('upHeight'):(this.height)/2);
|
2019-09-25 14:52:21 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
filterNode(value, data) {
|
|
|
|
if (!value) return true;
|
|
|
|
return data.name.indexOf(value) !== -1;
|
|
|
|
},
|
|
|
|
showContextMenu(e, obj, node, vueElem) {
|
|
|
|
if (obj) {
|
|
|
|
this.node = node;
|
|
|
|
this.selected = obj;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clickEvent(obj, data, ele) {
|
2019-09-25 15:34:29 +08:00
|
|
|
if (data.parent && data.parent.data){
|
|
|
|
this.mapId = data.parent.data.id;
|
|
|
|
}
|
|
|
|
switch(obj.type){
|
|
|
|
case 'scriptDesign':{
|
2019-09-26 09:07:19 +08:00
|
|
|
this.$router.push({ path: `${UrlConfig.design.scriptHome}/${this.mapId}` });
|
2019-09-25 15:34:29 +08:00
|
|
|
break;
|
|
|
|
}
|
2019-09-25 18:56:30 +08:00
|
|
|
case 'mapDesign': {
|
|
|
|
this.resize();
|
|
|
|
this.$router.push({ path: `${UrlConfig.design.mapDraw}/0/draft`, query: { name: '' } });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'lessonDesign': {
|
2019-09-26 15:08:53 +08:00
|
|
|
this.$router.push({ path: `${UrlConfig.design.lessonHome}` });
|
2019-09-25 18:56:30 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'runPlanDesign': {
|
2019-09-26 15:51:22 +08:00
|
|
|
this.$router.push({ path: `${UrlConfig.design.runPlan}/${this.mapId}` })
|
2019-09-25 18:56:30 +08:00
|
|
|
}
|
2019-09-25 15:34:29 +08:00
|
|
|
}
|
2019-09-25 14:52:21 +08:00
|
|
|
},
|
|
|
|
async refresh(filterSelect) {
|
|
|
|
this.loading = true;
|
|
|
|
this.treeData = this.treeList = [];
|
|
|
|
try {
|
|
|
|
const res = await getPublishMapTree(filterSelect);
|
2019-09-25 18:56:30 +08:00
|
|
|
|
2019-09-25 15:34:29 +08:00
|
|
|
res.data.forEach(elem=>{
|
|
|
|
if(elem.children)
|
|
|
|
{
|
|
|
|
elem.children=[
|
|
|
|
{
|
|
|
|
id:'1',
|
|
|
|
name:'地图设计',
|
|
|
|
type:'mapDesign'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id:'2',
|
|
|
|
name:'课程设计',
|
|
|
|
type:'lessonDesign'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id:'3',
|
|
|
|
name:'剧本设计',
|
|
|
|
type:'scriptDesign'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id:'4',
|
|
|
|
name:'运行图设计',
|
|
|
|
type:'runPlanDesign'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-25 14:52:21 +08:00
|
|
|
this.treeData = res.data;
|
2019-09-25 18:56:30 +08:00
|
|
|
|
2019-09-25 14:52:21 +08:00
|
|
|
this.treeList = this.filterText
|
|
|
|
? res.data.filter(elem => { return elem.name.includes(this.filterText); })
|
|
|
|
: res.data;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const mapId = getSessionStorage('demonList') || null;
|
|
|
|
this.$refs.tree.setCurrentKey(mapId);
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
this.loading = false;
|
|
|
|
this.$messageBox(this.$t('error.refreshFailed'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
drapHeight(height) {
|
|
|
|
this.heightUp = Number(height);
|
2019-09-25 18:56:30 +08:00
|
|
|
},
|
|
|
|
resize() {
|
|
|
|
this.widthLeft = Number(localStore.get('LeftWidth')) || this.widthLeft;
|
|
|
|
const width = this.$store.state.app.width - 521 - this.widthLeft;
|
|
|
|
const height = this.$store.state.app.height - 90;
|
|
|
|
this.$store.dispatch('config/resize', { width: width, height: height });
|
2019-09-26 15:51:22 +08:00
|
|
|
},
|
|
|
|
importf() {
|
|
|
|
const loading = this.$loading({
|
|
|
|
lock: true,
|
|
|
|
text: '正在导入中...',
|
|
|
|
spinner: 'el-icon-loading',
|
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
|
});
|
|
|
|
setTimeout(() => {
|
|
|
|
const obj = this.$refs.files;
|
|
|
|
if (!obj.files) return;
|
|
|
|
const f = obj.files[0];
|
|
|
|
const reader = new FileReader();
|
|
|
|
const that = this;
|
|
|
|
reader.readAsText(f, 'utf-8');
|
|
|
|
reader.onload = function(e) {
|
|
|
|
const data = e.target.result;
|
|
|
|
postBuildMapImport(JSON.parse(data)).then(res => {
|
|
|
|
loading.close();
|
|
|
|
that.$message.success('导入成功!');
|
|
|
|
that.refresh();
|
|
|
|
loading.close();
|
|
|
|
}).catch(error => {
|
|
|
|
loading.close();
|
|
|
|
that.$message.error('导入失败' + error.message);
|
|
|
|
});
|
|
|
|
obj.value = '';
|
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
|
|
|
createMap() {
|
|
|
|
this.$emit("createMap");
|
|
|
|
},
|
2019-09-25 14:52:21 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
.back-home {
|
|
|
|
float: right;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: #3ea726;
|
|
|
|
}
|
|
|
|
}
|
2019-09-26 15:51:22 +08:00
|
|
|
|
|
|
|
.buttonList{
|
|
|
|
padding: 8px 0px 8px 0px;
|
|
|
|
border-top: 1px #ccc solid;
|
|
|
|
}
|
|
|
|
.eachButton{
|
|
|
|
margin-left:10px;
|
|
|
|
}
|
|
|
|
.uploadDemo {
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
|
|
|
// float: right;
|
|
|
|
padding: 9px 15px;
|
|
|
|
margin-right: 3px;
|
|
|
|
cursor: pointer;
|
|
|
|
input {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
|
|
|
opacity: 0;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
2019-09-25 14:52:21 +08:00
|
|
|
</style>
|
|
|
|
<style>
|
|
|
|
.el-tree {
|
|
|
|
overflow-x: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-tree-node.is-current>.el-tree-node__content {
|
|
|
|
background-color: #e4e3e3 !important;
|
|
|
|
}
|
|
|
|
</style>
|