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

305 lines
9.3 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-08 15:27:30 +08:00
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<training-draft
ref="draftTrain"
2019-08-29 17:16:33 +08:00
:skin-code-list="skinCodeList"
2019-08-08 15:27:30 +08:00
:training-type-list="trainingTypeList"
:training-operate-type-map="trainingOperateTypeMap"
@refresh="reloadTable"
/>
2019-09-30 16:20:31 +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>
2019-08-08 15:27:30 +08:00
import { pageQueryTraining } from '@/api/jmap/training';
import { trainingNotify } from '@/api/simulation';
import { getCommodityMapProduct, getProductList } from '@/api/management/mapprd';
import { launchFullscreen } from '@/utils/screen';
2019-08-29 17:16:33 +08:00
import { getSkinCodeList } from '@/api/management/mapskin';
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 {
name: 'TrainingGeneration',
components: {
TrainingDraft
},
data() {
return {
2019-08-29 17:16:33 +08:00
skinCodeList: [],
2019-08-08 15:27:30 +08:00
trainingTypeList: [],
prdTypeList: [],
trainingOperateTypeMap: {},
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
2019-08-29 17:16:33 +08:00
labelWidth: '120px',
2019-08-08 15:27:30 +08:00
initLoadCallback: this.loadInitQueryList,
queryObject: {
2019-08-29 17:16:33 +08:00
skinCode: {
2019-08-08 15:27:30 +08:00
type: 'select',
2019-08-29 17:16:33 +08:00
label: this.$t('lesson.skinType'),
change: this.skinCodeChoose,
2019-08-08 15:27:30 +08:00
config: {
data: []
}
},
prdCode: {
type: 'select',
2019-08-29 17:16:33 +08:00
label: this.$t('lesson.product'),
2019-08-08 15:27:30 +08:00
change: this.prdChoose,
config: {
data: []
}
},
type: {
type: 'select',
2019-08-29 17:16:33 +08:00
label: this.$t('lesson.trainingType'),
2019-08-08 15:27:30 +08:00
change: this.typeChoose,
config: {
data: []
}
},
operateType: {
type: 'select',
2019-08-29 17:16:33 +08:00
label: this.$t('lesson.operationType'),
2019-08-08 15:27:30 +08:00
config: {
data: []
}
},
generateType: {
type: 'select',
2019-08-29 17:16:33 +08:00
label: this.$t('lesson.automaticOrManual'),
2019-08-08 15:27:30 +08:00
config: {
2019-08-29 17:16:33 +08:00
data: [{ value: '02', label: this.$t('lesson.manual') }, { value: '01', label: this.$t('lesson.automatic') }]
2019-08-08 15:27:30 +08:00
}
},
name: {
type: 'text',
2019-08-29 17:16:33 +08:00
label: this.$t('lesson.trainingName')
2019-08-08 15:27:30 +08:00
}
}
},
queryList: {
query: pageQueryTraining,
selectCheckShow: false,
indexShow: true,
columns: [
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.trainingName'),
2019-08-08 15:27:30 +08:00
prop: 'name'
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.skinType'),
prop: 'skinCode',
2019-08-08 15:27:30 +08:00
type: 'tag',
2019-08-29 17:16:33 +08:00
columnValue: (row) => { return this.$convertField(row.skinCode, this.skinCodeList, ['code', 'name']); },
2019-08-08 15:27:30 +08:00
tagType: (row) => { return ''; }
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.product'),
2019-08-08 15:27:30 +08:00
prop: 'prdCode',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.prdCode, this.prdTypeList, ['code', 'name']); },
2019-08-08 15:27:30 +08:00
tagType: (row) => { return 'success'; }
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.trainingType'),
2019-08-08 15:27:30 +08:00
prop: 'type',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.type, this.trainingTypeList, ['code', 'name']); },
2019-08-08 15:27:30 +08:00
tagType: (row) => { return 'success'; }
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.operationType'),
2019-08-08 15:27:30 +08:00
prop: 'operateType',
type: 'tag',
2019-08-08 15:57:36 +08:00
columnValue: (row) => { return this.$convertField(row.operateType, this.trainingOperateTypeMap[row.type], ['code', 'name']); },
2019-08-08 15:27:30 +08:00
tagType: (row) => { return 'success'; }
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.minDuration'),
2019-08-08 15:27:30 +08:00
prop: 'minDuration'
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.maxDuration'),
2019-08-08 15:27:30 +08:00
prop: 'maxDuration'
},
{
2019-08-29 17:16:33 +08:00
title: this.$t('lesson.remarks'),
2019-08-08 15:27:30 +08:00
prop: 'remarks'
},
{
type: 'button',
2019-08-29 17:16:33 +08:00
title: this.$t('global.operate'),
2019-08-08 15:27:30 +08:00
width: '250',
buttons: [
{
2019-08-29 17:16:33 +08:00
name: this.$t('lesson.demonstration'),
2019-08-08 15:27:30 +08:00
handleClick: this.demoDisplay,
type: ''
2019-09-30 16:20:31 +08:00
},
{
name: '实训录制',
handleClick: this.trainingRecord,
type: ''
}
2019-08-08 15:27:30 +08:00
]
}
],
actions: [
2019-08-29 17:16:33 +08:00
{ text: this.$t('lesson.generateTraining'), btnCode: 'employee_insert', handler: this.autoMaticTrainging },
{ text: this.$t('lesson.updateTraining'), btnCode: 'employee_insert', handler: this.editTrainingByType, type: 'warning'},
{ text: this.$t('lesson.deleteTraining'), btnCode: 'employee_insert', handler: this.delAutoMaticTrainging, type: 'danger'}
2019-08-08 15:27:30 +08:00
]
},
2019-07-26 13:32:43 +08:00
2019-08-08 15:27:30 +08:00
currentModel: {}
};
},
async created() {
await this.loadInitData();
const json = localStore.get(this.$route.path);
if (json && json.type) {
this.typeChoose(json);
}
if (json && json.prdCode) {
2019-08-29 17:16:33 +08:00
this.skinCodeChoose(json);
2019-08-08 15:27:30 +08:00
}
},
methods: {
async loadInitData() {
2019-08-29 17:16:33 +08:00
this.skinCodeList = [];
this.queryForm.queryObject.skinCode.config.data = [];
getSkinCodeList().then(response => {
this.skinCodeList = response.data;
2019-08-08 15:27:30 +08:00
response.data.forEach(elem => {
2019-08-29 17:16:33 +08:00
this.queryForm.queryObject.skinCode.config.data.push({ value: elem.code, label: elem.name });
2019-08-08 15:27:30 +08:00
});
});
2019-07-26 13:32:43 +08:00
2019-08-08 15:27:30 +08:00
this.prdTypeList = [];
getProductList({ pageSize: 500, pageNum: 1 }).then(res => {
const list = res.data.list;
if (list && list.length > 0) {
this.prdTypeList = list.filter(elem => { return elem.prdType != '03'; });
}
});
2019-07-26 13:32:43 +08:00
2019-08-08 15:27:30 +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-08-08 15:27:30 +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();
},
loadInitQueryList(form) {
2019-08-29 17:16:33 +08:00
if (form && form.skinCode) {
getCommodityMapProduct(form.skinCode).then((response) => {
2019-08-08 15:27:30 +08:00
const productList = response.data;
if (productList && productList.length > 0) {
productList.forEach(elem => {
// 过滤综合演练产品
if (elem.prdType != '03') {
this.queryForm.queryObject.prdCode.config.data.push({ value: elem.code, label: elem.name });
}
});
}
});
}
},
2019-08-29 17:16:33 +08:00
skinCodeChoose(form) {
2019-08-08 15:27:30 +08:00
this.queryForm.queryObject.prdCode.config.data = [];
form.type = '';
form.prdCode = '';
form.operateType = '';
this.loadInitQueryList(form);
},
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() {
2019-08-29 17:16:33 +08:00
this.$refs.draftTrain.show({ event: '01', title: this.$t('lesson.automaticGenerationOfTraining') });
2019-08-08 15:27:30 +08:00
},
editTrainingByType() {
2019-08-29 17:16:33 +08:00
this.$refs.draftTrain.show({ event: '02', title: this.$t('lesson.modifyTrainingByCategory') });
2019-08-08 15:27:30 +08:00
},
delAutoMaticTrainging() {
2019-08-29 17:16:33 +08:00
this.$refs.draftTrain.show({ event: '03', title: this.$t('lesson.deleteAutoGeneratedTraining') });
2019-08-08 15:27:30 +08:00
},
demoDisplay(index, node) {
trainingNotify({ trainingId: node.id }).then(resp => {
/** 区分演示和正式需要在演示时设置lessonId为0*/
const query = { group: resp.data, trainingId: node.id, lessonId: 0 };
this.$router.push({ path: `${UrlConfig.display}/manage`, query: query });
launchFullscreen();
}).catch(error => {
2019-08-29 17:16:33 +08:00
this.$messageBox(this.$t('error.createSimulationFailed') +error.message);
2019-08-08 15:27:30 +08:00
});
2019-07-26 13:32:43 +08:00
2019-08-08 15:27:30 +08:00
},
reloadTable() {
this.queryList.reload();
2019-09-30 16:20:31 +08:00
},
turnback() {
this.$router.go(-1)
},
trainingRecord(index, node) {
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-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>