fix: required
parent
2d62574eba
commit
6eeb57eadb
|
@ -3,40 +3,51 @@ import type { InputProps, TextAreaProps } from 'ant-design-vue';
|
||||||
|
|
||||||
import type { FileUploadProps } from './typing';
|
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 { Col, Input, Row, Textarea } from 'ant-design-vue';
|
||||||
|
|
||||||
import FileUpload from './file-upload.vue';
|
import FileUpload from './file-upload.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
defaultValue?: number | string;
|
||||||
fileUploadProps?: FileUploadProps;
|
fileUploadProps?: FileUploadProps;
|
||||||
inputProps?: InputProps;
|
inputProps?: InputProps;
|
||||||
inputType?: 'input' | 'textarea';
|
inputType?: 'input' | 'textarea';
|
||||||
|
modelValue?: number | string;
|
||||||
textareaProps?: TextAreaProps;
|
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) {
|
function handleReturnText(text: string) {
|
||||||
value.value = text;
|
modelValue.value = text;
|
||||||
emit('change', value.value);
|
emits('change', modelValue.value);
|
||||||
emit('update:value', value.value);
|
emits('update:value', modelValue.value);
|
||||||
|
emits('update:modelValue', modelValue.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputProps = computed(() => {
|
const inputProps = computed(() => {
|
||||||
return {
|
return {
|
||||||
...props.inputProps,
|
...props.inputProps,
|
||||||
value: value.value,
|
value: modelValue.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const textareaProps = computed(() => {
|
const textareaProps = computed(() => {
|
||||||
return {
|
return {
|
||||||
...props.textareaProps,
|
...props.textareaProps,
|
||||||
value: value.value,
|
value: modelValue.value,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue