<template>
  <el-dialog title="中介黑名单详情" :visible.sync="visible" width="800px" append-to-body>
    <el-descriptions :column="2" border>
      <!-- 核心字段 -->
      <el-descriptions-item label="中介类型">
        <span v-if="detailData.intermediaryType === '1'">个人</span>
        <span v-else-if="detailData.intermediaryType === '2'">实体</span>
        <span v-else>-</span>
      </el-descriptions-item>
      <el-descriptions-item label="姓名/机构名称">{{ detailData.name || detailData.enterpriseName || '-' }}</el-descriptions-item>
      <el-descriptions-item label="证件号/信用代码">
        <span v-if="detailData.intermediaryType === '1'">{{ detailData.personId || '-' }}</span>
        <span v-else>{{ detailData.socialCreditCode || '-' }}</span>
      </el-descriptions-item>

      <!-- 个人类型专属字段 -->
      <template v-if="detailData.intermediaryType === '1'">
        <el-descriptions-item label="人员类型">{{ detailData.personType || '-' }}</el-descriptions-item>
        <el-descriptions-item label="人员子类型">{{ detailData.personSubType || '-' }}</el-descriptions-item>
        <el-descriptions-item label="性别">
          <span v-if="detailData.gender === 'M'">男</span>
          <span v-else-if="detailData.gender === 'F'">女</span>
          <span v-else-if="detailData.gender === 'O'">其他</span>
          <span v-else>{{ detailData.gender || '-' }}</span>
        </el-descriptions-item>
        <el-descriptions-item label="证件类型">{{ detailData.idType || '-' }}</el-descriptions-item>
        <el-descriptions-item label="手机号码">{{ detailData.mobile || '-' }}</el-descriptions-item>
        <el-descriptions-item label="微信号">{{ detailData.wechatNo || '-' }}</el-descriptions-item>
        <el-descriptions-item label="联系地址" :span="2">{{ detailData.contactAddress || '-' }}</el-descriptions-item>
        <el-descriptions-item label="所在公司">{{ detailData.company || '-' }}</el-descriptions-item>
        <el-descriptions-item label="职位">{{ detailData.position || '-' }}</el-descriptions-item>
        <el-descriptions-item label="企业统一信用码">{{ detailData.socialCreditCode || '-' }}</el-descriptions-item>
        <el-descriptions-item label="关系类型">{{ detailData.relationType || '-' }}</el-descriptions-item>
        <el-descriptions-item label="关联人员ID">{{ detailData.relatedNumId || '-' }}</el-descriptions-item>
      </template>

      <!-- 机构类型专属字段 -->
      <template v-if="detailData.intermediaryType === '2'">
        <el-descriptions-item label="统一社会信用代码" :span="2">{{ detailData.socialCreditCode || '-' }}</el-descriptions-item>
        <el-descriptions-item label="主体类型">{{ detailData.enterpriseType || '-' }}</el-descriptions-item>
        <el-descriptions-item label="企业性质">{{ detailData.enterpriseNature || '-' }}</el-descriptions-item>
        <el-descriptions-item label="行业分类">{{ detailData.industryClass || '-' }}</el-descriptions-item>
        <el-descriptions-item label="所属行业">{{ detailData.industryName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="成立日期">{{ detailData.establishDate || '-' }}</el-descriptions-item>
        <el-descriptions-item label="注册地址" :span="2">{{ detailData.registerAddress || '-' }}</el-descriptions-item>
        <el-descriptions-item label="法定代表人">{{ detailData.legalRepresentative || '-' }}</el-descriptions-item>
        <el-descriptions-item label="法定代表人证件类型">{{ detailData.legalCertType || '-' }}</el-descriptions-item>
        <el-descriptions-item label="法定代表人证件号码" :span="2">{{ detailData.legalCertNo || '-' }}</el-descriptions-item>
        <el-descriptions-item label="股东1">{{ detailData.shareholder1 || '-' }}</el-descriptions-item>
        <el-descriptions-item label="股东2">{{ detailData.shareholder2 || '-' }}</el-descriptions-item>
        <el-descriptions-item label="股东3">{{ detailData.shareholder3 || '-' }}</el-descriptions-item>
        <el-descriptions-item label="股东4">{{ detailData.shareholder4 || '-' }}</el-descriptions-item>
        <el-descriptions-item label="股东5">{{ detailData.shareholder5 || '-' }}</el-descriptions-item>
      </template>

      <!-- 通用字段 -->
      <el-descriptions-item label="数据来源">
        <span v-if="detailData.dataSource === 'MANUAL'">手动录入</span>
        <span v-else-if="detailData.dataSource === 'SYSTEM'">系统同步</span>
        <span v-else-if="detailData.dataSource === 'IMPORT'">批量导入</span>
        <span v-else-if="detailData.dataSource === 'API'">接口获取</span>
        <span v-else>{{ detailData.dataSource || '-' }}</span>
      </el-descriptions-item>
      <el-descriptions-item label="备注" :span="2">{{ detailData.remark || '-' }}</el-descriptions-item>
      <el-descriptions-item label="创建时间">{{ detailData.createTime || '-' }}</el-descriptions-item>
    </el-descriptions>
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "DetailDialog",
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    detailData: {
      type: Object,
      default: () => ({})
    }
  },
  watch: {
    visible(val) {
      this.$emit("update:visible", val);
    }
  }
};
</script>
