2019-09-23 17:49:04 +08:00
|
|
|
<template>
|
2019-10-31 13:57:17 +08:00
|
|
|
<div v-loading="loading" class="joylink-card map-list-main">
|
|
|
|
<div class="clearfix">
|
2019-10-18 17:15:04 +08:00
|
|
|
<span>{{ $t('global.mapList') }}</span>
|
|
|
|
</div>
|
2019-10-29 14:41:47 +08:00
|
|
|
<div style="height: calc(100% - 47px);">
|
2020-01-13 13:33:35 +08:00
|
|
|
<filter-city v-if="project==='login' || project === 'hyd'" ref="filerCity" filter-empty :local-param-name="localParamName" @filterSelectChange="refresh" />
|
|
|
|
<el-input v-if="project==='login' ||project === 'hyd'" v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
|
2019-10-31 13:57:17 +08:00
|
|
|
<div style="height: calc(100% - 76px); overflow: auto;">
|
2019-10-29 14:41:47 +08:00
|
|
|
<el-tree
|
|
|
|
ref="tree"
|
|
|
|
:data="treeList"
|
2019-10-31 10:32:46 +08:00
|
|
|
node-key="key"
|
2019-10-29 14:41:47 +08:00
|
|
|
: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"
|
|
|
|
>
|
|
|
|
<span slot-scope="{ node }">
|
|
|
|
<span
|
|
|
|
class="el-icon-tickets"
|
|
|
|
/>
|
|
|
|
<span v-if="node.data.id ==='Simulation'"> {{ node.data.name+ $t('global.simulationSystem') }}</span>
|
|
|
|
<span v-else-if="node.data.id ==='Lesson'"> {{ node.data.name+ $t('global.lessonSystem') }}</span>
|
|
|
|
<span v-else-if="node.data.id ==='Exam'"> {{ node.data.name+ $t('global.examSystem') }}</span>
|
|
|
|
<span v-else-if="node.data.id ==='Plan'"> {{ node.data.name+ $t('global.runPlanSystem') }}</span>
|
|
|
|
<span v-else> {{ node.data.name }}</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-31 13:57:17 +08:00
|
|
|
</div>
|
2019-09-23 17:49:04 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
2019-10-29 14:14:14 +08:00
|
|
|
import { getTrainingSystemList, getSubSystemInfo, getSubSystemByProjectCode } 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-10-29 14:14:14 +08:00
|
|
|
import { ProjectCode } from '@/scripts/ConstDic';
|
2019-09-23 17:49:04 +08:00
|
|
|
|
2019-10-18 17:15:04 +08:00
|
|
|
export default {
|
2019-10-29 14:41:47 +08:00
|
|
|
name: 'DemonList',
|
|
|
|
components: {
|
|
|
|
FilterCity
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
height: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: true,
|
|
|
|
defaultShowKeys: [],
|
|
|
|
filterText: '',
|
|
|
|
treeList: [],
|
|
|
|
selected: {},
|
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
|
|
|
label: 'name'
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
},
|
|
|
|
mapId: '',
|
|
|
|
expandList: [],
|
|
|
|
filterSelect: '',
|
|
|
|
localParamName: 'training_cityCode'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
userId() {
|
|
|
|
return this.$store.state.user.id;
|
|
|
|
},
|
|
|
|
project() {
|
|
|
|
return getSessionStorage('project');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
filterText(val) {
|
|
|
|
this.$refs.tree.filter(val);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy () {
|
|
|
|
},
|
|
|
|
mounted() {
|
2019-12-30 18:06:40 +08:00
|
|
|
if (this.project === 'xty' || this.project === 'gzb') {
|
2019-10-29 14:41:47 +08:00
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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) {
|
|
|
|
localStore.set('trainingPlatformCheckId' + this.filterSelect + this.userId, obj.id);
|
|
|
|
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}`});
|
|
|
|
} else if ( obj.type === 'MapSystem') {
|
2019-12-26 11:01:54 +08:00
|
|
|
getSubSystemInfo(obj.id).then(resp => { // 查询子系统信息
|
2019-10-29 14:41:47 +08:00
|
|
|
let router = '';
|
|
|
|
switch (resp.data.type) {
|
|
|
|
case 'Exam':
|
|
|
|
this.setLocalRoute(`${UrlConfig.trainingPlatform.examHome}/${obj.id}`);
|
|
|
|
router = localStore.get('examDetail' + obj.id);
|
|
|
|
if (router) {
|
|
|
|
this.$router.push(router);
|
|
|
|
} else {
|
|
|
|
this.$router.push({ path: `${UrlConfig.trainingPlatform.examHome}/${obj.id}`});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Lesson':
|
|
|
|
this.setLocalRoute(`${UrlConfig.trainingPlatform.teachHome}/${obj.id}`);
|
|
|
|
router = localStore.get('teachDetail' + obj.id);
|
|
|
|
if (router) {
|
|
|
|
this.$router.push(router);
|
|
|
|
} else {
|
|
|
|
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachHome}/${obj.id}`});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Simulation':
|
|
|
|
this.setLocalRoute(`${UrlConfig.trainingPlatform.prodDetail}/${obj.id}?mapId=${this.mapId}`);
|
|
|
|
this.$router.push({ path: `${UrlConfig.trainingPlatform.prodDetail}/${obj.id}`, query: { mapId: this.mapId}});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}).catch((error) => {
|
|
|
|
if (error.code === '40004') {
|
|
|
|
this.$messageBox(this.$t('systemGenerate.getSubSystemInfoFail'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setLocalRoute(path) {
|
|
|
|
localStore.set('trainingPlatformRoute' + this.userId, path);
|
|
|
|
},
|
2019-10-31 10:32:46 +08:00
|
|
|
forTree(item) {
|
2019-10-31 13:57:17 +08:00
|
|
|
item.children && item.children.forEach(childrenItem => {
|
2019-10-31 10:32:46 +08:00
|
|
|
childrenItem.key = childrenItem.id + childrenItem.type;
|
|
|
|
if (childrenItem.children && childrenItem.children.length) {
|
|
|
|
this.forTree(childrenItem);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2019-10-29 14:41:47 +08:00
|
|
|
async refresh(filterSelect) {
|
|
|
|
this.loading = true;
|
|
|
|
this.treeList = [];
|
|
|
|
this.filterSelect = filterSelect;
|
|
|
|
try {
|
|
|
|
let res = {};
|
2019-12-30 18:06:40 +08:00
|
|
|
if (this.project === 'xty' || this.project === 'gzb') {
|
2019-10-29 14:41:47 +08:00
|
|
|
res = await getSubSystemByProjectCode(ProjectCode[this.project]);
|
|
|
|
} else {
|
|
|
|
res = await getTrainingSystemList(filterSelect);
|
|
|
|
}
|
2019-10-29 15:06:15 +08:00
|
|
|
this.$emit('goRoutePath', res.data);
|
2019-10-29 14:41:47 +08:00
|
|
|
res.data && res.data.forEach(item =>{
|
|
|
|
item.key = item.id + item.type;
|
2019-10-31 10:32:46 +08:00
|
|
|
this.forTree(item);
|
2019-10-29 14:41:47 +08:00
|
|
|
});
|
|
|
|
this.treeList = res.data;
|
|
|
|
this.getExpandList(filterSelect);
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const checkId = localStore.get('trainingPlatformCheckId' + filterSelect + this.userId) || null;
|
|
|
|
this.$refs.tree && this.$refs.tree.setCurrentKey(checkId);
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
this.loading = false;
|
2019-10-31 13:57:17 +08:00
|
|
|
this.$messageBox(this.$t('error.refreshFailed') + error);
|
2019-10-29 14:41:47 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
nodeExpand(obj, node, ele) {
|
2019-10-31 10:32:46 +08:00
|
|
|
const key = obj.id + obj.type;
|
2019-10-29 14:41:47 +08:00
|
|
|
this.expandList = this.expandList.filter(item => item !== key);
|
|
|
|
this.expandList.push(key);
|
|
|
|
localStore.set('trainIngPlatformExpandList' + this.filterSelect + this.userId, this.expandList);
|
|
|
|
},
|
|
|
|
nodeCollapse(obj, node, ele) {
|
2019-10-31 10:32:46 +08:00
|
|
|
const key = obj.id + obj.type;
|
2019-10-29 14:41:47 +08:00
|
|
|
this.expandList = this.expandList.filter(item => item !== key);
|
|
|
|
localStore.set('trainIngPlatformExpandList' + this.filterSelect + this.userId, this.expandList);
|
|
|
|
},
|
|
|
|
getExpandList(filterSelect) {
|
|
|
|
let expand = localStore.get('trainIngPlatformExpandList' + filterSelect + this.userId);
|
|
|
|
expand = expand ? (expand + '').split(',') : '';
|
|
|
|
if (expand instanceof Array) {
|
|
|
|
this.expandList = expand;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-18 17:15:04 +08:00
|
|
|
};
|
2019-09-23 17:49:04 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
2019-10-31 13:57:17 +08:00
|
|
|
.clearfix{
|
|
|
|
height: 47px;
|
|
|
|
line-height: 47px;
|
|
|
|
padding-left: 17px;
|
|
|
|
}
|
2019-09-23 17:49:04 +08:00
|
|
|
.back-home {
|
|
|
|
float: right;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: #3ea726;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<style>
|
|
|
|
.el-tree {
|
|
|
|
overflow-x: hidden;
|
|
|
|
}
|
2019-10-29 14:41:47 +08:00
|
|
|
.map-list-main{
|
|
|
|
text-align:left;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2019-09-23 17:49:04 +08:00
|
|
|
.el-tree-node.is-current>.el-tree-node__content {
|
|
|
|
background-color: #e4e3e3 !important;
|
|
|
|
}
|
|
|
|
</style>
|