f
This commit is contained in:
@@ -50,6 +50,17 @@ export namespace AgentApi {
|
|||||||
success: boolean;
|
success: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 代理等级降级 */
|
||||||
|
export interface DowngradeAgentParams {
|
||||||
|
agent_id: string;
|
||||||
|
to_level: number;
|
||||||
|
remark?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DowngradeAgentResp {
|
||||||
|
success: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AgentLinkListItem {
|
export interface AgentLinkListItem {
|
||||||
agent_id: number;
|
agent_id: number;
|
||||||
product_id: number;
|
product_id: number;
|
||||||
@@ -597,8 +608,19 @@ async function updateAgentMobile(params: AgentApi.UpdateAgentMobileParams) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理等级降级(管理端)
|
||||||
|
*/
|
||||||
|
async function downgradeAgent(params: AgentApi.DowngradeAgentParams) {
|
||||||
|
return requestClient.post<AgentApi.DowngradeAgentResp>(
|
||||||
|
'/agent/level/downgrade',
|
||||||
|
params,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
auditWithdrawal,
|
auditWithdrawal,
|
||||||
|
downgradeAgent,
|
||||||
generateDiamondInviteCode,
|
generateDiamondInviteCode,
|
||||||
getAgentCommissionList,
|
getAgentCommissionList,
|
||||||
getAgentConfig,
|
getAgentConfig,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export function getUpgradeTypeName(type: number): string {
|
|||||||
const map: Record<number, string> = {
|
const map: Record<number, string> = {
|
||||||
1: '自主付费',
|
1: '自主付费',
|
||||||
2: '钻石升级下级',
|
2: '钻石升级下级',
|
||||||
|
4: '管理端降级',
|
||||||
};
|
};
|
||||||
return map[type] || '未知';
|
return map[type] || '未知';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import LinkModal from './modules/link-modal.vue';
|
|||||||
import MobileEditModal from './modules/mobile-edit-modal.vue';
|
import MobileEditModal from './modules/mobile-edit-modal.vue';
|
||||||
import OrderModal from './modules/order-modal.vue';
|
import OrderModal from './modules/order-modal.vue';
|
||||||
import RebateModal from './modules/rebate-modal.vue';
|
import RebateModal from './modules/rebate-modal.vue';
|
||||||
|
import DowngradeModal from './modules/downgrade-modal.vue';
|
||||||
import UpgradeModal from './modules/upgrade-modal.vue';
|
import UpgradeModal from './modules/upgrade-modal.vue';
|
||||||
import WithdrawalModal from './modules/withdrawal-modal.vue';
|
import WithdrawalModal from './modules/withdrawal-modal.vue';
|
||||||
|
|
||||||
@@ -77,6 +78,12 @@ const [MobileEditModalComponent, mobileEditModalApi] = useVbenModal({
|
|||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 代理降级弹窗
|
||||||
|
const [DowngradeModalComponent, downgradeModalApi] = useVbenModal({
|
||||||
|
connectedComponent: DowngradeModal,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
// 表格配置
|
// 表格配置
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
@@ -147,33 +154,23 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
} as VxeTableGridOptions<AgentApi.AgentListItem>,
|
} as VxeTableGridOptions<AgentApi.AgentListItem>,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 更多操作菜单项
|
// 更多操作菜单项(降级仅黄金代理展示)
|
||||||
const moreMenuItems = [
|
const baseMoreMenuItems = [
|
||||||
{
|
{ key: 'edit-mobile', label: '修改手机号' },
|
||||||
key: 'edit-mobile',
|
{ key: 'links', label: '推广链接' },
|
||||||
label: '修改手机号',
|
{ key: 'rebate', label: '返佣记录' },
|
||||||
},
|
{ key: 'upgrade', label: '升级记录' },
|
||||||
{
|
{ key: 'order', label: '订单记录' },
|
||||||
key: 'links',
|
{ key: 'withdrawal', label: '提现记录' },
|
||||||
label: '推广链接',
|
] as const;
|
||||||
},
|
|
||||||
{
|
function getMoreMenuItems(row: AgentApi.AgentListItem) {
|
||||||
key: 'rebate',
|
const items = [...baseMoreMenuItems];
|
||||||
label: '返佣记录',
|
if (row.level === 2) {
|
||||||
},
|
items.push({ key: 'downgrade', label: '降级为普通代理' });
|
||||||
{
|
}
|
||||||
key: 'upgrade',
|
return items;
|
||||||
label: '升级记录',
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'order',
|
|
||||||
label: '订单记录',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'withdrawal',
|
|
||||||
label: '提现记录',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
// 团队首领信息
|
// 团队首领信息
|
||||||
const teamLeaderId = computed(() => route.query.team_leader_id);
|
const teamLeaderId = computed(() => route.query.team_leader_id);
|
||||||
@@ -236,6 +233,10 @@ function onActionClick(
|
|||||||
onViewWithdrawal(e.row);
|
onViewWithdrawal(e.row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'downgrade': {
|
||||||
|
onDowngrade(e.row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,6 +250,11 @@ function onEditMobile(row: AgentApi.AgentListItem) {
|
|||||||
mobileEditModalApi.setData(row).open();
|
mobileEditModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 代理降级
|
||||||
|
function onDowngrade(row: AgentApi.AgentListItem) {
|
||||||
|
downgradeModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
// 查看推广链接
|
// 查看推广链接
|
||||||
function onViewLinks(row: AgentApi.AgentListItem) {
|
function onViewLinks(row: AgentApi.AgentListItem) {
|
||||||
linkModalApi.setData({ agentId: row.id }).open();
|
linkModalApi.setData({ agentId: row.id }).open();
|
||||||
@@ -290,6 +296,7 @@ function onRefresh() {
|
|||||||
<FormDrawer @success="onRefresh" />
|
<FormDrawer @success="onRefresh" />
|
||||||
<LinkModalComponent />
|
<LinkModalComponent />
|
||||||
<MobileEditModalComponent @success="onRefresh" />
|
<MobileEditModalComponent @success="onRefresh" />
|
||||||
|
<DowngradeModalComponent @success="onRefresh" />
|
||||||
<CommissionModalComponent />
|
<CommissionModalComponent />
|
||||||
<RebateModalComponent />
|
<RebateModalComponent />
|
||||||
<UpgradeModalComponent />
|
<UpgradeModalComponent />
|
||||||
@@ -322,7 +329,10 @@ function onRefresh() {
|
|||||||
<Dropdown>
|
<Dropdown>
|
||||||
<Button type="link">更多操作</Button>
|
<Button type="link">更多操作</Button>
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<Menu :items="moreMenuItems" @click="(e) => onActionClick({ code: String(e.key), row })" />
|
<Menu
|
||||||
|
:items="getMoreMenuItems(row)"
|
||||||
|
@click="(e) => onActionClick({ code: String(e.key), row })"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { AgentApi } from '#/api/agent';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
Modal as AntModal,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { downgradeAgent } from '#/api/agent';
|
||||||
|
import { getLevelName } from '#/utils/agent';
|
||||||
|
|
||||||
|
const { TextArea } = Input;
|
||||||
|
|
||||||
|
/** 黄金代理仅能降为普通 */
|
||||||
|
const targetLevel = 1;
|
||||||
|
|
||||||
|
const rowData = ref<AgentApi.AgentListItem>();
|
||||||
|
const remark = ref('');
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
title: '代理降级',
|
||||||
|
destroyOnClose: true,
|
||||||
|
onOpenChange(isOpen) {
|
||||||
|
if (isOpen) {
|
||||||
|
const data = modalApi.getData<AgentApi.AgentListItem>();
|
||||||
|
if (data?.id != null) {
|
||||||
|
rowData.value = {
|
||||||
|
...data,
|
||||||
|
level: Number(data.level),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
rowData.value = undefined;
|
||||||
|
}
|
||||||
|
remark.value = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
success: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const impactTips = [
|
||||||
|
'仅降低代理等级,不会自动退还历史升级费用或收回已发返佣。',
|
||||||
|
'若存在等级高于目标等级的直接下级,将无法降级。',
|
||||||
|
'钻石代理不允许降级。',
|
||||||
|
];
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
const row = rowData.value;
|
||||||
|
if (!row?.id) {
|
||||||
|
message.warning('未获取到代理信息,请关闭后重试');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const level = Number(row.level);
|
||||||
|
if (level === 3) {
|
||||||
|
message.warning('钻石代理不允许降级');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (level !== 2) {
|
||||||
|
message.warning('当前等级不支持降级');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AntModal.confirm({
|
||||||
|
title: '确认降级',
|
||||||
|
content: `确定将「${row.mobile || row.id}」从${getLevelName(level)}降为${getLevelName(targetLevel)}吗?`,
|
||||||
|
okText: '确认降级',
|
||||||
|
okType: 'danger',
|
||||||
|
cancelText: '取消',
|
||||||
|
async onOk() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
await downgradeAgent({
|
||||||
|
agent_id: String(row.id),
|
||||||
|
to_level: targetLevel,
|
||||||
|
remark: remark.value?.trim() || undefined,
|
||||||
|
});
|
||||||
|
message.success('降级成功');
|
||||||
|
emit('success');
|
||||||
|
modalApi.close();
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal width="480px">
|
||||||
|
<div class="py-2">
|
||||||
|
<Alert
|
||||||
|
type="warning"
|
||||||
|
show-icon
|
||||||
|
class="mb-4"
|
||||||
|
message="降级说明"
|
||||||
|
>
|
||||||
|
<template #description>
|
||||||
|
<ul class="mb-0 list-disc pl-4">
|
||||||
|
<li v-for="(tip, index) in impactTips" :key="index">
|
||||||
|
{{ tip }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
|
</Alert>
|
||||||
|
<Form layout="vertical">
|
||||||
|
<Form.Item label="代理ID">
|
||||||
|
<Input :value="rowData?.id" disabled />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="当前等级">
|
||||||
|
<Input
|
||||||
|
:value="rowData ? getLevelName(Number(rowData.level)) : ''"
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="目标等级">
|
||||||
|
<Input :value="getLevelName(targetLevel)" disabled />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="备注">
|
||||||
|
<TextArea
|
||||||
|
v-model:value="remark"
|
||||||
|
placeholder="选填,将写入等级变更记录"
|
||||||
|
:rows="3"
|
||||||
|
allow-clear
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<Button @click="modalApi.close()">取消</Button>
|
||||||
|
<Button type="primary" danger :loading="loading" @click="handleSubmit">
|
||||||
|
确认降级
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
@@ -95,6 +95,7 @@ export function useUpgradeFormSchema(): VbenFormSchema[] {
|
|||||||
options: [
|
options: [
|
||||||
{ label: '自主付费', value: 1 },
|
{ label: '自主付费', value: 1 },
|
||||||
{ label: '钻石升级下级', value: 2 },
|
{ label: '钻石升级下级', value: 2 },
|
||||||
|
{ label: '管理端降级', value: 4 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user