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

230 lines
6.7 KiB
Vue
Raw Normal View History

2019-09-23 17:49:04 +08:00
<template>
2019-10-18 17:15:04 +08:00
<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" :local-param-name="localParamName" @filterSelectChange="refresh" />
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
2019-10-24 14:03:19 +08:00
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-125) +'px' }">
2019-10-18 17:15:04 +08:00
<el-tree
ref="tree"
:data="treeList"
node-key="id"
:props="defaultProps"
highlight-current
:span="22"
:filter-node-method="filterNode"
:default-expanded-keys="expandList"
@node-click="clickEvent"
@node-contextmenu="showContextMenu"
@node-expand="nodeExpand"
@node-collapse="nodeCollapse"
>
2019-10-22 18:34:05 +08:00
<span slot-scope="{ node }">
2019-09-23 17:49:04 +08:00
<span
2019-10-18 17:15:04 +08:00
class="el-icon-tickets"
2019-10-22 18:34:05 +08:00
/>
<span v-if="node.data.id ==='Simulation'">&nbsp;{{ node.data.name+ $t('global.simulationSystem') }}</span>
<span v-else-if="node.data.id ==='Lesson'">&nbsp;{{ node.data.name+ $t('global.lessonSystem') }}</span>
<span v-else-if="node.data.id ==='Exam'">&nbsp;{{ node.data.name+ $t('global.examSystem') }}</span>
<span v-else>&nbsp;{{ node.data.name }}</span>
2019-09-23 17:49:04 +08:00
</span>
2019-10-18 17:15:04 +08:00
</el-tree>
</el-scrollbar>
</el-card>
2019-09-23 17:49:04 +08:00
</template>
<script>
2019-10-18 17:15:04 +08:00
import { getPublishMapTree } from '@/api/management/mapprd';
2019-10-22 18:18:21 +08:00
import { getTrainingSystemList, getSubSystemInfo } from '@/api/trainingPlatform';
2019-10-18 17:15:04 +08:00
import { UrlConfig } from '@/router/index';
import FilterCity from '@/views/components/filterCity';
import localStore from 'storejs';
import { getSessionStorage } from '@/utils/auth';
2019-09-23 17:49:04 +08:00
2019-10-18 17:15:04 +08:00
export default {
name: 'DemonList',
components: {
FilterCity
},
props: {
height: {
type: Number,
required: true
}
},
data() {
return {
loading: true,
defaultShowKeys: [],
queryFunction: getPublishMapTree,
filterText: '',
treeList: [],
selected: {},
defaultProps: {
children: 'children',
label: 'name'
},
node: {
},
mapId: '',
expandList: [],
2019-10-18 17:23:25 +08:00
filterSelect: '',
2019-10-18 18:36:45 +08:00
localParamName: 'training_cityCode'
2019-10-18 17:15:04 +08:00
};
},
computed: {
2019-10-22 20:01:03 +08:00
userId() {
return this.$store.state.user.id;
2019-10-18 17:15:04 +08:00
},
project() {
return getSessionStorage('project');
}
},
watch: {
2019-10-21 10:02:49 +08:00
filterText(val) {
this.$refs.tree.filter(val);
}
2019-10-18 17:15:04 +08:00
},
beforeDestroy () {
},
mounted() {
},
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-10-22 20:01:03 +08:00
localStore.set('trainingPlatformCheckId'+this.filterSelect+this.userId, obj.id);
2019-10-18 17:15:04 +08:00
while (data) {
if (data.data.type === 'Map') {
this.mapId = data.data.id;
break;
}
data = data.parent;
}
if ( obj.type === 'Map') {
this.mapId = obj.id;
this.$router.push({ path: `${UrlConfig.trainingPlatform.permission}/${this.mapId}`});
2019-10-21 10:02:49 +08:00
} else if ( obj.type === 'MapSystem') {
2019-10-18 17:15:04 +08:00
getSubSystemInfo(obj.id).then(resp => {
2019-10-22 18:49:46 +08:00
let router = '';
2019-10-18 17:15:04 +08:00
switch (resp.data.type) {
case 'Exam':
2019-10-22 14:28:22 +08:00
this.setLocalRoute(`${UrlConfig.trainingPlatform.examHome}/${obj.id}`);
2019-10-22 18:49:46 +08:00
router = localStore.get('examDetail' + obj.id);
if (router) {
this.$router.push(router);
} else {
this.$router.push({ path: `${UrlConfig.trainingPlatform.examHome}/${obj.id}`});
}
2019-10-18 17:15:04 +08:00
break;
case 'Lesson':
2019-10-22 14:28:22 +08:00
this.setLocalRoute(`${UrlConfig.trainingPlatform.teachHome}/${obj.id}`);
2019-10-22 18:49:46 +08:00
router = localStore.get('teachDetail' + obj.id);
if (router) {
this.$router.push(router);
2019-10-22 18:18:21 +08:00
} else {
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachHome}/${obj.id}`});
2019-10-22 18:49:46 +08:00
}
2019-10-18 17:15:04 +08:00
break;
case 'Simulation':
2019-10-21 14:09:03 +08:00
this.setLocalRoute(`${UrlConfig.trainingPlatform.prodDetail}/${obj.id}?mapId=${this.mapId}`);
2019-10-18 17:15:04 +08:00
this.$router.push({ path: `${UrlConfig.trainingPlatform.prodDetail}/${obj.id}`, query: { mapId: this.mapId}});
break;
case 'Plan':
this.$router.push({ path: `${UrlConfig.trainingPlatform.runPlan}/${this.mapId}`, query: {skinCode: '02'} });
break;
2019-10-18 17:15:04 +08:00
}
}).catch((error) => {
if (error.code === '40004') {
this.$messageBox(this.$t('systemGenerate.getSubSystemInfoFail'));
}
2019-10-18 17:15:04 +08:00
});
}
},
setLocalRoute(path) {
2019-10-22 20:01:03 +08:00
localStore.set('trainingPlatformRoute'+this.userId, path);
2019-10-18 17:15:04 +08:00
},
async refresh(filterSelect) {
this.loading = true;
this.treeList = [];
this.filterSelect = filterSelect;
try {
let params={};
2019-10-22 18:18:21 +08:00
if (this.project === 'xty') {
params={'customized': 'xty'};
}
2019-10-22 18:18:21 +08:00
const res = await getTrainingSystemList(filterSelect, params);
2019-10-18 17:15:04 +08:00
res.data.forEach(item =>{
item.key = item.id + item.type;
item.children && item.children.forEach(childrenItem => {
childrenItem.key = childrenItem.id + item.type;
});
});
this.treeList = res.data;
this.getExpandList(filterSelect);
// this.changeCityWithPage(this.treeList);
this.$nextTick(() => {
2019-10-22 20:01:03 +08:00
const checkId = localStore.get('trainingPlatformCheckId'+filterSelect+this.userId) || null;
2019-10-18 17:15:04 +08:00
this.$refs.tree && this.$refs.tree.setCurrentKey(checkId);
this.loading = false;
});
} catch (error) {
this.loading = false;
this.$messageBox(this.$t('error.refreshFailed'));
}
},
nodeExpand(obj, node, ele) {
const key = obj.id;
this.expandList = this.expandList.filter(item => item!==key);
this.expandList.push(key);
2019-10-22 20:01:03 +08:00
localStore.set('trainIngPlatformExpandList'+this.filterSelect+this.userId, this.expandList);
2019-10-18 17:15:04 +08:00
},
nodeCollapse(obj, node, ele) {
const key = obj.id;
this.expandList = this.expandList.filter(item => item!==key);
2019-10-22 20:01:03 +08:00
localStore.set('trainIngPlatformExpandList'+this.filterSelect+this.userId, this.expandList);
2019-10-18 17:15:04 +08:00
},
getExpandList(filterSelect) {
2019-10-22 20:01:03 +08:00
let expand = localStore.get('trainIngPlatformExpandList'+filterSelect+this.userId);
2019-10-18 17:15:04 +08:00
expand = expand?(expand+'').split(','):'';
if (expand instanceof Array) {
this.expandList = expand;
}
}
// changeCityWithPage(treeList) {
// if (treeList.length > 0) {
// this.$router.push({ path: `${UrlConfig.trainingPlatform.permission}/${treeList[0].id}`});
// this.$refs.tree.setCurrentKey(treeList[0].id);
// }
// }
}
};
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>