zjk
2026-08-05 8a185cf7c56f786b64c25c99028ac101ab37ac51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
  auditFamilyCardApplication,
  getFamilyCardApplicationDetail,
  updateFamilyCardStatus,
} from '../api/admin'
import type { FamilyCardApplication } from '../types/admin'
 
const route = useRoute()
const router = useRouter()
const detail = ref<FamilyCardApplication>()
const loading = ref(false)
 
function text(value?: string | number) {
  return value === undefined || value === null || value === '' ? '-' : String(value)
}
 
function genderText(gender?: number | string) {
  if (gender === 1 || gender === '1') return '男'
  if (gender === 2 || gender === '2') return '女'
  return '-'
}
 
const cardholderInfo = computed(() => [
  { label: '持卡人姓名:', value: text(detail.value?.talentName) },
  { label: '身份证号:', value: text(detail.value?.talentIdCardNo) },
  { label: '联系方式:', value: text(detail.value?.talentMobile) },
  { label: '联系地址:', value: text(detail.value?.contactAddress) },
  { label: '工作地址:', value: text(detail.value?.workAddress) },
  { label: '性别:', value: genderText(detail.value?.gender) },
  { label: '人才等级:', value: text(detail.value?.cardLevel) },
  {
    label: '当前家属卡数量:',
    value: `${detail.value?.currentFamilyCardCount || 0}/${detail.value?.familyCardLimit || 2}`,
  },
])
 
const familyInfo = computed(() => [
  { label: '持卡人姓名:', value: text(detail.value?.familyName) },
  { label: '身份证号:', value: text(detail.value?.idCardNo) },
  { label: '手机号:', value: text(detail.value?.familyMobile) },
  { label: '与持卡人关系:', value: text(detail.value?.relationship) },
])
 
const isApplicationPage = computed(() => route.path.includes('family-card-applications'))
const isManagementPage = computed(() => route.path.includes('family-cards') && !isApplicationPage.value)
const isPending = computed(() => isApplicationPage.value && detail.value?.status === '待审核')
const canUnbind = computed(() => isManagementPage.value && detail.value?.status !== 0 && detail.value?.status !== '停用')
 
async function loadDetail() {
  loading.value = true
  try {
    detail.value = await getFamilyCardApplicationDetail(String(route.params.id))
  } finally {
    loading.value = false
  }
}
 
async function approveApplication() {
  if (!detail.value) return
  await ElMessageBox.confirm('确认通过该家属卡申请?通过后会生成家属卡。', '家属卡审核', { type: 'warning' })
  await auditFamilyCardApplication(detail.value.id, '已通过')
  ElMessage.success('家属卡申请已通过')
  router.back()
}
 
async function rejectApplication() {
  if (!detail.value) return
  const { value } = await ElMessageBox.prompt('请输入驳回原因', '家属卡审核', {
    inputValue: '资料不完整',
  })
  await auditFamilyCardApplication(detail.value.id, '已驳回', value)
  ElMessage.success('家属卡申请已驳回')
  router.back()
}
 
async function unbindCard() {
  if (!detail.value) return
  const cardId = detail.value.cardId || detail.value.familyCardId
  if (!cardId) {
    ElMessage.warning('未能获取家属卡信息')
    return
  }
  await ElMessageBox.confirm('确认解除绑定该家属卡?解除后家属将无法使用相关权益。', '解除绑定', { type: 'warning' })
  // 假设 0 代表停用/解除绑定
  await updateFamilyCardStatus(cardId, 0)
  ElMessage.success('家属卡已解除绑定')
  router.back()
}
 
onMounted(loadDetail)
</script>
 
<template>
  <div v-loading="loading" class="medical-application-detail-page">
    <section class="medical-application-detail-panel">
      <div class="reservation-detail-section">
        <h3>持卡人信息</h3>
        <div class="reservation-detail-grid single-line">
          <div v-for="item in cardholderInfo" :key="item.label" class="reservation-detail-item">
            <span>{{ item.label }}</span>
            <template v-if="item.label === '当前家属卡数量:'">
              <strong>{{ item.value }}</strong>
            </template>
            <strong v-else>{{ item.value }}</strong>
          </div>
        </div>
      </div>
 
      <div class="reservation-detail-section">
        <h3>家属信息</h3>
        <div class="reservation-detail-grid single-line" style="min-height: 74px; align-content: start;">
          <div v-for="item in familyInfo" :key="item.label" class="reservation-detail-item">
            <span>{{ item.label }}</span>
            <strong>{{ item.value }}</strong>
          </div>
        </div>
      </div>
    </section>
 
    <div v-if="isPending" style="display: flex; gap: 12px; margin-top: 12px;">
      <el-button type="primary" @click="approveApplication">审核通过</el-button>
      <el-button type="primary" @click="rejectApplication">审核不通过</el-button>
    </div>
 
    <div v-if="canUnbind" style="display: flex; gap: 12px; margin-top: 12px;">
      <el-button type="primary" @click="unbindCard">解除绑定</el-button>
    </div>
  </div>
</template>