rt-sim-training-client/src/views/designPlatform/demonList.vue

213 lines
7.4 KiB
Vue
Raw Normal View History

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-25 15:32:44 +08:00
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: heightUp-123 +'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':''}"
>&nbsp;{{ tnode.label }}</span>
</span>
</el-tree>
</el-scrollbar>
</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-25 15:32:44 +08:00
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-heightUp-123) +'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':''}"
>&nbsp;{{ tnode.label }}</span>
</span>
</el-tree>
</el-scrollbar>
</el-card>
</div>
</template>
<script>
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,
drapUp
},
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: '',
heightUp: 450
};
},
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':{
// this.$router.push({ path: `${UrlConfig.trainingPlatform.prodDetail}/${this.mapId}/${obj.id}` });
break;
}
}
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 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 15:34:29 +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);
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.back-home {
float: right;
cursor: pointer;
&:hover {
color: #3ea726;
}
}
</style>
<style>
.el-tree {
overflow-x: hidden;
}
.el-tree-node.is-current>.el-tree-node__content {
background-color: #e4e3e3 !important;
}
</style>