add button
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled

This commit is contained in:
2026-01-05 12:50:10 +08:00
parent f70d33a7d3
commit e4b2a1d35a
2 changed files with 115 additions and 35 deletions

View File

@@ -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<AgentApi.SystemConfig>(
'/agent/system-config',
);
}
/**
* 更新系统配置
*/
async function updateSystemConfig(params: AgentApi.UpdateSystemConfigReq) {
return requestClient.post<AgentApi.UpdateSystemConfigResp>(
'/agent/system-config',
params,
);
}
export {
@@ -635,4 +667,6 @@ export {
updateAgentMembershipConfig,
updateAgentProductionConfig,
updateAgentWalletBalance,
getSystemConfig,
updateSystemConfig,
};

View File

@@ -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<Props>();
// 用于一键解冻筛选的代理商ID
const unfreezeAgentId = ref<number | undefined>();
// 佣金安全防御模式配置
const commissionSafeMode = ref<boolean>(false);
const safeModeLoading = ref<boolean>(false);
// 代理商列表(完整列表)
const allAgentList = ref<AgentApi.AgentListItem[]>([]);
@@ -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<string, any>) => {
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({
<Page :auto-content-height="!agentId">
<Grid :table-title="agentId ? '佣金记录列表' : '所有佣金记录'">
<template #toolbar-tools>
<div class="flex items-center gap-2">
<span class="text-sm text-gray-600">选择代理商:</span>
<Select
v-model:value="unfreezeAgentId"
placeholder="全部代理商 / 输入代理ID或手机号"
:allow-clear="true"
:loading="agentList.length === 0"
style="width: 260px"
show-search
:filter-option="false"
:show-arrow="true"
:not-found-content="getNotFoundContent()"
@search="onAgentSearch"
@change="onAgentSelect"
>
<Select.Option
v-for="agent in agentList"
:key="agent.id"
:value="agent.id"
:label="`${agent.real_name || agent.mobile} (ID: ${agent.id})`"
<div class="flex items-center">
<Tooltip placement="top" title="开启后,佣金结算时将先冻结到钱包冻结余额,需要手动解冻才能使用;关闭后,佣金将直接结算到可用余额">
<div class="flex items-center gap-2 mr-4">
<span class="text-sm text-gray-600">安全防御模式:</span>
<Switch
v-model:checked="commissionSafeMode"
:loading="safeModeLoading"
checked-children="开启"
un-checked-children="关闭"
@change="onSafeModeChange"
/>
</div>
</Tooltip>
<div class="w-px h-6 bg-gray-300 mx-2"></div>
<div class="flex items-center gap-2">
<span class="text-sm text-gray-600">选择代理商:</span>
<Select
v-model:value="unfreezeAgentId"
placeholder="全部代理商 / 输入代理ID或手机号"
:allow-clear="true"
:loading="agentList.length === 0"
style="width: 260px"
show-search
:filter-option="false"
:show-arrow="true"
:not-found-content="getNotFoundContent()"
@search="onAgentSearch"
@change="onAgentSelect"
>
{{ agent.real_name || agent.mobile }} (ID: {{ agent.id }})
</Select.Option>
</Select>
<Button type="primary" @click="onBatchUnfreeze">
<span class="mr-1"></span>
一键解冻
</Button>
<Select.Option
v-for="agent in agentList"
:key="agent.id"
:value="agent.id"
:label="`${agent.real_name || agent.mobile} (ID: ${agent.id})`"
>
{{ agent.real_name || agent.mobile }} (ID: {{ agent.id }})
</Select.Option>
</Select>
<Button type="primary" @click="onBatchUnfreeze">
<span class="mr-1"></span>
一键解冻
</Button>
</div>
</div>
</template>
</Grid>