<template>
	<a-biaoge :data="commomParams.table.data" :columns="commomParams.table.columns" :pagination="commomParams.page"
		@page="getPage" :loading="loading">
	</a-biaoge>
</template>

<script setup lang="ts">
	import { ref, onMounted, computed } from 'vue';
	import {PostCompanyRecrBookList } from '@/apis/models';
	import { useCommon } from '@/hooks/useCommon';
	import { cols } from '@/components/meet/result/columns';
	import { warnToast, successToast } from '@/utils/toastHelper';
	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) => {
		if (data) {
			commomParams.value.search = data
		} else {
			commomParams.value.search = {
				page: 1,
				pagesize: 10,
				sort: 'id',
				sortby: 'asc',
				keyword: ''
			}
		}
		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 PostCompanyRecrBookList();
			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;
		}
	}

	// 申请
	const applyFor = (val) => {
		PostRecruitmentbookAdd({ recruitment_id: val, company_id: 0}).then(res => {
			successToast('预定成功')
		})
	}
	
	// 详情
	let detailData = ref<object>({})
	const toDetail = (val) => {
		PostRecruitmentbookAdd({ id: val}).then(res => {
			detailData.value = res.data
		})
	}
</script>

<style scoped lang="less">
	:deep(.ant-table-thead >tr>th) {
		background-color: #fff !important;
		border: none !important;
		color: #bbb !important;
	}

	:deep(.ant-table-thead >tr>th::before) {
		display: none !important;
	}

	:deep(.ant-table-tbody >tr >td) {
		border: none !important;
	}
</style>