support control object
This commit is contained in:
@@ -118,7 +118,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
control: {
|
control: {
|
||||||
type: String,
|
type: [String, Object],
|
||||||
default: "",
|
default: "",
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
@@ -136,7 +136,13 @@ const mediaUrl = ref("");
|
|||||||
|
|
||||||
const objForm = inject("form", props.form);
|
const objForm = inject("form", props.form);
|
||||||
const objControl =
|
const objControl =
|
||||||
!isEmpty(objForm) && props.control != "" ? objForm[props.control] : null;
|
typeof props.control == "object"
|
||||||
|
? props.control
|
||||||
|
: !isEmpty(objForm) &&
|
||||||
|
typeof props.control == "string" &&
|
||||||
|
props.control != ""
|
||||||
|
? objForm[props.control]
|
||||||
|
: null;
|
||||||
|
|
||||||
const label = ref(props.label);
|
const label = ref(props.label);
|
||||||
const feedbackInvalid = ref(props.feedbackInvalid);
|
const feedbackInvalid = ref(props.feedbackInvalid);
|
||||||
@@ -237,12 +243,10 @@ const handleFocus = (event: Event) => {
|
|||||||
emits("focus", event);
|
emits("focus", event);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBlur = (event: Event) => {
|
const handleBlur = async (event: Event) => {
|
||||||
if (objControl) {
|
if (objControl) {
|
||||||
objForm.validate(props.control);
|
objControl.validate();
|
||||||
feedbackInvalid.value = objForm[props.control].validation.result.valid
|
objControl.isValid();
|
||||||
? ""
|
|
||||||
: objForm[props.control].validation.result.invalidMessages[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = event.target as HTMLInputElement;
|
const target = event.target as HTMLInputElement;
|
||||||
|
|||||||
Reference in New Issue
Block a user