<!-- 轮换数量预警 -->
<template>
	<div>
		<a-space class="header">
			<div class="inputBox">
				<span class="title-box">{{ '承储企业' }}</span>
				<a-input :size="size" style="width: 200px" v-model:value="informationData.unitName" class="select-box"
					placeholder="请输入"></a-input>
			</div>
			<div class="btnBox">
				<a-button type="primary" style="margin-right: 24px" @click="searchData">查询</a-button>
				<a-button @click="reset">重置</a-button>
			</div>
		</a-space>
		<a-table :dataSource="dataSource" @change="onChangePage" :pagination="informationData"
			:row-key="(record) => record.key" :columns="columns"> </a-table>
	</div>
</template>
<script setup name="rotationProgram">
import rotationPlanApi from "@/api/rotationPlan.info/rotationPlanApi";
const dataSource = ref([])
const informationData = ref({
	unitName: '',
	current: 1,
	size: 10
})
const columns = [
	{
		title: '序号',
		dataIndex: 'Index',
		align: 'center',
		customRender: ({ text, record, index }) => {
			return `${index + 1}`
		}
	},
	{
		title: '年度',
		dataIndex: 'planYear',
		align: 'center',
		key: 'planYear'
	},
	{
		title: '企业名称',
		dataIndex: 'dwmc',
		align: 'center',
		key: 'dwmc'
	},
	{
		title: '库区名称',
		dataIndex: 'orgName',
		align: 'center',
		key: 'orgName'
	},
	{
		title: '实际轮换数量',
		dataIndex: 'actualRotationQuantity',
		align: 'center',
		key: 'actualRotationQuantity'
	},
	{
		title: '轮换数量百分比',
		dataIndex: 'rotationQuantityPercentage',
		align: 'center',
		key: 'rotationQuantityPercentage'
	},
	{
		title: '应轮换数量百分比',
		dataIndex: 'shouldRotationQuantityPercentage',
		align: 'center',
		key: 'shouldRotationQuantityPercentage'
	},
	{
		title: '预警时间',
		dataIndex: 'warningTime',
		align: 'center',
		key: 'warningTime'
	}
] //表头
// 分页列表
const getDataList = () => {
	const fd = { ...informationData.value }
	rotationPlanApi.rotationPage(fd).then((res) => {
		dataSource.value = []
		dataSource.value = res.records
		informationData.value.total = res.total
	})
}
// 表格分页
const onChangePage = (ev) => {
	informationData.value = { ...ev }
	if (isShowName.value == '1') {
		informationData.value.unitName = ''
	}
	getDataList()
}
//查询
const isShowName = ref('1')
const searchData = () => {
	informationData.value.current = 1
	if (informationData.value.total > 10) {
		isShowName.value = '2'
	} else {
		isShowName.value = '1'
	}
	getDataList()
}

// 重置输入框
const reset = () => {
	informationData.value = {
		unitName: '',
		current: 1,
		size: 10
	}
	getDataList()
}
onMounted(() => {
	getDataList()
});
</script>
<style lang="less" scoped>
.header {
	display: flex;
	padding-top: 20px;
	padding-left: 50px;
	margin-bottom: 32px;
}

.inputBox {
	display: flex;
}

.inputBoxContent {
	width: 400px;
}

.btnBox {
	width: 260px;
	margin-left: 20px;
	justify-content: start;
	display: flex;
}

.select-box {
	margin-left: 12px;
}

.title-box {
	line-height: 30px;
}

.ant-input-group-addon {
	border: 0;
}

.ant-input,
.ant-btn {
	border-radius: 5px;
}

.check {
	background-color: rgba(112, 125, 233);
	color: #fff;
}

.edit {
	background-color: rgba(222, 186, 80);
	color: #fff;
}

.delete {
	background-color: rgba(255, 70, 70);
	color: #fff;
}

::v-deep .ant-table-wrapper {
	padding: 0 10px;
}

.audit {
	background-color: rgba(83, 184, 36);
	color: #fff;
}

.ant-table-thead>tr>th {
	text-align: center;
}

.ant-table-tbody>tr>td {
	text-align: center;
}
</style>
