代码调整

This commit is contained in:
joylink_cuiweidong 2022-08-30 16:53:37 +08:00
parent 74cedff597
commit 68314b3b08

View File

@ -7,9 +7,9 @@
<el-select v-model="addModel.memberId" placeholder="" style="width:145px" size="mini" @change="changeMember"> <el-select v-model="addModel.memberId" placeholder="" style="width:145px" size="mini" @change="changeMember">
<el-option <el-option
v-for="item in memberList" v-for="item in memberList"
:key="item.code" :key="item.id"
:label="item.name" :label="item.normalName"
:value="item.code" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -58,6 +58,7 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import {covertMemberData} from '@/views/newMap/displayNew/utils';
import { getTrainingStepList, getTrainingMmembers, updateTrainingGradeRules, getTrainingGradeRules } from '@/api/trainingManage'; import { getTrainingStepList, getTrainingMmembers, updateTrainingGradeRules, getTrainingGradeRules } from '@/api/trainingManage';
export default { export default {
name: 'GradeRules', name: 'GradeRules',
@ -69,9 +70,7 @@ export default {
loading:false, loading:false,
title:'评分', title:'评分',
allstepList:[], allstepList:[],
memberList:[ memberList:[],
{code:'1', name:'行调'}
],
currentStepMap:{}, currentStepMap:{},
gradeRulesMap:{}, gradeRulesMap:{},
addModel:{ addModel:{
@ -108,10 +107,19 @@ export default {
}); });
// //
getTrainingMmembers(row.id).then(res=>{ getTrainingMmembers(row.id).then(res=>{
debugger; let activeTrainList = [];
// this.memberList = res.data; 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;
if (this.memberList.length > 0) { if (this.memberList.length > 0) {
this.changeMember(this.memberList[0].code); this.changeMember(this.memberList[0].id);
} }
// //
}).catch((e) => { }).catch((e) => {
@ -139,6 +147,7 @@ export default {
}); });
this.addModel.fullMarks = ''; this.addModel.fullMarks = '';
} }
debugger;
this.addModel.memberId = memberId; this.addModel.memberId = memberId;
}, },
doClose() { doClose() {
@ -157,8 +166,21 @@ export default {
details.push({elementId:key, score:this.currentStepMap[key]}); details.push({elementId:key, score:this.currentStepMap[key]});
}); });
this.addModel.details = details; this.addModel.details = details;
updateTrainingGradeRules(this.trainingId, this.addModel).then(resp => { const gradeRulesList = Object.values(this.gradeRulesMap);
gradeRulesList.forEach(gradeRule=>{
if (gradeRule.memberId == this.addModel.memberId) {
gradeRule = this.addModel;
}
});
if (!this.gradeRulesMap[this.addModel.memberId] && this.addModel.details.length > 0) {
gradeRulesList.push(this.addModel);
}
updateTrainingGradeRules(this.trainingId, gradeRulesList).then(resp => {
this.loading = false;
this.$message.success('更新实训评分规则成功!');
this.gradeRulesMap[this.addModel.memberId] = this.addModel;
}).catch((e) => { }).catch((e) => {
this.loading = false;
console.error(e); console.error(e);
this.$message.error('更新实训评分规则失败!'); this.$message.error('更新实训评分规则失败!');
}); });