From 9fb3367fd7e6fefa213afe22730cc7d4e3a8d5c0 Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Wed, 18 Mar 2026 10:47:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=85=85=E5=80=BC=E4=BB=A3?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/finance/agent-recharge/detail.vue | 320 ++++++++++---------- src/views/finance/agent-recharge/index.vue | 138 +++++---- update_context_menu.py | 220 -------------- 3 files changed, 240 insertions(+), 438 deletions(-) delete mode 100644 update_context_menu.py diff --git a/src/views/finance/agent-recharge/detail.vue b/src/views/finance/agent-recharge/detail.vue index ae1497a..16b1546 100644 --- a/src/views/finance/agent-recharge/detail.vue +++ b/src/views/finance/agent-recharge/detail.vue @@ -1,124 +1,42 @@ + + diff --git a/src/views/finance/agent-recharge/index.vue b/src/views/finance/agent-recharge/index.vue index ca3dd48..fc2de94 100644 --- a/src/views/finance/agent-recharge/index.vue +++ b/src/views/finance/agent-recharge/index.vue @@ -32,14 +32,29 @@ :pageSize="pagination.page_size" :total="pagination.total" :marginTop="10" + :row-class-name="getRowClassName" @size-change="handleSizeChange" @current-change="handleCurrentChange" + @row-contextmenu="handleRowContextMenu" + @cell-mouse-enter="handleCellMouseEnter" + @cell-mouse-leave="handleCellMouseLeave" > + + + + + + (null) + // 右键菜单 + const rechargeOperationMenuRef = ref>() + const currentOperatingRecharge = ref(null) + // 搜索表单初始值 const initialSearchState: AgentRechargeQueryParams = { shop_id: undefined, @@ -249,7 +272,6 @@ // 列配置 const columnOptions = [ - { label: 'ID', prop: 'id' }, { label: '充值单号', prop: 'recharge_no' }, { label: '店铺名称', prop: 'shop_name' }, { label: '充值金额', prop: 'amount' }, @@ -258,8 +280,7 @@ { label: '支付通道', prop: 'payment_channel' }, { label: '创建时间', prop: 'created_at' }, { label: '支付时间', prop: 'paid_at' }, - { label: '完成时间', prop: 'completed_at' }, - { label: '操作', prop: 'actions' } + { label: '完成时间', prop: 'completed_at' } ] const createFormRef = ref() @@ -323,15 +344,10 @@ // 动态列配置 const { columnChecks, columns } = useCheckedColumns(() => [ - { - prop: 'id', - label: 'ID', - width: 80 - }, { prop: 'recharge_no', label: '充值单号', - minWidth: 200, + minWidth: 240, formatter: (row: AgentRecharge) => { return h( 'span', @@ -374,7 +390,8 @@ { prop: 'payment_channel', label: '支付通道', - width: 120 + width: 120, + formatter: (row: AgentRecharge) => row.payment_channel || '-' }, { prop: 'created_at', @@ -393,46 +410,6 @@ label: '完成时间', width: 180, formatter: (row: AgentRecharge) => (row.completed_at ? formatDateTime(row.completed_at) : '-') - }, - { - prop: 'actions', - label: '操作', - width: 150, - fixed: 'right', - formatter: (row: AgentRecharge) => { - const buttons: any[] = [] - - // 待支付且线下转账的订单可以确认支付 - if (row.status === 1 && row.payment_method === 'offline') { - buttons.push( - h( - ElButton, - { - type: 'primary', - link: true, - size: 'small', - onClick: () => handleShowConfirmPay(row) - }, - () => '确认支付' - ) - ) - } - - buttons.push( - h( - ElButton, - { - type: 'primary', - link: true, - size: 'small', - onClick: () => handleViewDetail(row) - }, - () => '查看详情' - ) - ) - - return h('div', { style: 'display: flex; gap: 8px;' }, buttons) - } } ]) @@ -502,7 +479,7 @@ } const res = await AgentRechargeService.getAgentRecharges(params) if (res.code === 0) { - rechargeList.value = res.data.list || [] + rechargeList.value = res.data.items || [] pagination.total = res.data.total || 0 } } catch (error) { @@ -551,6 +528,8 @@ // 显示创建订单对话框 const showCreateDialog = async () => { + // 重新加载店铺列表,确保获取最新数据 + await loadShops() createDialogVisible.value = true } @@ -633,10 +612,65 @@ path: `${RoutesAlias.AgentRecharge}/detail/${row.id}` }) } + + // 充值订单操作菜单项配置 + const rechargeOperationMenuItems = computed((): MenuItemType[] => { + const items: MenuItemType[] = [] + + // 待支付且线下转账的订单可以确认支付 + if ( + currentOperatingRecharge.value?.status === 1 && + currentOperatingRecharge.value?.payment_method === 'offline' + ) { + items.push({ + key: 'confirm_pay', + label: '确认支付' + }) + } + + return items + }) + + // 显示充值订单操作右键菜单 + const showRechargeOperationMenu = (e: MouseEvent, row: AgentRecharge) => { + e.preventDefault() + e.stopPropagation() + currentOperatingRecharge.value = row + rechargeOperationMenuRef.value?.show(e) + } + + // 处理表格行右键菜单 + const handleRowContextMenu = (row: AgentRecharge, column: any, event: MouseEvent) => { + showRechargeOperationMenu(event, row) + } + + // 处理充值订单操作菜单选择 + const handleRechargeOperationMenuSelect = (item: MenuItemType) => { + if (!currentOperatingRecharge.value) return + + switch (item.key) { + case 'confirm_pay': + handleShowConfirmPay(currentOperatingRecharge.value) + break + } + } + + // 使用表格右键菜单功能 + const { + showContextMenuHint, + hintPosition, + getRowClassName, + handleCellMouseEnter, + handleCellMouseLeave + } = useTableContextMenu() diff --git a/update_context_menu.py b/update_context_menu.py deleted file mode 100644 index 99ee2b8..0000000 --- a/update_context_menu.py +++ /dev/null @@ -1,220 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -批量为表格页面添加右键菜单和悬浮提示功能 -""" - -import re -import os - -def add_imports(content): - """添加必要的导入""" - # 检查是否已经导入 - if 'useTableContextMenu' in content: - return content - - # 找到 useAuth 导入位置 - import_pattern = r"(import\s+{\s+useAuth\s+}\s+from\s+'@/composables/useAuth')" - - if re.search(import_pattern, content): - # 在 useAuth 后面添加 useTableContextMenu - content = re.sub( - import_pattern, - r"\1\n import { useTableContextMenu } from '@/composables/useTableContextMenu'", - content - ) - - # 添加 TableContextMenuHint 组件导入 - arttable_pattern = r"(import\s+ArtButtonTable\s+from\s+'@/components/core/forms/ArtButtonTable\.vue')" - if re.search(arttable_pattern, content): - content = re.sub( - arttable_pattern, - r"\1\n import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'", - content - ) - - # 如果没有 ArtMenuRight,添加它 - if 'ArtMenuRight' not in content: - content = re.sub( - arttable_pattern, - r"\1\n import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'\n import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'", - content - ) - - return content - -def add_context_menu_usage(content): - """添加 useTableContextMenu 的使用""" - if 'useTableContextMenu()' in content: - return content - - # 查找 const currentRow = ref 或类似的变量声明 - pattern = r"(const\s+currentRow\s*=\s*ref[^\n]+)" - - usage_code = """ - // 使用表格右键菜单功能 - const { - showContextMenuHint, - hintPosition, - getRowClassName, - handleCellMouseEnter, - handleCellMouseLeave - } = useTableContextMenu()""" - - if re.search(pattern, content): - content = re.sub(pattern, r"\1" + usage_code, content) - - return content - -def add_table_events(content): - """为 ArtTable 添加事件监听""" - # 查找 ArtTable 标签 - table_pattern = r"(]*?)(\s*@row-contextmenu=\"[^\"]+\")?([^>]*>)" - - if '@cell-mouse-enter' in content: - return content - - # 添加必要的属性和事件 - def replace_table(match): - prefix = match.group(1) - existing_contextmenu = match.group(2) or '' - suffix = match.group(3) - - # 如果没有 row-class-name,添加它 - if ':row-class-name' not in prefix and 'row-class-name' not in prefix: - prefix += '\n :row-class-name="getRowClassName"' - - # 如果没有 row-contextmenu,添加它 - if not existing_contextmenu and '@row-contextmenu' not in prefix: - existing_contextmenu = '\n @row-contextmenu="handleRowContextMenu"' - - # 添加 cell mouse 事件 - cell_events = '\n @cell-mouse-enter="handleCellMouseEnter"\n @cell-mouse-leave="handleCellMouseLeave"' - - return prefix + existing_contextmenu + cell_events + suffix - - content = re.sub(table_pattern, replace_table, content, flags=re.DOTALL) - - return content - -def add_hint_component(content): - """添加悬浮提示组件""" - if 'TableContextMenuHint' in content and ':visible="showContextMenuHint"' in content: - return content - - # 在 后添加提示组件 - table_end_pattern = r"()" - - hint_component = r"""\1 - - - """ - - content = re.sub(table_end_pattern, hint_component, content) - - return content - -def add_context_menu_component(content): - """添加右键菜单组件""" - if 'ArtMenuRight' in content and 'contextMenuRef' in content: - return content - - # 在提示组件后添加右键菜单 - hint_pattern = r"(]+/>)" - - menu_component = r"""\1 - - - """ - - content = re.sub(hint_pattern, menu_component, content) - - return content - -def add_css_styles(content): - """添加 CSS 样式""" - if 'table-row-with-context-menu' in content: - return content - - # 查找