rt-sim-training-client/src/views/lesson/trainingmanage/index.vue

284 lines
12 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-10-29 13:15:57 +08:00
<div style="height: 100%; overflow-y: auto;">
2019-11-11 13:34:35 +08:00
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" style="width: 98%;margin-left:1%;margin-top:20px;" />
2019-08-08 15:27:30 +08:00
<training-draft
ref="draftTrain"
2019-10-30 18:07:09 +08:00
:map-id-list="mapIdList"
2019-08-08 15:27:30 +08:00
:training-type-list="trainingTypeList"
:training-operate-type-map="trainingOperateTypeMap"
@refresh="reloadTable"
/>
2019-10-17 18:27:49 +08:00
<div class="draft">
<el-button-group>
<el-button type="primary" @click="turnback">{{ $t('global.back') }}</el-button>
</el-button-group>
</div>
2019-08-08 15:27:30 +08:00
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
2020-03-26 18:42:01 +08:00
import { pageQueryTraining, pageQueryTrainingNew } from '@/api/jmap/training';
2020-03-27 10:51:49 +08:00
import { trainingNotify, trainingNotifyNew } from '@/api/simulation';
2019-08-08 15:27:30 +08:00
import { launchFullscreen } from '@/utils/screen';
2019-11-08 16:22:05 +08:00
import { getPublishMapListOnline } from '@/api/jmap/map';
2019-08-08 15:27:30 +08:00
import { UrlConfig } from '@/router/index';
import TrainingDraft from './draft';
import localStore from 'storejs';
2019-07-26 13:32:43 +08:00
2019-08-08 15:27:30 +08:00
export default {
2019-10-29 13:15:57 +08:00
name: 'TrainingGeneration',
components: {
TrainingDraft
},
data() {
return {
2019-10-30 18:07:09 +08:00
mapIdList: [],
2019-10-29 13:15:57 +08:00
trainingTypeList: [],
trainingOperateTypeMap: {},
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '120px',
queryObject: {
prdType: {
2019-10-29 13:15:57 +08:00
type: 'select',
label: this.$t('lesson.prdType'),
2019-10-29 13:15:57 +08:00
change: this.prdChoose,
config: {
data: []
}
},
type: {
type: 'select',
label: this.$t('lesson.trainingType'),
change: this.typeChoose,
config: {
data: []
}
},
operateType: {
type: 'select',
label: this.$t('lesson.operationType'),
config: {
data: []
}
},
name: {
type: 'text',
label: this.$t('lesson.trainingName')
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('lesson.trainingName'),
prop: 'name'
},
{
title: this.$t('lesson.prdType'),
prop: 'prdType',
2019-10-29 13:15:57 +08:00
type: 'tag',
columnValue: (row) => { return this.$convertField(row.prdType, this.prdTypeList, ['value', 'label']); },
2019-10-29 13:15:57 +08:00
tagType: (row) => { return 'success'; }
},
{
title: this.$t('lesson.trainingType'),
prop: 'type',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.type, this.trainingTypeList, ['code', 'name']); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('lesson.operationType'),
prop: 'operateType',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.operateType, this.trainingOperateTypeMap[row.type], ['code', 'name']); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('lesson.minDuration'),
prop: 'minDuration'
},
{
title: this.$t('lesson.maxDuration'),
prop: 'maxDuration'
},
{
title: this.$t('lesson.remarks'),
prop: 'remarks'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '250',
buttons: [
{
name: this.$t('lesson.demonstration'),
handleClick: this.demoDisplay,
type: ''
}
/* {
2019-10-21 10:02:49 +08:00
name: this.$t('lesson.trainingRecord'),
2019-10-18 17:32:14 +08:00
handleClick: this.trainingRecord,
type: ''
2019-10-21 11:15:15 +08:00
}*/
2019-10-29 13:15:57 +08:00
]
}
],
actions: [
{ text: this.$t('lesson.generateTraining'), btnCode: 'employee_auto', handler: this.autoMaticTrainging },
{ text: this.$t('lesson.updateTraining'), btnCode: 'employee_edit', handler: this.editTrainingByType, type: 'warning'},
{ text: this.$t('lesson.deleteTraining'), btnCode: 'employee_delete', handler: this.delAutoMaticTrainging, type: 'danger'}
]
},
2019-07-26 13:32:43 +08:00
2019-10-29 13:15:57 +08:00
currentModel: {}
};
},
computed:{
prdTypeList() {
const productTypeList = ConstConfig.ConstSelect.prdType;
return Cookies.get('user_lang') == 'en'
? productTypeList.map(elem => { return { value: elem.value, label: elem.enlabel }; })
: productTypeList.map(elem => { return { value: elem.value, label: elem.label }; });
}
},
2019-10-29 13:15:57 +08:00
async created() {
await this.loadInitData();
const json = localStore.get(this.$route.path);
json.type = '';
json.prdType = '';
2019-10-29 13:15:57 +08:00
json.operateType = '';
},
methods: {
async loadInitData() {
2019-10-30 18:07:09 +08:00
this.mapIdList = [];
this.queryForm.queryObject.prdType.config.data = [];
2019-11-08 16:22:05 +08:00
getPublishMapListOnline().then(response => {
2019-10-30 18:07:09 +08:00
this.mapIdList = response.data;
2019-10-29 13:15:57 +08:00
});
this.queryForm.queryObject.prdType.config.data = this.prdTypeList;
2019-07-26 13:32:43 +08:00
2019-10-29 13:15:57 +08:00
// 获取实训类型
this.trainingTypeList = [];
this.$Dictionary.trainingType().then(list => {
this.trainingTypeList = list;
list.forEach(elem => {
this.queryForm.queryObject.type.config.data.push({ value: elem.code, label: elem.name });
});
});
2019-07-26 13:32:43 +08:00
2019-10-29 13:15:57 +08:00
this.trainingOperateTypeMap = {};
const list01 = await this.$Dictionary.stationControl();
this.trainingOperateTypeMap['01'] = list01; // 控制权实训
const list02 = await this.$Dictionary.signalOperation();
this.trainingOperateTypeMap['02'] = list02; // 信号机实训
const list03 = await this.$Dictionary.switchOperation();
this.trainingOperateTypeMap['03'] = list03; // 道岔实训
const list04 = await this.$Dictionary.sectionOperation();
this.trainingOperateTypeMap['04'] = list04; // 区段实训
const list05 = await this.$Dictionary.stationStandOperation();
this.trainingOperateTypeMap['05'] = list05; // 站台实训
const list06 = await this.$Dictionary.trainPlanOperation();
this.trainingOperateTypeMap['06'] = list06; // 行车计划实训
const list07 = await this.$Dictionary.trainOperation();
this.trainingOperateTypeMap['07'] = list07; // 列车实训
const list08 = await this.$Dictionary.limitOperation();
this.trainingOperateTypeMap['08'] = list08; // 限速实训
this.reloadTable();
},
prdChoose(form) {
form.type = '';
form.operateType = '';
},
typeChoose(form) {
this.queryForm.queryObject.operateType.config.data = [];
form.operateType = '';
if (form && form.type) {
this.trainingOperateTypeMap[form.type].forEach(elem => {
this.queryForm.queryObject.operateType.config.data.push({ value: elem.code, label: elem.name });
});
}
},
autoMaticTrainging() {
this.$refs.draftTrain.show({ event: '01', title: this.$t('lesson.automaticGenerationOfTraining') });
},
editTrainingByType() {
this.$refs.draftTrain.show({ event: '02', title: this.$t('lesson.modifyTrainingByCategory') });
},
delAutoMaticTrainging() {
this.$refs.draftTrain.show({ event: '03', title: this.$t('lesson.deleteAutoGeneratedTraining') });
},
demoDisplay(index, node) {
2020-03-27 10:51:49 +08:00
if (this.$route.query.drawWay == 'true') {
trainingNotifyNew({ trainingId: node.id }).then(resp => {
/** 区分演示和正式需要在演示时设置lessonId为0*/
const query = { group: resp.data, trainingId: node.id, lessonId: 0, mapId: this.$route.query.mapId};
this.$router.push({ path: `${UrlConfig.display}/manage`, query: query });
launchFullscreen();
}).catch(error => {
this.$messageBox(this.$t('error.createSimulationFailed') + error.message);
});
} else {
trainingNotify({ trainingId: node.id }).then(resp => {
/** 区分演示和正式需要在演示时设置lessonId为0*/
const query = { group: resp.data, trainingId: node.id, lessonId: 0, mapId: this.$route.query.mapId};
this.$router.push({ path: `${UrlConfig.display}/manage`, query: query });
launchFullscreen();
}).catch(error => {
this.$messageBox(this.$t('error.createSimulationFailed') + error.message);
});
}
2019-10-29 13:15:57 +08:00
},
reloadTable() {
this.queryList.reload();
},
turnback() {
this.$router.go(-1);
},
trainingRecord(index, node) {
2020-03-27 10:51:49 +08:00
if (this.$route.query.drawWay == 'true') {
trainingNotifyNew({ trainingId: node.id }).then(resp => {
this.group = resp.data;
this.$router.push({ path: `${UrlConfig.design.trainingRecord}/${node.id}/${node.name}`, query: { group: resp.data } });
}).catch(error => {
this.$messageBox(`${this.$t('error.createSimulationFailed')}: ${error.message}`);
});
} else {
trainingNotify({ trainingId: node.id }).then(resp => {
this.group = resp.data;
this.$router.push({ path: `${UrlConfig.design.trainingRecord}/${node.id}/${node.name}`, query: { group: resp.data } });
}).catch(error => {
this.$messageBox(`${this.$t('error.createSimulationFailed')}: ${error.message}`);
});
}
2019-10-29 13:15:57 +08:00
},
queryFunction(params) {
params['mapId'] = this.$route.query.mapId;
2020-03-26 18:42:01 +08:00
if (this.$route.query.drawWay == 'true') {
return pageQueryTrainingNew(params);
} else {
return pageQueryTraining(params);
}
2019-10-29 13:15:57 +08:00
}
}
2019-08-08 15:27:30 +08:00
};
</script>
2019-09-30 16:20:31 +08:00
<style rel="stylesheet/scss" lang="scss" scoped>
.draft {
width: 400px;
text-align: center;
margin: 20px auto;
}
</style>