<template>
	<xn-form-container title="详情" :width="900" :visible="visible" :destroy-on-close="true" @close="onClose">
		<a-form ref="formRef" :model="formData" :label-col="labelCol4" :wrapper-col="wrapperCol20">
			<a-descriptions :column="4" size="middle" bordered class="mb-2" :label-style="labelStyle" :contentStyle="contentStyle">
				<a-descriptions-item label="订单编号" :span="2">{{ formData.orderNumber }}</a-descriptions-item>
				<a-descriptions-item label="订单名称" :span="2">{{ formData.orderName }}</a-descriptions-item>
				<a-descriptions-item label="客户名称" :span="2">{{ formData.customerName }}</a-descriptions-item>
				<a-descriptions-item label="联系人" :span="2">{{ formData.customerContactName }}</a-descriptions-item>
				<a-descriptions-item label="手机号" :span="2">{{ formData.customerPhone }}</a-descriptions-item>
				<a-descriptions-item label="客户地址" :span="2">{{ formData.customerAddress }}</a-descriptions-item>
				<a-descriptions-item label="货品名称" :span="2">{{ formData.goodsName }}</a-descriptions-item>
				<a-descriptions-item label="货品规格" :span="2">{{ formData.goodsModel }}</a-descriptions-item>
				<a-descriptions-item label="订单来源" :span="2">
					<a-tag
						:color="
							formData.orderSource === '1'
								? 'orange'
								: formData.orderSource === '2'
								  ? 'green'
								  : 'purple'
						"
					>
						{{ $TOOL.dictTypeData('order_source', formData.orderSource) }}
					</a-tag>
				</a-descriptions-item>
				<a-descriptions-item label="订单状态" :span="2">
					<a-tag
						:color="
							formData.orderStatus === '1'
								? '#2db7f5'
								: formData.orderStatus === '2'
								  ? '#f50'
								  : '#f50'
						"
					>
						{{ $TOOL.dictTypeData('order_status', formData.orderStatus) }}
					</a-tag>
				</a-descriptions-item>
				<a-descriptions-item label="订单重量" :span="2">{{ formData.orderWeight }}</a-descriptions-item>
				<a-descriptions-item label="过磅重量" :span="2">{{ formData.netWeight }}</a-descriptions-item>
			</a-descriptions>
		</a-form>
	</xn-form-container>
</template>

<script setup name="recordDoubleForm">
	import { cloneDeep } from 'lodash-es'
	// 默认是关闭状态
	const visible = ref(false)
	const formData = ref({})
	const table = ref()
	const resultJson = ref()

	const labelStyle = {
		width: '20%'
	}
	const contentStyle = {
		width: '30%'
	}

	const labelCol4 = ref({span: 4, style: 'width: 26%; line-height: 20px; white-space: normal',})
	const labelCol8 = ref({span: 8, style: 'width: 26%; line-height: 20px; white-space: normal',})
	const wrapperCol20 = ref({span: 20})

	// 打开抽屉
	const onOpen = (record) => {
		visible.value = true
		//getRecordDoubleDetail(record)
		if(record){
			let recordData = cloneDeep(record)
			formData.value = Object.assign({}, recordData)
		}

	}
	const getRecordDoubleDetail = (record) => {
		const param = {
			id: record.id
		}
		tbRecordDoubleApi.recordDoubleDetailPic(param).then((data) => {
			Object.assign(record, data)
			formData.value = record
		})
	}
	// 关闭抽屉
	const onClose = () => {
		resultJson.value = ''
		visible.value = false
	}
	// 调用这个函数将子组件的一些数据和方法暴露出去
	defineExpose({
		onOpen
	})
</script>

<style scoped>
	.imgDiv ::v-deep .ant-image {
		margin-left: 20px;
		margin-top: 10px;
	}
	.imgDiv ::v-deep .ant-image-mask-info {
		margin-left: 20px;
		margin-top: 10px;
	}
</style>
