<template>
  <div class="tab-content">
    <div class="info-section">
      <div class="section-title-row">
        <div class="section-title-left">
          <span class="section-title-text">基本资质</span>
        </div>
      </div>

      <!-- 资质信息列表 -->

      <el-table :data="qualificationList" border style="width: 100%">
        <el-table-column prop="qualificationName" label="资质名称" align="center" />

        <el-table-column prop="qualificationLevel" label="资质级别" align="center" />

        <el-table-column prop="certificateNo" label="证件编号" align="center" />

        <el-table-column prop="issuingAuthority" label="发证机构" align="center" />

        <el-table-column label="资质到期日" align="center">
          <template #default="scope">
            <span v-if="scope.row.isLongValid == 1"> {{ formatDate(scope.row.endDate) }} 长期有效 </span>

            <span v-else>{{ formatDate(scope.row.endDate) }}</span>
          </template>
        </el-table-column>

        <el-table-column label="资质文件" align="center" min-width="300">
          <template #default="scope">
            <el-button v-if="scope.row.attachmentUrl" link type="primary" @click="emit('downloadQualification', scope.row)">
              {{ scope.row.attachmentName || '下载文件' }}
            </el-button>

            <span v-else>-</span>
          </template>
        </el-table-column>

        <!-- <el-table-column label="操作" align="center" width="200" fixed="right">
          <template #default="scope">
            <el-button link type="primary" @click="emit('viewQualification', scope.row)">查看</el-button>
          </template>
        </el-table-column> -->
      </el-table>

      <!-- 空状态 -->

      <!-- <div v-if="qualificationList.length === 0" class="empty-state">暂无资质信息</div> -->
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps<{
  qualificationList: any[];
  isViewMode: boolean;
}>();

/** 格式化日期 */

const formatDate = (dateStr: string) => {
  if (!dateStr) return '';

  // 去掉时分秒，只保留日期部分

  return dateStr.split(' ')[0];
};

const emit = defineEmits<{
  (e: 'downloadQualification', row: any): void;
  (e: 'viewQualification', row: any): void;
  (e: 'delete', row: any): void;
}>();
</script>
