驳回
This commit is contained in:
56
src/views/finance/agent-recharge/agentRechargeActions.ts
Normal file
56
src/views/finance/agent-recharge/agentRechargeActions.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { AgentRechargeStatus, type AgentRecharge } from '@/types/api'
|
||||
import { hasVoucherKeys } from '@/utils/business'
|
||||
|
||||
export interface AgentRechargeAction {
|
||||
label: string
|
||||
handler: () => void
|
||||
type: 'primary' | 'danger'
|
||||
}
|
||||
|
||||
interface BuildAgentRechargeActionsOptions {
|
||||
hasAuth: (permission: string) => boolean
|
||||
onViewPaymentVoucher: (row: AgentRecharge) => void
|
||||
onConfirmPayment: (row: AgentRecharge) => void
|
||||
onReject: (row: AgentRecharge) => void
|
||||
}
|
||||
|
||||
export const buildAgentRechargeActions = (
|
||||
row: AgentRecharge,
|
||||
options: BuildAgentRechargeActionsOptions
|
||||
): AgentRechargeAction[] => {
|
||||
const actions: AgentRechargeAction[] = []
|
||||
|
||||
if (
|
||||
row.payment_method === 'offline' &&
|
||||
hasVoucherKeys(row.payment_voucher_key) &&
|
||||
options.hasAuth('agent_recharge:view_payment_voucher')
|
||||
) {
|
||||
actions.push({
|
||||
label: '查看支付凭证',
|
||||
handler: () => options.onViewPaymentVoucher(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
if (
|
||||
row.status === AgentRechargeStatus.PENDING &&
|
||||
row.payment_method === 'offline' &&
|
||||
options.hasAuth('agent_recharge:confirm_payment')
|
||||
) {
|
||||
actions.push({
|
||||
label: '确认支付',
|
||||
handler: () => options.onConfirmPayment(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
if (row.status === AgentRechargeStatus.PENDING && options.hasAuth('agent_recharge:reject')) {
|
||||
actions.push({
|
||||
label: '拒绝',
|
||||
handler: () => options.onReject(row),
|
||||
type: 'danger'
|
||||
})
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
Reference in New Issue
Block a user