<template>
	<a-drawer
		:title="'人工补单过磅记录'"
		:width="1500"
		:visible="visible"
		:destroy-on-close="true"
		:footer-style="{ textAlign: 'right' }"
		@close="onClose"
	>
		<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
			<a-card title="预约信息" :bordered="false">
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="企业客户：" name="depotGrainName">
							<a-input v-model:value="formData.depotGrainName" disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="出入库：" name="depotBizType">
							<a-input v-model:value="formData.depotBizType" placeholder="请选择出入库:入库/出库" disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="粮食种类：" name="grainGroup">
							<a-input v-model:value="formData.grainGroup" placeholder="请选择出入库:粮食种类" disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="司机姓名：" name="driverName">
							<a-input v-model:value="formData.driverName" placeholder="请输入司机姓名" allow-clear disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="司机电话：" name="driverMobile">
							<a-input v-model:value="formData.driverMobile" placeholder="请输入" allow-clear disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="车牌号码：" name="licensePlate">
							<a-input v-model:value="formData.licensePlate" placeholder="请输入车牌号码" allow-clear disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="车牌颜色：" name="plateColor">
							<a-select v-model:value="formData.plateColor" placeholder="请输入车牌颜色" allow-clear :options="plateColorOptions"/>
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
			<a-card title="过磅信息" :bordered="false">
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="毛重(公斤)：" name="grossWeight">
							<a-input-number v-model:value="formData.grossWeight" placeholder="请输入毛重" style="width: 100%" @change="putNetWeight"
											allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛时间：" name="grossTime">
							<a-date-picker v-model:value="formData.grossTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择过毛时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="皮重(公斤)：" name="tareWeight">
							<a-input v-model:value="formData.tareWeight" placeholder="请输入皮重" style="width:100%" @change="putNetWeight" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮时间：" name="tareTime">
							<a-date-picker v-model:value="formData.tareTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择过皮时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="价格(元/吨)：" name="unitPrice">
							<a-input-number v-model:value="formData.unitPrice" placeholder="请输入价格" :min="0.01" style="width:100%" @change="putTotalPrice"
											allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="净重(公斤)：" name="netWeight">
							<a-input v-model:value="formData.netWeight" placeholder="请输入净重" allow-clear disabled/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="总价(元)：" name="totalPrice">
							<a-input v-model:value="formData.totalPrice" allow-clear disabled/>
						</a-form-item>
					</a-col>
				</a-row>
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="过毛车牌图片：" name="grossPlateNames">
							<a-upload
								v-model:file-list="formData.grossPlateNames"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossPlateNames || formData.grossPlateNames.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛车图片：" name="grossLicenseNames">
							<a-upload
								v-model:file-list="formData.grossLicenseNames"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossLicenseNames || formData.grossLicenseNames.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛车头抓拍：" name="grossCaptureHeads">
							<a-upload
								v-model:file-list="formData.grossCaptureHeads"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossCaptureHeads || formData.grossCaptureHeads.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛车尾抓拍：" name="grossCaptureTails">
							<a-upload
								v-model:file-list="formData.grossCaptureTails"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossCaptureTails || formData.grossCaptureTails.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛车仓抓拍：" name="grossCaptureWares">
							<a-upload
								v-model:file-list="formData.grossCaptureWares"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossCaptureWares || formData.grossCaptureWares.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛车身抓拍：" name="grossCaptureBodys">
							<a-upload
								v-model:file-list="formData.grossCaptureBodys"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossCaptureBodys || formData.grossCaptureBodys.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过毛磅房抓拍：" name="grossCapturePoundRooms">
							<a-upload
								v-model:file-list="formData.grossCapturePoundRooms"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.grossCapturePoundRooms || formData.grossCapturePoundRooms.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
				</a-row>
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="过皮车牌图片：" name="tarePlateNames">
							<a-upload
								v-model:file-list="formData.tarePlateNames"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.tarePlateNames || formData.tarePlateNames.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮车图片：" name="tareLicenseNames">
							<a-upload
								v-model:file-list="formData.tareLicenseNames"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.tareLicenseNames || formData.tareLicenseNames.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮车头抓拍：" name="tareCaptureHeads">
							<a-upload
								v-model:file-list="formData.tareCaptureHeads"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.tareCaptureHeads || formData.tareCaptureHeads.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮车尾抓拍：" name="tareCaptureTails">
							<a-upload
								v-model:file-list="formData.tareCaptureTails"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.tareCaptureTails || formData.tareCaptureTails.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮车仓抓拍：" name="tareCaptureWares">
							<a-upload
								v-model:file-list="formData.tareCaptureWares"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.tareCaptureWares || formData.tareCaptureWares.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮车身抓拍：" name="tareCaptureBodys">
							<a-upload
								v-model:file-list="formData.tareCaptureBodys"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.tareCaptureBodys || formData.tareCaptureBodys.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="过皮磅房抓拍：" name="tareCapturePoundRooms">
							<a-upload
								v-model:file-list="formData.tareCapturePoundRooms"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
								style="width:300px;height:300px"
							>
								<div v-if="!formData.tareCapturePoundRooms || formData.grossCapturePoundRooms.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
			<a-card title="门禁信息" :bordered="false">
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="水份：" name="samplingShuiFen">
							<a-input v-model:value="formData.samplingShuiFen" placeholder="请输入水份" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="水容重：" name="samplingRongZhong">
							<a-input v-model:value="formData.samplingRongZhong" placeholder="请输入容重" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="不完善率：" name="samplingQueShao">
							<a-input v-model:value="formData.samplingQueShao" placeholder="请输入不完善率" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="霉变：" name="samplingMeiBian">
							<a-input v-model:value="formData.samplingMeiBian" placeholder="请输入霉变" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="杂质：" name="samplingZaZhi">
							<a-input v-model:value="formData.samplingZaZhi" placeholder="请输入杂质" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="杂质：" name="samplingZaZhi">
							<a-input v-model:value="formData.samplingZaZhi" placeholder="请输入杂质" allow-clear/>
						</a-form-item>
					</a-col>
				</a-row>
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="进场时间：" name="inTime">
							<a-date-picker v-model:value="formData.inTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择过毛时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="出场时间：" name="outTime">
							<a-date-picker v-model:value="formData.outTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择过毛时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
			<a-card title="扦样信息" v-if="formData.depotBizType === '入库'" :bordered="false">
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="水份：" name="samplingShuiFen">
							<a-input v-model:value="formData.samplingShuiFen" placeholder="请输入水份" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="水容重：" name="samplingRongZhong">
							<a-input v-model:value="formData.samplingRongZhong" placeholder="请输入容重" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="不完善率：" name="samplingQueShao">
							<a-input v-model:value="formData.samplingQueShao" placeholder="请输入不完善率" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="霉变：" name="samplingMeiBian">
							<a-input v-model:value="formData.samplingMeiBian" placeholder="请输入霉变" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="杂质：" name="samplingZaZhi">
							<a-input v-model:value="formData.samplingZaZhi" placeholder="请输入杂质" allow-clear/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="杂质：" name="samplingZaZhi">
							<a-input v-model:value="formData.samplingZaZhi" placeholder="请输入杂质" allow-clear/>
						</a-form-item>
					</a-col>
				</a-row>
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="到达时间：" name="truckInTime">
							<a-date-picker v-model:value="formData.truckInTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择过毛时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="离开时间：" name="truckOutTime">
							<a-date-picker v-model:value="formData.truckOutTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择过毛时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="到达图片一：" name="truckPicInOnes">
							<a-upload
								v-model:file-list="formData.truckPicInOnes"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.truckPicInOnes || formData.truckPicInOnes.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="到达图片二：" name="truckPicInTwos">
							<a-upload
								v-model:file-list="formData.truckPicInTwos"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.truckPicInTwos || formData.truckPicInTwos.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="离开图片一：" name="truckPicOutOnes">
							<a-upload
								v-model:file-list="formData.truckPicOutOnes"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.truckPicOutOnes || formData.truckPicOutOnes.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="离开图片二：" name="truckPicOutTwos">
							<a-upload
								v-model:file-list="formData.truckPicOutTwos"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.truckPicOutTwos || formData.truckPicOutTwos.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
			<a-card title="装货卸货" v-if="formData.depotBizType === '入库'" :bordered="false">
				<a-row :gutter="21">
					<a-col :span="3">
						<a-form-item label="库位：" name="depotShed">
							<a-select v-model:value="formData.depotShed" placeholder="请选择库位" :options="depotShedOptions"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="卸货前拍照时间：" name="onePicTime">
							<a-date-picker v-model:value="formData.onePicTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="卸货后拍照时间：" name="twoPicTime">
							<a-date-picker v-model:value="formData.twoPicTime" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择时间"
										   style="width: 100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="卸货前图片：" name="onePicUrls">
							<a-upload
								v-model:file-list="formData.onePicUrls"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.onePicUrls || formData.onePicUrls.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
					<a-col :span="3">
						<a-form-item label="卸货后图片：" name="twoPicUrls">
							<a-upload
								v-model:file-list="formData.twoPicUrls"
								v-model:action="customUpload"
								list-type="picture-card"
								@preview="handlePreview"
								@change="handleChange"
								accept="image/png, image/jpeg, image/jpg"
							>
								<div v-if="!formData.twoPicUrls || formData.twoPicUrls.length < 1">
									<a-icon type="plus"/>
									<div class="ant-upload-text">
										Upload
									</div>
								</div>
							</a-upload>
							<a-modal :visible="previewVisible" :footer="null" @cancel="handleCancel">
								<img alt="example" style="width: 100%" :src="previewImage"/>
							</a-modal>
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
		</a-form>
		<template #footer>
			<a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
			<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
		</template>
	</a-drawer>
