From 0d04de0486ac8eb27a9eeeff831f3c1e36bb42cb Mon Sep 17 00:00:00 2001 From: sunzhuangzhuang <961120009@qq.com> Date: Thu, 21 Aug 2025 10:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=A2=9E=E5=8A=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AgentDashboard.vue | 415 +++++++++++++++++++++++++++++------ 1 file changed, 348 insertions(+), 67 deletions(-) diff --git a/src/views/AgentDashboard.vue b/src/views/AgentDashboard.vue index 659ad37..37c8044 100644 --- a/src/views/AgentDashboard.vue +++ b/src/views/AgentDashboard.vue @@ -117,17 +117,6 @@ - - @@ -167,32 +156,36 @@ stripe style="width: 100%" :row-class-name="({ row }) => row.is_early_merchant ? 'early-merchant' : ''" + border + size="small" + class="responsive-table" > - + - - + + - + - + - - - - - + + + + +
@@ -253,43 +250,48 @@
- - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + +
+ +
@@ -350,6 +354,97 @@
+ + + +
+
+

商户转账记录

+
+ + + + + 刷新 + +
+
+ + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+
@@ -382,7 +477,7 @@ import { GridComponent } from 'echarts/components' import VChart from 'vue-echarts' -import api from '@/utils/api' +import api, { transferAPI } from '@/utils/api' // 注册ECharts组件 use([ @@ -416,6 +511,14 @@ const commissionsPage = ref(1) const commissionsPageSize = ref(10) const commissionsTotal = ref(0) +// 转账记录数据 +const transfers = ref([]) +const loadingTransfers = ref(false) +const transfersPage = ref(1) +const transfersPageSize = ref(10) +const transfersTotal = ref(0) +const selectedMerchantId = ref(null) + // 图表相关数据 const chartPeriod = ref('7d') const chartLoading = ref(false) @@ -513,6 +616,54 @@ const loadCommissions = async () => { } } +const loadTransfers = async () => { + if (!agentInfo.value) return + + loadingTransfers.value = true + try { + // 构建请求参数 + const params = { + page: transfersPage.value, + limit: transfersPageSize.value + } + + // 如果选择了特定商户,则添加到请求参数中 + let userId = selectedMerchantId.value + + // 如果没有选择特定商户,则获取代理下所有商户的转账记录 + if (!userId) { + // 使用代理ID获取所有相关商户的转账记录 + const { data } = await api.get(`/agents/merchants/${agentInfo.value.id}/transfers`, { + params + }) + console.log(data,'data1'); + + transfers.value = data.data.transfers + transfersTotal.value = data.data.pagination.total + } else { + // 获取特定商户的转账记录 + const { data } = await transferAPI.getUserTransfersByUserId(userId, params) + + transfers.value = data.data.transfers + transfersTotal.value = data.data.pagination.total + } + } catch (error) { + console.error('加载转账记录失败:', error) + ElMessage.error('加载转账记录失败') + } finally { + loadingTransfers.value = false + } +} + +const viewMerchantTransfers = (merchant) => { + // 设置选中的商户ID + selectedMerchantId.value = merchant.id + // 切换到转账记录标签页 + activeTab.value = 'transfers' + // 加载该商户的转账记录 + loadTransfers() +} + const handleLogout = async () => { try { await ElMessageBox.confirm('确定要退出登录吗?', '确认退出', { @@ -592,8 +743,101 @@ const getCommissionStatusText = (status) => { return '已生成' } +/** + * 获取转账状态标签类型 + * @param {string} status - 转账状态 + * @returns {string} 标签类型 + */ +const getTransferStatusType = (status) => { + const types = { + pending: 'warning', + confirmed: 'success', + rejected: 'danger', + received: 'success', + cancelled: 'info' + } + return types[status] || 'info' +} + +/** + * 获取转账状态文本 + * @param {string} status - 转账状态 + * @returns {string} 显示文本 + */ +const getTransferStatusText = (status) => { + const texts = { + pending: '待确认', + confirmed: '已确认', + rejected: '已拒绝', + received: '已收到', + cancelled: '已取消' + } + return texts[status] || status +} + +/** + * 获取转账类型标签类型 + * @param {string} type - 转账类型 + * @returns {string} 标签类型 + */ +const getTransferTypeType = (type) => { + const types = { + deposit: 'success', + withdraw: 'warning', + transfer: 'primary', + commission: 'success', + refund: 'info', + penalty: 'danger', + initial: 'primary', + return: 'info', + user_to_user: 'primary', + user_to_public: 'warning', + public_to_user: 'success' + } + return types[type] || 'info' +} + +/** + * 获取转账类型文本 + * @param {string} type - 转账类型 + * @returns {string} 显示文本 + */ +const getTransferTypeText = (type) => { + const texts = { + deposit: '充值', + withdraw: '提现', + transfer: '转账', + commission: '佣金', + refund: '退款', + penalty: '罚金', + initial: '初始转账', + return: '返还转账', + user_to_user: '用户转账', + user_to_public: '用户转公户', + public_to_user: '公户转用户' + } + return texts[type] || type +} + +/** + * 格式化日期时间 + * @param {string|Date} date - 需要格式化的日期 + * @returns {string} - 格式化后的日期字符串或原文本 + */ const formatDateTime = (date) => { - return new Date(date).toLocaleString('zh-CN') + if (!date) return '' + + // 尝试转换为日期对象 + const dateObj = new Date(date) + + // 检查是否为有效日期 + if (isNaN(dateObj.getTime())) { + // 如果不是有效日期,返回原文本 + return date + } + + // 如果是有效日期,进行格式化 + return dateObj.toLocaleString('zh-CN') } /** @@ -839,7 +1083,8 @@ onMounted(async () => { await Promise.all([ loadChartData(), loadMerchants(), - loadCommissions() + loadCommissions(), + loadTransfers() ]) } }) @@ -1427,7 +1672,37 @@ onMounted(async () => { } } +/* 响应式表格样式 */ +.responsive-table { + width: 100%; + overflow-x: auto; +} + +@media (max-width: 768px) { + .hide-on-mobile { + display: none; + } + + :deep(.el-table .cell) { + padding-left: 5px; + padding-right: 5px; + } + + :deep(.el-table) { + font-size: 12px; + } + + :deep(.el-tag) { + transform: scale(0.9); + transform-origin: left center; + } +} + @media (max-width: 480px) { + .hide-on-small-mobile { + display: none; + } + .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; @@ -1471,5 +1746,11 @@ onMounted(async () => { .chart-card { padding: 16px; } + + :deep(.el-pagination) { + justify-content: center; + flex-wrap: wrap; + row-gap: 8px; + } } \ No newline at end of file