<template>
	<a-drawer :width="500" title="搜索" placement="right" :open="openSearchModel" @close="onClose">
		<a-form :model="commomParams.search">
			<a-row :gutter="[10]">
				<a-col span="24">
					<a-form-item>
						<a-input addon-before="企业名称" v-model:value="commomParams.search.keyword"
							placeholder="请输入企业名称" />
					</a-form-item>
				</a-col>
				<a-col span="24">
					<a-form-item>
						<a-input addon-before="请选择公司" v-model:value="commomParams.search.company_id"
							placeholder="请输入企业名称" />
					</a-form-item>
				</a-col>
			</a-row>
		</a-form>
	</a-drawer>
</template>

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

	openSearchModel = computed(() => {
		return store.state.openSearchModel;
	})


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

	commomParams.value.search = commomParams.value.search as listType;
	commomParams.value.search.company_id = 0;
	watch(() => props.search_params, (newVal) => {
		emit('searchData', commomParams.value.search)
	})

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

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

	const onClose = () => {
		clearSearch()
		hideSearch()
	}
</script>

<style>
</style>