<template>
	<xn-form-container
		:title="'过磅记录详情'"
		:width="1200"
		v-model:open="open"
		:destroy-on-close="true"
		@close="onClose"
	>
		<a-descriptions>
			<a-descriptions-item span="3" label="车次编码">{{ formData.carNumber }}</a-descriptions-item>
			<a-descriptions-item label="车牌号码">{{ formData.licensePlate }}</a-descriptions-item>
			<a-descriptions-item span="2" label="车牌颜色">{{ formData.plateColor }}</a-descriptions-item>
			<a-descriptions-item label="发货单位">{{ formData.shippingCompany }}</a-descriptions-item>
			<a-descriptions-item label="收货单位">{{ formData.receiptCompany }}</a-descriptions-item>
			<a-descriptions-item label="运输单位">{{ formData.transportCompany }}</a-descriptions-item>
			<!-- <a-descriptions-item label="运输路线">{{ formData.transportRoute }}</a-descriptions-item> -->
			<a-descriptions-item label="货品名称">{{ formData.goodsName }}</a-descriptions-item>
			<a-descriptions-item label="货品规格">{{ formData.goodsModel }}</a-descriptions-item>
			<a-descriptions-item label="司机姓名">{{ formData.driverName }}</a-descriptions-item>
			<a-descriptions-item label="订单名称">{{ formData.orderName }}</a-descriptions-item>
			<a-descriptions-item label="订单编号">{{ formData.orderNumber }}</a-descriptions-item>
			<a-descriptions-item label="客户名称">{{ formData.customerName }}</a-descriptions-item>
			<a-descriptions-item label="司机电话">{{ formData.driverMobile }}</a-descriptions-item>
			<a-descriptions-item label="过磅人">{{ formData.extKey1 }}</a-descriptions-item>
			<a-descriptions-item label="打印时间">{{ formData.extKey2 }}</a-descriptions-item>
		</a-descriptions>
		<a-divider></a-divider>
		<a-descriptions>
			<a-descriptions-item label="毛重"
				><a-tag color="blue">{{ formData.grossWeight }} KG</a-tag></a-descriptions-item
			>
			<a-descriptions-item label="皮重"
				><a-tag color="orange">{{ formData.tareWeight }} KG</a-tag></a-descriptions-item
			>
			<a-descriptions-item label="净重"
				><a-tag color="green">{{ formData.netWeight }} KG</a-tag></a-descriptions-item
			>
		</a-descriptions>
		<a-divider></a-divider>
		<a-descriptions title="过毛">
			<a-descriptions-item label="过磅时间">{{ formData.grossTime }}</a-descriptions-item>
		</a-descriptions>
		<a-space>
			<a-image :width="200" :src="formData.grossPlateName" />
			<a-image :width="200" :src="formData.grossLicenseName" />
		</a-space>
		<a-space style="margin-top: 15px; margin-left: 10px">
			<a-image v-if="formData.grossCaptureHead != null" :width="200" :src="formData.grossCaptureHead" />
			<a-image v-if="formData.grossCaptureTail != null" :width="200" :src="formData.grossCaptureTail" />
			<a-image v-if="formData.grossCaptureBody != null" :width="200" :src="formData.grossCaptureBody" />
		</a-space>
		<a-space style="margin-top: 15px; margin-left: 10px">
			<a-image v-if="formData.grossCaptureWare != null" :width="200" :src="formData.grossCaptureWare" />
			<a-image v-if="formData.grossCapturePoundRoom != null" :width="200" :src="formData.grossCapturePoundRoom" />
		</a-space>
		<a-divider></a-divider>
		<a-descriptions title="过皮" style="margin-top: 15px">
			<a-descriptions-item label="过磅时间">{{ formData.tareTime }}</a-descriptions-item>
		</a-descriptions>
		<a-space>
			<a-image :width="200" :src="formData.tarePlateName" />
			<a-image :width="200" :src="formData.tareLicenseName" />
		</a-space>
		<a-space style="margin-top: 15px; margin-left: 10px">
			<a-image v-if="formData.tareCaptureHead != null" :width="200" :src="formData.tareCaptureHead" />
			<a-image v-if="formData.tareCaptureTail != null" :width="200" :src="formData.tareCaptureTail" />
			<a-image v-if="formData.tareCaptureBody != null" :width="200" :src="formData.tareCaptureBody" />
		</a-space>
		<a-space style="margin-top: 15px; margin-left: 10px">
			<a-image v-if="formData.tareCaptureWare != null" :width="200" :src="formData.tareCaptureWare" />
			<a-image v-if="formData.tareCapturePoundRoom != null" :width="200" :src="formData.tareCapturePoundRoom" />
		</a-space>
		<template #footer>
			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
		</template>
	</xn-form-container>
</template>

<script setup name="bizRecordForm">
	import tool from '@/utils/tool'
	import { cloneDeep } from 'lodash-es'
	import bizRecordApi from '@/api/biz/bizRecordApi'

	// 抽屉状态
	const open = ref(false)
	const emit = defineEmits({ successful: null })
	// const formRef = ref()
	// 表单数据
	const formData = ref({})
	// const submitLoading = ref(false)
	const tareTypeOptions = ref([])

	// 打开抽屉
	const onOpen = (record) => {
		open.value = true
		tareTypeOptions.value = tool.dictList('TARE_TYPE')
		if (record) {
			/*const param = {
				id: record.id
			}
			bizRecordApi.bizRecordDetail(param).then((data) => {
				formData.value = Object.assign({}, data)
			})*/
			let recordData = cloneDeep(record)
			formData.value = Object.assign({}, recordData)
		}
	}
	// 关闭抽屉
	const onClose = () => {
		// formRef.value.resetFields()
		formData.value = {}
		open.value = false
	}
	// 抛出函数
	defineExpose({
		onOpen
	})
</script>
