<template>
	<!-- 进度管控 -->
	<div class="pricemoitorrecord">
		<a-card :bordered="false">
			<a-space class="search">
				<div class="silt-title" style="margin-right: 12px">
					<span style="text-align: right; width: 70px; margin-right: 0px; display: block; line-height: 30px">{{
						'轮换年度 &nbsp; '
					}}</span>
					<a-input style="width: 220px" v-model:value="SearchFormDel.rotationYear" placeholder="请输入" />
				</div>
				<div class="btnBox">
					<a-button style="margin-right: 4px" type="primary" class="primarySele" @click="Search"> 查询 </a-button>
					<a-button style="margin-right: 4px" class="snowy-buttom-left" @click="onReset"> 重置 </a-button>
					<!-- <a-button type="link" @click="onView('chenk', { id: '1' })">查看</a-button> -->
				</div>
			</a-space>
		</a-card>
		<div class="list" style="margin-top: 10px">
			<a-table :dataSource="tableData" :pagination="pagination" :columns="tableColumns">
				<template #bodyCell="{ column, record }">
					<template v-if="column.key === '操作'">
						<a-button type="link" @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/planControl') {
				setTimeout(() => {
					onSearch()
				}, 0)
			}
		},
		{ immediate: true, deep: true }
	)

	const { tableData, onSearch, handlePageChange, pagination, Search, onReset, SearchFormDel } = listPagination(
		{ rotationYear: '' },
		business.JDGKlist,
		{},
		{},
		'1'
	)

	const tableColumns = [
		{
			title: '序号',
			dataIndex: 'Index',
			align: 'center',
			customRender: ({ text, record, index }) => {
				return `${index + 1}`
			}
		},
		{ title: '轮换年度', dataIndex: 'rotationYear' },
		{ title: '轮出总数量', dataIndex: 'outPlanQuantity' },
		{ title: '已轮出数量', dataIndex: 'ckslSum' },
		{ title: '轮入总数量', dataIndex: 'inPlanQuantity' },
		{ title: '已轮入数量', dataIndex: 'rkslSum' },
		{ title: '操作', key: '操作' }
	]

	// 查看表单数据
	const onView = (record, row) => {
		switch (record) {
			case 'add':
				router.push('/business/personnelDel?add')
				break
			case 'del':
				DEl(row)
				break
			case 'chenk':
				router.push(`/rotation/warehousePlan?code=${true}&id=${row.id}&rotationYear=${row.rotationYear}`)
				break
			case 'edit':
				router.push(`/business/personnelDel?code=1&id=${row.id}`)
				break
			default:
				break
		}
	}
</script>
<style lang="less" scoped>
	.search {
		padding-top: 20px;
		padding-left: 50px;
		margin-bottom: 32px;
		.btnBox {
			display: inline-block;
			width: 200px;
			display: flex;
			justify-content: space-around;
			align-items: center;
		}
	}
	.silt-title {
		display: flex;
		span {
			text-align: right;
		}
	}
</style>
