<template>
	<a-form  :model="commomParams.search">
		<a-row :gutter="[10]">
			<a-col span="6">
				<a-form-item>
					<a-input addon-before="企业名称" v-model:value="commomParams.search.expired" placeholder="请输入企业名称" />
				</a-form-item>
			</a-col>
			<a-col span="6">
				<a-form-item>
					<a-input addon-before="登录名称" v-model:value="commomParams.search.status" placeholder="请输入登录名称" />
				</a-form-item>
			</a-col>
			<a-col>
				<a-form-item>
					<a-button type="primary" @click="getData">
						搜索
					</a-button>
				</a-form-item>
			</a-col>
			<a-col>
				<a-form-item>
					<a-button danger @click="clearSearch">
						清空搜索
					</a-button>
				</a-form-item>
			</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();

	interface listType {
		expired : Number | 0,
		status: Number | 0
	}

	commomParams.value.search = commomParams.value.search as listType;
	commomParams.value.search.expired = 1;
	commomParams.value.search.status = 1;
	
	watch(() => props.search_params, (newVal) => {
		console.log(newVal)
	})

	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>