<script setup>
	import { message } from 'ant-design-vue'
	import { getById } from '@/api/storageJob/fumigation'

	const props = defineProps({
		visible: {
			type: Boolean,
			required: false,
			default: false
		},
		editData: {
			type: Object,
			required: false,
			default: null
		},
		action: {
			type: String,
			required: false,
			default: null
		}
	})

	const isView = computed(() => props.action === 'view')
	const isAdd = computed(() => props.action === 'add')
	const isEdit = computed(() => props.action === 'edit')
	const isApprove = computed(() => props.action === 'approve')
	const readonly = computed(() => {
		return isView.value || isApprove.value
	})

	const show = ref(props.visible)
	const formData = ref({})
	const getData = () => {
		getById(props.editData.id).then((resp) => {
			formData.value = resp
		})
	}

	watch(
		() => props.visible,
		(n, o) => {
			if (n) {
				getData()
			}
			show.value = n
		}
	)

	const emit = defineEmits(['update:visible', 'on-approve'])

	const close = () => emit('update:visible', false)

	const submitLoading = ref(false)

	const save = () => {
		close()
	}
</script>

<template>
	<xn-form-container title="详细信息" width="80%" v-model:visible="show" :destroy-on-close="true" @close="close">
		<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
			<a-divider>熏蒸作业</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="熏蒸作业库区" name="orgName">
						<a-input :disabled="readonly" v-model:value="formData.orgName" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="熏蒸作业单号" name="orderNumber">
						<a-input :disabled="readonly" v-model:value="formData.orderNumber" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="熏蒸开始时间" name="startTime">
						<a-date-picker
							v-model:value="formData.startTime"
							format="YYYY-MM-DD HH:mm:ss"
							:show-time="true"
							:disabled="readonly"
						/>
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="熏蒸结束时间" name="endTime">
						<a-date-picker
							v-model:value="formData.endTime"
							format="YYYY-MM-DD HH:mm:ss"
							:show-time="true"
							:disabled="readonly"
						/>
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="第几次熏蒸" name="nnumber">
						<a-input :disabled="readonly" v-model:value="formData.nnumber" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="仓房名称" name="storehouseName">
						<a-input :disabled="readonly" v-model:value="formData.storehouseName" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>气密性情况</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="气密性检测时间" name="qmxsj">
						<a-date-picker
							v-model:value="formData.qmxsj"
							format="YYYY-MM-DD HH:mm:ss"
							:show-time="true"
							:disabled="readonly"
						/>
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="检测方式" name="jcfs">
						<a-input :disabled="readonly" v-model:value="formData.jcfs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="检测结果" name="jcjg">
						<a-input :disabled="readonly" v-model:value="formData.jcjg" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="是否达标" name="sfdb">
						<a-input :disabled="readonly" v-model:value="formData.sfdb" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="检测人员" name="jcry">
						<a-input :disabled="readonly" v-model:value="formData.jcry" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>虫害发生情况</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="害虫检测单号" name="chjcdh">
						<a-input :disabled="readonly" v-model:value="formData.chjcdh" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="发生部位" name="fsbw">
						<a-input :disabled="readonly" v-model:value="formData.fsbw" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="虫口密度" name="ckmd">
						<a-input :disabled="readonly" v-model:value="formData.ckmd" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="主要害虫虫种" name="zyhccz">
						<a-input :disabled="readonly" v-model:value="formData.zyhccz" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="害虫抗药性分析" name="hckyxfx">
						<a-input :disabled="readonly" v-model:value="formData.hckyxfx" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>熏蒸设备配置及作业审批</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="常规熏蒸方式" name="cgxzfs">
						<a-input :disabled="readonly" v-model:value="formData.cgxzfs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="环流熏蒸方式" name="hlxzfs">
						<a-input :disabled="readonly" v-model:value="formData.hlxzfs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="环流熏蒸与内环流技术结合" name="hlxzynhljsjh">
						<a-input :disabled="readonly" v-model:value="formData.hlxzynhljsjh" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="熏蒸方案制定" name="xzfazd">
						<a-input :disabled="readonly" v-model:value="formData.xzfazd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="熏蒸方案起草人" name="xzfaqcr">
						<a-input :disabled="readonly" v-model:value="formData.xzfaqcr" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="熏蒸方案批准人" name="xzfapzr">
						<a-input :disabled="readonly" v-model:value="formData.xzfapzr" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="熏蒸方案报备情况" name="xzfabbqk">
						<a-input :disabled="readonly" v-model:value="formData.xzfabbqk" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>药剂使用情况</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="施药人员资质情况" name="syryzzqk">
						<a-input :disabled="readonly" v-model:value="formData.syryzzqk" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="施药资质审核" name="syzzsh">
						<a-input :disabled="readonly" v-model:value="formData.syzzsh" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="药剂名称" name="drugName">
						<a-input :disabled="readonly" v-model:value="formData.drugName" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="剂型" name="jx">
						<a-input :disabled="readonly" v-model:value="formData.jx" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="浓度" name="nd">
						<a-input :disabled="readonly" v-model:value="formData.nd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="粮堆单位用药量" name="dldwyyl">
						<a-input :disabled="readonly" v-model:value="formData.dldwyyl" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="空间单位用药量" name="kjdwyyl">
						<a-input :disabled="readonly" v-model:value="formData.kjdwyyl" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="总用药量" name="zyl">
						<a-input :disabled="readonly" v-model:value="formData.zyl" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="施药方法" name="syff">
						<a-input :disabled="readonly" v-model:value="formData.syff" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="辅助施药措施" name="fzsycs">
						<a-input :disabled="readonly" v-model:value="formData.fzsycs" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>防护器具</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="空气呼吸器及安全检查情况" name="kqhxqjaqjcqk">
						<a-input :disabled="readonly" v-model:value="formData.kqhxqjaqjcqk" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="磷化氢检测装置调试情况" name="lhqjczztsqk">
						<a-input :disabled="readonly" v-model:value="formData.lhqjczztsqk" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="氧气深度检测装置调试情况" name="yqsdjczztsqk">
						<a-input :disabled="readonly" v-model:value="formData.yqsdjczztsqk" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="磷化氢报警仪安全检查" name="lhqbjyaqjc">
						<a-input :disabled="readonly" v-model:value="formData.lhqbjyaqjc" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="氧气报警仪安全检查" name="yqbjyaqjc">
						<a-input :disabled="readonly" v-model:value="formData.yqbjyaqjc" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="周边作业警示设施情况是否正常" name="zbzyjsssqksfzc">
						<a-input :disabled="readonly" v-model:value="formData.zbzyjsssqksfzc" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>散气作业</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="散气前磷化氢浓度" name="sqqlhqnd">
						<a-input :disabled="readonly" v-model:value="formData.sqqlhqnd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="散气日期" name="sqrq">
						<a-date-picker v-model:value="formData.sqrq" format="YYYY-MM-DD" :disabled="readonly" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="散气方法" name="sqfa">
						<a-input :disabled="readonly" v-model:value="formData.sqfa" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="散气持续天数" name="sqcxts">
						<a-input :disabled="readonly" v-model:value="formData.sqcxts" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="散气结束时磷化氢浓度" name="sqjsslhqnd">
						<a-input :disabled="readonly" v-model:value="formData.sqjsslhqnd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="散气批准人" name="sqpzr">
						<a-input :disabled="readonly" v-model:value="formData.sqpzr" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>残渣处理</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="残渣收集作业时间" name="czsjzysj">
						<a-date-picker
							v-model:value="formData.czsjzysj"
							format="YYYY-MM-DD HH:mm:ss"
							:show-time="true"
							:disabled="readonly"
						/>
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="残渣收集作业人数" name="czsjzyrs">
						<a-input :disabled="readonly" v-model:value="formData.czsjzyrs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="残渣收集方法" name="czsjff">
						<a-input :disabled="readonly" v-model:value="formData.czsjff" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="残渣处理措施" name="czclcs">
						<a-input :disabled="readonly" v-model:value="formData.czclcs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="残渣处理作业人数" name="czclzyrs">
						<a-input :disabled="readonly" v-model:value="formData.czclzyrs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="残渣处理批准人" name="czclpzr">
						<a-input :disabled="readonly" v-model:value="formData.czclpzr" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>熏蒸效果评价</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="熏蒸后虫口密度" name="xzhckmd">
						<a-input :disabled="readonly" v-model:value="formData.xzhckmd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="培养15天后活虫数" name="py15Thhcs">
						<a-input :disabled="readonly" v-model:value="formData.py15Thhcs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="培养45天后活虫数" name="py45Thhcs">
						<a-input :disabled="readonly" v-model:value="formData.py45Thhcs" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="熏蒸效果评价" name="xzxgpj">
						<a-input :disabled="readonly" v-model:value="formData.xzxgpj" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="熏蒸负责人" name="xzfzr">
						<a-input :disabled="readonly" v-model:value="formData.xzfzr" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="熏蒸作业人员" name="xzzyrr">
						<a-input :disabled="readonly" v-model:value="formData.xzzyrr" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-divider>补药情况</a-divider>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="补药前仓内磷化氢浓度" name="byqcnlhqnd">
						<a-input :disabled="readonly" v-model:value="formData.byqcnlhqnd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="磷化氢浓度单位" name="lhqnddw">
						<a-input :disabled="readonly" v-model:value="formData.lhqnddw" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="目标浓度" name="mbnd">
						<a-input :disabled="readonly" v-model:value="formData.mbnd" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="计算补药量" name="jsbyl">
						<a-input :disabled="readonly" v-model:value="formData.jsbyl" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="实际补药量" name="sjbyl">
						<a-input :disabled="readonly" v-model:value="formData.sjbyl" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="补药方法" name="byfa">
						<a-input :disabled="readonly" v-model:value="formData.byfa" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="作业人数" name="zyrs">
						<a-input :disabled="readonly" v-model:value="formData.zyrs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="补药作业批准人" name="byzypzr">
						<a-input :disabled="readonly" v-model:value="formData.byzypzr" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="现场指挥人" name="xczhr">
						<a-input :disabled="readonly" v-model:value="formData.xczhr" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="峰值浓度" name="fznd">
						<a-input :disabled="readonly" v-model:value="formData.fznd" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="目标浓度维持天数" name="mbndwcts">
						<a-input :disabled="readonly" v-model:value="formData.mbndwcts" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="漏气位置监测" name="lqwzjc">
						<a-input :disabled="readonly" v-model:value="formData.lqwzjc" />
					</a-form-item>
				</a-col>
			</a-row>

			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="漏气部位采取的补救措施" name="lqbwcqdbjcs">
						<a-input :disabled="readonly" v-model:value="formData.lqbwcqdbjcs" />
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="密闭时间" name="mbsj">
						<a-date-picker
							v-model:value="formData.mbsj"
							format="YYYY-MM-DD HH:mm:ss"
							:show-time="true"
							:disabled="readonly"
						/>
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-form-item label="CT值" name="ctValue">
						<a-input :disabled="readonly" v-model:value="formData.ctValue" />
					</a-form-item>
				</a-col>
			</a-row>
		</a-form>
		<template #footer>
			<a-button style="margin-right: 8px" @click="close">关闭</a-button>
			<a-button v-if="!readonly" style="margin-right: 8px" type="primary" @click="save" :loading="submitLoading">
				保存
			</a-button>
		</template>
	</xn-form-container>
</template>

<style scoped></style>
