<template>
	<el-dialog v-model="state.dialogVisible" draggable title="退回审批详情" width="50%" append-to-body destroy-on-close>
		<div class="collapse-container">
			<el-form label-width="110px" :model="state.ruleForm" class="show-info-form">
				<el-row :gutter="35">
					<el-divider content-position="left">
						<el-text tag="b" size="large"> 退回详情 </el-text>
					</el-divider>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
						<el-form-item label="工单编码"> {{ state.detail.order?.no }} </el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
						<el-form-item label="工单标题"> {{ state.detail.order?.title }} </el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
						<el-form-item label="申请人"> {{ state.detail.creatorName }} </el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
						<el-form-item label="申请部门"> {{ state.detail.creatorOrgName }} </el-form-item>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
						<el-form-item label="申请时间"> {{ formatDate(state.detail?.creationTime, 'YYYY-mm-dd HH:MM:SS') }} </el-form-item>
					</el-col>
					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
						<el-form-item label="申请理由"> {{ state.detail.content }} </el-form-item>
					</el-col>
					<el-divider content-position="left">
						<el-text tag="b" size="large"> 审批详情 </el-text>
					</el-divider>
					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
						<el-form-item label="审批结果">
							{{ state.detail.state === 1 ? '审批通过' : '审批拒绝' }}
						</el-form-item>
					</el-col>
					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
						<el-form-item label="审批意见" prop="auditContent">
							{{ state.detail.auditContent }}
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
		</div>
	</el-dialog>
</template>
<script setup lang="ts" name="returnAuditDetailDialog">
import { reactive } from 'vue';
import { formatDate } from '@/utils/formatTime';
import { returnAuditDetail } from '@/api/business/return';

// 定义子组件向父组件传值/事件
const emit = defineEmits(['updateList']);
// 定义变量内容
const state = reactive<any>({
	dialogVisible: false, // 是否显示弹窗
	loading: false, // 是否显示加载
	detail: {}, // 详情信息
});
// 打开弹窗
const openDialog = async (val: any) => {
	state.loading = true;
	state.dialogVisible = true;
	try {
		const { result } = await returnAuditDetail(val.id);
		state.detail = result;
	} catch (e) {
		console.log(e);
	} finally {
		state.loading = false;
	}
};
// 关闭弹窗
const closeDialog = () => {
	state.dialogVisible = false;
};
defineExpose({
	openDialog,
	closeDialog,
});
</script>
