<template>
	<el-dialog v-model="state.dialogVisible" draggable title="二次办理明细" width="40%" append-to-body destroy-on-close @close="close">
		<div class="collapse-container" v-loading="state.loading">
			<el-form ref="ruleFormRef" label-width="80px" :model="state.ruleForm" class="show-info-form">
				<el-row :gutter="35">
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="办理人"> {{ state.ruleForm?.auditUser }} </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
            <el-form-item label="办理时间"> {{ formatDate(state.ruleForm?.auditTime, '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="办理理由" class="formatted-text">
							{{state.ruleForm.content}}
            </el-form-item>
					</el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
            <el-form-item label="附件">
              <annex-list name="附件列表" readonly :businessId="state.ruleForm.id" classify="查看附件" v-model="state.ruleForm.files" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" v-if="state.ruleForm?.auditContent">
            <el-form-item label="审批意见" class="formatted-text">
							{{state.ruleForm.auditContent}}
            </el-form-item>
          </el-col>
					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" v-if="state.ruleForm?.sendBackContent">
						<el-form-item label="退回意见" class="formatted-text">
							{{state.ruleForm.sendBackContent}}
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
		</div>
		<template #footer>
			<span class="dialog-footer">
				<el-button @click="closeDialog" class="default-button">关 闭</el-button>
			</span>
		</template>
	</el-dialog>
</template>
<script setup lang="ts">
import { defineAsyncComponent, reactive, ref } from 'vue';
import { secondHandleDetail } from "@/api/business/secondHandle";
import { formatDate } from "@/utils/formatTime";
import { transformFile } from "@/utils/tools";

// 引入组件
const AnnexList = defineAsyncComponent(() => import('@/components/AnnexList/index.vue'));

// 定义子组件向父组件传值/事件
const emit = defineEmits(['updateList']);
// 定义变量内容
const state = reactive<any>({
	dialogVisible: false, // 是否显示弹窗
	loading: false, // 是否显示加载
	ruleForm: {

	},
});
const ruleFormRef = ref<RefType>();
const ids = ref<any>([]);
// 打开弹窗
const openDialog = async (id: string) => {
  secondHandleDetail(id)
    .then((res: any) => {
      state.ruleForm = res.result;
      state.ruleForm.files = transformFile(res.result.files);
      state.dialogVisible = true;
    })
    .catch((err: any) => {});
};
// 关闭弹窗
const closeDialog = () => {
	state.dialogVisible = false;
};
const close = () => {
	ruleFormRef.value?.clearValidate();
};

defineExpose({
	openDialog,
	closeDialog,
});
</script>
