实训调整

This commit is contained in:
fan 2022-08-31 17:03:10 +08:00
parent a1dd644078
commit e935e29001
5 changed files with 55 additions and 16 deletions

View File

@ -8,7 +8,8 @@ const training = {
simulationPause: false, // 实训 暂停判断 simulationPause: false, // 实训 暂停判断
stepOrder: 1, stepOrder: 1,
operateOrder: 0, operateOrder: 0,
stepOverCount: 0 stepOverCount: 0,
trainingScore: ''
}, },
getters: { getters: {
teachMode: (state) => { teachMode: (state) => {
@ -28,6 +29,9 @@ const training = {
}, },
stepOverCount: (state) => { stepOverCount: (state) => {
return state.stepOverCount; return state.stepOverCount;
},
trainingScore: (state) => {
return state.trainingScore;
} }
}, },
mutations: { mutations: {
@ -63,6 +67,9 @@ const training = {
}, },
clearStepOverCount: (state) => { clearStepOverCount: (state) => {
state.clearStepOverCount = 0; state.clearStepOverCount = 0;
},
setTrainingScore: (state, score) => {
state.trainingScore = score;
} }
}, },
actions: { actions: {
@ -99,6 +106,9 @@ const training = {
clearStepOverCount: ({commit}) => { clearStepOverCount: ({commit}) => {
commit('clearStepOverCount'); commit('clearStepOverCount');
}, },
setTrainingScore: ({commit}, score) => {
commit('setTrainingScore', score);
},
checkTrainingOperate:({commit, state}, trainingOperate) => { checkTrainingOperate:({commit, state}, trainingOperate) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const stepList = JSON.parse(state.trainingDetail.stepJson); const stepList = JSON.parse(state.trainingDetail.stepJson);

View File

@ -10,6 +10,7 @@
<el-radio-button :label="TrainingMode.PRACTICE">{{ $t('display.lesson.practiceMode') }}</el-radio-button> <el-radio-button :label="TrainingMode.PRACTICE">{{ $t('display.lesson.practiceMode') }}</el-radio-button>
<el-radio-button :label="TrainingMode.TEST">{{ $t('display.lesson.testMode') }}</el-radio-button> <el-radio-button :label="TrainingMode.TEST">{{ $t('display.lesson.testMode') }}</el-radio-button>
</el-radio-group> </el-radio-group>
<span v-if="demoMode === TrainingMode.TEST" class="display-score">{{ $t('display.lesson.score') }}{{ trainingScore }}</span>
</div> </div>
<TrainingList ref="trainingList" @editBlob="editBlob" /> <TrainingList ref="trainingList" @editBlob="editBlob" />
</div> </div>
@ -44,6 +45,9 @@ export default {
}, },
trainingSwitch() { trainingSwitch() {
return this.$store.state.trainingNew.trainingSwitch; return this.$store.state.trainingNew.trainingSwitch;
},
trainingScore() {
return this.$store.state.trainingNew.trainingScore;
} }
}, },
mounted() { mounted() {
@ -109,4 +113,20 @@ export default {
overflow: hidden; overflow: hidden;
z-index: 35; z-index: 35;
} }
.display-score {
background-color: black;
display: -moz-inline-box;
display: inline-block;
text-align: left;
border: 1px solid lightskyblue;
width: 100px;
height: 32px;
line-height: 24px;
border-radius: 4px;
padding-left: 2px;
margin-left: 10px;
font-family: "Microsoft" !important;
font-size: 18px !important;
color: #fff;
}
</style> </style>

View File

@ -78,6 +78,7 @@ export default {
this.$store.dispatch('trainingNew/changeTeachMode', ''); this.$store.dispatch('trainingNew/changeTeachMode', '');
}, },
mounted() { mounted() {
this.$store.dispatch('trainingNew/setTrainingScore', '');
}, },
methods: { methods: {
overallTranslation(flag) { overallTranslation(flag) {
@ -96,6 +97,7 @@ export default {
handlerStart() { handlerStart() {
startTraining(this.group, {mode: this.teachMode}).then(() => { startTraining(this.group, {mode: this.teachMode}).then(() => {
this.$store.dispatch('trainingNew/trainingStart'); this.$store.dispatch('trainingNew/trainingStart');
this.$store.dispatch('trainingNew/setTrainingScore', '');
}).catch(() => { }).catch(() => {
this.$message.error('开始实训失败!'); this.$message.error('开始实训失败!');
}); });
@ -109,10 +111,11 @@ export default {
}); });
}, },
handlerEnd() { handlerEnd() {
endTraining(this.group).then(() => { endTraining(this.group).then((resp) => {
this.$store.dispatch('trainingNew/trainingEnd'); this.$store.dispatch('trainingNew/trainingEnd');
this.$store.dispatch('socket/clearTrainingStepTip'); this.$store.dispatch('socket/clearTrainingStepTip');
this.$store.dispatch('trainingNew/clearStepOrder'); this.$store.dispatch('trainingNew/clearStepOrder');
this.$store.dispatch('trainingNew/setTrainingScore', resp.data);
}).catch(() => { }).catch(() => {
this.$message.error('结束实训失败!'); this.$message.error('结束实训失败!');
}); });

View File

@ -191,6 +191,7 @@ export default {
setOperations(data) { setOperations(data) {
if (data) { if (data) {
this.tableData[data.index].operations = data.stepDetail.operations; this.tableData[data.index].operations = data.stepDetail.operations;
} }
}, },
handleDelete(index, row) { handleDelete(index, row) {

View File

@ -13,12 +13,12 @@
<el-row style="font-size: 16px;padding: 5px;overflow: hidden;word-wrap: break-word;"> <el-row style="font-size: 16px;padding: 5px;overflow: hidden;word-wrap: break-word;">
<el-col :span="4">操作详情</el-col> <el-col :span="4">操作详情</el-col>
<el-col :span="20"> <el-col :span="20">
<!-- <div v-for="item in stepDetail.operations" :key="item"> <!--<div v-for="item in stepDetail.operations" :key="item">
<div>{{ item }}</div> <div>{{ item }}</div>
</div>--> </div>-->
<template v-for="(item, index) in stepDetail.operations"> <template v-for="(item, index) in stepDetail.operations">
<div :key="index"> <div :key="index">
<el-tag closable @close="deleteOperation(index)"> <el-tag :type="tagIndex === index? 'success':''" closable @close="deleteOperation(index)" @click="changeTagIndex(index)">
{{ covertString(item) }} {{ covertString(item) }}
</el-tag> </el-tag>
</div> </div>
@ -41,6 +41,7 @@ export default {
dialogVisible: false, dialogVisible: false,
dialogWidth: 500, dialogWidth: 500,
dataIndex: 0, dataIndex: 0,
tagIndex: 0,
stepDetail: { stepDetail: {
id: '', id: '',
description: '', description: '',
@ -66,8 +67,6 @@ export default {
methods: { methods: {
doShow(data) { doShow(data) {
if (data) { if (data) {
// this.stepDetail = data;
// console.log(this.stepDetail, 'stepDetail');
this.stepDetail.id = data.data.id; this.stepDetail.id = data.data.id;
this.stepDetail.description = data.data.description; this.stepDetail.description = data.data.description;
this.stepDetail.operations = data.data.operations || []; this.stepDetail.operations = data.data.operations || [];
@ -79,10 +78,22 @@ export default {
this.dialogVisible = true; this.dialogVisible = true;
}, },
deleteOperation(index) { deleteOperation(index) {
if (this.tagIndex === index) {
this.tagIndex = 0;
}
this.stepDetail.operations.splice(index, 1); this.stepDetail.operations.splice(index, 1);
}, },
changeTagIndex(index) {
this.tagIndex = index;
},
backStepList() { backStepList() {
this.$emit('backStepList', { index: this.dataIndex, stepDetail: this.stepDetail }); const tipPosition = {};
if (this.stepDetail.operations[this.tagIndex]) {
tipPosition.domId = this.stepDetail.operations[this.tagIndex].domId;
tipPosition.deviceCode = this.stepDetail.operations[this.tagIndex].deviceCode;
tipPosition.operateIndex = this.tagIndex;
}
this.$emit('backStepList', { index: this.dataIndex, stepDetail: this.stepDetail, tipPosition: tipPosition });
this.dialogVisible = false; this.dialogVisible = false;
this.stepDetail = { this.stepDetail = {
id: '', id: '',
@ -90,15 +101,9 @@ export default {
operations: [] operations: []
}; };
this.dataIndex = 0; this.dataIndex = 0;
this.tagIndex = 0;
}, },
covertString(data) { covertString(data) {
// const datate = {
// deviceCode: '',
// userOperationType: '',
// domId: '',
// operationType: '',
// params: ''
// };
const userOperationTypeMap = { const userOperationTypeMap = {
rightClick: '右键点击', rightClick: '右键点击',
leftClick: '左键点击', leftClick: '左键点击',
@ -137,8 +142,8 @@ export default {
.editContentTabLable{ .editContentTabLable{
position: absolute; position: absolute;
background: #fff; background: #fff;
border-radius: 5px 0px 0px 5px ; border-radius: 5px 0 0 5px ;
padding: 5px 0px; padding: 5px 0;
width: 23px; width: 23px;
text-align: center; text-align: center;
left: 50%; left: 50%;