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

282 lines
12 KiB
Vue
Raw Normal View History

2019-09-23 17:49:04 +08:00
<template>
2021-04-16 09:48:03 +08:00
<div v-loading="loading" class="map-list-main">
<div class="mapListName">
<span>{{ $t('global.mapList') }}</span>
2019-10-18 17:15:04 +08:00
</div>
2021-04-16 09:48:03 +08:00
<template v-if="!IsProject">
<filter-city ref="filerCity" filter-empty local-param-name="training_cityCode" @filterSelectChange="refresh" />
<el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
</template>
2021-01-05 15:09:07 +08:00
<div id="trainingMapTree" class="left-map-list">
<el-tree
ref="tree"
:data="treeList"
node-key="key"
:props="{children:'children',label:'name'}"
highlight-current
:span="22"
:filter-node-method="filterNode"
:default-expanded-keys="expandList"
@node-click="clickEvent"
@node-expand="nodeExpand"
@node-collapse="nodeCollapse"
>
<span slot-scope="{ node }">
<span
class="el-icon-tickets"
/>
2021-01-05 15:09:07 +08:00
<span v-if="node.data.id ==='Simulation'" :id="node.data.key">&nbsp;{{ node.data.name+ $t('global.simulationSystem') }}</span>
<span v-else-if="node.data.id ==='Lesson'" :id="node.data.key">&nbsp;{{ node.data.name+ $t('global.lessonSystem') }}</span>
<span v-else-if="node.data.id ==='Exam'" :id="node.data.key">&nbsp;{{ node.data.name+ $t('global.examSystem') }}</span>
<span v-else-if="node.data.id ==='Plan'" :id="node.data.key">&nbsp;{{ node.data.name+ $t('global.runPlanSystem') }}</span>
<span v-else :id="node.data.key">&nbsp;{{ node.data.name }}</span>
</span>
</el-tree>
2019-10-29 14:41:47 +08:00
</div>
</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';
import { getPublishMapInfo } from '@/api/jmap/map';
import { UrlConfig } from '@/scripts/ConstDic';
2019-10-18 17:15:04 +08:00
import FilterCity from '@/views/components/filterCity';
import localStore from 'storejs';
import { getSessionStorage } from '@/utils/auth';
2020-07-09 10:25:04 +08:00
import { GetMapListByProjectList } from '@/scripts/ProjectConfig';
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
},
data() {
return {
loading: true,
filterText: '',
treeList: [],
mapId: '',
expandList: [],
2020-11-25 13:31:36 +08:00
filterSelect: ''
2019-10-29 14:41:47 +08:00
};
},
computed: {
userId() {
return this.$store.state.user.id;
},
project() {
return getSessionStorage('project');
},
IsProject() {
// 实训平台 是否为通过项目code获取地图列表的项目
return GetMapListByProjectList.includes(this.project);
2019-10-29 14:41:47 +08:00
}
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
mounted() {
if (this.IsProject) {
2019-10-29 14:41:47 +08:00
this.refresh();
}
},
methods: {
filterNode(value, data) {
if (!value) return true;
2020-11-12 14:06:13 +08:00
return data.name.includes(value);
2019-10-29 14:41:47 +08:00
},
2020-09-22 11:31:18 +08:00
clickEvent(obj, data, ele, isReplace = false) {
if (ele) {
if ( ele.expanded) {
ele.expanded = false;
} else {
ele.expanded = true;
}
}
localStore.set('trainingPlatformCheckId' + this.filterSelect + this.userId + this.project, obj.key);
2020-12-04 18:10:07 +08:00
this.mapId = obj.key.split('-')[0];
2019-10-29 14:41:47 +08:00
if ( obj.type === 'Map') {
this.mapId = obj.id;
2020-11-30 11:14:52 +08:00
const router = { path: `${UrlConfig.trainingPlatform.permission}/${this.mapId}`};
this.toNextPage(isReplace, router);
} else if ( obj.type === 'System' ) {
const router = { path: `${UrlConfig.trainingPlatform.secondaryHome}`, query: { type: obj.id } };
this.toNextPage(isReplace, router);
2019-10-29 14:41:47 +08:00
} else if ( obj.type === 'MapSystem') {
getSubSystemInfo(obj.id).then(resp => { // 查询子系统信息
2019-10-29 14:41:47 +08:00
let router = '';
switch (resp.data.type) {
case 'Exam':
2021-03-30 14:31:25 +08:00
// this.setLocalRoute(`${UrlConfig.trainingPlatform.examHome}/${obj.id}`);
2021-03-30 10:40:38 +08:00
// router = localStore.get('examDetail' + obj.id);
// if (!router) { router = { path: `${UrlConfig.trainingPlatform.examHome}/${obj.id}`}; }
// this.toNextPage(isReplace, router);
2021-03-30 14:31:25 +08:00
router = { path: `${UrlConfig.trainingPlatform.examHome}/${obj.id}`};
this.toNextPage(isReplace, router);
2019-10-29 14:41:47 +08:00
break;
case 'Lesson':
this.setLocalRoute(`${UrlConfig.trainingPlatform.teachHome}/${obj.id}`);
2021-01-12 13:18:52 +08:00
router = { path: `${UrlConfig.trainingPlatform.teachHome}/${obj.id}`};
2020-11-30 11:14:52 +08:00
this.toNextPage(isReplace, router);
2019-10-29 14:41:47 +08:00
break;
case 'Simulation':
if (resp.data.prdType == '08') {
// 运行图编辑工作站
getPublishMapInfo(this.mapId).then(rest => {
this.setLocalRoute(`${UrlConfig.trainingPlatform.runPlan}/${this.mapId}?lineCode=${rest.data.lineCode}`);
router = { path: `${UrlConfig.trainingPlatform.runPlan}/${this.mapId}`, query: { lineCode: rest.data.lineCode}};
this.toNextPage(isReplace, router);
});
} else {
this.setLocalRoute(`${UrlConfig.trainingPlatform.prodDetail}/${obj.id}?mapId=${this.mapId}`);
router = { path: `${UrlConfig.trainingPlatform.prodDetail}/${obj.id}`, query: { mapId: this.mapId}};
this.toNextPage(isReplace, router);
}
2019-10-29 14:41:47 +08:00
break;
}
}).catch((error) => {
if (error.code === '40004') {
this.$messageBox(this.$t('systemGenerate.getSubSystemInfoFail'));
}
});
}
},
2020-11-30 11:14:52 +08:00
toNextPage(isReplace, router) {
isReplace ? this.$router.replace(router) : this.$router.push(router);
},
2019-10-29 14:41:47 +08:00
setLocalRoute(path) {
localStore.set('trainingPlatformRoute' + this.userId + this.project, path);
2019-10-29 14:41:47 +08:00
},
forTree(item) {
item.children && item.children.forEach(childrenItem => {
2020-12-04 18:10:07 +08:00
childrenItem.key = item.key + '-' + childrenItem.id;
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 = {};
if (this.IsProject) {
2020-07-09 10:25:04 +08:00
res = await getSubSystemByProjectCode();
2019-10-29 14:41:47 +08:00
} 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 =>{
2020-12-04 18:10:07 +08:00
item.key = item.id;
this.forTree(item);
2019-10-29 14:41:47 +08:00
});
if (this.project === 'cgy') {
this.treeList = [];
res.data.forEach(item => {
const childList = [];
2022-06-27 13:22:25 +08:00
if (item && item.children && item.children.length > 3) {
item.children.forEach(elem => {
if (elem.id === 'Lesson') {
childList[0] = elem;
} else if (elem.id === 'Exam') {
childList[3] = elem;
} else if (elem.id === 'Simulation') {
childList[1] = elem;
} else {
childList[2] = elem;
}
});
item.children = childList;
}
});
}
2019-10-29 14:41:47 +08:00
this.treeList = res.data;
this.getExpandList(filterSelect);
this.$nextTick(() => {
2020-12-04 18:10:07 +08:00
let checkId = localStore.get('trainingPlatformCheckId' + filterSelect + this.userId + this.project) || null;
2020-12-06 21:56:00 +08:00
checkId = checkId && checkId.includes('-') ? checkId : null;
2019-10-29 14:41:47 +08:00
this.$refs.tree && this.$refs.tree.setCurrentKey(checkId);
if (!this.$route.path.includes('result') && !this.$route.path.includes('/trainingPlatform/teach/')) {
checkId && this.findTree(this.treeList, checkId);
!checkId && this.treeList && this.treeList.length && this.clickEvent(this.treeList[0], {data: this.treeList[0]});
}
2021-01-05 15:09:07 +08:00
setTimeout(()=> {
if (checkId) {
const checkIdDom = document.getElementById(checkId);
const mapTreeDom = document.getElementById('trainingMapTree');
if (checkIdDom && mapTreeDom) {
mapTreeDom.scrollTop = checkIdDom.offsetTop;
}
2021-01-05 15:09:07 +08:00
}
2021-01-06 16:01:26 +08:00
this.loading = false;
2021-01-05 15:09:07 +08:00
}, 200);
2019-10-29 14:41:47 +08:00
});
} catch (error) {
this.loading = false;
this.$message.error(this.$t('error.refreshFailed'));
2019-10-29 14:41:47 +08:00
}
},
2020-07-24 10:14:59 +08:00
/* 根据localstorage缓存的trainingPlatformCheckId跳转右侧显示页面 */
findTree(treeList, checkId, data) {
treeList && treeList.length && treeList.forEach(item =>{
if (item.type === 'Map') {
data = item;
}
if (checkId === item.key) {
2020-09-22 11:31:18 +08:00
this.clickEvent(item, {data: data}, null, true);
2020-07-24 10:14:59 +08:00
} else {
this.findTree(item.children, checkId, data);
}
});
},
2019-10-29 14:41:47 +08:00
nodeExpand(obj, node, ele) {
const key = obj.key;
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.project, this.expandList);
2019-10-29 14:41:47 +08:00
},
nodeCollapse(obj, node, ele) {
const key = obj.key;
this.expandList = this.expandList.filter(item => (item !== key && !item.startsWith(`${key}-`)));
localStore.set('trainIngPlatformExpandList' + this.filterSelect + this.userId + this.project, this.expandList);
2019-10-29 14:41:47 +08:00
},
getExpandList(filterSelect) {
2020-07-24 10:14:59 +08:00
this.expandList = [];
let expand = localStore.get('trainIngPlatformExpandList' + filterSelect + this.userId + this.project);
2019-10-29 14:41:47 +08:00
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>
.mapListName{
padding: 15px 0px 15px 17px;
2019-09-23 17:49:04 +08:00
}
.left-map-list{
width: 100%;
flex: 1;
overflow: auto;
padding-bottom: 10px;
padding-top: 5px;
2019-09-23 17:49:04 +08:00
}
2019-10-29 14:41:47 +08:00
.map-list-main{
height: 100%;
display:flex;
flex-direction:column;
2019-10-29 14:41:47 +08:00
}
</style>
<style>
.el-tree {
overflow-x: hidden;
}
2019-09-23 17:49:04 +08:00
.el-tree-node.is-current>.el-tree-node__content {
background-color: #e4e3e3 !important;
}
</style>