diff --git a/src/views/vehicle/credit-score-quantification.vue b/src/views/vehicle/credit-score-quantification.vue index f148242..5f863b6 100644 --- a/src/views/vehicle/credit-score-quantification.vue +++ b/src/views/vehicle/credit-score-quantification.vue @@ -232,7 +232,7 @@ = 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, '') @@ -4009,10 +4028,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) { @@ -4126,6 +4142,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'); @@ -4240,7 +4261,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(