修复业务模块bug

This commit is contained in:
2026-08-14 02:49:46 +08:00
parent eceac8b31f
commit 6e012d766c
7 changed files with 1825 additions and 238 deletions
@@ -218,11 +218,11 @@
<el-input v-model="itemForm.itemName" maxlength="20" />
</el-form-item>
<el-form-item label="分值" required>
<el-input-number v-model="itemForm.score" :min="0" :precision="2" :controls="false" />
<el-input-number v-model="itemForm.score" :min="1" :precision="0" :step="1" :controls="false" />
</el-form-item>
</div>
<el-form-item label="得分说明">
<el-input v-model="itemForm.scoreDescription" maxlength="300" />
<el-input v-model="itemForm.scoreDescription" maxlength="300" class="score-description-input" />
</el-form-item>
<el-form-item label="选项描述">
<el-input v-model="itemForm.optionDescription" maxlength="100" />
@@ -232,7 +232,7 @@
<div class="option-row" v-for="(option, index) in itemForm.options" :key="index">
<el-input v-model="option.optionName" maxlength="100" />
<div class="option-score">
<el-input-number v-model="option.score" :min="0" :precision="2" :controls="false" />
<el-input-number v-model="option.score" :min="1" :precision="0" :step="1" :controls="false" />
<span class="score-unit"></span>
</div>
<el-link
@@ -534,10 +534,10 @@ export default {
emptyItem() {
return {
itemName: '',
score: 0,
score: 1,
scoreDescription: '',
optionDescription: '',
options: [{ optionName: '', score: 0 }],
options: [{ optionName: '', score: 1 }],
};
},
emptyStandard() {
@@ -561,7 +561,7 @@ export default {
items: (category.items || []).map(item => ({
...item,
options:
item.options && item.options.length ? item.options : [{ optionName: '', score: 0 }],
item.options && item.options.length ? item.options : [{ optionName: '', score: 1 }],
})),
};
});
@@ -624,6 +624,10 @@ export default {
this.$message.warning('请输入分值');
return;
}
if (!this.isPositiveInteger(this.itemForm.score)) {
this.$message.warning('分值只能输入正整数');
return;
}
if (!this.itemForm.options.length) {
this.$message.warning('至少添加1条档位选项');
return;
@@ -639,12 +643,18 @@ export default {
this.$message.warning('请完整填写档位选项');
return;
}
if (this.itemForm.options.some(option => !this.isPositiveInteger(option.score))) {
this.$message.warning('选项分数只能输入正整数');
return;
}
const item = JSON.parse(JSON.stringify(this.itemForm));
item.itemName = String(item.itemName || '').trim();
item.options = item.options.map(option => ({
...option,
optionName: String(option.optionName || '').trim(),
score: Number(option.score),
}));
item.score = Number(item.score);
if (this.currentItemIndex >= 0) {
this.currentCategory.items.splice(this.currentItemIndex, 1, item);
} else {
@@ -660,7 +670,7 @@ export default {
this.currentCategory.items.splice(index, 1);
},
addOption() {
this.itemForm.options.push({ optionName: '', score: 0 });
this.itemForm.options.push({ optionName: '', score: 1 });
},
removeOption(index) {
this.itemForm.options.splice(index, 1);
@@ -779,6 +789,9 @@ export default {
isBlankValue(value) {
return value === undefined || value === null || value === '';
},
isPositiveInteger(value) {
return /^\d+$/.test(String(value)) && Number(value) > 0;
},
hasRangeOverlap(list, lowerProp, upperProp) {
const ranges = list
.map(item => ({
@@ -810,10 +823,18 @@ export default {
return false;
}
for (const item of category.items) {
if (!this.isPositiveInteger(item.score)) {
this.$message.warning(`${item.itemName || '评分项目'}的分值只能为正整数`);
return false;
}
if (!item.options || item.options.length === 0) {
this.$message.warning(`${item.itemName}至少存在1条档位选项`);
return false;
}
if (item.options.some(option => !this.isPositiveInteger(option.score))) {
this.$message.warning(`${item.itemName || '评分项目'}的选项分数只能为正整数`);
return false;
}
}
}
const creditLevels = this.configForm.standards
@@ -842,6 +863,10 @@ export default {
this.$message.warning('发布前请完整填写评分项目名称');
return false;
}
if (!this.isPositiveInteger(item.score)) {
this.$message.warning(`${item.itemName || '评分项目'}的分值只能为正整数`);
return false;
}
if (!item.options || item.options.length === 0) {
this.$message.warning(`${item.itemName || '评分项目'}至少配置1个档位选项`);
return false;
@@ -853,6 +878,10 @@ export default {
this.$message.warning(`${item.itemName || '评分项目'}的档位选项未填写完整`);
return false;
}
if (item.options.some(option => !this.isPositiveInteger(option.score))) {
this.$message.warning(`${item.itemName || '评分项目'}的选项分数只能为正整数`);
return false;
}
}
}
@@ -1103,6 +1132,10 @@ export default {
text-align: center;
}
:deep(.score-description-input .el-input__inner) {
text-align: left;
}
&__top {
display: grid;
grid-template-columns: 360px 360px;