2022-08-30 15:43:21 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-dialog :title="title" :visible.sync="dialogVisible" width="800px" :modal="false" :before-close="doClose" center>
|
|
|
|
|
<!-- -->
|
|
|
|
|
<!-- <span>角色:</span> -->
|
|
|
|
|
<el-form ref="form" :model="addModel" label-width="70px" :rules="rules">
|
|
|
|
|
<el-form-item label="角色:" prop="memberId" style="display:inline-block">
|
|
|
|
|
<el-select v-model="addModel.memberId" placeholder="" style="width:145px" size="mini" @change="changeMember">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in memberList"
|
2022-08-30 16:53:37 +08:00
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.normalName"
|
|
|
|
|
:value="item.id"
|
2022-08-30 15:43:21 +08:00
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="总分:" prop="fullMarks" style="display:inline-block">
|
|
|
|
|
<el-input-number v-model="addModel.fullMarks" style="width:145px" :min="0" size="mini" :step="1" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<!-- <span style="margin-left:10px">总分:</span> -->
|
|
|
|
|
<!-- </el-form-item> -->
|
|
|
|
|
<el-table
|
|
|
|
|
id="gradeRules"
|
|
|
|
|
ref="gradeRules"
|
|
|
|
|
:data="allstepList"
|
|
|
|
|
border
|
|
|
|
|
:height="350"
|
|
|
|
|
style="border:1px #ccc solid;"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column
|
|
|
|
|
type="index"
|
|
|
|
|
label="序号"
|
|
|
|
|
width="80"
|
|
|
|
|
/>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="description"
|
|
|
|
|
label="步骤描述"
|
|
|
|
|
width="468"
|
|
|
|
|
/>
|
|
|
|
|
<el-table-column
|
|
|
|
|
prop="score"
|
|
|
|
|
label="扣分分值"
|
|
|
|
|
width="200"
|
|
|
|
|
>
|
|
|
|
|
<template v-if="addModel.memberId==scope.row.memberId" slot-scope="scope">
|
|
|
|
|
<el-input-number v-model="currentStepMap[scope.row.id]" style="width:145px" :min="0" :step="1" size="mini" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<el-row justify="center" style="margin-top:20px">
|
|
|
|
|
<el-col :span="6" :offset="7">
|
|
|
|
|
<el-button @click="cancel">取消</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8" :offset="0">
|
|
|
|
|
<el-button type="primary" :loading="loading" @click="commit">确定 </el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
2022-08-30 16:53:37 +08:00
|
|
|
|
import {covertMemberData} from '@/views/newMap/displayNew/utils';
|
2022-08-30 15:43:21 +08:00
|
|
|
|
import { getTrainingStepList, getTrainingMmembers, updateTrainingGradeRules, getTrainingGradeRules } from '@/api/trainingManage';
|
|
|
|
|
export default {
|
|
|
|
|
name: 'GradeRules',
|
|
|
|
|
props: {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
trainingId:'',
|
|
|
|
|
loading:false,
|
|
|
|
|
title:'评分',
|
|
|
|
|
allstepList:[],
|
2022-08-30 16:53:37 +08:00
|
|
|
|
memberList:[],
|
2022-08-30 15:43:21 +08:00
|
|
|
|
currentStepMap:{},
|
|
|
|
|
gradeRulesMap:{},
|
|
|
|
|
addModel:{
|
|
|
|
|
memberId:'',
|
|
|
|
|
fullMarks:'',
|
|
|
|
|
details:[
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
rules:{
|
|
|
|
|
memberId: [
|
|
|
|
|
{ required: true, message: '请选择角色', trigger: 'blur' },
|
|
|
|
|
{ required: true, message: '请选择角色', trigger: 'change' }
|
|
|
|
|
],
|
|
|
|
|
fullMarks: [
|
|
|
|
|
{ required: true, message: '请输入总分', trigger: 'blur' },
|
|
|
|
|
{ required: true, message: '请输入总分', trigger: 'change' }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
doShow(row) {
|
|
|
|
|
this.dialogVisible = true;
|
|
|
|
|
this.trainingId = row.id;
|
|
|
|
|
// 获取步骤
|
|
|
|
|
getTrainingStepList(row.id).then(resp => {
|
|
|
|
|
if (resp.data) {
|
|
|
|
|
this.allstepList = resp.data;
|
|
|
|
|
// 获取规则
|
|
|
|
|
getTrainingGradeRules(row.id).then(response=>{
|
|
|
|
|
this.gradeRulesMap = {};
|
|
|
|
|
response.data.forEach(gradeRule=>{
|
|
|
|
|
this.gradeRulesMap[gradeRule.memberId] = gradeRule;
|
|
|
|
|
});
|
|
|
|
|
// 获取角色信息
|
|
|
|
|
getTrainingMmembers(row.id).then(res=>{
|
2022-08-30 16:53:37 +08:00
|
|
|
|
let activeTrainList = [];
|
|
|
|
|
if (this.$store.state.training.started) {
|
|
|
|
|
activeTrainList = this.$store.state.map.activeTrainList;
|
|
|
|
|
}
|
|
|
|
|
// 获取仿真成员列表
|
|
|
|
|
const result = covertMemberData(activeTrainList, res.data);
|
|
|
|
|
let list = [];
|
|
|
|
|
result.deviceListData.forEach(item => {
|
|
|
|
|
list = list.concat(item);
|
|
|
|
|
});
|
|
|
|
|
this.memberList = list;
|
2022-08-30 15:43:21 +08:00
|
|
|
|
if (this.memberList.length > 0) {
|
2022-08-30 16:53:37 +08:00
|
|
|
|
this.changeMember(this.memberList[0].id);
|
2022-08-30 15:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
}).catch((e) => {
|
|
|
|
|
console.error(e);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}).catch((e) => {
|
|
|
|
|
console.error(e);
|
|
|
|
|
this.$message.error('获取实训步骤信息失败!');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
changeMember(memberId) {
|
|
|
|
|
this.currentStepMap = {};
|
|
|
|
|
if (this.gradeRulesMap[memberId]) {
|
|
|
|
|
this.addModel.fullMarks = this.gradeRulesMap[memberId].fullMarks;
|
|
|
|
|
this.gradeRulesMap[memberId].details.forEach(each=>{
|
|
|
|
|
this.currentStepMap[each.elementId] = each.score;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.allstepList.forEach(each=>{
|
|
|
|
|
if (each.memberId == memberId) {
|
|
|
|
|
this.currentStepMap[each.id] = 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.addModel.fullMarks = '';
|
2022-08-30 17:28:47 +08:00
|
|
|
|
this.addModel.details = [];
|
2022-08-30 15:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
this.addModel.memberId = memberId;
|
|
|
|
|
},
|
|
|
|
|
doClose() {
|
|
|
|
|
this.dialogVisible = false;
|
|
|
|
|
},
|
|
|
|
|
cancel() {
|
|
|
|
|
this.doClose();
|
|
|
|
|
},
|
|
|
|
|
commit() {
|
2022-08-30 17:28:47 +08:00
|
|
|
|
const that = this;
|
|
|
|
|
that.$refs.form.validate((valid) => {
|
2022-08-30 15:43:21 +08:00
|
|
|
|
if (valid) {
|
2022-08-30 17:28:47 +08:00
|
|
|
|
const keyList = Object.keys(that.currentStepMap);
|
2022-08-30 15:43:21 +08:00
|
|
|
|
const details = [];
|
|
|
|
|
keyList.forEach(key=>{
|
2022-08-30 17:28:47 +08:00
|
|
|
|
details.push({elementId:key, score:that.currentStepMap[key]});
|
2022-08-30 15:43:21 +08:00
|
|
|
|
});
|
2022-08-30 17:28:47 +08:00
|
|
|
|
that.addModel.details = details;
|
|
|
|
|
const gradeRulesList = Object.values(that.gradeRulesMap);
|
2022-08-30 17:58:07 +08:00
|
|
|
|
gradeRulesList.map(gradeRule=>{
|
2022-08-30 17:28:47 +08:00
|
|
|
|
if (gradeRule.memberId == that.addModel.memberId) {
|
2022-08-30 17:58:07 +08:00
|
|
|
|
gradeRule.details = [...that.addModel.details];
|
|
|
|
|
gradeRule.fullMarks = that.addModel.fullMarks;
|
2022-08-30 16:53:37 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2022-08-30 17:28:47 +08:00
|
|
|
|
if (!that.gradeRulesMap[that.addModel.memberId] && that.addModel.details.length > 0) {
|
|
|
|
|
gradeRulesList.push(that.addModel);
|
|
|
|
|
}
|
|
|
|
|
if (that.addModel.details.length > 0) {
|
|
|
|
|
that.loading = true;
|
|
|
|
|
updateTrainingGradeRules(that.trainingId, gradeRulesList).then(resp => {
|
|
|
|
|
that.loading = false;
|
|
|
|
|
that.gradeRulesMap[that.addModel.memberId] = JSON.parse(JSON.stringify(that.addModel));
|
|
|
|
|
that.$message.success('更新实训评分规则成功!');
|
|
|
|
|
}).catch((e) => {
|
|
|
|
|
that.loading = false;
|
|
|
|
|
console.error(e);
|
|
|
|
|
that.$message.error('更新实训评分规则失败!');
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
that.$message.error('该角色不存在');
|
2022-08-30 16:53:37 +08:00
|
|
|
|
}
|
2022-08-30 15:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|