<template>
	<!-- 总表 -->
	<div class="statisticsTableAll">
		<div class="tableBox">
			<a-table
				size="small"
				:scroll="{ x: 'calc(700px + 50%)', y: true }"
				bordered
				:pagination="false"
				:dataSource="tableData"
				:columns="tableColumns"
			>
				<template #bodyCell="{ column, record, index }">
					<template v-if="column.key === 'INDEX'">{{ index + 1 }}</template>
					<template v-else>{{ record[column.key] }}</template>
				</template>
			</a-table>
		</div>
	</div>
</template>
<script setup name="statisticsTableAll">
	import api from '@/api/RLGI/system.js'
	import getTableChildren from './getTableChild'
	const tableData = ref([])
	const tableColumns = [
		{ title: '序号', width: 50, key: 'INDEX', align: 'center' },
		{ title: '承储企业', ellipsis: true, align: 'center', width: 250, key: 'orgName' },
		{ title: '地方储备', align: 'center', children: getTableChildren('_地方储备', 'df') },
		{ title: '省级储备', align: 'center', children: getTableChildren('_省级储备', 'sj') },
		{ title: '市(州)级储备', align: 'center', children: getTableChildren('_市级储备', 'cj') },
		{ title: '县(区)级储备', align: 'center', children: getTableChildren('_县级储备', 'xj') }
	]

	onMounted(() => {
		getTableData()
	})
	function getTableData() {
		api.getCrkKcswDatas().then((res) => {
			tableData.value = res
		})
	}
</script>
<style lang="less" scoped>
	.tableBox {
		padding: 20px 30px;
		background: #fff;
		height: calc(100vh - 201px);
		::v-deep(.ant-table) {
			.ant-table-body {
				height: calc(100vh - 380px);
			}
		}
	}
</style>
