<!--
 * @Descripttion: 输入框模糊检索组件
 * @Author: 龙运模
 * @Date: 2024年07月11日
 * @LastEditors: 龙运模
 * @LastEditTime:
-->

<template>
	<div class="scDatePicker">
		<el-input v-bind="$attrs" class="input" v-model="localText" @input="textChange" :size="size" :placeholder="placeholder" clearable></el-input>
	</div>
</template>

<script>
export default {
	name: "inputVague",
	props:{
		activation_text: {
			type: Object,
			default: ()=>({ operator: "link", value: "" })
		},
		size:{ type: String, default: "small" },
		placeholder:{type:String, default:"请输入"},
	},
	watch:{
		activation_text:{
			handler(val){
				if(val && typeof val.value === 'string'){
					this.localText = val.value.replace(/%/g, "");
				}
			},
			immediate:true,
			deep:true
		}
	},
	data(){
		return{
			localText:'',
		}
	},
	mounted() {

	},
	methods:{
		textChange(e){
			this.localText = e;
			this.emitActivationText();
		},
		emitActivationText() {
			this.$emit('update:activation_text', {
				operator: this.activation_text.operator,
				value: this.localText ? this.activation_text.operator==="="?this.localText:'%'+this.localText+'%':""
			});
			this.$emit('fetchData');
		}
	}
}
</script>

<style scoped lang="scss">
.scDatePicker{
	width: 100%;
}
</style>
