From 3eb6a2b31df94771c37aafa71a0722f21ab9e5ae Mon Sep 17 00:00:00 2001
From: Z-WICK <2289431216@qq.com>
Date: Tue, 6 Jan 2026 14:56:10 +0800
Subject: [PATCH] =?UTF-8?q?fix(deduction):=20=E4=BF=AE=E5=A4=8D=E6=89=A3?=
=?UTF-8?q?=E5=88=86=E9=A1=B9=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- form对象添加itemName字段解决编辑时名称不显示
- 查询时过滤空字符串参数避免无数据问题
- 字段名deductionPoints改为deductionPoint与后端一致
---
src/views/martial/deduction/index.vue | 50 +++++++++++++++++++--------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/src/views/martial/deduction/index.vue b/src/views/martial/deduction/index.vue
index 65a0d5c..81122f7 100644
--- a/src/views/martial/deduction/index.vue
+++ b/src/views/martial/deduction/index.vue
@@ -26,7 +26,7 @@
v-for="item in competitionList"
:key="item.id"
:label="item.competitionName"
- :value="item.id"
+ :value="String(item.id)"
/>
@@ -43,7 +43,7 @@
v-for="item in projectList"
:key="item.id"
:label="item.projectName"
- :value="item.id"
+ :value="String(item.id)"
/>
@@ -146,14 +146,14 @@
show-overflow-tooltip
/>
- -{{ row.deductionPoints }}
+ -{{ row.deductionPoint }}
@@ -225,7 +225,7 @@
v-for="item in competitionList"
:key="item.id"
:label="item.competitionName"
- :value="item.id"
+ :value="String(item.id)"
/>
@@ -240,7 +240,7 @@
v-for="item in projectList"
:key="item.id"
:label="item.projectName"
- :value="item.id"
+ :value="String(item.id)"
/>
@@ -251,9 +251,9 @@
maxlength="100"
/>
-
+
@@ -389,6 +389,7 @@ const queryParams = reactive({
size: 10,
competitionId: null,
projectId: null,
+ itemName: '',
})
// 表单数据
@@ -396,7 +397,8 @@ const form = reactive({
id: null,
competitionId: null,
projectId: null,
- deductionPoints: 0.5,
+ itemName: '',
+ deductionPoint: 0.5,
sortOrder: 0,
description: ''
})
@@ -421,7 +423,7 @@ const rules = {
{ required: true, message: '请输入扣分项名称', trigger: 'blur' },
{ min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
],
- deductionPoints: [
+ deductionPoint: [
{ required: true, message: '请输入扣分值', trigger: 'blur' }
],
sortOrder: [
@@ -504,10 +506,17 @@ const fetchData = async () => {
loading.value = true
try {
+ // 过滤掉空字符串的参数
+ const params = {}
+ Object.keys(queryParams).forEach(key => {
+ if (queryParams[key] !== '' && queryParams[key] !== null && queryParams[key] !== undefined) {
+ params[key] = queryParams[key]
+ }
+ })
const res = await getDeductionList(
queryParams.current,
queryParams.size,
- queryParams
+ params
)
// 根据axios响应拦截器的处理,数据在 res.data.data 中
const data = res.data?.data || {}
@@ -535,7 +544,7 @@ const handleReset = () => {
size: 10,
competitionId: competitionId,
projectId: null,
- itemName: ''
+ itemName: '',
})
if (competitionId) {
fetchData()
@@ -555,11 +564,22 @@ const handleAdd = () => {
}
// 编辑
-const handleEdit = (row) => {
+const handleEdit = async (row) => {
dialogTitle.value = '编辑扣分项'
Object.keys(form).forEach((key) => {
form[key] = row[key]
})
+ // Convert competitionId to string for el-select matching
+ if (form.competitionId) {
+ form.competitionId = String(form.competitionId)
+ }
+ if (form.projectId) {
+ form.projectId = String(form.projectId)
+ }
+ // Load project list for the competition first
+ if (form.competitionId) {
+ await loadProjectList(form.competitionId)
+ }
dialogVisible.value = true
}
@@ -670,7 +690,7 @@ const resetForm = () => {
competitionId: null,
projectId: null,
itemName: '',
- deductionPoints: 0.5,
+ deductionPoint: 0.5,
sortOrder: 0,
description: ''
})