</template>

<script setup name="depotTruckWeighDoubleForm">
import tool from '@/utils/tool'
import {cloneDeep} from 'lodash-es'
import {required, rules} from '@/utils/formRules'
import depotTruckWeighDoubleApi from '@/api/biz/depotTruckWeighDoubleApi'
import fileApi from "@/api/dev/fileApi.js";
import dictOptionsApi from "@/api/biz/dictOptionsApi";
// 抽屉状态
const visible = ref(false)
const emit = defineEmits({successful: null})
const formRef = ref()
// 表单数据
const formData = ref({})
const submitLoading = ref(false)
let grossPlateNames = ref([])
const depotShedOptions = ref([])

// 打开抽屉
const onOpen = (record) => {
	visible.value = true
	if (record) {
		let recordData = cloneDeep(record)
		formData.value = Object.assign({}, recordData)
		formData.value.unitPrice = formData.value.samplingPrice
		formData.value.grossPlateNames = []
		formData.value.grossLicenseNames = []
		formData.value.grossCaptureHeads = []
		formData.value.grossCaptureTails = []
		formData.value.grossCaptureWares = []
		formData.value.grossCaptureBodys = []
		formData.value.grossCapturePoundRooms = []
		formData.value.tarePlateNames = []
		formData.value.tareLicenseNames = []
		formData.value.tareCaptureHeads = []
		formData.value.tareCaptureTails = []
		formData.value.tareCaptureWares = []
		formData.value.tareCaptureBodys = []
		formData.value.tareCapturePoundRooms = []
		formData.value.truckPicInOnes = []
		formData.value.truckPicInTwos = []
		formData.value.truckPicOutOnes = []
		formData.value.truckPicOutTwos = []
		formData.value.onePicUrls = []
		formData.value.twoPicUrls = []
		if (formData.value.depotBizType === '入库')
			dictOptionsApi.options({'dictValue': '库位', depotId: formData.value.depotId}).then((data) => {
				depotShedOptions.value = data
			})
	}
}
// 关闭抽屉
const onClose = () => {
	formRef.value.resetFields()
	formData.value = {}
	visible.value = false
}
// 默认要校验的
const formRules = {
	plateColor: [required('请输入')],
	grossWeight: [required('请输入')],
	tareWeight: [required('请输入')],
	netWeight: [required('请输入')],
	grossTime: [required('请输入')],
	tareTime: [required('请输入')],
	unitPrice: [required('请输入'), rules.amountCheck],
	totalPrice: [required('请输入'), rules.amountCheck],
	depotShed: [required('请输入')],
}
// 计算净重
const putNetWeight = () => {
	if (formData.value.grossWeight && formData.value.tareWeight) {
		formData.value.netWeight = formData.value.grossWeight - formData.value.tareWeight
		putTotalPrice()
	}
}
// 计算总价
const putTotalPrice = () => {
	if (formData.value.netWeight && formData.value.unitPrice)
		formData.value.totalPrice = formData.value.unitPrice * 10000 * formData.value.netWeight / 10000000
}
// 验证并提交数据
const onSubmit = () => {
	formData.value.grossPlateNames.map((item) => {
		formData.value.grossPlateName = item.originFileObj.url
	})
	formData.value.grossLicenseNames.map((item) => {
		formData.value.grossLicenseName = item.originFileObj.url
	})
	formData.value.grossCaptureHeads.map((item) => {
		formData.value.grossCaptureHead = item.originFileObj.url
	})
	formData.value.grossCaptureTails.map((item) => {
		formData.value.grossCaptureTail = item.originFileObj.url
	})
	formData.value.grossCaptureWares.map((item) => {
		formData.value.grossCaptureWare = item.originFileObj.url
	})
	formData.value.grossCaptureBodys.map((item) => {
		formData.value.grossCaptureBody = item.originFileObj.url
	})
	formData.value.grossCapturePoundRooms.map((item) => {
		formData.value.grossCapturePoundRoom = item.originFileObj.url
	})
	formData.value.tarePlateNames.map((item) => {
		formData.value.tarePlateName = item.originFileObj.url
	})
	formData.value.tareLicenseNames.map((item) => {
		formData.value.tareLicenseName = item.originFileObj.url
	})
	formData.value.tareCaptureHeads.map((item) => {
		formData.value.tareCaptureHead = item.originFileObj.url
	})
	formData.value.tareCaptureTails.map((item) => {
		formData.value.tareCaptureTail = item.originFileObj.url
	})
	formData.value.tareCaptureWares.map((item) => {
		formData.value.tareCaptureWare = item.originFileObj.url
	})
	formData.value.tareCaptureBodys.map((item) => {
		formData.value.tareCaptureBody = item.originFileObj.url
	})
	formData.value.tareCapturePoundRooms.map((item) => {
		formData.value.tareCapturePoundRoom = item.originFileObj.url
	})
	formData.value.truckPicInOnes.map((item) => {
		formData.value.truckPicInOne = item.originFileObj.url
	})
	formData.value.truckPicInTwos.map((item) => {
		formData.value.truckPicInTwo = item.originFileObj.url
	})
	formData.value.truckPicOutOnes.map((item) => {
		formData.value.truckPicOutOne = item.originFileObj.url
	})
	formData.value.truckPicOutTwos.map((item) => {
		formData.value.truckPicOutTwo = item.originFileObj.url
	})
	formData.value.onePicUrls.map((item) => {
		formData.value.onePicUrl = item.originFileObj.url
	})
	formData.value.twoPicUrls.map((item) => {
		formData.value.twoPicUrl = item.originFileObj.url
	})
	formRef.value
		.validate()
		.then(() => {
			submitLoading.value = true
			const formDataParam = cloneDeep(formData.value)
			formDataParam.billGroup = '人工补单'
			depotTruckWeighDoubleApi
				.depotTruckWeighDoubleSubmitForm(formDataParam, true)
				.then(() => {
					onClose()
					emit('successful')
				})
				.finally(() => {
					submitLoading.value = false
				})
		})
}
const customUpload = (data) => {
	//保存图片
	const fileData = new FormData()
	fileData.append('file', data)
	fileData.append('depotId', formData.value.depotId)
	fileData.append('type', "body")
	fileApi
		.fileUploadInnerMinioReturnUrl(fileData)
		.then((result) => {
			data.url = result
		})
}
// 抛出函数
defineExpose({
	onOpen
})
const plateColorOptions = tool.dictList('车牌颜色')
</script>

<script>
const getBase64 = (file) => {
	return new Promise((resolve, reject) => {
		// FileReader类就是专门用来读文件的
		const reader = new FileReader()
		reader.readAsDataURL(file)
		// 成功和失败返回对应的信息，reader.result一个base64，可以直接使用
		reader.onload = () => resolve(reader.result)
		// 失败返回失败的信息
		reader.onerror = (error) => reject(error)
	})
}
export default {
	data() {
		return {
			previewVisible: false,
			previewImage: '',
		};
	},
	methods: {
		handleCancel() {
			this.previewVisible = false;
		},
		async handlePreview(file) {
			if (!file.url && !file.preview) {
				file.preview = await getBase64(file.originFileObj);
			}
			this.previewImage = file.url || file.preview;
			this.previewVisible = true;
		},
		handleChange({grossPlateNames}) {
			this.grossPlateNames = grossPlateNames;
		},
	},
};
</script>
