JavaScript 代码优化: 提交评分前检查未完成部门
async handlSumbmitData() { this.submitCheckInfo.appraiseeIds = []; this.submitCheckInfo.appraiseeNames = [];
if (this.tableData?.length) { this.tableData .flatMap(({ scoreList }) => scoreList) .forEach((item) => { if (!item.assessScore) { this.submitCheckInfo.appraiseeIds.push(item.appraiseeId); } });
const set = new Set(this.submitCheckInfo.appraiseeIds);
this.submitCheckInfo.appraiseeIds = Array.from(set);
this.tableData.forEach((s) => {
if (this.submitCheckInfo.appraiseeIds.includes(s.assesseeId)) {
this.submitCheckInfo.appraiseeNames.push(s.assessee);
}
});
if (this.submitCheckInfo.appraiseeNames?.length) {
this.submitCheckInfo.message = this.submitCheckInfo.appraiseeNames.join('、');
const message = '请先完成所有评分,再提交。未完成评分的部门有:' + this.submitCheckInfo.message + '。';
const options = {
confirmButtonText: '确定',
showCancelButton: false,
type: 'warning',
dangerouslyUseHTMLString: true,
};
await $MessageBox.$confirm(message, options);
return;
}
}
const { result, data } = await this.requestScoreItem('submit');
if (!data.checkResult) { const options = { confirmButtonText: '确定', showCancelButton: false, type: 'warning', dangerouslyUseHTMLString: true, };
await $MessageBox.$confirm(data.message, options);
return;
}
if (result) { $Message.success('提交成功'); this.hanldGetTodoMessage(); } }
原文地址: https://www.cveoy.top/t/topic/pSJM 著作权归作者所有。请勿转载和采集!