<template>
  <Dialog :title="dialogTitle" v-model="dialogVisible">
    <el-descriptions title="" border :column="1">
      <el-descriptions-item label="用户id">{{ info?.userId || '-' }}</el-descriptions-item>
      <el-descriptions-item label="所属企业id">{{ info?.enterpriseId || '-' }}</el-descriptions-item>
      <el-descriptions-item label="认证人姓名">{{ info?.name || '-' }}</el-descriptions-item>
      <el-descriptions-item label="状态">
        <dict-tag :type="DICT_TYPE.MENDUNER_ENTERPRISE_AUTH_STATUS" :value="info?.status" />
      </el-descriptions-item>
      <el-descriptions-item label="人像照">
        <el-image style="width: 80px; height: 80px" :src="info?.frontUrl || ''"  :preview-src-list="[info?.frontUrl, info?.backUrl]"/>
      </el-descriptions-item>
      <el-descriptions-item label="国徽照">
        <el-image style="width: 80px; height: 80px" :src="info?.backUrl || ''" :preview-src-list="[info?.frontUrl, info?.backUrl]" />
      </el-descriptions-item>
      <el-descriptions-item label="审核原因">{{ info?.reason || '-' }}</el-descriptions-item>
    </el-descriptions>
    <template #footer>
      <el-button @click="dialogVisible = false">取 消</el-button>
    </template>
  </Dialog>
</template>

<script setup lang="ts">
import { EnterpriseAuthApi } from '@/api/menduner/system/enterprise/auth'
import { DICT_TYPE } from '@/utils/dict'

defineOptions({ name: 'EnterpriseAuthDetails' })
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('认证信息') // 弹窗的标题
const emit = defineEmits(['success']) // 定义 success 事件，用于操作成功后的回调

/** 打开弹窗 */
const open = async (id: Number) => {
  dialogVisible.value = true
  getData(id)
}

const info = ref({})
const getData = async (id) => {
  if (!id) return
  const data = await EnterpriseAuthApi.getEnterpriseAuth(id)
  info.value = data
}


defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>