<template>
    <uni-easyinput @input="change"  v-model="inputValue" v-if="['textarea'].includes(field.format)" @blur="change" 
        :placeholder="field.description || placeholder || `请输入${field.title}`" type="textarea" :disabled="props.field.readonly"/>
    <uni-easyinput v-if="!field.format" v-bind="getBindValue" :placeholder="placeholder" type="text" :disabled="props.field.readonly"/>
</template>
<script lang="ts" setup>

const emits = defineEmits(['update:modelValue'])
const props = defineProps({
    modelValue: {
        type: [String, Number]
    },
    placeholder: {
        type: String
    },
    readyonly: {
        type: Boolean,
        default: () => false
    },
    field: {
        type: Object,
        required: true
    },
})

const inputValue = ref(props.modelValue)
const getBindValue = computed(() => {
    const attrs = useAttrs()
    const obj = { ...attrs, ...props }
    return obj
})

// const format = computed(() => {
//     return props.field.format
// })

const change = (e: any) => {
    emits('update:modelValue', inputValue.value)
}
</script>
<script lang="ts">
export default {
    options: {
        styleIsolation: 'apply-shared', //解除样式隔离
    }

}
</script>
<style scoped >

:deep(.is-disabled){
    border-color: #e5e5e5 !important;
    background-color: #fff !important;
    color:#333 !important;
}
</style>