<template>
	<a-drawer
		:title="'飞行监管详情'"
		: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-descriptions :column="1" size="middle" bordered class="mb-2">
				<a-descriptions-item label="监管类型">{{ formData.siteType }}</a-descriptions-item>
				<a-descriptions-item label="监管等级">{{ formData.siteLv }}</a-descriptions-item>
				<a-descriptions-item label="监管信息">{{ formData.siteMsg }}</a-descriptions-item>
				<a-descriptions-item label="监管图片">
					<a v-if="formData.sitePicUrl" :href="formData.sitePicUrl" target="_blank">
						<img :src="formData.sitePicUrl" alt="avatar" style="max-height: 100px; max-width: 100px"/></a>
				</a-descriptions-item>
				<a-descriptions-item label="监管时间">{{ formData.createTime }}</a-descriptions-item>
				<a-descriptions-item label="是否异常">{{ formData.alarmFlag }}</a-descriptions-item>
				<a-descriptions-item label="处理确认状态">{{ formData.saveState }}</a-descriptions-item>
				<a-descriptions-item label="处理信息">{{ formData.saveMsg }}</a-descriptions-item>
				<a-descriptions-item label="处理时间">{{ formData.saveTime }}</a-descriptions-item>
				<a-descriptions-item label="处理图片">
					<a v-if="formData.savePicUrl" :href="formData.savePicUrl" target="_blank">
						<img :src="formData.savePicUrl" alt="avatar" style="max-height: 100px; max-width: 100px"/></a>
				</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="depotFlyerSiteLogWarnForm">
import tool from '@/utils/tool'
import {cloneDeep} from 'lodash-es'
import {required} from '@/utils/formRules'
import depotFlyerSiteLogWarnApi from '@/api/biz/depotFlyerSiteLogWarnApi'
import sysConfig from "@/config";
import fileApi from "@/api/dev/fileApi";
// 抽屉状态
const visible = ref(false)
const emit = defineEmits({successful: null})
const formRef = ref()
// 表单数据
const formData = ref({})
const submitLoading = ref(false)

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