<!-- 信用档案-信用数据管理 -->
<template>
	<div class="pricemoitorrecord">
		<a-card :bordered="false">
			<a-space class="search">
				<div class="silt-title">
					<span style="width: 70px; margin-right: 8px; text-align: right; display: block; line-height: 30px">{{
						'地区'
					}}</span>
					<a-select style="width: 220px" v-model:value="SearchFormDel.area">
						<a-select-option v-for="item in optionsGender" :key="item.id" :value="item.id">{{
							item.dictLabel
						}}</a-select-option>
					</a-select>
				</div>
				<div class="silt-title">
					<span style="width: 70px; margin-right: 8px; text-align: right; display: block; line-height: 30px">
						库区名称
					</span>
					<a-input style="width: 220px" v-model:value="SearchFormDel.orgName" placeholder="请输入" />
				</div>
				<div class="silt-title">
					<span style="width: 70px; margin-right: 8px; text-align: right; display: block; line-height: 30px">
						品种
					</span>
					<a-input style="width: 220px" v-model:value="SearchFormDel.grainVarietyName" placeholder="请输入" />
				</div>
			</a-space>
			<a-space class="search">
				<div class="silt-title">
					<span style="width: 70px; margin-right: 8px; text-align: right; display: block; line-height: 30px">{{
						'等级'
					}}</span>
					<a-input style="width: 220px" v-model:value="SearchFormDel.grainGradeName" placeholder="请输入" />
				</div>
				<div class="silt-title">
					<span style="width: 70px; margin-right: 8px; text-align: right; display: block; line-height: 30px">
						存储时间
					</span>
					<a-range-picker
						style="width: 450px"
						v-model:value="startWarningTimeDEl"
						@change="changng"
						valueFormat="YYYY-MM-DD HH:mm:ss"
					/>
				</div>
				<div class="btnBox">
					<a-button type="primary" class="primarySele" @click="Search"> 查询 </a-button>
					<a-button class="primarySele snowy-buttom-left" @click="onReset"> 重置 </a-button>
					<a-button type="primary" class="primarySele" @click="onView('add', {})"> 查看 </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.dataIndex === 'creditLevel'">
						<div v-if="record.creditLevel == '1'">一级</div>
						<div v-if="record.creditLevel == '2'">二级</div>
						<div v-if="record.creditLevel == '3'">三级</div>
					</template>
					<template v-if="column.key === '操作'">
						<a-button type="link" @click="onView('view', record)">查看</a-button>
					</template>
				</template>
			</a-table>
		</div>
	</div>
</template>
<script setup name="sharing">
	import { listPagination } from '@/hook/listlistPagination.js'
	import { reactive, ref, onMounted } from 'vue'
	import business from '@/api/daily/daily.js'
	import { useRouter } from 'vue-router'
	import { defineComponent } from 'vue'
	const formRef = ref(null)
	const router = useRouter()

	const tableColumns = [
		{
			title: '序号',
			dataIndex: 'Index',
			align: 'center',
			customRender: ({ text, record, index }) => {
				return `${index + 1}`
			}
		},
		{ title: '所在地区', align: 'center', dataIndex: 'area' },
		{ title: '库区名称', align: 'center', dataIndex: 'orgName' },
		{ title: '仓房名称', align: 'center', dataIndex: 'storehouseName' },
		{ title: '货位名称', align: 'center', dataIndex: 'warehouseName' },
		{ title: '品种', align: 'center', dataIndex: 'grainVarietyName' },
		{ title: '性质', align: 'center', dataIndex: 'grainNatureName' },
		{ title: '粮食等级', align: 'center', dataIndex: 'grainGradeName' },
		{ title: '粮食数量', align: 'center', dataIndex: 'lssl' }
	]

	const { DEl, change, tableData, onSearch, handlePageChange, pagination, SearchFormDel } = listPagination(
		{ area: '', orgName: '', grainVarietyName: '', grainGradeName: '', startDate: '', endDate: '' },
		business.ZKSLlist,
		{},
		{ sortOrder: 'ASCEND' }
	)

	// 查看表单数据
	const onView = (record, row) => {
		switch (record) {
			case 'add':
				router.push('/daily/InventoryDel?add')
				break
			case 'del':
				DEl(row)
				break
			case 'view':
				router.push(`/daily/InventoryDel?codeTTY=${true}&id=${row.id}`)
				break
			case 'edit':
				router.push(`/daily/InventoryDel?codeTTY=1&id=${row.id}`)
				break
			default:
				// router.push('/business/personnelDel')
				break
		}
	}

	const startWarningTimeDEl = ref([])
	const changng = (v) => {
		startWarningTimeDEl.value = v
	}
	const Search = () => {
		pagination.current = 1
		pagination.pageSize = 5
		onSearch({
			...SearchFormDel.value,
			startDate: startWarningTimeDEl.value[0] || '',
			endDate: startWarningTimeDEl.value[1] || ''
		})
	}
	const onReset = () => {
		startWarningTimeDEl.value[0] = ''
		startWarningTimeDEl.value[1] = ''
		for (let key in SearchFormDel.value) {
			SearchFormDel.value[key] = ''
		}
		pagination.current = 1
		pagination.pageSize = 5
		onSearch()
	}
	onMounted(() => {
		DQlist()
	})

	const optionsGender = ref([])
	const DQlist = async () => {
		const res = await business.TJFXDQ({ parentId: '1781535965870915586' })
		optionsGender.value = res
	}
</script>
<style lang="less" scoped>
	.search {
		padding-top: 20px;
		// padding-left: 50px;
		margin-bottom: 32px;
		.btnBox {
			width: 100%;
			display: inline-block;
			display: flex;
			justify-content: space-around;
			align-items: center;
			.primarySele {
				margin-left: 20px;
				margin-right: 20px;
			}
		}
	}
	.silt-title {
		display: flex;
		margin-right: 10px;
	}
</style>
