This commit is contained in:
李远 2026-03-13 18:44:53 +08:00
parent 76ca0186dd
commit 27be2e59ca
23 changed files with 895 additions and 99 deletions

View File

@ -0,0 +1,23 @@
import { request } from '@/api';
import type { searchParams, pointDiffConfigParams } from '@/api/types/account/agent'
// 获取代理列表
export async function getAgentListApi(params: searchParams): Promise<any> {
return request.get<any>('/agent/getAgentList2', { ...params })
}
//获取代理点差配置
export async function getPointDiffConfigApi(params: pointDiffConfigParams): Promise<any> {
return request.get<any>('/agent/getSelfVarietyPointDiffConfig',{...params})
}
//获取风控模板选项
export async function getRiskTemplateOptionsApi(): Promise<any> {
return request.get<any>('/agent/getRiskControlOptions')
}
//获取手续费模板选项
export async function getFeeTemplateOptionsApi(): Promise<any> {
return request.get<any>('user/getFeeSettingOptions')
}
//编辑代理点差
export async function editPointDiffConfigApi(params: pointDiffConfigParams): Promise<any> {
return request.post<any>('/agent/editAgent',{...params})
}

View File

@ -1,8 +1,8 @@
import { request } from '@/api';
import type { accountSearchParams, accountListResponse, accountCreateParams } from '@/api/types/account'
import type { searchParams, accountListResponse, accountCreateParams } from '@/api/types/account/client'
// 获取客户列表
export async function getClientListApi(params: accountSearchParams): Promise<accountListResponse> {
export async function getClientListApi(params: searchParams): Promise<accountListResponse> {
return request.get<accountListResponse>('/user/getUserList', { ...params })
}

View File

@ -0,0 +1,12 @@
import { request } from '@/api';
import type{ searchParams,pointDiffConfigParams } from '@/api/types/account/market'
// 查询做市商列表
export async function getMarketListApi(params: searchParams): Promise<any> {
return request.get<any>('agent/getAgentList', { ...params })
}
//获取代理点差配置
export async function getPointDiffConfigApi(params: pointDiffConfigParams): Promise<any> {
return request.get<any>('/agent/getSelfVarietyPointDiffConfig',{...params})
}

View File

@ -3,7 +3,7 @@ import type {
MenuFormParams,
DeleteMenuParams,
MenuListResponse
} from '@/api/types/menu';
} from '@/api/types/system/menu';
/**
*

View File

@ -6,7 +6,7 @@ import type {
GetRolePermissionParams,
RoleListResponse,
PermissionIdsResponse
} from '@/api/types/role';
} from '@/api/types/system/role';
/**
*

View File

@ -1,11 +1,5 @@
/**
* @description
* @param {accountSearchParams} params -
* @response {accountListResponse}
*
*/
// 客户列表查询参数
export interface accountSearchParams {
// 通用查询参数
export interface searchParams {
page?: number
page_size?: number
username?: string
@ -14,6 +8,14 @@ export interface accountSearchParams {
reg_end_time?: string
}
/**
* @description
* @param {accountSearchParams} params -
* @response {accountListResponse}
*
*/
// 定义列表项的类型
interface UserItem {
id: number;
@ -33,6 +35,7 @@ export interface accountListResponse {
data: UserItem[];
total: number;
per_page: number;
current_page: number;
}
/**
@ -53,3 +56,8 @@ export interface accountCreateParams {
is_levelup?: number;
status?: number;
}
//获取代理点差配置
export interface pointDiffConfigParams {
user_id: number | string
}

16
src/api/types/account/agent.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
// 通用查询参数
export interface searchParams {
page?: number
page_size?: number
username?: string
status?: string | number
reg_start_time?: string
reg_end_time?: string
user_name?: string
}
//获取代理点差配置
export interface pointDiffConfigParams {
user_id: number | string
}

58
src/api/types/account/client.d.ts vendored Normal file
View File

@ -0,0 +1,58 @@
// 通用查询参数
export interface searchParams {
page?: number
page_size?: number
username?: string
status?: string | number
reg_start_time?: string
reg_end_time?: string
}
/**
* @description
* @param {accountSearchParams} params -
* @response {accountListResponse}
*
*/
// 定义列表项的类型
interface UserItem {
id: number;
username: string;
par_uid: number;
created_at: string; // 时间字符串类型
status: number;
parent: ParentUser; // 嵌套的父级用户对象
}
// 定义完整响应数据的类型
interface UserResponse {
data: UserItem[]; // 数据是 UserItem 类型的数组
}
export interface accountListResponse {
data: UserItem[];
total: number;
per_page: number;
current_page: number;
}
/**
* @description
* @param {accountCreateParams} params -
* @response {void}
*/
// 客户创建类型
export interface accountCreateParams {
reg_type?: number
email?: string
mobile?: string
parent_id?: number | string
fee_setting_id?: number | string
risk_control_id?: number | string
user_id?: string;
username?: string;
is_levelup?: number;
status?: number;
}

8
src/api/types/account/market.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
// 查询参数
export interface searchParams {
user_name?: string
}
//获取代理点差配置
export interface pointDiffConfigParams {
user_id: number | string
}

View File

@ -1,4 +1,4 @@
import type { ApiResponse } from './index';
import type { ApiResponse } from '../index';
/** 菜单基础参数类型(新增/编辑通用) */
export interface MenuFormParams {

View File

@ -1,4 +1,4 @@
import type { ApiResponse } from './index';
import type { ApiResponse } from '../index';
// 角色基础参数(创建/编辑通用)
export interface RoleFormParams {

View File

@ -1,9 +1,8 @@
<template>
<div class="pagination-container">
<el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="pageSizes"
:total="total" :disabled="disabled" :background="background" :small="small"
:hide-on-single-page="hideOnSinglePage" :layout="layout" @size-change="handleSizeChange"
@current-change="handleCurrentChange" />
:total="total" :disabled="disabled" :background="background" size="small" :layout="layout"
@size-change="handleSizeChange" @current-change="handleCurrentChange" />
</div>
</template>
@ -32,7 +31,7 @@ const props = defineProps({
//
pageSizes: {
type: Array,
default: () => [10, 20, 50, 100]
default: () => [1, 10, 20, 50, 100] as unknown[]
},
//
disabled: {
@ -44,16 +43,6 @@ const props = defineProps({
type: Boolean,
default: true
},
//
small: {
type: Boolean,
default: false
},
//
hideOnSinglePage: {
type: Boolean,
default: true
},
// Element Plus
layout: {
type: String,
@ -112,5 +101,6 @@ const handleCurrentChange = (val: number) => {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
}
</style>

View File

@ -44,4 +44,11 @@ const props = withDefaults(defineProps<Props>(), {
border: true,
highlightCurrentRow: true,
})
</script>
</script>
<style scoped lang="scss">
.table-container {
max-height: calc(100vh - 180px);
overflow: auto;
}
</style>

View File

@ -115,7 +115,7 @@ const staticMenuList = ref<ElMenuItem[]>(
{
id: 33,
label: '做市商管理',
path: '3-3', // index="3-3"
path: '/account/market-maker', // index="3-3"
icon: ''
}
]

View File

@ -110,6 +110,14 @@ const routes = [
meta: {
title: '代理管理', // 左侧菜单显示的标题
}
},
{
path: 'market-maker',
name: 'MarketMaker',
component: () => import('@/views/account/market-maker/index.vue'),
meta: {
title: '做市商管理', // 左侧菜单显示的标题
}
}
]
},

View File

@ -4,19 +4,29 @@
@reset="handleReset">
</AgentSearch>
<AgentTable :table-data="agentTree" :columns="agentTableColumnsOptions" row-key="id" />
<AgentTable :table-data="agentTree" :columns="agentTableColumnsOptions" row-key="id">
<template #status="{ row }">
<el-switch :model-value="row.status === 1" :active-value="true" :inactive-value="false" active-text="启用"
inactive-text="禁用" />
</template>
<template #pointDifference="{ row }">
<el-button type="primary" size="small" @click="handlePointDifference(row)">
查看
</el-button>
</template>
<template #edit="{ row }">
<el-button type="primary" size="small" @click="handleEdit(row)">
编辑
</el-button>
</template>
</AgentTable>
<AgentPagination v-model="agentSearchForm.page" v-model:page-size-value="agentSearchForm.pageSize"
:total="agentSearchForm.total" @pagination-change="handlePaginationChange" />
<AgentDialog :visible="dialogVisible" :title="dialogTitle" :type="dialogType" :fullscreen="true"
@cancel="handleCancel" @close="handleClose">
<template #header>
<div class="dialog-header">
<span class="dialog-title">查看点差</span>
<span class="dialog-close-text" @click="dialogVisible = false">关闭</span>
</div>
</template>
<AgentDialog :visible="dialogVisible" :title="dialogTitle" :type="dialogType" :fullscreen="dialogFullscreen" @submit="handleSubmit"
@cancel="handleCancel" @close="handleClose" :class="{ 'edit-dialog': isEdit }">
<AgentForm :form-data="agentForm" :form-rules="agentFormRules" :form-items="agentFormItems"
:options-map="agentFormOptionsMap" v-if="isEdit" />
<AgentTable :table-data="agentPointTree" :columns="agentPointTableColumnsOptions" row-key="id" />
</AgentDialog>
</div>
@ -27,9 +37,13 @@ import AgentSearch from '@/components/common/Search.vue'
import AgentTable from '@/components/common/Table.vue'
import AgentPagination from '@/components/common/Pagination.vue'
import AgentDialog from '@/components/common/Dialog.vue'
import AgentForm from '@/components/common/Form.vue'
//
import { getAgentListApi, getPointDiffConfigApi, getRiskTemplateOptionsApi, getFeeTemplateOptionsApi,editPointDiffConfigApi } from '@/api/modules/account/agent'
//
import { agentSearch, agentTableColumns, agentPointTableColumns } from './options'
import { agentSearch, agentTableColumns, agentPointTableColumns, PointDiffFormItem } from './options'
//
const agentSearchOptions = ref(agentSearch)
@ -39,7 +53,7 @@ const agentSearchForm = ref({
startDateTime: '',
endDateTime: '',
page: 1,
pageSize: 10,
pageSize: 100,
total: 100,
})
@ -48,12 +62,266 @@ const agentTree = ref<any[]>([])
const agentTableColumnsOptions = ref(agentTableColumns)
//
const dialogVisible = ref(true)
const dialogVisible = ref(false)
const dialogTitle = ref('查看点差')
const dialogFullscreen = ref(false)
const dialogType = ref('add')
const dialogWidth = ref('100%')
const agentPointTree = ref<any[]>([])
const agentPointTableColumnsOptions = ref(agentPointTableColumns)
//
const isEdit = ref(false)
const agentFormItems = ref(PointDiffFormItem)
const agentFormRules = ref({
username: [{ required: true, message: '请输入代理名称', trigger: ['blur'] }],
parentUsername: [{ required: true, message: '请输入所属上级', trigger: ['blur'] }],
feeRate: [{ required: true, message: '请输入手续费', trigger: ['blur'] }],
riskTemplate: [{ required: true, message: '请选择风控模板', trigger: ['change'] }],
feeTemplate: [{ required: true, message: '请选择手续费模板', trigger: ['change'] }],
})
const agentForm = ref({
username: '',
parentUsername: '',
feeRate: '',
riskTemplate: '',
feeTemplate: '',
})
const agentFormOptionsMap = ref<any>({
riskTemplate: [],
feeTemplate: [],
})
/**
* @description 统一获取数据
*/
/**
* 处理字符串数值转数字 + 相加 + 保留五位小数
* @param {Array<string>} strNums - 待处理的字符串数值数组 ["0.00000", "0.00000"]
* @returns {number} 相加后保留五位小数的数字最终结果
*/
function sumStrNumsWith5Decimals(strNums: string[]) {
// 1.
let total = 0;
// 2.
strNums.forEach(strNum => {
// /0
const num = parseFloat(strNum) || 0;
total += num;
});
// 3.
const result = parseFloat(total.toFixed(5));
return result;
}
//
const mapObjectToOptions = (obj: Record<string, string>) => {
console.log('obj', obj)
return Object.entries(obj).map(([label, value]) => ({
label, // /
value // /ID
}))
}
//
const fetchAgentList = async () => {
const params = {
page: agentSearchForm.value.page,
page_size: agentSearchForm.value.pageSize,
user_name: agentSearchForm.value.username,
reg_start_time: agentSearchForm.value.startDateTime.length > 0 ? `${agentSearchForm.value.startDateTime} 0:00:00` : '',
reg_end_time: agentSearchForm.value.endDateTime.length > 0 ? `${agentSearchForm.value.endDateTime} 23:59:59` : '',
}
try {
const data = await getAgentListApi(params)
//
agentSearchForm.value.total = data.total || 0
agentSearchForm.value.pageSize = Number(data.per_page) || 0
//
agentTree.value = data.data.map((item: any) => {
//item
const walletNums = [
// undefined
item.wallet_capital?.commission_fee_handling || '0.00000',
item.wallet_capital?.commission_point_diff || '0.00000'
];
//
const rebateTotalAmount = sumStrNumsWith5Decimals(walletNums);
return {
...item,
createTime: item.created_at || '',
feeRate: item.wallet_capital.fee_handling_percent,
rebateRate: item.wallet_capital.commission_fee_handling,
pointDifference: item.wallet_capital.commission_point_diff,
rebateTotalAmount: rebateTotalAmount,
clientCount: item.son_user.length,
level: item.role.title,
parentUsername: item.par_uid === item.parent.id ? item.parent.username : '',
}
})
} catch (err) {
console.error('获取代理列表失败', err)
}
}
//
const fetchAgentPointDiffConfig = async (id: number | string) => {
console.log(id)
const params = {
user_id: id
}
try {
const data = await getPointDiffConfigApi(params)
//
agentPointTree.value = data.data.map((item: any) => ({
...item,
varietyName: item.name,
varietyCode: item.code,
pointDifference: item.point_diff,
assignedPointDifference: item.target_point_diff
}))
} catch (err) {
console.error('获取代理点差配置失败', err)
}
}
//
const optionsFetched = ref(false)
const getOptions = async () => {
//
if (optionsFetched.value) return
try {
const [riskTemplateRes, feeTemplateRes] = await Promise.all([
getRiskTemplateOptionsApi(), // riskTemplateRes
getFeeTemplateOptionsApi(), // feeTemplateRes
])
console.log('获取表单选项:', riskTemplateRes, feeTemplateRes)
// label=value=ID
agentFormOptionsMap.value.riskTemplate = mapObjectToOptions(feeTemplateRes as Record<string, string>)
agentFormOptionsMap.value.feeTemplate = riskTemplateRes.map((item: any) => ({
label: item.name,
value: item.id
}))
optionsFetched.value = true //
} catch (error) {
console.error('获取表单选项失败:', error)
}
}
/**
* @description 页面加载完成后获取数据
*/
onMounted(() => {
fetchAgentList()
})
/**
* @description 搜索方法
*/
const handleSearch = () => {
fetchAgentList()
}
const handleReset = () => {
//
agentSearchForm.value = {
username: '',
status: '正常',
startDateTime: '',
endDateTime: '',
page: 1,
pageSize: 10,
total: 100,
}
fetchAgentList()
}
const handleDialogType = (type: string) => {
console.log('handleDialogType', type)
if (type === 'edit') {
isEdit.value = true
dialogFullscreen.value = false
} else {
isEdit.value = false
dialogFullscreen.value = true
}
}
/**
* @description 查看点差方法
*/
const handlePointDifference = (row: any) => {
dialogVisible.value = true
dialogTitle.value = '查看点差'
dialogType.value = 'view'
handleDialogType(dialogType.value)
console.log(dialogType.value)
fetchAgentPointDiffConfig(row.id)
}
/**
* @description 编辑方法
*/
const handleEdit = (row: any) => {
dialogVisible.value = true
dialogTitle.value = '编辑点差'
dialogType.value = 'edit'
dialogFullscreen.value = false
handleDialogType(dialogType.value)
console.log(dialogType.value)
getOptions()
// fetchAgentPointDiffConfig(row.id)
}
/**
* @description 分页方法
*/
const handlePaginationChange = (page: { currentPage: number, pageSize: number }) => {
agentSearchForm.value.page = page.currentPage
agentSearchForm.value.pageSize = page.pageSize
handleSearch()
}
/**
* @description dialog方法
*/
const handleSubmit = async () => {
if (dialogType.value === 'edit') {
const params = {
user_id: "",
toucun_percent: "",
point_diffs_json: "",
fee_handling_percent: "",
}
await editPointDiffConfigApi(params)
await fetchAgentList()
dialogVisible.value = false
} else {
}
}
//
const handleCancel = () => {
dialogVisible.value = false
dialogType.value = 'view'
}
//
const handleClose = () => {
dialogVisible.value = false
dialogType.value = 'view'
}
</script>
<style scoped lang="scss">
@ -63,5 +331,11 @@ const agentPointTableColumnsOptions = ref(agentPointTableColumns)
display: none;
}
}
:deep(.edit-dialog) {
.el-dialog__footer {
display: block;
}
}
}
</style>

View File

@ -25,17 +25,19 @@ export const agentSearch = [
// 定义表格列配置
export const agentTableColumns = [
{ prop: 'id', label: 'ID', align: 'center' as const },
{ prop: 'id', label: 'ID', align: 'center' as const, width: '80px' },
{ prop: 'username', label: '代理名称', align: 'center' as const },
{ prop: 'registerTime', label: '注册时间', align: 'center' as const },
{ prop: 'status', label: '状态', align: 'center' as const },
{ prop: 'pointDifference', label: '点差', align: 'center' as const },
{ prop: 'createTime', label: '注册时间', align: 'center' as const },
{ slotName: 'status', label: '状态', align: 'center' as const },
{ prop: 'feeRate', label: '手续费', align: 'center' as const },
{ prop: 'rebateRate', label: '手续费返佣', align: 'center' as const },
{ prop: 'pointDifference2', label: '点差', align: 'center' as const },
{ prop: 'pointDifference', label: '点差返佣', align: 'center' as const },
{ slotName: 'pointDifference', label: '点差', align: 'center' as const },
{ prop: 'rebateTotalAmount', label: '返佣总金额', align: 'center' as const },
{ prop: 'clientCount', label: '客户数量', align: 'center' as const },
{ prop: 'level', label: '级别', align: 'center' as const },
{ prop: 'parentUsername', label: '所属上级', align: 'center' as const },
{ slotName: 'edit', label: '编辑', align: 'center' as const },
]
@ -46,3 +48,17 @@ export const agentPointTableColumns = [
{ prop: 'pointDifference', label: '可用点差', align: 'center' as const },
{ prop: 'assignedPointDifference', label: '已分配点差', align: 'center' as const },
]
//编辑点差form配置
export const PointDiffFormItem = [
//代理名称
{ prop: 'username', label: '代理名称', type: 'input' as const, placeholder: '代理名称', width: '120px' },
//所属上级
{ prop: 'parentUsername', label: '所属上级', type: 'input' as const, placeholder: '所属上级', width: '120px' },
//手续费
{ prop: 'feeRate', label: '手续费', type: 'input' as const, placeholder: '手续费', width: '120px' },
//风控模板
{ prop: 'riskTemplate', label: '风控模板', type: 'select' as const, placeholder: '风控模板', width: '120px' },
//手续费模板
{ prop: 'feeTemplate', label: '手续费模板', type: 'select' as const, placeholder: '手续费模板', width: '120px' },
]

View File

@ -20,8 +20,8 @@
</el-button>
</template>
</ClientTable>
<ClientPagination v-model="currentPage" v-model:page-size-value="pageSize" :total="total"
@pagination-change="handlePaginationChange" />
<ClientPagination :modelValue="clientSearchForm.currentPage" :pageSizeValue="clientSearchForm.pageSize"
:total="total" @pagination-change="handlePaginationChange" />
</div>
<!-- 客户弹窗 -->
<ClientDialog :visible="dialogVisible" :title="dialogTitle" :type="dialogType" @confirm="handleSubmit"
@ -79,8 +79,8 @@ import { rules } from './rules'
//
const clientSearchOptions = ref(clientSearch)
const clientSearchForm = ref({
page: 1,
pageSize: 10,
currentPage: 1,
pageSize: 1,
username: '',
status: '正常',
startDateTime: '',
@ -91,12 +91,11 @@ const clientSearchForm = ref({
const clientTree = ref<any[]>([])
const treeProps = ref({
children: 'parent',
label: 'username'
})
//
const total = ref(0)
const pageSize = ref(1)
const currentPage = ref(1)
// dialog
const dialogTitle = ref('')
@ -136,6 +135,7 @@ interface ClientFormOptionsMap {
riskTemplate: FormOption[];
agentUsername: FormOption[];
isUpgrade: FormOption[];
status: FormOption[];
}
const clientFormOptionsMap = ref<ClientFormOptionsMap>({
feeTemplate: [],
@ -145,12 +145,16 @@ const clientFormOptionsMap = ref<ClientFormOptionsMap>({
{ label: '是', value: 1 },
{ label: '否', value: 2 }
],
status: [
{ label: '正常', value: 1 },
{ label: '禁用', value: 2 }
],
})
//
const fetchClientList = async () => {
const params = {
page: clientSearchForm.value.page,
page: clientSearchForm.value.currentPage,
page_size: clientSearchForm.value.pageSize,
username: clientSearchForm.value.username,
status: clientSearchForm.value.status === '正常' ? 1 : 2,
@ -163,12 +167,12 @@ const fetchClientList = async () => {
//
agentUsername: item.par_uid === item.parent?.id ? item.parent?.username : '',
}));
//
total.value = data.total; //
pageSize.value = Number(data.per_page); //
//
total.value = Number(data.total)
clientSearchForm.value.currentPage = Number(data.current_page)
clientSearchForm.value.pageSize = Number(data.per_page)
}
onMounted(async () => {
console.log('客户列表', clientTree.value)
await fetchClientList()
})
/**
@ -179,7 +183,6 @@ onMounted(async () => {
const handleSearch = async () => {
try {
await fetchClientList()
console.log('客户列表', clientSearchForm.value)
} catch (err) {
console.error('获取客户列表失败', err)
}
@ -188,13 +191,14 @@ const handleSearch = async () => {
//
const handleReset = () => {
clientSearchForm.value = {
page: 1,
pageSize: 10,
currentPage: 1,
pageSize: 1,
username: '',
status: '正常',
startDateTime: '',
endDateTime: '',
}
fetchClientList() //
}
//
@ -202,26 +206,36 @@ const handleDialogType = (type: string) => {
clientFormOptions.value = type === 'add' ? clientAddFormItem : clientChangeFormItem
}
//
const mapObjectToOptions = (obj: Record<string, string>) => {
return Object.entries(obj).map(([label, value]) => ({
label, // /
value // /ID
}))
}
//
const optionsFetched = ref(false)
const getOptions = async () => {
//
if (optionsFetched.value) return
try {
//
const [agentRes, feeTemplateRes, riskTemplateRes] = await Promise.all([
getAgentOptionsApi(),
getFeeTemplateOptionsApi(),
getRiskTemplateOptionsApi()
]);
])
const agentOptions = mapObjectToOptions(agentRes as Record<string, string>);
const feeTemplateOptions = mapObjectToOptions(feeTemplateRes as Record<string, string>);
const riskTemplateOptions = mapObjectToOptions(riskTemplateRes as Record<string, string>);
// label=value=ID
clientFormOptionsMap.value.agentUsername = mapObjectToOptions(agentRes as Record<string, string>)
clientFormOptionsMap.value.feeTemplate = mapObjectToOptions(feeTemplateRes as Record<string, string>)
clientFormOptionsMap.value.riskTemplate = mapObjectToOptions(riskTemplateRes as Record<string, string>)
//
clientFormOptionsMap.value.agentUsername = agentOptions;
clientFormOptionsMap.value.feeTemplate = feeTemplateOptions;
clientFormOptionsMap.value.riskTemplate = riskTemplateOptions;
optionsFetched.value = true //
} catch (error) {
console.error('获取表单选项失败:', error);
console.error('获取表单选项失败:', error)
ElMessage.error('获取表单选项失败,请稍后重试')
}
}
@ -252,8 +266,9 @@ const handleChange = async (row: any) => {
}
//
const handlePaginationChange = (page: number) => {
clientSearchForm.value.page = page
const handlePaginationChange = (page: { currentPage: number, pageSize: number }) => {
clientSearchForm.value.currentPage = page.currentPage
clientSearchForm.value.pageSize = page.pageSize
handleSearch()
}
@ -261,15 +276,6 @@ const handlePaginationChange = (page: number) => {
* @description: dialog事件
*/
//
const mapObjectToOptions = (obj: Record<string, string>) => {
return Object.entries(obj).map(([label, value]) => ({
label: label, //
value: value // ID
}));
}
//
const handleAdd = async () => {
dialogVisible.value = true
@ -296,7 +302,6 @@ const handleSubmit = async () => {
await fetchClientList()
dialogVisible.value = false
} else {
console.log('编辑客户', clientForm.value)
const params = {
user_id: clientForm.value.id,
risk_control_id: clientForm.value.riskTemplate,

View File

@ -55,7 +55,7 @@ export const clientTableColumns = [
{ prop: 'created_at', label: '注册时间', align: 'center' as const },
{ prop: 'agentUsername', label: '所属代理', align: 'center' as const },
{ label: '状态', slotName: 'status', align: 'center' as const },
{ label: '操作', slotName: 'action', align: 'center' as const }
{ label: '操作', slotName: 'action', align: 'center' as const }
]
//定义添加客户form配置
@ -65,7 +65,7 @@ export const clientAddFormItem = [
{ prop: 'feeTemplate', label: '手续费模板', type: 'select' as const, placeholder: '选择手续费模板' },
{ prop: 'riskTemplate', label: '风控模板', type: 'select' as const, placeholder: '选择风控模板' },
{ prop: 'agentUsername', label: '所属上级', type: 'select' as const, placeholder: '所属上级' },
{ prop: 'phoneOrEmail', label: '', type: 'slot' as const, slotName: 'phoneOrEmail'},
{ prop: 'phoneOrEmail', label: '', type: 'slot' as const, slotName: 'phoneOrEmail' },
]
//定义修改客户form配置
@ -74,20 +74,21 @@ export const clientChangeFormItem = [
{ prop: 'riskTemplate', label: '风控模板', type: 'select' as const, placeholder: '选择风控模板' },
{ prop: 'changeName', label: '客户名称', type: 'input' as const, placeholder: '客户名称' },
{ prop: 'isUpgrade', label: '是否升级为代理', type: 'radio' as const, placeholder: '是否升级为代理', labelWidth: '140px' },
{ prop: 'status', label: '选择状态', type: 'radio' as const, placeholder: '请选择状态', labelWidth: '140px' },
]
// 国家码选项
interface CountryItem {
name: string
code: string
name: string
code: string
}
export const countryOptions = ref<CountryItem[]>([
{ name: '中国', code: '+86' },
{ name: '中国台湾', code: '+886' },
{ name: '中国香港', code: '+852' },
{ name: '中国澳门', code: '+853' },
{ name: '韩国', code: '+82' },
{ name: '美国', code: '+1' },
{ name: '新加坡', code: '+65' }
{ name: '中国', code: '+86' },
{ name: '中国台湾', code: '+886' },
{ name: '中国香港', code: '+852' },
{ name: '中国澳门', code: '+853' },
{ name: '韩国', code: '+82' },
{ name: '美国', code: '+1' },
{ name: '新加坡', code: '+65' }
])

View File

@ -27,6 +27,10 @@ export const rules = (): FormRules => {
isUpgrade: [
{ required: true, message: '请选择是否升级为代理', trigger: ['blur'] },
],
//选择状态
status: [
{ required: true, message: '请选择状态', trigger: ['blur'] },
],
//客户名称
changeName: [
{ required: true, message: '请输入客户名称', trigger: ['blur'] },

View File

@ -1,5 +1,307 @@
<template>
<div>
<h1>做市商管理</h1>
<div class="market">
<MarketSearch :search-form="marketSearchForm" :search-options="marketSearchOptions" @search="handleSearch"
@reset="handleReset">
<template #button="{ form }">
<el-button type="primary" @click="handleAddAgent()">
添加代理
</el-button>
<el-button type="primary" @click="handleEditAgent(row)">
编辑
</el-button>
</template>
</MarketSearch>
<MarketTable :table-data="marketTree" :columns="marketTableColumnsOptions" row-key="id">
<template #pointSpread="{ row }">
<el-button type="primary" size="small" @click="handleViewPointDiff(row)">
查看
</el-button>
</template>
</MarketTable>
<AgentPagination v-model="marketSearchForm.page" v-model:page-size-value="marketSearchForm.pageSize"
:total="marketSearchForm.total" @pagination-change="handlePaginationChange" />
<MarketDialog :visible="dialogVisible" :title="dialogTitle" :type="dialogType" @submit="handleSubmit"
@cancel="handleCancel" @close="handleClose" :fullscreen="dialogFullscreen"
:class="{ isAddOrEdit: 'isAddOrEdit-dialog' }">
<MarketForm :form-data="marketForm" :form-rules="marketFormRules" :form-items="marketFormItemOptions"
:options-map="marketFormOptionsMap" v-if="isAddOrEdit" />
<MarketTable :table-data="marketPointTree" :columns="marketPointTableColumnsOptions" row-key="id" />
</MarketDialog>
</div>
</template>
<script lang="ts" setup>
//
import MarketSearch from '@/components/common/Search.vue'
import MarketTable from '@/components/common/Table.vue'
import MarketPagination from '@/components/common/Pagination.vue'
import MarketDialog from '@/components/common/Dialog.vue'
import MarketForm from '@/components/common/Form.vue'
//
import { getMarketListApi, getPointDiffConfigApi } from '@/api/modules/account/market'
//
import { marketSearch, marketTableColumns, marketFormItem, marketPointTableColumns } from './options'
/**
* @description 搜索配置
*/
const marketSearchForm = ref<any>({
accountName: '',
page: 1,
pageSize: 10,
})
const marketSearchOptions = ref<any>(marketSearch)
/**
* @description 表格配置
*/
const marketTableColumnsOptions = ref<any>(marketTableColumns)
const marketTree = ref<any>([
{
id: 1,
agentRelation: "一级代理", //
accountName: "代理001", //
level: "一级", //
basicAccount: "500000.00", //
margin: "100000.00", //
stopOrderMargin: "50000.00", //
positionTransferMargin: "30000.00", //
pointSpreadCommission: "8520.68", //
pointSpread: "0.58", //
commissionRatio: "0.05%", //
commissionReturn: "4260.34", //
closeProfitLoss: "12850.72", //
riskMargin: "20000.00", //
serviceFee: "1500.00" //
},
{
id: 2,
agentRelation: "二级代理", //
accountName: "代理002", //
level: "二级", //
basicAccount: "200000.00", //
margin: "50000.00", //
stopOrderMargin: "20000.00", //
positionTransferMargin: "10000.00", //
pointSpreadCommission: "3680.25", //
pointSpread: "0.32", //
commissionRatio: "0.03%", //
commissionReturn: "1104.08", //
closeProfitLoss: "4820.15", //
riskMargin: "8000.00", //
serviceFee: "600.00" //
}
])
/**
* @description 分页配置
*/
const total = ref<number>(0)
/**
* @description dialog配置
*/
const dialogVisible = ref<boolean>(false)
const dialogTitle = ref<string>('')
const dialogType = ref<string>('add')
const dialogFullscreen = ref(false)
/**
* @description 点差表格配置
*/
const marketPointTree = ref<any>([])
const marketPointTableColumnsOptions = ref<any>(marketPointTableColumns)
/**
* @description 表单数据
*/
const isAddOrEdit = ref<boolean>(false)
const marketForm = ref<any>({
accountName: '',
level: '',
parentAccountName: '',
position: '',
commissionRatio: '',
})
const marketFormItemOptions = ref<any>(marketFormItem)
const marketFormRules = ref<any>()
const marketFormOptionsMap = ref<any>({
})
/**
* @description 统一获取数据
*/
//
const fetchMarketList = async () => {
const params = {
page: marketSearchForm.value.page,
page_size: marketSearchForm.value.pageSize,
user_name: marketSearchForm.value.accountName
}
const data = await getMarketListApi(params)
//
marketTree.value = data.data.map((item: any) => ({
...item,
agentRelation: item.path_name || '--', //
accountName: item.username || '', //
level: item.role_id || '', // role_id 1-> 2->
basicAccount: item.wallet_capital?.amount || '0.00000', //
margin: item.wallet_capital?.bail || '0.00000', //
stopOrderMargin: item.wallet_capital?.bail_stop_order || '0.00000', //
positionTransferMargin: item.wallet_capital?.bail_change_order || '0.00000', //
pointSpreadCommission: item.wallet_capital?.commission_point_diff || '0.00000', //
commissionRatio: item.wallet_capital?.toucun_percent || '0.00000', //
commissionReturn: item.wallet_capital?.commission_fee_handling || '0.00000', //
closeProfitLoss: item.wallet_capital?.closing_profit || '0.00000', //
riskMargin: item.wallet_capital?.risk || '0.00000', //
serviceFee: item.wallet_capital?.service || '0.00000' //
}))
//
total.value = Number(data.total)
marketSearchForm.value.page = Number(data.current_page)
marketSearchForm.value.pageSize = Number(data.per_page)
}
//
const fetchPointDiffConfig = async () => {
const params = {
user_id: marketForm.value.id
}
const data = await getPointDiffConfigApi(params)
}
/**
* @description 组件挂载时获取数据
*/
onMounted(() => {
fetchMarketList()
})
/**
* @description 搜索
*/
const handleSearch = async () => {
await fetchMarketList()
}
const handleReset = () => {
marketSearchForm.value.accountName = ''
handleSearch()
}
/**
* @description 处理弹窗类型
*/
const handleDialogType = (type: string) => {
console.log('handleDialogType', type)
if (type === 'add') {
isAddOrEdit.value = true
} else {
isAddOrEdit.value = false
}
}
/**
* @description 新增做市商
*/
const handleAddAgent = () => {
dialogVisible.value = true
dialogTitle.value = '新增做市商'
dialogType.value = 'add'
handleDialogType(dialogType.value)
}
/**
* @description 编辑做市商
*/
const handleEditAgent = (row: any) => {
dialogVisible.value = true
dialogTitle.value = '编辑做市商'
dialogType.value = 'edit'
marketForm.value = { ...row }
handleDialogType(dialogType.value)
}
/**
* @description 查看点差
*/
const handleViewPointDiff = (row: any) => {
dialogVisible.value = true
dialogTitle.value = '查看点差'
dialogType.value = 'view'
handleDialogType(dialogType.value)
}
/**
* @description 分页变更
*/
const handlePaginationChange = (params: any) => {
marketSearchForm.value.page = params.currentPage
marketSearchForm.value.pageSize = params.pageSize
handleSearch()
}
/**
* @description 提交表单
*/
const handleSubmit = async () => {
if (dialogType.value === 'add') {
} else if (dialogType.value === 'edit') {
}
dialogVisible.value = false
handleSearch()
}
/**
* @description 取消操作
*/
const handleCancel = () => {
dialogVisible.value = false
dialogType.value = 'add'
}
/**
* @description 关闭弹窗
*/
const handleClose = () => {
dialogVisible.value = false
dialogType.value = 'add'
}
</script>
<style scoped lang="scss">
.el-form {
.el-form-item {
flex: none !important;
}
}
.market {
.search-container {
:deep(.el-form) {
.el-form-item {
flex: none;
}
}
}
}
:deep(.el-dialog) {
.el-dialog__footer {
display: none;
}
}
:deep(.edit-dialog) {
.el-dialog__footer {
display: block;
}
}
</style>

View File

@ -0,0 +1,64 @@
//做市商搜索配置
export const marketSearch = [
{ label: '账户名', prop: 'accountName', type: 'input', placeholder: '请输入账户名', width: '340px', },
]
export const marketTableColumns = [
{ label: 'ID', prop: 'id', align: 'center' as const },
//代理关系
{ label: '代理关系', prop: 'agentRelation', align: 'center' as const },
//账户名
{ label: '账户名', prop: 'accountName', align: 'center' as const },
//级别
{ label: '级别', prop: 'level', align: 'center' as const },
//基本账户
{ label: '基本账户', prop: 'basicAccount', align: 'center' as const },
//保证金
{ label: '保证金', prop: 'margin', align: 'center' as const },
//停止接单保证金
{ label: '停止接单保证金', prop: 'stopOrderMargin', align: 'center' as const, width: '160px' },
//持仓转移保证金
{ label: '持仓转移保证金', prop: 'positionTransferMargin', align: 'center' as const, width: '160px' },
//点差返佣
{ label: '点差返佣', prop: 'pointSpreadCommission', align: 'center' as const },
//点差
{ label: '点差', slotName: 'pointSpread', align: 'center' as const },
//手续费比例
{ label: '手续费比例', prop: 'commissionRatio', align: 'center' as const },
//手续费返佣
{ label: '手续费返佣', prop: 'commissionReturn', align: 'center' as const },
//平仓盈亏
{ label: '平仓盈亏', prop: 'closeProfitLoss', align: 'center' as const },
//浮动盈亏
{ label: '浮动盈亏', prop: 'floatProfitLoss', align: 'center' as const },
//风险金
{ label: '风险金', prop: 'riskMargin', align: 'center' as const },
//服务费
{ label: '服务费', prop: 'serviceFee', align: 'center' as const },
]
//做市商添加配置
export const marketFormItem = [
{ label: '账户名称', prop: 'accountName', type: 'input', placeholder: '请输入账户名称', },
//级别
{
label: '级别', prop: 'level', type: 'select', placeholder: '请选择级别', options: [
{ label: '一级', value: '1' },
{ label: '二级', value: '2' },
{ label: '三级', value: '3' },
]
},
//所属上级
{ label: '所属上级', prop: 'parentAccountName', type: 'select', placeholder: '请输入所属上级账户名称', },
//头寸
{ label: '头寸', prop: 'position', type: 'input', placeholder: '请输入头寸', },
//手续费
{ label: '手续费', prop: 'commissionRatio', type: 'input', placeholder: '请输入手续费', },
]
export const marketPointTableColumns = ([
{ prop: 'varietyName', label: '名称', align: 'center' as const },
{ prop: 'varietyCode', label: '编号', align: 'center' as const },
{ prop: 'pointDifference', label: '可分配点差', align: 'center' as const },
{ prop: 'assignedPointDifference', label: '已分配点差', align: 'center' as const },
])

View File

@ -126,7 +126,7 @@ const handleLogin = async () => {
mobile: loginForm.value.phone,
login_type: getStorage('loginType', 'session') === 'email' ? 1 : 2,
code: loginForm.value.code,
password: md5Encrypt(loginForm.value.password)
password: loginForm.value.password
};
await userStore.login(loginParams);
activeTab.value = 'email'; // tab