<template>
  <div class="px-4 pb-4">
    <div class="grid grid-cols-[max-content_1fr] gap-x-2 gap-y-3">
      <!-- 经办法院/执行法院 -->
      <span class="text-base text-[#666666]">{{ isSpecialCase ? '执行法院' : '经办法院' }}：</span>
      <span class="text-base font-medium text-[#333333]">{{ caseData.n_jbfy || caseData.executiveCourt || "—" }}</span>

      <!-- 所属地域 -->
      <span class="text-base text-[#666666]">所属地域：</span>
      <span class="text-base font-medium text-[#333333]">{{ caseData.c_ssdy || caseData.province || "—" }}</span>

      <!-- 案件类型 -->
      <template v-if="caseData.n_ajlx">
        <span class="text-base text-[#666666]">案件类型：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_ajlx || "—" }}</span>
      </template>

      <!-- 案号 -->
      <template v-if="caseData.c_ah">
        <span class="text-base text-[#666666]">案号：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_ah || "—" }}</span>
      </template>

      <!-- 原审案号 -->
      <template v-if="caseData.c_ah_ys">
        <span class="text-base text-[#666666]">原审案号：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_ah_ys || "—" }}</span>
      </template>

      <!-- 后续案号 -->
      <template v-if="caseData.c_ah_hx">
        <span class="text-base text-[#666666]">后续案号：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_ah_hx || "—" }}</span>
      </template>

      <!-- 立案时间 -->
      <template v-if="caseData.d_larq || caseData.fileDate || caseData.larq">
        <span class="text-base text-[#666666]">立案时间：</span>
        <span class="text-base font-medium text-[#333333]">{{ formatDate(caseData.d_larq || caseData.fileDate || caseData.larq) }}</span>
      </template>

      <!-- 立案案由 -->
      <template v-if="caseData.n_laay_tree || caseData.n_laay">
        <span class="text-base text-[#666666]">立案案由：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_laay_tree || caseData.n_laay || "暂无" }}</span>
      </template>

      <!-- 立案案由标签 -->
      <template v-if="caseData.n_laay_tag">
        <span class="text-base text-[#666666]">立案案由标签：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_laay_tag || "—" }}</span>
      </template>

      <!-- 当事人信息 -->
      <template v-if="caseData.c_dsrxx && caseData.c_dsrxx.length > 0">
        <span class="text-base text-[#666666]">当事人信息：</span>
        <span class="text-base font-medium text-[#333333]">
          <span v-for="(party, partyIndex) in caseData.c_dsrxx" :key="partyIndex">
            {{ party.n_ssdw || "其他" }}: {{ party.c_mc }}<span v-if="partyIndex < caseData.c_dsrxx.length - 1">; </span>
          </span>
        </span>
      </template>

      <!-- 失信被执行人特有字段 -->
      <template v-if="caseType === 'breachCase'">
        <!-- 案号 -->
        <template v-if="caseData.caseNumber">
          <span class="text-base text-[#666666]">案号：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.caseNumber || "—" }}</span>
        </template>

        <!-- 发布日期 -->
        <template v-if="caseData.issueDate">
          <span class="text-base text-[#666666]">发布日期：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatDate(caseData.issueDate) }}</span>
        </template>

        <!-- 性别 -->
        <template v-if="caseData.sex">
          <span class="text-base text-[#666666]">性别：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.sex || "—" }}</span>
        </template>

        <!-- 履行情况 -->
        <template v-if="caseData.fulfillStatus">
          <span class="text-base text-[#666666]">履行情况：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.fulfillStatus || "—" }}</span>
        </template>

        <!-- 判决金额估计 -->
        <template v-if="caseData.estimatedJudgementAmount">
          <span class="text-base text-[#666666]">判决金额估计：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.estimatedJudgementAmount) || "—" }}</span>
        </template>

        <!-- 失信被执行人行为具体情形 -->
        <template v-if="caseData.concreteDetails">
          <span class="text-base text-[#666666]">行为具体情形：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.concreteDetails || "—" }}</span>
        </template>

        <!-- 生效法律文书确定的义务 -->
        <template v-if="caseData.obligation">
          <span class="text-base text-[#666666]">生效法律文书确定的义务：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.obligation || "—" }}</span>
        </template>

        <!-- 执行依据单位 -->
        <template v-if="caseData.enforcementBasisOrganization">
          <span class="text-base text-[#666666]">执行依据单位：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.enforcementBasisOrganization || "—" }}</span>
        </template>

        <!-- 执行依据文号 -->
        <template v-if="caseData.enforcementBasisNumber">
          <span class="text-base text-[#666666]">执行依据文号：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.enforcementBasisNumber || "—" }}</span>
        </template>
      </template>

      <!-- 限制消费被执行人特有字段 -->
      <template v-if="caseType === 'consumptionRestriction'">
        <!-- 案件编号 -->
        <template v-if="caseData.caseNumber">
          <span class="text-base text-[#666666]">案件编号：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.caseNumber || "—" }}</span>
        </template>

        <!-- 发布日期 -->
        <template v-if="caseData.issueDate">
          <span class="text-base text-[#666666]">发布日期：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatDate(caseData.issueDate) }}</span>
        </template>

        <!-- 立案时间 -->
        <template v-if="caseData.fileDate">
          <span class="text-base text-[#666666]">立案时间：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatDate(caseData.fileDate) }}</span>
        </template>
      </template>

      <!-- 刑事案件特有字段 -->
      <template v-if="caseType === 'criminal'">
        <!-- 定罪罪名 -->
        <template v-if="caseData.n_dzzm">
          <span class="text-base text-[#666666]">定罪罪名：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.n_dzzm || "—" }}</span>
        </template>

        <!-- 定罪罪名详细 -->
        <template v-if="caseData.n_dzzm_tree">
          <span class="text-base text-[#666666]">定罪罪名详细：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.n_dzzm_tree || "—" }}</span>
        </template>

        <!-- 判处结果 -->
        <template v-if="caseData.n_pcjg">
          <span class="text-base text-[#666666]">判处结果：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.n_pcjg || "—" }}</span>
        </template>

        <!-- 犯罪金额 -->
        <template v-if="caseData.n_fzje">
          <span class="text-base text-[#666666]">犯罪金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_fzje) || "—" }}</span>
        </template>

        <!-- 被请求赔偿金额 -->
        <template v-if="caseData.n_bqqpcje">
          <span class="text-base text-[#666666]">被请求赔偿金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_bqqpcje) || "—" }}</span>
        </template>

        <!-- 财产刑执行金额 -->
        <template v-if="caseData.n_ccxzxje">
          <span class="text-base text-[#666666]">财产刑执行金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_ccxzxje) || "—" }}</span>
        </template>

        <!-- 财产刑执行金额估计 -->
        <template v-if="caseData.n_ccxzxje_gj">
          <span class="text-base text-[#666666]">财产刑执行金额估计：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_ccxzxje_gj) || "—" }}</span>
        </template>

        <!-- 判处赔偿金额 -->
        <template v-if="caseData.n_pcpcje">
          <span class="text-base text-[#666666]">判处赔偿金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_pcpcje) || "—" }}</span>
        </template>

        <!-- 判处赔偿金额估计 -->
        <template v-if="caseData.n_pcpcje_gj">
          <span class="text-base text-[#666666]">判处赔偿金额估计：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_pcpcje_gj) || "—" }}</span>
        </template>

        <!-- 被请求赔偿金额估计 -->
        <template v-if="caseData.n_bqqpcje_gj">
          <span class="text-base text-[#666666]">被请求赔偿金额估计：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_bqqpcje_gj) || "—" }}</span>
        </template>
      </template>

      <!-- 执行案件特有字段 -->
      <template v-if="caseType === 'implement'">
        <!-- 申请执行标的金额 -->
        <template v-if="caseData.n_sqzxbdje">
          <span class="text-base text-[#666666]">申请执行标的金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_sqzxbdje) || "—" }}</span>
        </template>

        <!-- 实际到位金额 -->
        <template v-if="caseData.n_sjdwje !== undefined">
          <span class="text-base text-[#666666]">实际到位金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_sjdwje) || "—" }}</span>
        </template>

        <!-- 未执行金额 -->
        <template v-if="caseData.n_wzxje !== undefined">
          <span class="text-base text-[#666666]">未执行金额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_wzxje) || "—" }}</span>
        </template>

        <!-- 相关案件号 -->
        <template v-if="caseData.c_gkws_glah">
          <span class="text-base text-[#666666]">相关案件号：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.c_gkws_glah || "—" }}</span>
        </template>
      </template>

      <!-- 非诉保全审查案件特有字段 -->
      <template v-if="caseType === 'preservation'">
        <!-- 申请保全数额 -->
        <template v-if="caseData.n_sqbqse">
          <span class="text-base text-[#666666]">申请保全数额：</span>
          <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_sqbqse) || "—" }}</span>
        </template>

        <!-- 申请保全标的物 -->
        <template v-if="caseData.c_sqbqbdw">
          <span class="text-base text-[#666666]">申请保全标的物：</span>
          <span class="text-base font-medium text-[#333333]">{{ caseData.c_sqbqbdw || "—" }}</span>
        </template>
      </template>

      <!-- 案件通用字段 -->
      <!-- 诉讼地位 -->
      <template v-if="caseData.n_ssdw">
        <span class="text-base text-[#666666]">诉讼地位：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_ssdw || "—" }}</span>
      </template>

      <!-- 一审诉讼地位 -->
      <template v-if="caseData.n_ssdw_ys">
        <span class="text-base text-[#666666]">一审诉讼地位：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_ssdw_ys || "—" }}</span>
      </template>

      <!-- 案件进展阶段 -->
      <template v-if="caseData.n_ajjzjd">
        <span class="text-base text-[#666666]">案件进展阶段：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_ajjzjd || "—" }}</span>
      </template>

      <!-- 审理程序 -->
      <template v-if="caseData.n_slcx">
        <span class="text-base text-[#666666]">审理程序：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_slcx || "—" }}</span>
      </template>

      <!-- 法院所属层级 -->
      <template v-if="caseData.n_jbfy_cj">
        <span class="text-base text-[#666666]">法院所属层级：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_jbfy_cj || "—" }}</span>
      </template>

      <!-- 起诉标的金额 -->
      <template v-if="caseData.n_qsbdje">
        <span class="text-base text-[#666666]">起诉标的金额：</span>
        <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_qsbdje) || "—" }}</span>
      </template>

      <!-- 起诉标的金额估计 -->
      <template v-if="caseData.n_qsbdje_gj">
        <span class="text-base text-[#666666]">起诉标的金额估计：</span>
        <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_qsbdje_gj) || "—" }}</span>
      </template>

      <!-- 结案标的金额 -->
      <template v-if="caseData.n_jabdje">
        <span class="text-base text-[#666666]">结案标的金额：</span>
        <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_jabdje) || "—" }}</span>
      </template>

      <!-- 结案标的金额估计 -->
      <template v-if="caseData.n_jabdje_gj">
        <span class="text-base text-[#666666]">结案标的金额估计：</span>
        <span class="text-base font-medium text-[#333333]">{{ formatLawsuitMoney(caseData.n_jabdje_gj) || "—" }}</span>
      </template>

      <!-- 结案案由 -->
      <template v-if="caseData.n_jaay_tree || caseData.n_jaay">
        <span class="text-base text-[#666666]">结案案由：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_jaay_tree || caseData.n_jaay || "—" }}</span>
      </template>

      <!-- 结案案由标签 -->
      <template v-if="caseData.n_jaay_tag">
        <span class="text-base text-[#666666]">结案案由标签：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_jaay_tag || "—" }}</span>
      </template>

      <!-- 结案方式 -->
      <template v-if="caseData.n_jafs">
        <span class="text-base text-[#666666]">结案方式：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_jafs || "—" }}</span>
      </template>

      <!-- 结案时间 -->
      <template v-if="caseData.d_jarq">
        <span class="text-base text-[#666666]">结案时间：</span>
        <span class="text-base font-medium text-[#333333]">{{ formatDate(caseData.d_jarq) }}</span>
      </template>

      <!-- 胜诉估计 -->
      <template v-if="caseData.n_pj_victory">
        <span class="text-base text-[#666666]">胜诉估计：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.n_pj_victory || "—" }}</span>
      </template>

      <!-- 公开文书ID -->
      <template v-if="caseData.c_gkws_id">
        <span class="text-base text-[#666666]">公开文书ID：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_gkws_id || "—" }}</span>
      </template>

      <!-- 相关当事人 -->
      <template v-if="caseData.c_gkws_dsr">
        <span class="text-base text-[#666666]">相关当事人：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_gkws_dsr || "—" }}</span>
      </template>

      <!-- 判决结果 -->
      <template v-if="caseData.c_gkws_pjjg">
        <span class="text-base text-[#666666]">判决结果：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_gkws_pjjg || "—" }}</span>
      </template>

      <!-- 审理方式信息 -->
      <template v-if="caseData.c_slfsxx">
        <span class="text-base text-[#666666]">审理方式信息：</span>
        <span class="text-base font-medium text-[#333333]">{{ caseData.c_slfsxx || "—" }}</span>
      </template>

      <!-- 后续案件信息 -->
      <template v-if="caseData.next">
        <span class="text-base text-[#666666]">后续案件：</span>
        <span class="text-base font-medium text-[#333333]">
          {{ caseData.next.c_ah }}
          <span v-if="caseData.next.stage_type" class="ml-2 text-sm px-2 py-0.5 rounded bg-[#EB3C3C1A] text-[#EB3C3C]">
            {{
              caseData.next.stage_type === 2
                ? "二审"
                : caseData.next.stage_type === 3
                  ? "再审"
                  : caseData.next.stage_type === 4
                    ? "申请再审"
                    : caseData.next.stage_type === 5
                      ? "执行"
                      : "其他"
            }}
          </span>
        </span>
      </template>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { formatDate, formatLawsuitMoney } from '../utils/lawsuitUtils.js'

const props = defineProps({
  caseData: {
    type: Object,
    required: true
  },
  typeColor: {
    type: String,
    default: 'text-blue-600 bg-blue-50'
  },
  caseType: {
    type: String,
    required: true
  }
})

// 判断是否为特殊案件类型（失信被执行人、限高被执行人）
const isSpecialCase = computed(() => {
  return props.caseType === 'breachCase' || props.caseType === 'consumptionRestriction'
})
</script>

