<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>
|