<template>
    <el-input :size="state.size.size" class="search-input" v-model="myValue" :placeholder="placeholder || state.lang.pleaseEnter"
        :disabled="disabled" :clearable="clearable"></el-input>
</template>

<script lang="ts" setup>
import { useStore } from "vuex";
import { reactive, onMounted, ref, watch } from "vue";

const { state, commit, dispatch } = useStore();

const prop = defineProps({
    modelValue: null,
    placeholder: {
        type: String,
        default: null
    },
    disabled: {
        type: Boolean,
        default: false,
    },
    clearable: {
        type: Boolean,
        default: true,
    },
    width: {
        type: Number,
        default: 150,
    }
});
const emit = defineEmits(["update:modelValue"]);
const myValue = ref(null);
const width = ref('150px');
watch(myValue, (n, o) => {
    emit('update:modelValue', n);
})
onMounted(() => {
    myValue.value = prop.modelValue;
    width.value = prop.width + 'px';
});
</script>
<style lang="scss" scoped>
//@import url(); 引入公共css类
.search-input {
    width: v-bind('width');
    margin-right: v-bind('state.size.searchMargin');
    ::v-deep .el-input__wrapper{
        background-color: v-bind('state.style.itemBg');
    }
}
</style>