<!-- 合法性审核 -->
<template>
	<div>
		<a-space class="header">
			<div class="input-box">
				<div class="silt-title">
					<span style="width: 62px; display: block">{{ '申报人' }}</span>
					<a-input style="width: 220px" v-model:value="informationData.reporter" placeholder="请输入" />
				</div>
				<div class="input-box-sle">
					<span class="title-box">{{ '申报部门' }}</span>
					<a-input style="width: 220px" v-model:value="informationData.sysOrgName" placeholder="请输入" />
				</div>
				<div class="input-box-sle">
					<span class="title-box">{{ '申报日期' }}</span>
					<a-date-picker v-model:value="informationData['reportDate']" value-format="YYYY-MM-DD" />
				</div>
			</div>
			<div class="btnBox">
				<a-button style="margin-right: 16px" @click="searchData">查询</a-button>
				<a-button style="margin-right: 16px" @click="reset">重置</a-button>
			</div>
		</a-space>
		<a-table
			:dataSource="dataSource"
			:row-key="(record) => record.key"
			:pagination="tablePage"
			@change="onChangePage"
			:columns="columns"
		>
			<template #bodyCell="{ column, record }">
				<template v-if="column.key === 'action'">
					<span>
						<a-button class="check" @click="check(record)">查看</a-button>
						<a-button
							v-if="record.auditStatus != 1 && record.auditStatus != 2"
							class="flow"
							@click="AuditingData(record)"
							>审核</a-button
						>
					</span>
				</template>
			</template>
		</a-table>
		<!-- 查看--编辑--新增等操作 -->
		<Auditing :dataObj="dataObj" @isVisible="isVisible" />
	</div>
</template>
<script lang="jsx" setup name="auditRequest">
	import alPolicyFileReportApi from '@/api/policy.info/alPolicyFileReportApi'
	import Auditing from './Auditing.vue'
	const columns = computed(() => [
		{
			title: '序号',
			dataIndex: 'Index',
			align: 'center',
			customRender: ({ text, record, index }) => {
				return `${index + 1}`
			}
		},
		{
			title: '标题',
			dataIndex: 'title',
			align: 'center',
			key: 'title',
			width: '300px'
		},
		{
			title: '申报部门',
			dataIndex: 'sysOrgName',
			align: 'center',
			key: 'sysOrgName'
		},
		{
			title: '申报人',
			dataIndex: 'reporter',
			align: 'center',
			key: 'reporter'
		},
		{
			title: '申报日期',
			dataIndex: 'reportDate',
			align: 'center',
			key: 'reportDate'
		},
		{
			title: '审核人',
			dataIndex: 'auditUserName',
			align: 'center',
			key: 'auditUserName'
		},
		{
			title: '审核状态',
			dataIndex: 'auditStatus',
			align: 'center',
			key: 'auditStatus',
			customRender: ({ text, record, index }) => <div>{text === 1 ? '已审核' : text === 2 ? '驳回' : '待审核'}</div>
		},
		{
			title: '审核时间',
			dataIndex: 'auditTime',
			align: 'center',
			key: 'auditTime'
		},
		{
			title: '操作',
			dataIndex: 'action',
			align: 'center',
			key: 'action',
			width: '380px'
		}
	])
	const dataSource = ref([])
	const dataObj = ref({
		visible: false,
		titleText: '',
		showLock: false,
		isType: '',
		id: '',
		status: null
	})
	const informationData = ref({
		reporter: '',
		reportDate: '',
		policyType: '1',
		sysOrgName: '',
		current: 1,
		size: 10
	})
	// 表格分页
	const onChangePage = (ev) => {
		Object.assign(informationData, ev)
		onSearch()
	}
	// 列表分页
	const onSearch = () => {
		const fd = { ...informationData.value }
		alPolicyFileReportApi.unitInfoPage(fd).then((res) => {
			dataSource.value = []
			dataSource.value = res.records
		})
	}
	// 查询
	const searchData = () => {
		onSearch()
	}
	// 重置
	const reset = () => {
		dataObj.value.isType = ''
		informationData.value = {
			reporter: '',
			reportDate: '',
			policyType: '1',
			sysOrgName: '',
			current: 1,
			size: 10
		}
		onSearch()
	}
	// 查看
	const check = (row) => {
		dataObj.value.id = row.id
		dataObj.value.requestId = row.requestId || ''
		dataObj.value.isType = '3'
		dataObj.value.titleText = '查看合法性审核'
		dataObj.value.visible = true
		dataObj.value.showLock = true
	}
	// 审核
	const AuditingData = (row) => {
		dataObj.value.id = row.id
		dataObj.value.requestId = row.requestId || ''
		dataObj.value.isType = '2'
		dataObj.value.titleText = '合法性审核'
		dataObj.value.visible = true
		dataObj.value.showLock = false
	}
	// 子组件传递
	const isVisible = (val) => {
		dataObj.value.visible = false
		dataObj.value.showLock = false
		dataObj.value.titleText = ''
		onSearch()
	}

	onMounted(() => {
		onSearch()
	})
</script>
<style scoped>
	.header {
		display: flex;
		padding: 20px;
		width: 100%;
	}
	.input-box {
		display: flex;
		width: 100%;
	}
	.input-box-sle {
		width: 56%;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 24px;
	}
	.title-box {
		width: 68px;
	}
	.inputBoxContent {
		width: 400px;
	}
	.silt-title {
		width: 280px;
		display: flex;
		align-items: center;
		margin-right: 32px;
	}
	.btnBox {
		display: flex;
	}
	.ant-input-group-addon {
		border: 0;
	}
	.ant-input,
	.ant-btn {
		border-radius: 5px;
	}
	.ant-pagination {
		margin-top: 12px;
		float: right;
		margin-right: 16px;
	}
	.add-btn {
		background-color: rgba(112, 125, 233);
	}
	.check {
		background-color: rgba(112, 125, 233);
		color: #fff;
		margin-left: 8px;
	}
	.edit {
		background-color: rgba(222, 186, 80);
		color: #fff;
		margin-left: 8px;
	}
	.flow {
		background-color: #22ce8d;
		color: #fff;
		margin-left: 8px;
	}
	.delete {
		background-color: rgba(255, 70, 70);
		color: #fff;
		margin-left: 8px;
	}
	.audit {
		background-color: rgba(83, 184, 36);
		color: #fff;
		margin-left: 8px;
	}
	.ant-table-thead > tr > th {
		text-align: center;
	}
	.ant-table-tbody > tr > td {
		text-align: center;
	}
</style>
