<template>
	<a-form :model="commomParams.search">
		<a-row :gutter="20">
			<a-col span="6">
				<a-form-item>
					<a-input-search v-model:value="commomParams.search.keyword" placeholder="请输入验证码"  enter-button="搜索"
						@search="getData" />
				</a-form-item>
			</a-col>
			<a-col span="6">
				<a-button type="primary" @click="clearSearch">重置</a-button>
			</a-col>
		</a-row>
	</a-form> 
</template>

<script lang="ts" setup>
	import { ref, onMounted, watch, computed } from 'vue';
	import { useCommon } from '@/hooks/useCommon';
	let { commomParams } = useCommon();
	let props = defineProps(['search_params']);
	const emit = defineEmits();


	watch(() => props.search_params, (newVal) => {
		emit('searchData', commomParams.value.search)
	},{
		immediate: true
	})

	const getData = () => {
		emit('searchData', commomParams.value.search)
	}

	// 清空搜索
	const clearSearch = () => {
		commomParams.value.search = {
			page: 1,
			pagesize: 10,
			sort: 'id',
			sortby: 'asc',
			keyword: ''
		}
		emit('clearData', commomParams.value.search)
	}
	
	
	
	
	
</script>

<style>
</style>