<template>
    <a-drawer
        :title="formData.id ? '编辑过磅记录图片表' : '增加过磅记录图片表'"
        :width="600"
        :visible="visible"
        :destroy-on-close="true"
        :footer-style="{ textAlign: 'right' }"
        @close="onClose"
    >
        <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
            <a-form-item label="企业客户：" name="depotId">
                <a-select v-model:value="formData.depotId" placeholder="请选择项目编码" :options="depotIdOptions" />
            </a-form-item>
            <a-form-item label="车辆预约ID：" name="truckBookId">
                <a-input v-model:value="formData.truckBookId" placeholder="请输入车辆预约ID" allow-clear />
            </a-form-item>
            <a-form-item label="过毛车牌图片：" name="grossPlateName">
                <a-input v-model:value="formData.grossPlateName" placeholder="请输入过毛车牌图片" allow-clear />
            </a-form-item>
            <a-form-item label="过毛车图片：" name="grossLicenseName">
                <a-input v-model:value="formData.grossLicenseName" placeholder="请输入过毛车图片" allow-clear />
            </a-form-item>
            <a-form-item label="过毛车头相机抓拍：" name="grossCaptureHead">
                <a-input v-model:value="formData.grossCaptureHead" placeholder="请输入过毛车头相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过毛车尾相机抓拍：" name="grossCaptureTail">
                <a-input v-model:value="formData.grossCaptureTail" placeholder="请输入过毛车尾相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过毛车仓相机抓拍：" name="grossCaptureWare">
                <a-input v-model:value="formData.grossCaptureWare" placeholder="请输入过毛车仓相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过毛车身相机抓拍：" name="grossCaptureBody">
                <a-input v-model:value="formData.grossCaptureBody" placeholder="请输入过毛车身相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过毛磅房相机抓拍：" name="grossCapturePoundRoom">
                <a-input v-model:value="formData.grossCapturePoundRoom" placeholder="请输入过毛磅房相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过皮车牌图片：" name="tarePlateName">
                <a-input v-model:value="formData.tarePlateName" placeholder="请输入过皮车牌图片" allow-clear />
            </a-form-item>
            <a-form-item label="过皮车图片：" name="tareLicenseName">
                <a-input v-model:value="formData.tareLicenseName" placeholder="请输入过皮车图片" allow-clear />
            </a-form-item>
            <a-form-item label="过皮车头相机抓拍：" name="tareCaptureHead">
                <a-input v-model:value="formData.tareCaptureHead" placeholder="请输入过皮车头相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过皮车尾相机抓拍：" name="tareCaptureTail">
                <a-input v-model:value="formData.tareCaptureTail" placeholder="请输入过皮车尾相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过皮车仓相机抓拍：" name="tareCaptureWare">
                <a-input v-model:value="formData.tareCaptureWare" placeholder="请输入过皮车仓相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过皮车身相机抓拍：" name="tareCaptureBody">
                <a-input v-model:value="formData.tareCaptureBody" placeholder="请输入过皮车身相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="过皮磅房相机抓拍：" name="tareCapturePoundRoom">
                <a-input v-model:value="formData.tareCapturePoundRoom" placeholder="请输入过皮磅房相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="高拍仪图片：" name="metronome">
                <a-input v-model:value="formData.metronome" placeholder="请输入高拍仪图片" allow-clear />
            </a-form-item>
            <a-form-item label="云端识别图片推送状态（字典 1：未上传、2：已上传）：" name="cloudGrossCameraFlag">
                <a-input v-model:value="formData.cloudGrossCameraFlag" placeholder="请输入云端识别图片推送状态（字典 1：未上传、2：已上传）" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛车牌图片：" name="cloudGrossPlateName">
                <a-input v-model:value="formData.cloudGrossPlateName" placeholder="请输入云端过毛车牌图片" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛车图片：" name="cloudGrossLicenseName">
                <a-input v-model:value="formData.cloudGrossLicenseName" placeholder="请输入云端过毛车图片" allow-clear />
            </a-form-item>
            <a-form-item label="云端抓拍图片推送状态（字典 1：未上传、2：已上传）：" name="cloudGrossCaptureFlag">
                <a-input v-model:value="formData.cloudGrossCaptureFlag" placeholder="请输入云端抓拍图片推送状态（字典 1：未上传、2：已上传）" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛车头相机抓拍：" name="cloudGrossCaptureHead">
                <a-input v-model:value="formData.cloudGrossCaptureHead" placeholder="请输入云端过毛车头相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛车尾相机抓拍：" name="cloudGrossCaptureTail">
                <a-input v-model:value="formData.cloudGrossCaptureTail" placeholder="请输入云端过毛车尾相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛车仓相机抓拍：" name="cloudGrossCaptureWare">
                <a-input v-model:value="formData.cloudGrossCaptureWare" placeholder="请输入云端过毛车仓相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛车身相机抓拍：" name="cloudGrossCaptureBody">
                <a-input v-model:value="formData.cloudGrossCaptureBody" placeholder="请输入云端过毛车身相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过毛磅房相机抓拍：" name="cloudGrossCapturePoundRoom">
                <a-input v-model:value="formData.cloudGrossCapturePoundRoom" placeholder="请输入云端过毛磅房相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端识别图片推送状态（字典 1：未上传、2：已上传）：" name="cloudTareCameraFlag">
                <a-input v-model:value="formData.cloudTareCameraFlag" placeholder="请输入云端识别图片推送状态（字典 1：未上传、2：已上传）" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮车牌图片：" name="cloudTarePlateName">
                <a-input v-model:value="formData.cloudTarePlateName" placeholder="请输入云端过皮车牌图片" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮车图片：" name="cloudTareLicenseName">
                <a-input v-model:value="formData.cloudTareLicenseName" placeholder="请输入云端过皮车图片" allow-clear />
            </a-form-item>
            <a-form-item label="云端抓拍图片推送状态（字典 1：未上传、2：已上传）：" name="cloudTareCaptureFlag">
                <a-input v-model:value="formData.cloudTareCaptureFlag" placeholder="请输入云端抓拍图片推送状态（字典 1：未上传、2：已上传）" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮车头相机抓拍：" name="cloudTareCaptureHead">
                <a-input v-model:value="formData.cloudTareCaptureHead" placeholder="请输入云端过皮车头相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮车尾相机抓拍：" name="cloudTareCaptureTail">
                <a-input v-model:value="formData.cloudTareCaptureTail" placeholder="请输入云端过皮车尾相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮车仓相机抓拍：" name="cloudTareCaptureWare">
                <a-input v-model:value="formData.cloudTareCaptureWare" placeholder="请输入云端过皮车仓相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮车身相机抓拍：" name="cloudTareCaptureBody">
                <a-input v-model:value="formData.cloudTareCaptureBody" placeholder="请输入云端过皮车身相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端过皮磅房相机抓拍：" name="cloudTareCapturePoundRoom">
                <a-input v-model:value="formData.cloudTareCapturePoundRoom" placeholder="请输入云端过皮磅房相机抓拍" allow-clear />
            </a-form-item>
            <a-form-item label="云端高拍仪图片推送状态（字典 1：未上传、2：已上传）：" name="cloudMetronomeFlag">
                <a-input v-model:value="formData.cloudMetronomeFlag" placeholder="请输入云端高拍仪图片推送状态（字典 1：未上传、2：已上传）" allow-clear />
            </a-form-item>
            <a-form-item label="云端高拍仪图片：" name="cloudMetronome">
                <a-input v-model:value="formData.cloudMetronome" placeholder="请输入云端高拍仪图片" allow-clear />
            </a-form-item>
        </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="depotTruckWeighDoublePicForm">
    import tool from '@/utils/tool'
    import { cloneDeep } from 'lodash-es'
    import { required } from '@/utils/formRules'
    import depotTruckWeighDoublePicApi from '@/api/biz/depotTruckWeighDoublePicApi'
    // 抽屉状态
    const visible = ref(false)
    const emit = defineEmits({ successful: null })
    const formRef = ref()
    // 表单数据
    const formData = ref({})
    const submitLoading = ref(false)
    const depotIdOptions = ref([])

    // 打开抽屉
    const onOpen = (record) => {
        visible.value = true
        if (record) {
            let recordData = cloneDeep(record)
            formData.value = Object.assign({}, recordData)
        }
        depotIdOptions.value = tool.dictList('depotId')
    }
    // 关闭抽屉
    const onClose = () => {
        formRef.value.resetFields()
        formData.value = {}
        visible.value = false
    }
    // 默认要校验的
    const formRules = {
    }
    // 验证并提交数据
    const onSubmit = () => {
        formRef.value
            .validate()
            .then(() => {
                submitLoading.value = true
                const formDataParam = cloneDeep(formData.value)
                depotTruckWeighDoublePicApi
                    .depotTruckWeighDoublePicSubmitForm(formDataParam, !formDataParam.id)
                    .then(() => {
                        onClose()
                        emit('successful')
                    })
                    .finally(() => {
                        submitLoading.value = false
                    })
            })
    }
    // 抛出函数
    defineExpose({
        onOpen
    })
</script>
