<template>
  <div>
    <a-row :gutter="20">
      <!-- 基本信息 -->
      <a-col :span="6">
        <div><span class="label">出生日期:</span> {{ dayjs(formData.birthDate).format('YYYY-MM-DD') || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">所属站点:</span> {{ formData.stationName || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">关爱巡访电话:</span> {{ formData.careVisitPhone || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">联系方式:</span> {{ formData.contact1 || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">其他电话1:</span> {{ formData.otherPhone1 || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">其他电话2:</span> {{ formData.otherPhone2 || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">社保卡号:</span> {{ formData.socialSecurityCardNumber || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">证件类型:</span> {{ dicsStore.getDictLabel('CARD_TYPE', formData.identityType) || '-' }}
        </div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">证件号码:</span> {{ formData.identityNo || '-' }}</div>
      </a-col>


      <a-col :span="6">
        <div><span class="label">护理等级:</span> {{ dicsStore.getDictLabel('Care_Level', formData.archive.nursingLevel) ||
          '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">健康状况:</span> {{ dicsStore.getDictLabel('Health_Condition',
          formData.archive.healthStatus) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">生存状态:</span> {{ dicsStore.getDictLabel('LIVING_STATUS',
          formData.archive.survivalStatus) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">服务状态:</span> {{ dicsStore.getDictLabel('SERVICE_STATUS',
          formData.archive.serviceStatus) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">服务形式:</span> {{ dicsStore.getDictLabel('Service_Format', formData.archive.serviceForm)
          || '-' }}</div>
      </a-col>

      <!-- 其他字段 -->
      <a-col :span="6">
        <div><span class="label">居住情况:</span> {{ dicsStore.getDictLabel('Living_Situation',
          formData.archive.livingSituation) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">子女情况:</span> {{ dicsStore.getDictLabel('CHILDREN_STATE',
          formData.archive.childrenSituation) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">统计分类:</span> {{ dicsStore.getDictLabel('Statistical_Classification',
          formData.archive.statisticsCategory) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">智力情况:</span> {{ dicsStore.getDictLabel('Intellectual_Condition',
          formData.archive.intellectualSituation) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">长期照料失能子女:</span> {{ dicsStore.getDictLabel('Disabled_Child',
          formData.archive.longTermCareForDisabledChildren) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">子女探望情况:</span> {{ dicsStore.getDictLabel('Frequency_Visits',
          formData.archive.childrenVisitStatus) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">人户分离:</span> {{ dicsStore.getDictLabel('Separation',
          formData.archive.householdResidenceSeparation) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">民族:</span> {{ dicsStore.getDictLabel('Ethnicity', formData.archive.ethnicity) || '-' }}
        </div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">完成能力评估:</span> {{ dicsStore.getDictLabel('Capability_Assessment',
          formData.archive.completedCapacityAssessment) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">住出租屋/地下室:</span> {{ dicsStore.getDictLabel('Property_Basement',
          formData.archive.livesInRentedRoomOrBasement) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">经济来源:</span> {{ dicsStore.getDictLabel('Source_Income',
          formData.archive.economicSource) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">文化程度:</span> {{ dicsStore.getDictLabel('Level_Education',
          formData.archive.educationLevel) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">宗教信仰:</span> {{ dicsStore.getDictLabel('Religious_belief', formData.archive.religion)
          || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">职业情况:</span> {{ dicsStore.getDictLabel('Employment_Status',
          formData.archive.occupation) || '-' }}</div>
      </a-col>
      <a-col :span="6">
        <div><span class="label">政治面貌:</span> {{ dicsStore.getDictLabel('Political_affiliation',
          formData.archive.politicalAffiliation) || '-' }}</div>
      </a-col>

      <a-col :span="6">
        <div><span class="label">婚姻情况:</span> {{ dicsStore.getDictLabel('Marital_Status',
          formData.archive.maritalStatus) || '-' }}</div>
      </a-col>
      <!-- 政府购买服务时间 -->
      <a-col :span="12">
        <div>
          <span class="label">政府购买服务时间:</span>
          {{ formatDate(formData.archive.starGovernmentService) }}- {{ formatDate(formData.archive.endGovernmentService)
          }}
        </div>
      </a-col>
      <a-col :span="24">
        <div>
          <span class="label">家庭地址:</span>
          {{ formatArea(formData.archive.homeAreaLabels) }} {{ formData.archive.homeDetailAddress || '' }}
          <span v-if="formData.lag && formData.lat" style="color: #999;">
            (经度: {{ formData.lag }}, 纬度: {{ formData.lat }})
          </span>
        </div>
      </a-col>
      <a-col :span="24">
        <div>
          <span class="label">户籍地址:</span>
          {{ formatArea(formData.archive.houseAreaLabels) }} {{ formData.archive.householdDetailAddress || '' }}
        </div>
      </a-col>
    </a-row>
  </div>
</template>

<script setup>
import { ref, defineProps, defineExpose } from 'vue';
import dayjs from 'dayjs'
import { useDicsStore } from '@/store'
const dicsStore = useDicsStore()
const props = defineProps({
  formData: {
    type: Object,
    default: () => ({})
  }
});


// 格式化地址数组
const formatArea = (areaArray) => {
  if (!areaArray || !Array.isArray(areaArray)) return '-';
  return areaArray.filter(item => item).join(' / ');
};

// 格式化时间
const formatDate = (date) => {
  if (!date) return '-';
  return new Date(date).toLocaleDateString();
};

// 打开文件链接
const openFile = (url) => {
  window.open(url, '_blank');
};
</script>
<style scoped>
.customer-detail {
  padding: 20px;
  font-size: 14px;
  color: #333;
}

.field-item {
  margin-bottom: 12px;
  line-height: 1.6;
}

.label {
  display: inline-block;
  line-height: 45px;
}

.cursor-pointer {
  cursor: pointer;
}

:deep(.el-tag) {
  cursor: pointer;
}
</style>
