<template>
	<job-intention-search @searchData="searchData" @clearData="clearData" :search_params="commomParams.search"></job-intention-search>
	<a-c-operation @refresh="clearData"  :need_add="false"></a-c-operation>
	<a-c-table :data="commomParams.table.data" :columns="commomParams.table.columns" :pagination="commomParams.page"
		@page="getPage" :loading="loading">
	</a-c-table>
</template>

<script setup lang="ts">
	import { ref, onMounted } from 'vue';
	import JobIntentionSearch from '@/views/statistics/resume/jobIntention/search/index.vue';
	import { GetStatsPosition } from '@/apis/models';
	import { cols } from '@/views/statistics/resume/jobIntention/columns';
	import { useCommon } from '@/hooks/useCommon';
	let {  commomParams } = useCommon();
	
	let loading = ref<Boolean>(true);


	onMounted(() => {
		getData(commomParams.value.search);
	})
	
	const searchData = (data : object) => {
		commomParams.value.search = data
		getData();
	}
	
	const clearData = (data : object) => {
		commomParams.value.search = data
		getData();
	}
	
	const getPage = (data : object) => {
		commomParams.value.search.page = data.current;
		commomParams.value.search.pagesize = data.pageSize;
		getData();
	}
	
	const getData = async () => {
		try {
			loading.value = true;
			let res = await GetStatsPosition(commomParams.value.search);
			loading.value = false;
			commomParams.value.table.data = res.data.list;
			commomParams.value.table.columns = cols;
			commomParams.value.page = {
				current: commomParams.value.search.page,
				pageSize: commomParams.value.search.pagesize,
				total: res.data.total,
				pageSizeOptions: ['10', '20', '30', '40'],
				hideOnSinglePage: false,
				showSizeChanger: true
			};
		} catch {
			loading.value = false;
		}
	}
</script>

<style>
</style>