|
|
@ -123,17 +123,15 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<template v-else-if="col.bodyType === 'checkbox'"> |
|
|
<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> |
|
|
|
|
|
|
|
|
<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)" /> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
@ -550,17 +548,19 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else if (col.bodyType === "checkbox") { |
|
|
} else if (col.bodyType === "checkbox") { |
|
|
// checkbox类型的校验逻辑 - 通常checkbox不需要必填校验,除非明确指定 |
|
|
|
|
|
// 如果需要必填,可以检查是否至少选中一个 |
|
|
|
|
|
if (col.required && !col.bodyDisabled) { |
|
|
|
|
|
const hasChecked = Array.isArray(mainValue) ? mainValue.length > 0 : mainValue; |
|
|
|
|
|
|
|
|
// checkbox类型的校验逻辑 |
|
|
|
|
|
// checkbox只在actFill时进行必填校验 |
|
|
|
|
|
if (!col.bodyDisabled && this.templateFillType === 'actFill') { |
|
|
|
|
|
// 单个checkbox:值必须为true |
|
|
|
|
|
// checkbox组:至少选中一个 |
|
|
|
|
|
const hasChecked = Array.isArray(mainValue) ? mainValue.length > 0 : mainValue === true; |
|
|
if (!hasChecked) { |
|
|
if (!hasChecked) { |
|
|
const errorItem = { |
|
|
const errorItem = { |
|
|
rowIndex, |
|
|
rowIndex, |
|
|
colIndex, |
|
|
colIndex, |
|
|
field: col.prop, |
|
|
field: col.prop, |
|
|
label: this.$t(col.label), |
|
|
label: this.$t(col.label), |
|
|
error: `请选择${this.$t(col.label)}` |
|
|
|
|
|
|
|
|
error: `请勾选${this.$t(col.label)}` |
|
|
}; |
|
|
}; |
|
|
errors.push(errorItem); |
|
|
errors.push(errorItem); |
|
|
this.formErrors.push(errorItem); |
|
|
this.formErrors.push(errorItem); |
|
|
|