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

176 lines
6.6 KiB
Vue
Raw Normal View History

2019-09-23 17:49:04 +08:00
<template>
<el-card v-loading="loading" class="map-list-main">
<div slot="header" class="clearfix">
<span>{{ $t('global.mapList') }}</span>
</div>
<filter-city ref="filerCity" filter-empty :query-function="queryFunction" @filterSelectChange="refresh" />
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-125) +'px' }">
<el-tree
ref="tree"
:data="treeList"
node-key="id"
:props="defaultProps"
highlight-current
:span="22"
:filter-node-method="filterNode"
2019-09-27 14:46:08 +08:00
:default-expanded-keys="expandList"
2019-09-23 17:49:04 +08:00
@node-click="clickEvent"
@node-contextmenu="showContextMenu"
2019-09-27 14:46:08 +08:00
@node-expand="nodeExpand"
@node-collapse="nodeCollapse"
2019-09-23 17:49:04 +08:00
>
<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>
</template>
<script>
import { getPublishMapTree } from '@/api/management/mapprd';
2019-09-26 15:08:53 +08:00
import { getTrainingSystemList } from '@/api/trainingPlatform'
2019-09-23 17:49:04 +08:00
import { UrlConfig } from '@/router/index';
import { getSessionStorage, setSessionStorage, removeSessionStorage } from '@/utils/auth';
import FilterCity from '@/views/components/filterCity';
2019-09-27 18:02:32 +08:00
import localStore from 'storejs';
2019-09-23 17:49:04 +08:00
export default {
2019-09-27 14:46:08 +08:00
name: 'DemonList',
2019-09-23 17:49:04 +08:00
components: {
FilterCity
},
props: {
height: {
type: Number,
required: true
}
},
data() {
return {
loading: true,
defaultShowKeys: [],
queryFunction: getPublishMapTree,
filterText: '',
treeData: [],
treeList: [],
selected: {},
defaultProps: {
children: 'children',
label: 'name'
},
node: {
},
2019-09-27 14:46:08 +08:00
mapId: '',
2019-09-27 18:02:32 +08:00
expandList: [],
filterSelect: ''
2019-09-23 17:49:04 +08:00
};
},
watch: {
filterText(val) {
this.treeList = this.treeData.filter((res) => {
return res.name.includes(val);
});
}
},
beforeDestroy () {
2019-09-27 14:46:08 +08:00
},
mounted() {
2019-09-23 17:49:04 +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-27 18:02:32 +08:00
setSessionStorage('trainingPlatformCheckId'+this.filterSelect, obj.id);
2019-09-27 14:46:08 +08:00
while (data) {
if (data.data.type === 'map') {
this.mapId = data.data.id;
break;
}
data = data.parent;
2019-09-23 17:49:04 +08:00
}
2019-09-27 14:46:08 +08:00
if (obj.type === '仿真系统') {
this.$router.push({ path: `${UrlConfig.trainingPlatform.prodDetail}/${this.mapId}`, query: { prodId: obj.code, type: obj.type }});
2019-09-23 17:49:04 +08:00
} else if ( obj.type === 'map'){
this.mapId = obj.id;
2019-09-25 13:05:01 +08:00
this.$router.push({ path: `${UrlConfig.trainingPlatform.permission}/${this.mapId}`});
2019-09-27 14:46:08 +08:00
} else if ( obj.type === '教学系统' ){
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachDetail}`, query: { prodId: obj.code, type: obj.type }});
} else if ( obj.type === '考试系统' ){
this.$router.push({ path: `${UrlConfig.trainingPlatform.course}/${this.mapId}`, query: { prodId: obj.code, type: obj.type }});
2019-09-23 17:49:04 +08:00
}
2019-09-27 18:02:32 +08:00
localStore.set('trainingPlatformRoute',this.$router.history.current.fullPath);
2019-09-23 17:49:04 +08:00
},
async refresh(filterSelect) {
this.loading = true;
this.treeData = this.treeList = [];
2019-09-27 18:02:32 +08:00
this.filterSelect = filterSelect;
2019-09-23 17:49:04 +08:00
try {
2019-09-26 15:08:53 +08:00
const res = await getTrainingSystemList({cityCode:filterSelect});
2019-09-23 17:49:04 +08:00
this.treeData = res.data;
this.treeList = this.filterText
? res.data.filter(elem => { return elem.name.includes(this.filterText); })
: res.data;
2019-09-27 18:02:32 +08:00
this.getExpandList(filterSelect);
2019-09-23 17:49:04 +08:00
this.$nextTick(() => {
2019-09-27 18:02:32 +08:00
const checkId = getSessionStorage('trainingPlatformCheckId'+filterSelect) || null;
this.$refs.tree && this.$refs.tree.setCurrentKey(checkId);
2019-09-23 17:49:04 +08:00
this.loading = false;
});
} catch (error) {
this.loading = false;
this.$messageBox(this.$t('error.refreshFailed'));
}
2019-09-27 14:46:08 +08:00
},
nodeExpand(obj, node, ele) {
const key = obj.id;
this.expandList = this.expandList.filter(item => item!==key);
this.expandList.push(key);
2019-09-27 18:02:32 +08:00
setSessionStorage('trainIngPlatformExpandList'+this.filterSelect,this.expandList)
2019-09-27 14:46:08 +08:00
},
nodeCollapse(obj, node, ele) {
const key = obj.id;
this.expandList = this.expandList.filter(item => item!==key);
2019-09-27 18:02:32 +08:00
setSessionStorage('trainIngPlatformExpandList'+this.filterSelect,this.expandList)
2019-09-27 14:46:08 +08:00
},
2019-09-27 18:02:32 +08:00
getExpandList(filterSelect) {
let expand = getSessionStorage('trainIngPlatformExpandList'+filterSelect);
2019-09-27 14:46:08 +08:00
expand = expand?(expand+'').split(','):'';
if (expand instanceof Array){
this.expandList = expand;
}
2019-09-23 17:49:04 +08:00
}
}
};
</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>