调整评分量化表

This commit is contained in:
2026-08-25 13:44:20 +08:00
parent 8955ef16c7
commit f3c29ef2bf
2 changed files with 37 additions and 16 deletions
+26 -5
View File
@@ -3975,6 +3975,25 @@ export default {
getScoreRule(detail = {}) {
return this.parseScoreOptions(detail.optionsJson)[0] || null;
},
getScoreTypeCalculatedScore(detail = {}) {
const rule = this.getScoreRule(detail);
const base = Number(detail.baseValue);
const input = Number(detail.scoreInput);
if (!rule || !Number.isFinite(base) || !Number.isFinite(input)) return null;
const increase = rule.changeType !== 'decrease';
const valid = increase ? input >= base : input <= base;
if (!valid) return null;
const distance = increase ? input - base : base - input;
const stepScore = Math.abs(Number(rule.score || 0));
if (!Number.isFinite(stepScore)) return null;
const projectScore = this.getScoreItemFullScore(detail);
const signedStep = rule.scoreType === 'subtract' ? -stepScore : stepScore;
const calculatedScore = Number(detail.score || 0) + distance * signedStep;
return Number(Math.min(Math.max(calculatedScore, 0), projectScore).toFixed(2));
},
handleScoreValueInput(detail, value) {
const raw = String(value ?? '')
.replace(/[^\d.-]/g, '')
@@ -4007,10 +4026,7 @@ export default {
this.calculateScore(this.currentScore);
return;
}
const distance = increase ? input - base : base - input;
const stepScore = Math.abs(Number(rule.score || 0));
const signedStep = rule.scoreType === 'subtract' ? -stepScore : stepScore;
detail.selfScore = Number((Number(detail.score || 0) + distance * signedStep).toFixed(2));
detail.selfScore = this.getScoreTypeCalculatedScore(detail);
this.calculateScore(this.currentScore);
},
scoreOptionChange(detail, optionValue) {
@@ -4124,6 +4140,11 @@ export default {
},
calculateScore(score) {
const details = score.details || [];
details.forEach(detail => {
if (!this.isScoreTypeDetail(detail) || String(detail.scoreInput ?? '').trim() === '') return;
const calculatedScore = this.getScoreTypeCalculatedScore(detail);
if (calculatedScore !== null) detail.selfScore = calculatedScore;
});
const basicDetails = this.getScoreCategoryDetailsByList(details, 'basic');
const plusDetails = this.getScoreCategoryDetailsByList(details, 'plus');
const minusDetails = this.getScoreCategoryDetailsByList(details, 'minus');
@@ -4238,7 +4259,7 @@ export default {
const invalidScoreInput = this.currentScore.details.find(item => {
if (!this.isScoreTypeDetail(item)) return false;
const input = String(item.scoreInput ?? '').trim();
return input !== '' && item.selfScore === '';
return input !== '' && this.getScoreTypeCalculatedScore(item) === null;
});
if (invalidScoreInput) {
this.$message.warning(