diff --git a/apps/web-antd/src/api/agent/agent.ts b/apps/web-antd/src/api/agent/agent.ts index e090767..f632ecd 100644 --- a/apps/web-antd/src/api/agent/agent.ts +++ b/apps/web-antd/src/api/agent/agent.ts @@ -354,6 +354,19 @@ export interface GetAgentLinkProductStatisticsParams {} balance: number; // 修改后的余额 } + // 系统配置相关接口 + export interface SystemConfig { + commission_safe_mode: boolean; // 佣金安全防御模式 + } + + export interface UpdateSystemConfigReq { + commission_safe_mode: boolean; // 佣金安全防御模式:true-冻结模式,false-直接结算模式 + } + + export interface UpdateSystemConfigResp { + success: boolean; // 是否成功 + } + } /** @@ -611,6 +624,25 @@ async function updateAgentWalletBalance(params: AgentApi.UpdateAgentWalletBalanc ); } +/** + * 获取系统配置 + */ +async function getSystemConfig() { + return requestClient.get( + '/agent/system-config', + ); +} + +/** + * 更新系统配置 + */ +async function updateSystemConfig(params: AgentApi.UpdateSystemConfigReq) { + return requestClient.post( + '/agent/system-config', + params, + ); +} + export { @@ -635,4 +667,6 @@ export { updateAgentMembershipConfig, updateAgentProductionConfig, updateAgentWalletBalance, + getSystemConfig, + updateSystemConfig, }; diff --git a/apps/web-antd/src/views/agent/agent-commission/list.vue b/apps/web-antd/src/views/agent/agent-commission/list.vue index a695cd4..2d282e1 100644 --- a/apps/web-antd/src/views/agent/agent-commission/list.vue +++ b/apps/web-antd/src/views/agent/agent-commission/list.vue @@ -2,7 +2,7 @@ import { computed, h, onMounted, ref } from 'vue'; import { Page } from '@vben/common-ui'; -import { Button, message, Modal, Select } from 'ant-design-vue'; +import { Button, message, Modal, Select, Switch, Tooltip } from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { @@ -11,6 +11,8 @@ import { getAgentList, getAgentWallet, updateAgentCommissionStatus, + getSystemConfig, + updateSystemConfig, } from '#/api/agent'; import type { AgentApi } from '#/api'; @@ -25,6 +27,10 @@ const props = defineProps(); // 用于一键解冻筛选的代理商ID const unfreezeAgentId = ref(); +// 佣金安全防御模式配置 +const commissionSafeMode = ref(false); +const safeModeLoading = ref(false); + // 代理商列表(完整列表) const allAgentList = ref([]); @@ -86,11 +92,41 @@ function getNotFoundContent() { return '暂无代理商'; } -// 页面加载时获取代理商列表 -onMounted(() => { +// 页面加载时获取代理商列表和系统配置 +onMounted(async () => { loadAgentList(); + await loadSystemConfig(); }); +// 加载系统配置 +async function loadSystemConfig() { + try { + const config = await getSystemConfig(); + commissionSafeMode.value = config.commission_safe_mode; + } catch (error: any) { + console.error('加载系统配置失败:', error); + message.error('加载系统配置失败'); + } +} + +// 切换安全防御模式 +async function onSafeModeChange(checked: boolean | string | number) { + const isChecked = Boolean(checked); + safeModeLoading.value = true; + try { + await updateSystemConfig({ commission_safe_mode: isChecked }); + commissionSafeMode.value = isChecked; + message.success(`佣金安全防御模式已${isChecked ? '开启' : '关闭'}`); + } catch (error: any) { + const errorMsg = error?.response?.data?.msg || error?.message || '操作失败,请重试'; + message.error(errorMsg); + // 恢复原状态 + commissionSafeMode.value = !isChecked; + } finally { + safeModeLoading.value = false; + } +} + // 操作处理函数 function onActionClick({ code, row }: { code: string; row: any }) { switch (code) { @@ -348,11 +384,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ proxyConfig: { ajax: { query: async ({ page, form, sort }: any, formValues: Record) => { - console.log('=== 佣金列表查询参数 ==='); - console.log('第一个参数 (params):', { page, form, sort }); - console.log('第二个参数 (formValues):', formValues); - console.log(' queryParams.value:', queryParams.value); - return await getAgentCommissionList({ ...queryParams.value, ...formValues, @@ -375,34 +406,49 @@ const [Grid, gridApi] = useVbenVxeGrid({