驳回
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
AgentRechargeListResponse,
|
||||
CreateAgentRechargeRequest,
|
||||
ConfirmOfflinePaymentRequest,
|
||||
RejectAgentRechargeRequest,
|
||||
BaseResponse
|
||||
} from '@/types/api'
|
||||
|
||||
@@ -55,4 +56,16 @@ export class AgentRechargeService extends BaseService {
|
||||
data
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝代理充值订单
|
||||
* @param id 充值订单ID
|
||||
* @param data 拒绝请求参数
|
||||
*/
|
||||
static rejectAgentRecharge(
|
||||
id: number,
|
||||
data: RejectAgentRechargeRequest
|
||||
): Promise<BaseResponse<void>> {
|
||||
return this.post<BaseResponse<void>>(`/api/admin/agent-recharges/${id}/reject`, data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,3 +72,8 @@ export interface CreateAgentRechargeRequest {
|
||||
export interface ConfirmOfflinePaymentRequest {
|
||||
operation_password: string
|
||||
}
|
||||
|
||||
// 拒绝代理充值订单请求
|
||||
export interface RejectAgentRechargeRequest {
|
||||
reject_reason: string
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
3
src/views/finance/agent-recharge/agentRechargeDisplay.ts
Normal file
3
src/views/finance/agent-recharge/agentRechargeDisplay.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const formatRejectionReason = (reason?: string | null): string => {
|
||||
return reason || '-'
|
||||
}
|
||||
@@ -167,6 +167,38 @@
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<!-- 拒绝充值订单对话框 -->
|
||||
<ElDialog
|
||||
v-model="rejectDialogVisible"
|
||||
title="拒绝充值订单"
|
||||
width="500px"
|
||||
@closed="handleRejectDialogClosed"
|
||||
>
|
||||
<ElForm ref="rejectFormRef" :model="rejectForm" :rules="rejectRules" label-width="100px">
|
||||
<ElFormItem label="充值单号">
|
||||
<span>{{ currentRecharge?.recharge_no }}</span>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="拒绝原因" prop="reject_reason">
|
||||
<ElInput
|
||||
v-model="rejectForm.reject_reason"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
maxlength="500"
|
||||
show-word-limit
|
||||
placeholder="请输入拒绝原因"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton @click="rejectDialogVisible = false">取消</ElButton>
|
||||
<ElButton type="danger" @click="handleRejectRecharge" :loading="rejectLoading">
|
||||
确认拒绝
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<!-- 支付凭证预览 -->
|
||||
<PaymentVoucherDialog
|
||||
:file-keys="paymentVoucherFileKeys"
|
||||
@@ -198,7 +230,8 @@
|
||||
AgentRechargeStatus,
|
||||
AgentRechargePaymentMethod,
|
||||
CreateAgentRechargeRequest,
|
||||
ConfirmOfflinePaymentRequest
|
||||
ConfirmOfflinePaymentRequest,
|
||||
RejectAgentRechargeRequest
|
||||
} from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
@@ -207,6 +240,7 @@
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import PaymentVoucherDialog from '@/components/business/PaymentVoucherDialog.vue'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import { buildAgentRechargeActions } from './agentRechargeActions'
|
||||
|
||||
defineOptions({ name: 'AgentRechargeList' })
|
||||
|
||||
@@ -217,9 +251,11 @@
|
||||
const createLoading = ref(false)
|
||||
const voucherUploading = ref(false)
|
||||
const confirmPayLoading = ref(false)
|
||||
const rejectLoading = ref(false)
|
||||
const tableRef = ref()
|
||||
const createDialogVisible = ref(false)
|
||||
const confirmPayDialogVisible = ref(false)
|
||||
const rejectDialogVisible = ref(false)
|
||||
const currentRecharge = ref<AgentRecharge | null>(null)
|
||||
const paymentVoucherFileKeys = ref<string[]>([])
|
||||
|
||||
@@ -337,6 +373,7 @@
|
||||
|
||||
const createFormRef = ref<FormInstance>()
|
||||
const confirmPayFormRef = ref<FormInstance>()
|
||||
const rejectFormRef = ref<FormInstance>()
|
||||
const uploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const MIN_RECHARGE_AMOUNT = 0.01
|
||||
|
||||
@@ -374,6 +411,10 @@
|
||||
]
|
||||
})
|
||||
|
||||
const rejectRules = reactive<FormRules>({
|
||||
reject_reason: [{ required: true, message: '请输入拒绝原因', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const createForm = reactive<{
|
||||
amount: number
|
||||
payment_method: string
|
||||
@@ -392,6 +433,10 @@
|
||||
operation_password: ''
|
||||
})
|
||||
|
||||
const rejectForm = reactive<RejectAgentRechargeRequest>({
|
||||
reject_reason: ''
|
||||
})
|
||||
|
||||
const rechargeList = ref<AgentRecharge[]>([])
|
||||
|
||||
// 格式化货币 - 将分转换为元
|
||||
@@ -735,6 +780,44 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 显示拒绝对话框
|
||||
const handleShowReject = (row: AgentRecharge) => {
|
||||
currentRecharge.value = row
|
||||
rejectDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 拒绝对话框关闭后的清理
|
||||
const handleRejectDialogClosed = () => {
|
||||
rejectFormRef.value?.resetFields()
|
||||
rejectForm.reject_reason = ''
|
||||
currentRecharge.value = null
|
||||
}
|
||||
|
||||
// 拒绝代理充值订单
|
||||
const handleRejectRecharge = async () => {
|
||||
const formRef = rejectFormRef.value
|
||||
const recharge = currentRecharge.value
|
||||
if (!formRef || !recharge) return
|
||||
|
||||
await formRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
rejectLoading.value = true
|
||||
try {
|
||||
await AgentRechargeService.rejectAgentRecharge(recharge.id, {
|
||||
reject_reason: rejectForm.reject_reason
|
||||
})
|
||||
ElMessage.success('拒绝成功')
|
||||
rejectDialogVisible.value = false
|
||||
await getTableData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
rejectLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 处理名称点击
|
||||
const handleNameClick = (row: AgentRecharge) => {
|
||||
if (hasAuth('agent_recharge:detail_page')) {
|
||||
@@ -754,35 +837,12 @@
|
||||
|
||||
// 获取操作按钮
|
||||
const getActions = (row: AgentRecharge) => {
|
||||
const actions: any[] = []
|
||||
|
||||
// 线下支付且有凭证可以查看
|
||||
if (
|
||||
row.payment_method === 'offline' &&
|
||||
hasVoucherKeys(row.payment_voucher_key) &&
|
||||
hasAuth('agent_recharge:view_payment_voucher')
|
||||
) {
|
||||
actions.push({
|
||||
label: '查看支付凭证',
|
||||
handler: () => handleViewPaymentVoucher(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
// 待支付且线下转账的订单可以确认支付
|
||||
if (
|
||||
row.status === 1 &&
|
||||
row.payment_method === 'offline' &&
|
||||
hasAuth('agent_recharge:confirm_payment')
|
||||
) {
|
||||
actions.push({
|
||||
label: '确认支付',
|
||||
handler: () => handleShowConfirmPay(row),
|
||||
type: 'primary'
|
||||
})
|
||||
}
|
||||
|
||||
return actions
|
||||
return buildAgentRechargeActions(row, {
|
||||
hasAuth,
|
||||
onViewPaymentVoucher: handleViewPaymentVoucher,
|
||||
onConfirmPayment: handleShowConfirmPay,
|
||||
onReject: handleShowReject
|
||||
})
|
||||
}
|
||||
|
||||
// 查看支付凭证
|
||||
|
||||
Reference in New Issue
Block a user