fix(card): 卡密页概览与补发把 api 返回值多剥了一层,并补上补发菜单项
- api.get/post 已经直接返回 data.data,之前又读 .data,导致安全概览不渲染、 补发成功也走到失败分支 - 卡片操作菜单新增「作废并补发新卡密」,仅登录卡显示(充值卡用禁用/删除即可) - 补发成功后刷新列表与概览 实测(浏览器真实点击):菜单出现 禁用/作废并补发新卡密/删除 → 点击后 toast「已补发新卡密:VFY-LPMC-KBW5-2DHA-NP2S」→ 列表出现新卡、 旧卡变 void、主体 display_name 同步、新卡密登录成功且余额 200 延续。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { ColumnDef } from '@tanstack/vue-table'
|
||||
import type { Composer } from 'vue-i18n'
|
||||
|
||||
import { Ban, MoreHorizontal, Trash2 } from 'lucide-vue-next'
|
||||
import { Ban, KeyRound, MoreHorizontal, Trash2 } from 'lucide-vue-next'
|
||||
import { h } from 'vue'
|
||||
|
||||
import type { Card } from '@/pages/admin/cards/data/schema'
|
||||
@@ -196,6 +196,14 @@ export function getColumns(actions: {
|
||||
isBanned ? t('admin.cards.enable') : t('admin.cards.disable'),
|
||||
]),
|
||||
h(DropdownMenuSeparator),
|
||||
// 只有登录卡能补发:换一把钥匙,主体/余额/设备都不动
|
||||
card.purpose === 'credential' && actions.onReissue
|
||||
? h(DropdownMenuItem, { onClick: () => actions.onReissue!(card) }, () => [
|
||||
h(KeyRound, { class: 'mr-2 h-4 w-4' }),
|
||||
'作废并补发新卡密',
|
||||
])
|
||||
: null,
|
||||
card.purpose === 'credential' && actions.onReissue ? h(DropdownMenuSeparator) : null,
|
||||
h(DropdownMenuItem, { class: 'text-destructive', onClick: () => actions.onDelete(card) }, () => [
|
||||
h(Trash2, { class: 'mr-2 h-4 w-4' }),
|
||||
t('admin.cards.delete'),
|
||||
|
||||
@@ -175,15 +175,10 @@ async function reissueCard(row: Card) {
|
||||
if (!ok)
|
||||
return
|
||||
try {
|
||||
const res: any = await api.post(`/dev/cards/${row.id}/reissue`, {})
|
||||
const data = res.data
|
||||
if (data.code === 200) {
|
||||
toast.success(`已补发新卡密:${data.data.new_key}`)
|
||||
fetchCards()
|
||||
}
|
||||
else {
|
||||
toast.error(data.message || '补发失败')
|
||||
}
|
||||
const data: any = await api.post(`/dev/cards/${row.id}/reissue`, {})
|
||||
toast.success(`已补发新卡密:${data?.new_key || ''}`)
|
||||
fetchCards()
|
||||
fetchSecurity()
|
||||
}
|
||||
catch (e: any) {
|
||||
toast.error(e?.response?.data?.message || '补发失败')
|
||||
@@ -195,10 +190,7 @@ const secStats = ref<any>(null)
|
||||
async function fetchSecurity() {
|
||||
try {
|
||||
const qs = appFilter.value ? `?application_id=${appFilter.value}` : ''
|
||||
const res: any = await api.get(`/dev/cards/security${qs}`)
|
||||
const payload = res?.data ?? res
|
||||
if (payload?.code === 200)
|
||||
secStats.value = payload.data
|
||||
secStats.value = await api.get(`/dev/cards/security${qs}`)
|
||||
}
|
||||
catch { /* 概览失败不影响列表 */ }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user