<template>
	<a-drawer
		:title="'预约详情'"
		:width="800"
		:visible="visible"
		:destroy-on-close="true"
		:footer-style="{ textAlign: 'right' }"
		@close="onClose"
	>
		<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
			<a-descriptions :column="1" size="middle" bordered class="mb-2">
				<a-descriptions-item label="企业客户">{{ formData.depotGrainName }}</a-descriptions-item>
				<a-descriptions-item label="预约号">{{ formData.truckBookId }}</a-descriptions-item>
				<a-descriptions-item label="出入库">{{ formData.depotBizType }}</a-descriptions-item>
				<a-descriptions-item label="粮食种类">{{ formData.grainGroup }}</a-descriptions-item>
				<a-descriptions-item label="粮食类型">{{ formData.grainType }}</a-descriptions-item>
				<a-descriptions-item label="车牌">{{ formData.licensePlate }}&nbsp{{ formData.licensePlateBack }}</a-descriptions-item>
				<a-descriptions-item label="司机">{{ formData.driverName }}&nbsp{{ formData.driverMobile }}</a-descriptions-item>
				<a-descriptions-item label="司机行驶证">
					<a v-if="formData.driverTravel" :href="formData.driverTravel" target="_blank">
						<img :src="formData.driverTravel" alt="avatar" style="max-height: 100px; max-width: 100px"/></a>
				</a-descriptions-item>
				<a-descriptions-item label="司机驾驶证">
					<a v-if="formData.driverLicense" :href="formData.driverLicense" target="_blank">
						<img :src="formData.driverLicense" alt="avatar" style="max-height: 100px; max-width: 100px"/></a>
				</a-descriptions-item>
				<a-descriptions-item label="经办人身份证号">{{ formData.keeperCitizenId }}</a-descriptions-item>
				<a-descriptions-item label="企业单位">{{ formData.companyName }}</a-descriptions-item>
				<a-descriptions-item label="企业单位联系人">{{ formData.companySalesmanName }}&nbsp{{ formData.companySalesmanMobile }}</a-descriptions-item>
				<a-descriptions-item label="收款人">{{ formData.payeeName }}&nbsp{{ formData.payeeMobile }}</a-descriptions-item>
				<a-descriptions-item label="收款人开户行">{{ formData.payeeBank }}</a-descriptions-item>
				<a-descriptions-item label="收款人开户行账户">{{ formData.payeeBankBillNo }}</a-descriptions-item>
				<a-descriptions-item label="预约状态">{{ formData.bookState }}</a-descriptions-item>
				<a-descriptions-item label="进程">{{ formData.bizFlowName }}</a-descriptions-item>
				<a-descriptions-item label="审批状态">{{ formData.depotOpApprovalState }}</a-descriptions-item>
				<a-descriptions-item label="审批时间">{{ formData.depotOpApprovalTime }}</a-descriptions-item>
				<a-descriptions-item label="审批信息">{{ formData.depotOpApprovalMsg }}</a-descriptions-item>
			</a-descriptions>
		</a-form>
		<template #footer>
			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
		</template>
	</a-drawer>
</template>

<script setup name="depotTruckBookForm">
import tool from '@/utils/tool'
import {cloneDeep} from 'lodash-es'
import {required, rules} from '@/utils/formRules'
import depotTruckBookApi from '@/api/biz/depotTruckBookApi'
import dictOptionsApi from "@/api/biz/dictOptionsApi"
import sysConfig from "@/config";
// 抽屉状态
const visible = ref(false)
const emit = defineEmits({successful: null})
const formRef = ref()
// 表单数据
const formData = ref({})
const submitLoading = ref(false)
const depotBizTypeOptions = ref([])
const grainGroupOptions = ref([])
const grainTypeOptions = ref([])
const depotIdOptions = ref([])

// 打开抽屉
const onOpen = (record) => {
	visible.value = true
	if (record) {
		let recordData = cloneDeep(record)
		formData.value = Object.assign({}, recordData)
		// 让其回显
		if (formData.value.driverTravel)
			formData.value.driverTravel = sysConfig.API_URL + formData.value.driverTravel
		if (formData.value.driverLicense)
			formData.value.driverLicense = sysConfig.API_URL + formData.value.driverLicense
	}
}
// 关闭抽屉
const onClose = () => {
	formRef.value.resetFields()
	formData.value = {}
	visible.value = false
}
// 默认要校验的
const formRules = {}
// 抛出函数
defineExpose({
	onOpen
})
</script>
