调整评分量化表
This commit is contained in:
@@ -232,7 +232,7 @@
|
|||||||
<el-form-item label="分值" required>
|
<el-form-item label="分值" required>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="itemForm.score"
|
v-model="itemForm.score"
|
||||||
:min="0.01"
|
:min="0"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
:step="0.01"
|
:step="0.01"
|
||||||
:controls="false"
|
:controls="false"
|
||||||
@@ -821,10 +821,10 @@ export default {
|
|||||||
!this.isPositiveDecimal(option.changeValue) ||
|
!this.isPositiveDecimal(option.changeValue) ||
|
||||||
!option.changeUnit ||
|
!option.changeUnit ||
|
||||||
!option.scoreType ||
|
!option.scoreType ||
|
||||||
!this.isPositiveDecimal(option.score)
|
!this.isNonNegativeDecimal(option.score)
|
||||||
);
|
);
|
||||||
if (invalidScoreOption) {
|
if (invalidScoreOption) {
|
||||||
this.$message.warning('请完整填写基础分值,并确保数值为正数且最多两位小数');
|
this.$message.warning('请完整填写基础分值,并确保数值不能为负数且最多两位小数');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -987,15 +987,15 @@ export default {
|
|||||||
},
|
},
|
||||||
isPositiveDecimal(value) {
|
isPositiveDecimal(value) {
|
||||||
const number = Number(value);
|
const number = Number(value);
|
||||||
console.log(
|
|
||||||
value,
|
|
||||||
Number.isFinite(number),
|
|
||||||
number,
|
|
||||||
Math.abs(number * 100 - Math.round(number * 100))
|
|
||||||
);
|
|
||||||
if (!Number.isFinite(number) || number <= 0) return false;
|
if (!Number.isFinite(number) || number <= 0) return false;
|
||||||
return Math.abs(number * 100 - Math.round(number * 100)) < 1e-8;
|
return Math.abs(number * 100 - Math.round(number * 100)) < 1e-8;
|
||||||
},
|
},
|
||||||
|
isNonNegativeDecimal(value) {
|
||||||
|
if (value === undefined || value === null || String(value).trim() === '') return false;
|
||||||
|
const number = Number(value);
|
||||||
|
if (!Number.isFinite(number) || number < 0) return false;
|
||||||
|
return Math.abs(number * 100 - Math.round(number * 100)) < 1e-8;
|
||||||
|
},
|
||||||
isAnyNumber(value) {
|
isAnyNumber(value) {
|
||||||
const text = String(value ?? '').trim();
|
const text = String(value ?? '').trim();
|
||||||
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(text) && Number.isFinite(Number(text));
|
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(text) && Number.isFinite(Number(text));
|
||||||
@@ -1051,7 +1051,7 @@ export default {
|
|||||||
!this.isPositiveDecimal(option.changeValue) ||
|
!this.isPositiveDecimal(option.changeValue) ||
|
||||||
!this.scoreUnitOptions.includes(option.changeUnit) ||
|
!this.scoreUnitOptions.includes(option.changeUnit) ||
|
||||||
!option.scoreType ||
|
!option.scoreType ||
|
||||||
!this.isPositiveDecimal(option.score)
|
!this.isNonNegativeDecimal(option.score)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.$message.warning(`${item.itemName || '评分项目'}的基础分值配置不完整`);
|
this.$message.warning(`${item.itemName || '评分项目'}的基础分值配置不完整`);
|
||||||
@@ -1106,7 +1106,7 @@ export default {
|
|||||||
!this.isPositiveDecimal(option.changeValue) ||
|
!this.isPositiveDecimal(option.changeValue) ||
|
||||||
!this.scoreUnitOptions.includes(option.changeUnit) ||
|
!this.scoreUnitOptions.includes(option.changeUnit) ||
|
||||||
!option.scoreType ||
|
!option.scoreType ||
|
||||||
!this.isPositiveDecimal(option.score)
|
!this.isNonNegativeDecimal(option.score)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.$message.warning(`${item.itemName || '评分项目'}的基础分值配置不完整`);
|
this.$message.warning(`${item.itemName || '评分项目'}的基础分值配置不完整`);
|
||||||
|
|||||||
@@ -3975,6 +3975,25 @@ export default {
|
|||||||
getScoreRule(detail = {}) {
|
getScoreRule(detail = {}) {
|
||||||
return this.parseScoreOptions(detail.optionsJson)[0] || null;
|
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) {
|
handleScoreValueInput(detail, value) {
|
||||||
const raw = String(value ?? '')
|
const raw = String(value ?? '')
|
||||||
.replace(/[^\d.-]/g, '')
|
.replace(/[^\d.-]/g, '')
|
||||||
@@ -4007,10 +4026,7 @@ export default {
|
|||||||
this.calculateScore(this.currentScore);
|
this.calculateScore(this.currentScore);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const distance = increase ? input - base : base - input;
|
detail.selfScore = this.getScoreTypeCalculatedScore(detail);
|
||||||
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));
|
|
||||||
this.calculateScore(this.currentScore);
|
this.calculateScore(this.currentScore);
|
||||||
},
|
},
|
||||||
scoreOptionChange(detail, optionValue) {
|
scoreOptionChange(detail, optionValue) {
|
||||||
@@ -4124,6 +4140,11 @@ export default {
|
|||||||
},
|
},
|
||||||
calculateScore(score) {
|
calculateScore(score) {
|
||||||
const details = score.details || [];
|
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 basicDetails = this.getScoreCategoryDetailsByList(details, 'basic');
|
||||||
const plusDetails = this.getScoreCategoryDetailsByList(details, 'plus');
|
const plusDetails = this.getScoreCategoryDetailsByList(details, 'plus');
|
||||||
const minusDetails = this.getScoreCategoryDetailsByList(details, 'minus');
|
const minusDetails = this.getScoreCategoryDetailsByList(details, 'minus');
|
||||||
@@ -4238,7 +4259,7 @@ export default {
|
|||||||
const invalidScoreInput = this.currentScore.details.find(item => {
|
const invalidScoreInput = this.currentScore.details.find(item => {
|
||||||
if (!this.isScoreTypeDetail(item)) return false;
|
if (!this.isScoreTypeDetail(item)) return false;
|
||||||
const input = String(item.scoreInput ?? '').trim();
|
const input = String(item.scoreInput ?? '').trim();
|
||||||
return input !== '' && item.selfScore === '';
|
return input !== '' && this.getScoreTypeCalculatedScore(item) === null;
|
||||||
});
|
});
|
||||||
if (invalidScoreInput) {
|
if (invalidScoreInput) {
|
||||||
this.$message.warning(
|
this.$message.warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user