|
|
@ -122,6 +122,19 @@ |
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" /> |
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" /> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
<template v-else-if="col.bodyType === 'checkbox'"> |
|
|
|
|
|
<div class="flex flex-wrap"> |
|
|
|
|
|
<HandleFormItem |
|
|
|
|
|
:fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
|
|
:fieldItemLabel="fieldItemLabel" |
|
|
|
|
|
type="checkbox" |
|
|
|
|
|
v-model="row[col.prop]" |
|
|
|
|
|
:item="getBodyItem(col, rowIndex)" |
|
|
|
|
|
@change="onCheckboxChange(rowIndex, colIndex, col, $event)" |
|
|
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<div v-show="isShowOther(row[col.prop], col)" class="flex flex1"> |
|
|
<div v-show="isShowOther(row[col.prop], col)" class="flex flex1"> |
|
|
@ -342,6 +355,18 @@ export default { |
|
|
this.onErrorUpdate(rowIndex, colIndex, col.prop, !isValid); |
|
|
this.onErrorUpdate(rowIndex, colIndex, col.prop, !isValid); |
|
|
this.$emit("onCheckboxTagChange", rowIndex, col, value) |
|
|
this.$emit("onCheckboxTagChange", rowIndex, col, value) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// checkbox变化 |
|
|
|
|
|
onCheckboxChange(rowIndex, colIndex, col, value) { |
|
|
|
|
|
this.localDataSource[rowIndex][col.prop] = value; |
|
|
|
|
|
// 输入时清除对应表单项的错误状态 |
|
|
|
|
|
this.formErrors = this.formErrors.filter(error => |
|
|
|
|
|
!(error.rowIndex === rowIndex && |
|
|
|
|
|
error.colIndex === colIndex && |
|
|
|
|
|
error.field === col.prop) |
|
|
|
|
|
); |
|
|
|
|
|
this.$emit("onCheckboxChange", rowIndex, col, value); |
|
|
|
|
|
this.justUpdateFilledFormData(); |
|
|
|
|
|
}, |
|
|
handleClickButton(e, data, key, rowIndex, colIndex) { |
|
|
handleClickButton(e, data, key, rowIndex, colIndex) { |
|
|
this.$emit("clickButton", key, rowIndex, colIndex, e, data,) |
|
|
this.$emit("clickButton", key, rowIndex, colIndex, e, data,) |
|
|
}, |
|
|
}, |
|
|
@ -524,6 +549,23 @@ export default { |
|
|
this.formErrors.push(errorItem); |
|
|
this.formErrors.push(errorItem); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} else if (col.bodyType === "checkbox") { |
|
|
|
|
|
// checkbox类型的校验逻辑 - 通常checkbox不需要必填校验,除非明确指定 |
|
|
|
|
|
// 如果需要必填,可以检查是否至少选中一个 |
|
|
|
|
|
if (col.required && !col.bodyDisabled) { |
|
|
|
|
|
const hasChecked = Array.isArray(mainValue) ? mainValue.length > 0 : mainValue; |
|
|
|
|
|
if (!hasChecked) { |
|
|
|
|
|
const errorItem = { |
|
|
|
|
|
rowIndex, |
|
|
|
|
|
colIndex, |
|
|
|
|
|
field: col.prop, |
|
|
|
|
|
label: this.$t(col.label), |
|
|
|
|
|
error: `请选择${this.$t(col.label)}` |
|
|
|
|
|
}; |
|
|
|
|
|
errors.push(errorItem); |
|
|
|
|
|
this.formErrors.push(errorItem); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if (isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType !== 'span' && col.bodyType !== 'button') { |
|
|
if (isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType !== 'span' && col.bodyType !== 'button') { |
|
|
const errorItem = { |
|
|
const errorItem = { |
|
|
@ -735,6 +777,15 @@ export default { |
|
|
if (col.bodyDisabled) { |
|
|
if (col.bodyDisabled) { |
|
|
item.disabled = col.bodyDisabled; |
|
|
item.disabled = col.bodyDisabled; |
|
|
} |
|
|
} |
|
|
|
|
|
// 支持动态checkboxLabel - 从行数据中获取 |
|
|
|
|
|
const dynamicLabelKey = col.prop + 'Label'; |
|
|
|
|
|
if (currentItem && currentItem[dynamicLabelKey]) { |
|
|
|
|
|
// 优先从行数据中获取动态label(如jzbh1Label) |
|
|
|
|
|
item.checkboxLabel = currentItem[dynamicLabelKey]; |
|
|
|
|
|
} else if (col.checkboxLabel !== undefined && col.checkboxLabel !== '') { |
|
|
|
|
|
// 否则使用列配置的checkboxLabel |
|
|
|
|
|
item.checkboxLabel = this.$t(col.checkboxLabel); |
|
|
|
|
|
} |
|
|
return item |
|
|
return item |
|
|
}, |
|
|
}, |
|
|
getBodyButtonItem(col,) { |
|
|
getBodyButtonItem(col,) { |
|
|
|