From 6eeb57eadbf02315ede4d552e5326f7b10ce94b2 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Tue, 27 May 2025 22:14:49 +0800 Subject: [PATCH] fix: required --- .../src/components/upload/input-upload.vue | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/web-antd/src/components/upload/input-upload.vue b/apps/web-antd/src/components/upload/input-upload.vue index 11ee4cf03..0b2df8540 100644 --- a/apps/web-antd/src/components/upload/input-upload.vue +++ b/apps/web-antd/src/components/upload/input-upload.vue @@ -3,40 +3,51 @@ import type { InputProps, TextAreaProps } from 'ant-design-vue'; import type { FileUploadProps } from './typing'; -import { computed, ref } from 'vue'; +import { computed } from 'vue'; +import { useVModel } from '@vueuse/core'; import { Col, Input, Row, Textarea } from 'ant-design-vue'; import FileUpload from './file-upload.vue'; const props = defineProps<{ + defaultValue?: number | string; fileUploadProps?: FileUploadProps; inputProps?: InputProps; inputType?: 'input' | 'textarea'; + modelValue?: number | string; textareaProps?: TextAreaProps; }>(); -const emit = defineEmits(['change', 'update:value']); +const emits = defineEmits<{ + (e: 'change', payload: number | string): void; + (e: 'update:value', payload: number | string): void; + (e: 'update:modelValue', payload: number | string): void; +}>(); -const value = ref(''); +const modelValue = useVModel(props, 'modelValue', emits, { + defaultValue: props.defaultValue, + passive: true, +}); function handleReturnText(text: string) { - value.value = text; - emit('change', value.value); - emit('update:value', value.value); + modelValue.value = text; + emits('change', modelValue.value); + emits('update:value', modelValue.value); + emits('update:modelValue', modelValue.value); } const inputProps = computed(() => { return { ...props.inputProps, - value: value.value, + value: modelValue.value, }; }); const textareaProps = computed(() => { return { ...props.textareaProps, - value: value.value, + value: modelValue.value, }; });