This commit is contained in:
2024-09-24 17:04:44 +08:00
parent 6cd84e0021
commit 30528311c1
77 changed files with 2251 additions and 1361 deletions

View File

@@ -89,8 +89,14 @@ const _sfc_main = defineComponent({
}
return rulesArrs;
});
const filedValue = computed(() => props.prop ? layForm.model[props.prop] : void 0);
watch(() => filedValue.value, (val) => validate(), { deep: true });
const filedValue = computed(
() => props.prop ? layForm.model[props.prop] : void 0
);
watch(
() => filedValue.value,
(val) => validate(),
{ deep: true }
);
const errorMsg = ref();
const errorStatus = ref(false);
const validate = (callback) => {
@@ -101,7 +107,11 @@ const _sfc_main = defineComponent({
let model = {};
let validateMessage = null;
if (layForm.useCN) {
validateMessage = Object.assign({}, cnValidateMessage, layForm.validateMessage);
validateMessage = Object.assign(
{},
cnValidateMessage,
layForm.validateMessage
);
model[props.label || props.prop] = filedValue.value;
} else {
layForm.validateMessage && (validateMessage = layForm.validateMessage);
@@ -143,12 +153,14 @@ const _sfc_main = defineComponent({
expose({ validate, clearValidate });
onMounted(() => {
if (props.prop) {
layForm.addField(reactive({
...toRefs(props),
$el: formItemRef,
validate,
clearValidate
}));
layForm.addField(
reactive({
...toRefs(props),
$el: formItemRef,
validate,
clearValidate
})
);
}
});
const getMarginLeft = computed(() => {
@@ -179,7 +191,9 @@ const _sfc_main = defineComponent({
}, [
props.prop && unref(isRequired) ? (openBlock(), createElementBlock("span", {
key: 0,
class: normalizeClass(["layui-required", "layui-icon"].concat((_a = unref(layForm).requiredIcons) != null ? _a : ""))
class: normalizeClass(
["layui-required", "layui-icon"].concat((_a = unref(layForm).requiredIcons) != null ? _a : "")
)
}, [
renderSlot(_ctx.$slots, "required", {
props: { ...props, model: unref(layForm).model }