<!-- 储备数量-->
<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.lkmc" class="select-box"
					placeholder="请输入"></a-input>
				<span class="title-box">{{ '品种' }}</span>
				<a-input :size="size" style="width: 200px" v-model:value="informationData.pzName" class="select-box"
					placeholder="请输入"></a-input>
				<span class="title-box">{{ '性质' }}</span>
				<a-input :size="size" style="width: 200px" v-model:value="informationData.hwxzName" class="select-box"
					placeholder="请输入"></a-input>
				<span class="title-box">{{ '等级' }}</span>
				<a-input :size="size" style="width: 200px" v-model:value="informationData.djName" 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="tableData" @change="onChangePage" :pagination="informationData"
			:row-key="(record) => record.key" :columns="columns">
		</a-table>
	</div>
</template>
<script setup>
import reserveQuantityApi from '@/api/reserve.info/reserveQuantityApi.js'
import { useRoute, useRouter } from 'vue-router'

const route = useRoute()
const unitId = ref(route.query)
const informationData = ref({
	lkmc: '',
	pzName: '',
	hwxzName: '',
	djName: '',
	current: 1,
	size: 10
})
const columns = [
	{
		title: '序号',
		dataIndex: 'Index',
		align: 'center',
		customRender: ({ text, record, index }) => {
			return `${index + 1}`
		}
	},
	{
		title: '库区名称',
		dataIndex: 'lkmc',
		align: 'center',
		key: 'lkmc'
	},
	{
		title: '仓房名称',
		dataIndex: 'storehouseName',
		align: 'center',
		key: 'storehouseName'
	},
	{
		title: '货位',
		dataIndex: 'storehouseName',
		align: 'center',
		key: 'storehouseName'
	},
	{
		title: '品种',
		dataIndex: 'pzName',
		align: 'center',
		key: 'pzName'
	},
	{
		title: '性质',
		dataIndex: 'hwxzName',
		align: 'center',
		key: 'hwxzName'
	},
	{
		title: '等级',
		dataIndex: 'djName',
		align: 'center',
		key: 'djName'
	},
	{
		title: '数量',
		dataIndex: 'kcslSum',
		align: 'center',
		key: 'kcslSum'
	}
] //表头
const tableData = ref([])
// 分页列表
const getDataList = () => {
	const fd = { ...informationData.value, ...unitId.value }
	reserveQuantityApi.storagePageList(fd).then((res) => {
		tableData.value = []
		tableData.value = res.records
		informationData.value.total = res.total
	})
}
// 表格分页
const onChangePage = (ev) => {
	informationData.value = { ...ev }
	if (isShowName.value == '1') {
		informationData.value.lkmc = ''
		informationData.value.pzName = ''
		informationData.value.hwxzName = ''
		informationData.value.djName = ''
	}
	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 = {
		lkmc: '',
		pzName: '',
		hwxzName: '',
		djName: '',
		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;
	margin-left: 20px;
}

.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;
}

::v-deep .ant-pagination-options {
	display: none !important;
}
</style>