<template>
	<!-- 轮换计划半月报表 -->
	<div class="halfMonthForm pageContent">
		<a-space class="search">
			库区名称:<a-input v-model:value="SearchFormDel.orgName" />
			<div class="btnBox">
				<a-button type="primary" @click="Search"> 查询 </a-button>
				<a-button @click="onReset"> 重置 </a-button>
			</div>
		</a-space>
		<div class="list">
			<a-table :dataSource="tableData" :pagination="pagination" :columns="tableColumns">
				<template #bodyCell="{ column, record }">
					<template v-if="column.key === 'CZ'">
						<a-button class="view" @click="onView('chenk', record)">查看</a-button>
					</template>
				</template>
			</a-table>
		</div>
	</div>
</template>
<script setup>
	import business from '@/api/basic.info/RotationProgram'
	import { listPagination } from '@/hook/listlistPagination.js'
	import { reactive, ref, watch } from 'vue'
	import { useRouter, useRoute } from 'vue-router'
	import { defineComponent } from 'vue'
	import useRouterdel from '@/router/index'
	const router = useRouter()
	const route = useRoute()
	watch(
		() => route,
		(newVal) => {
			if (newVal.fullPath == '/rotation/halfMonthForm') {
				setTimeout(() => {
					onSearch()
				}, 0)
			}
		},
		{ immediate: true, deep: true }
	)

	const tableColumns = [
		{
			title: '序号',
			dataIndex: 'Index',
			align: 'center',
			customRender: ({ text, record, index }) => {
				return `${index + 1}`
			}
		},
		{ title: '年度', dataIndex: 'planYear' },
		{ title: '库区名称', align: 'center', dataIndex: 'orgName' },
		{ title: '轮出数量', align: 'center', dataIndex: 'outPlanQuantity' },
		{ title: '轮入数量', align: 'center', dataIndex: 'inPlanQuantity' },
		{ title: '上报时间', align: 'center', dataIndex: 'reportTime' },
		{ title: '操作', width: 200, key: 'CZ' }
	]

	const { tableData, onSearch, handlePageChange, pagination, Search, onReset, SearchFormDel } = listPagination(
		{ orgName: '' },
		business.LHJHBYlist,
		{},
		{},
		'1'
	)
	// 查看表单数据
	const onView = (record, row) => {
		switch (record) {
			case 'add':
				router.push('/business/personnelDel?add')
				break
			case 'del':
				DEl(row)
				break
			case 'chenk':
				router.push(`/rotation/halfMonthFormDetail?code=${true}&id=${row.id}`)
				break
			case 'edit':
				router.push(`/business/personnelDel?code=1&id=${row.id}`)
				break
			default:
				break
		}
	}
</script>
<style lang="less" scoped>
	.view {
		background-color: rgba(112, 125, 233);
		color: #fff;
	}
	.edit {
		background-color: rgba(210, 176, 61);
		color: #fff;
	}
	.remove {
		background-color: rgba(255, 70, 70);
		color: #fff;
	}
	.add {
		background-color: rgba(83, 184, 36);
		color: #fff;
	}
	.pageContent {
		background: #fff;
		padding: 10px 20px;
		.search {
			padding: 10px 0;
			.btnBox {
				display: flex;
				> * {
					margin-right: 10px;
				}
			}
		}
	}
</style>
