<template>
	<a-modal v-model:visible="showPositionModel" title="查看职位" @cancel="cancelModal" width="80%" :footer="null">
		<a-c-table :data="commomParams.table.data" :columns="commomParams.table.columns" :pagination="commomParams.page"
			@page="getPage" :loading="loading">
		</a-c-table>
	</a-modal>
</template>

<script setup lang="ts">
	import { ref, onMounted, computed, defineProps, watch, defineEmits } from 'vue';
	import { GetCompanyJobList } from '@/apis/models';
	import { useCommon } from '@/hooks/useCommon';
	import { cols } from '@/views/company/list/position/columns';
	let { store, commomParams } = useCommon();
	const emit = defineEmits();
	let props = defineProps(['position_record']);
	let loading = ref<Boolean>(true);

	let showPositionModel = computed(() => {
		return store.state.showPositionModel;
	})
	
	
	
	let position_record = ref<Object>({});
	watch(() => props.position_record, (newVal1) => {
		position_record.value = newVal1;
		commomParams.value.search.keyword = newVal1.full_name;
		getData()
	})

	const getData = async (val) => {
		try {
			loading.value = true;
			let res = await GetCompanyJobList(commomParams.value.search);
			loading.value = false;
			commomParams.value.table.data = res.data.rows;
			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,
				full_name: position_record.value.full_name
			};
		} catch {
			loading.value = false;
		}
	}
	
	const getPage = (data:object) => {
		commomParams.value.search.page = data.current;
		commomParams.value.search.pagesize = data.pageSize;
		getData();
	}
	
	const cancelModal = () => {
		store.commit('getShowPositionModel', {
			showPositionModel: false
		})
	}

	
</script>

<style>
</style>