Compare commits

..

6 Commits
main ... test

Author SHA1 Message Date
21938f330f . 2026-07-07 16:23:13 +08:00
019d09df3e 人员列表 2026-07-01 14:59:56 +08:00
e9c9dcd9c5 添加搜索 2026-07-01 14:18:27 +08:00
242cc83843 添加搜索 2026-07-01 10:48:27 +08:00
3986db42f5 添加搜索 2026-06-30 17:05:28 +08:00
0c291f2870 取款计算金额 2026-06-30 13:41:08 +08:00
30 changed files with 1206 additions and 682 deletions

17
.env.pro Normal file
View File

@ -0,0 +1,17 @@
# 生产环境标识Vite 内置变量,无需修改)
NODE_ENV = production
# 生产环境接口基础地址
VITE_API_BASE_URL = https://adminapi.apimcapital.top/api
# 请求超时时间(毫秒)
VITE_REQUEST_TIMEOUT = 10000
# 可选:生产环境其他配置(如关闭调试)
VITE_DEBUG = false
# 交易mqtt
VITE_MQTT_TRANSACTION_HOST=wss://adminapi.apimcapital.top/mqtt
# exe 下载基础地址
VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.apimcapital.top

View File

@ -15,3 +15,6 @@ VITE_MQTT_TRANSACTION_HOST=wss://adminapi.apimcapital.top/mqtt
# exe 下载基础地址
VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.apimcapital.top
# config.json 独立部署在 h5 域名下,需要该域名侧配置 CORS
VITE_UPDATE_URL = https://adminh5.apimcapital.top/config.json

View File

@ -15,3 +15,7 @@ VITE_MQTT_TRANSACTION_HOST = wss://adminapi.duxiang.wiki/mqtt
# exe 下载基础地址
VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.duxiang.wiki
# config.json 独立部署在 h5 域名下,需要该域名侧配置 CORS
VITE_UPDATE_URL = https://adminh5.duxiang.wiki/config.json

View File

@ -6,8 +6,9 @@
"scripts": {
"dev": "vite",
"dev:test": "vite --mode test",
"dev:pro": "vite --mode pro",
"build": "run-p type-check \"build-only {@}\" --",
"build:prod": "vite build --mode production",
"build:prod": "vite build --mode pro",
"build:test": "vite build --mode test",
"preview": "vite preview",
"build-only": "vite build",

60
src/api/modules/config.ts Normal file
View File

@ -0,0 +1,60 @@
import axios from 'axios'
import { request as baseRequest } from '@/api'
// 抑制未使用导入告警
void baseRequest
/**
* config.json ios
*/
export type IosConfig = {
/** iOS 下载地址(跳转目标) */
upload_url?: string
}
/**
* /config.json
*/
export type AppConfig = {
ios?: IosConfig
// 后续若有 android / pc / 版本号等配置也可在此扩展
[key: string]: unknown
}
/**
* axios
* - baseURL src/api/index.ts VITE_API_BASE_URL
* - token loading /
* - request
*/
const staticRequest = axios.create({
timeout: 10000,
headers: { 'Content-Type': 'application/json;charset=utf-8' },
})
/**
* config.json
*
*
* 1. src/api/index.ts service baseURL = VITE_API_BASE_URL
* request.get('/config.json') /config.json 404
* 2. config.json h5 https://adminh5.xxx.com/config.json
* VITE_UPDATE_URL/ VITE_EXE_DOWNLOAD_BASE_URL
* 3. config.json h5 Nginx / CDN CORS
* Access-Control-Allow-Origin: <管理后台域名>
* Access-Control-Allow-Methods: GET
*
*
* @returns Promise<AppConfig>
*/
export async function getConfigApi(): Promise<AppConfig> {
// 使用相对路径 /config.json
// - 开发环境由 vite.config.ts 的 server.proxy 转发到 h5 域名,避免 CORS
// - 生产环境需要运维在 Nginx / 网关上做同等代理(例如把 /config.json 反代到 h5 域名)
const url = '/config.json'
const sep = url.includes('?') ? '&' : '?'
const finalUrl = `${url}${sep}t=${new Date().getTime()}&channel=web`
const res = await staticRequest.get<AppConfig>(finalUrl)
return res.data
}

View File

@ -0,0 +1,45 @@
import { request } from '@/api';
import type {
WorkerListResponse,
WorkerFormParams,
EditWorkerParams,
WorkerRoleOption,
WorkerRoleOptionResponse,
} from '@/api/types/system/worker.d';
/**
*
* @param params
* @returns Promise<WorkerListResponse>
*/
export async function getWorkerListApi(params: { username?: string } = {}): Promise<WorkerListResponse> {
return request.get<WorkerListResponse>('/worker/getWorkerList', params);
}
/**
*
* @returns Promise<WorkerRoleOptionResponse>
*/
export async function getWorkerRoleIdOptionApi(): Promise<WorkerRoleOptionResponse> {
return request.get<WorkerRoleOptionResponse>('/worker/getWorkerRoleIdOptions', undefined, { showMessage: false });
}
/**
*
* @param params usernameemailrole_id
* @returns Promise<void>
*/
export async function addWorkerApi(params: WorkerFormParams): Promise<void> {
return request.post<void>('/worker/addWorker', params);
}
/**
*
* @param params user_idusernameemailstatus
* @returns Promise<void>
*/
export async function editWorkerApi(params: EditWorkerParams): Promise<void> {
return request.post<void>('/worker/editWorker', params, { showMessage: false });
}
export type { WorkerRoleOption };

View File

@ -0,0 +1,60 @@
/**
* -
*
*
* - GET /api/trade/profit/statistics
* - POST /api/trade/profit/export url
*
*
* - mainAccountName
* - subAccountName
* - startDate (YYYY-MM-DD)
* - endDate (YYYY-MM-DD)
*
*
* - id
* - mainAccountName
* - subAccountName
* - profitAmount
* - orderCount
* - lotCount
* - winRate 0~1 0~100
*
* request get/post src/api/index.ts
* 使 request.get / request.post
*/
import { request } from '@/api'
export interface IProfitStatisticsQuery {
mainAccountName?: string
subAccountName?: string
startDate?: string
endDate?: string
}
export interface IProfitStatisticsItem {
id?: string | number
mainAccountName?: string
subAccountName?: string
profitAmount?: number | string
orderCount?: number | string
lotCount?: number | string
winRate?: number | string
[key: string]: any
}
/** 查询账户盈利统计列表 */
export const getProfitStatisticsList = (params: IProfitStatisticsQuery) => {
return request.get<{
list?: IProfitStatisticsItem[]
records?: IProfitStatisticsItem[]
data?: IProfitStatisticsItem[]
}>('/api/trade/profit/statistics', params)
}
/** 导出账户盈利统计(后端返回文件流 / 下载链接) */
export const exportProfitStatistics = (params: IProfitStatisticsQuery) => {
return request.post<Blob>('/api/trade/profit/export', params, {
responseType: 'blob',
} as any)
}

49
src/api/types/system/worker.d.ts vendored Normal file
View File

@ -0,0 +1,49 @@
import type { ApiResponse } from '../index';
/** 员工角色信息 */
export interface WorkerRoleInfo {
id: number;
title: string;
}
/** 员工列表单条数据 */
export interface WorkerItem {
id: number;
username: string;
email: string;
role_id: number;
status: number; // 1:正常 2:封禁
created_at: string;
role: WorkerRoleInfo;
}
/** 员工列表响应 */
export type WorkerListResponse = WorkerItem[];
/** 员工角色下拉选项 */
export interface WorkerRoleOption {
id: number;
title: string;
}
/** 员工角色下拉选项响应 */
export type WorkerRoleOptionResponse = WorkerRoleOption[];
/** 新增员工表单参数 */
export interface WorkerFormParams {
username: string;
email: string;
role_id: number | null;
}
/** 编辑员工表单参数 */
export interface EditWorkerParams {
user_id: number;
username: string;
email: string;
status: number; // 1:正常 2:封禁
}
/** 接口返回结构(兼容 data 包裹场景) */
export interface WorkerListApiResponse extends ApiResponse<WorkerItem[]> {}
export interface WorkerRoleOptionApiResponse extends ApiResponse<WorkerRoleOption[]> {}

View File

@ -47,7 +47,7 @@
<el-button type="primary" :loading="buttonLoading" @click="$emit('search')">
{{ buttonConfig.searchText || '搜索' }}
</el-button>
<el-button :loading="buttonLoading" @click="$emit('reset')">
<el-button :loading="buttonLoading" @click="$emit('reset')" v-if="isShowReset">
{{ buttonConfig.resetText || '重置' }}
</el-button>
<!-- 按钮区插槽 -->
@ -97,6 +97,10 @@ const props = defineProps({
type: Array as () => SearchOption[],
required: true,
},
isShowReset:{
type: Boolean,
default: true,
},
buttonConfig: {
type: Object as () => ButtonConfig,
default: () => ({}),

View File

@ -271,6 +271,21 @@ onMounted(() => {
document.addEventListener('contextmenu', handleGlobalContextMenu)
})
// router/index.ts dynamicRoutesReady
// tab
watch(
() => route.fullPath,
() => {
// tab
if (tabsStore.activeTab && tabsStore.activeTab !== route.path) {
const targetTab = tabsStore.tabs.find(item => item.path === tabsStore.activeTab)
if (targetTab && targetTab.path !== route.path) {
router.replace({ path: targetTab.path, query: targetTab.query })
}
}
}
)
onUnmounted(() => {
tabsContainerRef.value?.removeEventListener('scroll', checkScroll)
document.removeEventListener('click', handleGlobalClick)

View File

@ -132,14 +132,17 @@ export const useTabsStore = defineStore('tabs', () => {
if (existIndex === -1) {
// 新标签页,添加到列表
tabs.value.push({ ...tab, breadcrumbs })
// 只有新增标签时才激活它
activeTab.value = tab.path
} else {
// 已存在的标签页,更新面包屑(确保数据是最新的)
const existingTab = tabs.value[existIndex]
if (existingTab) {
existingTab.breadcrumbs = breadcrumbs
}
// 已存在的标签,不要覆盖当前激活状态,
// 避免在页面刷新/路由重新匹配时把激活的 tab 错误地切回当前路由
}
activeTab.value = tab.path
saveTabs()
}

View File

@ -42,6 +42,7 @@ const searchForm = ref({
username: '',
subAccountId: '',
type: '',
orderNo: '',
startTime: initTime.start,
endTime: initTime.end,
})
@ -92,6 +93,7 @@ const getFundDetailList = async () => {
: '2026-03-15 23:59:59',
user_name: searchForm.value.username,
account_id: searchForm.value.subAccountId,
trade_id: searchForm.value.orderNo,
type: searchForm.value.type || '',
}
//
@ -137,6 +139,7 @@ const handleReset = () => {
username: '',
subAccountId: '',
type: '',
orderNo: '',
startTime: initTime.start,
endTime: initTime.end,
}

View File

@ -3,7 +3,7 @@
*/
export const search = [
//单号
// { prop: 'orderNo', label: '单号', type: 'input' as const, placeholder: '请输入流水单号', width: '140px' },
{ prop: 'orderNo', label: '单号', type: 'input' as const, placeholder: '请输入流水单号', width: '140px' },
//用户名
{
prop: 'username',

View File

@ -1,65 +1,25 @@
<template>
<Dialog :visible="dialogVisible"
:title="currentStep === 1 ? t('withdraw.dialog.title1') : t('withdraw.dialog.title2')" width="600px"
:show-footer="false" @close="handleUpdateVisible">
<!-- 第一步输入金额并展示计算明细 -->
:show-footer="false" @close="handleCloseDialog">
<!-- 第一步输入金额 -->
<div v-if="currentStep === 1" class="step1-container">
<!-- 钱包余额展示 -->
<div class="wallet-section">
<div class="section-label">{{ t('withdraw.dialog.walletBalance') }}</div>
<div class="wallet-grid">
<div v-for="(item, index) in walletItems" :key="index" class="wallet-item">
<span class="wallet-label">{{ item.label }}</span>
<span class="wallet-value" :class="{ available: item.field === 'available' }">{{ item.value }}</span>
</div>
</div>
<!-- 钱包余额简化展示 -->
<div class="wallet-balance">
<span class="wallet-label">{{ t('withdraw.dialog.walletBalance') }}</span>
<span class="wallet-value">{{ walletBalance }}</span>
<!-- <span class="wallet-currency">{{ currentCurrency }}</span> -->
</div>
<!-- 金额输入 -->
<div class="amount-section">
<div class="section-label">
{{ t('withdraw.dialog.amount') }}
<span class="max-balance">最大可取{{ totalWalletBalance }}</span>
<span class="max-balance">最大可取{{ walletBalance }}</span>
</div>
<el-input v-model="withdrawAmount" type="number" :placeholder="t('withdraw.dialog.amountPlaceholder')"
@input="handleAmountInput">
<template #prepend>{{ currentCurrency }}</template>
<el-input v-model="withdrawAmount" type="number" :placeholder="t('withdraw.dialog.amountPlaceholder')">
<!-- <template #prepend>{{ currentCurrency }}</template> -->
</el-input>
<div v-if="amountError" class="amount-error">{{ amountError }}</div>
</div>
<!-- 合计扣除 -->
<div v-if="totalDeducted && parseFloat(totalDeducted) > 0" class="total-section">
<div class="total-label">{{ t('withdraw.dialog.totalDeducted') }}</div>
<div class="total-value">-{{ totalDeducted }} {{ currentCurrency }}</div>
</div>
<!-- 扣除计算明细 - 用盒子展示 -->
<div v-if="withdrawAmount && calculatedData.length > 0" class="calculation-section">
<div class="section-label">{{ t('withdraw.dialog.deductionDetails') }}</div>
<div class="calculation-grid">
<div v-for="(item, index) in calculatedData" :key="index" class="calc-item">
<div class="calc-type">{{ item.type }}</div>
<div class="calc-values">
<div class="calc-original">
<span class="label">{{ t('withdraw.dialog.originalBalance') }}</span>
<span class="value">{{ item.original }}</span>
</div>
<div class="calc-deducted">
<span class="label">{{ t('withdraw.dialog.deductedAmount') }}</span>
<span class="value deducted">-{{ item.deducted }}</span>
</div>
<div class="calc-remaining">
<span class="label">{{ t('withdraw.dialog.remaining') }}</span>
<span class="value">{{ item.remaining }}</span>
</div>
</div>
</div>
</div>
<div class="calc-summary">
<span class="label">{{ t('withdraw.dialog.totalDeducted') }}</span>
<span class="total-value">{{ totalDeducted }}</span>
</div>
</div>
<!-- 快捷金额 -->
@ -84,11 +44,7 @@
<div class="amount-info">
<div class="info-row">
<span class="info-label">{{ t('withdraw.dialog.withdrawAmount') }}</span>
<span class="info-value">{{ withdrawAmount }} USD</span>
</div>
<div class="info-row" v-for="(item, index) in calculatedData" :key="index">
<span class="info-label">{{ item.typeLabel }}</span>
<span class="info-value">{{ item.deducted }} USD</span>
<span class="info-value">{{ withdrawAmount }} </span>
</div>
</div>
@ -139,8 +95,7 @@ import { ref, computed, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import Dialog from '@/components/common/Dialog.vue'
import { getWalletCapital, agentWithdraw, withdraw } from '@/api/modules/capital/withdraw'
import { getStorage } from '@/utils/storage'
import { getWalletCapital, withdraw } from '@/api/modules/capital/withdraw'
const { t } = useI18n()
@ -154,7 +109,6 @@ interface Props {
channel_code?: string
currency?: {
symbol: string
}
}
}
@ -165,29 +119,9 @@ interface Emits {
}
interface WalletInfo {
user_id: string
amount: string
commission_point_diff: string
freeze: string
risk: string
service: string
toucun_percent: string
fee_handling_percent: string
commission_fee_handling: string
bail: string
bail_stop_order: string
bail_change_order: string
risk_control_id: string
fee_setting_id: string
closing_profit: string
}
interface CalculatedItem {
type: string
typeLabel: string
original: string
deducted: string
remaining: string
freeze: string
}
const props = defineProps<Props>()
@ -197,179 +131,40 @@ const dialogVisible = ref(props.visible)
const currentStep = ref(1)
const withdrawAmount = ref('')
const submitLoading = ref(false)
const amountError = ref('')
//
const handleAmountInput = (value: string) => {
const numValue = parseFloat(value)
if (isNaN(numValue)) {
amountError.value = ''
calculatedData.value = []
return
}
if (numValue > totalWalletBalance.value) {
amountError.value = `输入金额不能超过最大可取金额 ${totalWalletBalance.value.toFixed(2)}`
calculatedData.value = []
return
}
amountError.value = ''
calculateWithdraw()
}
//
const userInfo: any = getStorage('userInfo')
const roleId = userInfo?.role_id || 6
//
const isAgent = computed(() => roleId >= 5)
//
const currentCurrency = computed(() => props.channelInfo?.currency?.symbol || '-')
// const currentCurrency = computed(() => props.channelInfo?.currency?.symbol || '-')
// = amount - freeze - ( + + + + )
const availableBalance = computed(() => {
const amount = parseFloat(walletInfo.value.amount || '0')
const freeze = parseFloat(walletInfo.value.freeze || '0')
//
let walletSum =
Math.max(0, parseFloat(walletInfo.value.freeze)) +
Math.max(0, parseFloat(walletInfo.value.risk || '0')) +
Math.max(0, parseFloat(walletInfo.value.service || '0')) +
Math.max(0, parseFloat(walletInfo.value.commission_fee_handling || '0')) +
Math.max(0, parseFloat(walletInfo.value.commission_point_diff || '0'));
if (+roleId === 3 || +roleId === 4) {
walletSum += Math.max(0, parseFloat(walletInfo.value.closing_profit || '0'))
}
return floorMoney(amount - walletSum)
})
//
// roleId >= 5 totalWalletBalance availableBalance
const totalWalletBalance = computed(() => {
const amount = parseFloat(walletInfo.value.amount || '0')
const freeze = parseFloat(walletInfo.value.freeze || '0')
console.log('walletInfo.value:', amount, freeze);
// + + + +
const walletSum =
parseFloat(walletInfo.value.commission_fee_handling || '0') +
parseFloat(walletInfo.value.commission_point_diff || '0') +
parseFloat(walletInfo.value.service || '0') +
parseFloat(walletInfo.value.risk || '0') +
parseFloat(Math.max(0, +walletInfo.value.closing_profit) + '')
if (roleId >= 5) {
// roleId >= 5
// availableBalance = amount - freeze - walletSum
// const availableBal = Math.max(0, amount - walletSum)
return floorMoney(amount - freeze)
}
return floorMoney(walletSum)
})
const floorMoney = (num: number) => {
const cents = Math.floor(num * 100);
return cents / 100;
}
//
const feeLabelMap: Record<string, string> = {
'手续费': '手续费佣金',
'点差': '点差佣金',
'服务费': '服务费',
'风险金': '风险金',
'盈亏': '盈亏',
'可用余额': '可用余额',
}
//
const feeFieldMap: Record<string, keyof WalletInfo | 'available'> = {
'手续费': 'commission_fee_handling',
'点差': 'commission_point_diff',
'服务费': 'service',
'风险金': 'risk',
'盈亏': 'closing_profit',
'可用余额': 'available', // computed
}
//
const feeOrder = computed(() => {
const orders: Record<number, string[]> = {
1: ['手续费', '点差', '服务费', '风险金', '盈亏'], //
2: ['手续费', '点差', '服务费'], //
3: ['手续费', '点差', '服务费', '盈亏'], //
4: ['手续费', '点差', '服务费', '盈亏'], //
5: ['手续费', '点差', '可用余额'], //
6: ['手续费', '点差', '可用余额'], //
}
return orders[roleId] ?? orders[6] ?? []
})
//
const walletItems = computed(() => {
const items: { label: string; value: string; field: string }[] = []
for (const feeType of feeOrder.value) {
const field = feeFieldMap[feeType]
if (!field) continue
let value: string
if (field === 'available') {
value = availableBalance.value.toFixed(2)
} else {
value = walletInfo.value[field] || '0.00'
}
items.push({
label: feeLabelMap[feeType] || feeType,
value,
field,
})
}
return items
})
//
//
const walletInfo = ref<WalletInfo>({
user_id: '',
amount: '',
commission_point_diff: '0',
freeze: '0',
risk: '0',
service: '0',
toucun_percent: '0',
fee_handling_percent: '0',
commission_fee_handling: '0',
amount: '0',
bail: '0',
bail_stop_order: '0',
bail_change_order: '0',
risk_control_id: '',
fee_setting_id: '',
closing_profit: '0',
freeze: '0',
})
//
const calculatedData = ref<CalculatedItem[]>([])
//
const totalDeducted = computed(() => {
return calculatedData.value.reduce((sum, item) => sum + parseFloat(item.deducted || '0'), 0).toFixed(2)
// = amount - bail - freeze2
const walletBalance = computed(() => {
const amount = parseFloat(walletInfo.value.amount || '0')
const bail = parseFloat(walletInfo.value.bail || '0')
const freeze = parseFloat(walletInfo.value.freeze || '0')
const result = amount - bail - freeze
// toFixed JS
const [intPart, decPart = ''] = String(result).split('.')
const truncatedDec = (decPart + '00').slice(0, 2)
return `${intPart}.${truncatedDec}`
})
//
const quickAmounts = ['100', '500', '1000', '5000']
// props channelInfo
//
const currentChannelCode = computed(() => {
return props.channelCode || props.channelInfo?.channel_code || ''
})
// TRC/ERC
const isCryptoChannel = computed(() => {
return ['TRC', 'ERC', "ADJUST"].includes(currentChannelCode.value)
return ['TRC', 'ERC', 'ADJUST'].includes(currentChannelCode.value)
})
// BANK
@ -380,21 +175,10 @@ const isBankChannel = computed(() => {
//
const formRef = ref<FormInstance>()
const formData = ref({
channel_id: '',
withdraw_address: '',
//
withdraw_fee_handle: '',
withdraw_point_diff: '',
withdraw_service_fee: '',
withdraw_head_fee: '',
withdraw_risk_fee: '',
withdraw_blance: '', // 使
//
beneficiary_name: '',
beneficiary_enname: '',
beneficiary_bank_name: '',
swift_bic_code: '',
beneficiary_bank_address: '',
beneficiary_bank_account: '',
})
@ -419,28 +203,22 @@ watch(() => props.visible, (val) => {
const initData = async () => {
currentStep.value = 1
withdrawAmount.value = ''
calculatedData.value = []
formData.value = {
withdraw_address: '',
beneficiary_name: '',
beneficiary_enname: '',
beneficiary_bank_name: '',
beneficiary_bank_account: '',
}
//
try {
const res: any = await getWalletCapital()
if (res) {
walletInfo.value = {
commission_fee_handling: res.commission_fee_handling || '0',
commission_point_diff: '' + floorMoney(res.commission_point_diff - res.freeze || 0) || '0',
service: res.service || '0',
risk: res.risk || '0',
closing_profit: res.closing_profit || '0',
toucun_percent: res.toucun_percent || '0',
amount: res.amount || '0',
user_id: res.user_id || '',
freeze: res.freeze || '0',
bail: res.bail || '0',
bail_stop_order: res.bail_stop_order || '0',
bail_change_order: res.bail_change_order || '0',
risk_control_id: res.risk_control_id || '',
fee_setting_id: res.fee_setting_id || '',
fee_handling_percent: res.fee_handling_percent || '0',
freeze: res.freeze || '0',
}
}
} catch (error) {
@ -448,58 +226,14 @@ const initData = async () => {
}
}
//
const calculateWithdraw = () => {
const amount = parseFloat(withdrawAmount.value) || 0
if (amount <= 0) {
calculatedData.value = []
return
}
const results: CalculatedItem[] = []
let remaining = amount
for (const feeType of feeOrder.value) {
const field = feeFieldMap[feeType]
if (!field) continue
// available
let original: number
if (field === 'available') {
original = availableBalance.value
} else {
original = parseFloat(walletInfo.value[field] || '0')
}
if (original <= 0) continue
const deducted = Math.min(remaining, original).toFixed(2)
const newRemaining = Math.max(0, remaining - original)
results.push({
type: feeType,
typeLabel: feeLabelMap[feeType] || feeType,
original: original.toFixed(2),
deducted: deducted,
remaining: Math.max(0, original - parseFloat(deducted)).toFixed(2),
})
remaining = newRemaining
if (remaining <= 0) break
}
calculatedData.value = results
}
//
const handleQuickAmount = (amount: string) => {
withdrawAmount.value = amount
calculateWithdraw()
}
//
const handleUpdateVisible = (val: boolean) => {
emit('update:visible', val)
// Dialog
const handleCloseDialog = () => {
emit('update:visible', false)
}
//
@ -516,50 +250,17 @@ const handleBack = () => {
//
const handleNextStep = () => {
const amount = parseFloat(withdrawAmount.value)
if (!withdrawAmount.value || amount <= 0) {
if (!withdrawAmount.value || isNaN(amount) || amount <= 0) {
ElMessage.warning('请输入取款金额')
return
}
if (amount > totalWalletBalance.value) {
ElMessage.warning(`输入金额不能超过最大可取金额 ${totalWalletBalance.value.toFixed(2)}`)
const maxBalance = parseFloat(walletBalance.value)
if (amount > maxBalance) {
ElMessage.warning(`输入金额不能超过钱包余额 ${walletBalance.value}`)
return
}
//
formData.value.withdraw_fee_handle = '0'
formData.value.withdraw_point_diff = '0'
formData.value.withdraw_service_fee = '0'
formData.value.withdraw_risk_fee = '0'
formData.value.withdraw_head_fee = '0'
formData.value.withdraw_blance = '0'
//
for (const feeType of feeOrder.value) {
const deducted = calculatedData.value.find(item => item.type === feeType)?.deducted || '0'
switch (feeType) {
case '手续费':
formData.value.withdraw_fee_handle = deducted
break
case '点差':
formData.value.withdraw_point_diff = deducted
break
case '服务费':
formData.value.withdraw_service_fee = deducted
break
case '风险金':
formData.value.withdraw_risk_fee = deducted
break
case '盈亏':
formData.value.withdraw_head_fee = deducted
break
case '可用余额':
formData.value.withdraw_blance = deducted
break
}
}
currentStep.value = 2
}
@ -577,74 +278,29 @@ const handleSubmit = async () => {
const params: any = {
channel_id: props.channelId,
amount: +withdrawAmount.value,
withdraw_address: formData.value.withdraw_address,
}
//
for (const feeType of feeOrder.value) {
switch (feeType) {
case '手续费':
params.withdraw_fee_handle = formData.value.withdraw_fee_handle
break
case '点差':
params.withdraw_point_diff = formData.value.withdraw_point_diff
break
case '服务费':
params.withdraw_service_fee = formData.value.withdraw_service_fee
break
case '风险金':
params.withdraw_risk_fee = formData.value.withdraw_risk_fee
break
case '盈亏':
params.withdraw_head_fee = formData.value.withdraw_head_fee
break
case '可用余额':
params.withdraw_blance = formData.value.withdraw_blance
break
}
}
if (isAgent.value) {
// -
if (isCryptoChannel.value) {
// - --
params.withdraw_address = formData.value.withdraw_address
params.beneficiary_name = '--'
params.beneficiary_enname = '--'
params.beneficiary_bank_name = '--'
params.beneficiary_bank_account = '--'
params.swift_bic_code = '--'
params.beneficiary_bank_address = '--'
} else if (isBankChannel.value) {
// -
// -
params.withdraw_address = '--'
params.beneficiary_name = formData.value.beneficiary_name
params.beneficiary_enname = formData.value.beneficiary_enname
params.beneficiary_bank_name = formData.value.beneficiary_bank_name
params.beneficiary_bank_account = formData.value.beneficiary_bank_account
//
params.withdraw_address = '--'
}
// --
params.swift_bic_code = '--'
params.beneficiary_bank_address = '--'
}
await withdraw(params)
} else {
// - --
if (isBankChannel.value) {
params.withdraw_address = '--'
params.beneficiary_name = formData.value.beneficiary_name
params.beneficiary_enname = formData.value.beneficiary_enname
params.beneficiary_bank_name = formData.value.beneficiary_bank_name
params.beneficiary_bank_account = formData.value.beneficiary_bank_account
} else {
params.beneficiary_name = '--'
params.beneficiary_enname = '--'
params.beneficiary_bank_name = '--'
params.beneficiary_bank_account = '--'
params.swift_bic_code = '--'
params.beneficiary_bank_address = '--'
}
await agentWithdraw(params)
}
ElMessage.success('取款申请已提交')
dialogVisible.value = false
@ -660,50 +316,31 @@ const handleSubmit = async () => {
<style scoped lang="scss">
.step1-container {
.section-label {
margin-bottom: 12px;
font-size: 14px;
font-weight: 500;
color: #303133;
}
}
.wallet-section {
.wallet-balance {
display: flex;
align-items: baseline;
padding: 16px 20px;
margin-bottom: 20px;
padding: 16px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 8px;
color: #fff;
.section-label {
color: rgba(255, 255, 255, 0.9);
font-size: 13px;
}
.wallet-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
}
.wallet-item {
display: flex;
flex-direction: column;
padding: 12px;
background: rgba(255, 255, 255, 0.15);
border-radius: 6px;
.wallet-label {
margin-bottom: 6px;
font-size: 12px;
color: rgba(255, 255, 255, 0.8);
margin-right: 8px;
font-size: 14px;
color: rgba(255, 255, 255, 0.85);
}
.wallet-value {
font-size: 18px;
font-size: 24px;
font-weight: 700;
color: #fff;
}
.wallet-currency {
margin-left: 6px;
font-size: 14px;
color: rgba(255, 255, 255, 0.85);
}
}
@ -725,120 +362,14 @@ const handleSubmit = async () => {
font-weight: normal;
}
}
.amount-error {
margin-top: 8px;
font-size: 12px;
color: #f56c6c;
}
}
.total-section {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px;
margin-bottom: 16px;
background: #fef0f0;
border-radius: 8px;
border: 1px solid #fde2e2;
.total-label {
font-size: 14px;
color: #606266;
}
.total-value {
font-size: 18px;
font-weight: 700;
color: #f56c6c;
}
}
.calculation-section {
margin-bottom: 24px;
.section-label {
margin-bottom: 12px;
font-size: 14px;
font-weight: 500;
color: #303133;
}
.calculation-grid {
display: flex;
flex-direction: column;
gap: 12px;
}
.calc-item {
padding: 16px;
background: #f5f7fa;
border-radius: 8px;
border: 1px solid #ebeef5;
}
.calc-type {
margin-bottom: 12px;
font-size: 14px;
font-weight: 600;
color: #303133;
}
.calc-values {
display: flex;
gap: 24px;
}
.calc-original,
.calc-deducted,
.calc-remaining {
display: flex;
flex-direction: column;
.label {
margin-bottom: 4px;
font-size: 12px;
color: #909399;
}
.value {
font-size: 16px;
font-weight: 600;
color: #303133;
&.deducted {
color: #f56c6c;
}
}
}
.calc-summary {
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid #ebeef5;
.label {
font-size: 14px;
color: #606266;
}
.total-value {
margin-left: 8px;
font-size: 20px;
font-weight: 600;
color: #f56c6c;
}
}
}
.quick-amounts {
display: flex;
gap: 12px;
flex-wrap: wrap;
margin-bottom: 8px;
}
}
.dialog-footer {

View File

@ -41,11 +41,11 @@ export const withdrawCheckTableColumns = [
{ prop: 'real_amount', label: '到账金额', align: 'center' as const, width: 120, isNumber: true },
{ prop: 'rate', label: '汇率', align: 'center' as const, width: 100 },
{ prop: 'channel_name', label: '渠道', align: 'center' as const, width: 140 },
{ prop: 'withdraw_service_fee', label: '服务费', align: 'center' as const, width: 100, isNumber: true },
{ prop: 'withdraw_head_fee', label: '头寸', align: 'center' as const, width: 120, isNumber: true },
{ prop: 'withdraw_fee_handle', label: '代理手续费', align: 'center' as const, width: 120, isNumber: true },
{ prop: 'withdraw_point_diff', label: '点差', align: 'center' as const, width: 100, isNumber: true },
{ prop: 'withdraw_risk_fee', label: '风控费', align: 'center' as const, isNumber: true , width: 180},
// { prop: 'withdraw_service_fee', label: '服务费', align: 'center' as const, width: 100, isNumber: true },
// { prop: 'withdraw_head_fee', label: '头寸', align: 'center' as const, width: 120, isNumber: true },
// { prop: 'withdraw_fee_handle', label: '代理手续费', align: 'center' as const, width: 120, isNumber: true },
// { prop: 'withdraw_point_diff', label: '点差', align: 'center' as const, width: 100, isNumber: true },
// { prop: 'withdraw_risk_fee', label: '风控费', align: 'center' as const, isNumber: true , width: 180},
{ prop: 'withdraw_address', label: '提现地址', align: 'center' as const, width: 180},
{ prop: 'beneficiary_bank_account', label: '银行账号', align: 'center' as const, width: 180},
{ prop: 'beneficiary_bank_name', label: '银行名称', align: 'center' as const, width: 180},

View File

@ -136,11 +136,11 @@ const tagType = computed<'danger' | 'success' | 'warning' | 'primary'>(() => {
const cardData = ref([
{ label: '总金额', value: '0', icon: markRaw(Money) },
{ label: '盈利', value: '0', icon: markRaw(Trophy) },
{ label: '手续费佣金', value: '0', icon: markRaw(Coin) },
{ label: '可提现点差佣金', value: '0', icon: markRaw(Wallet) },
// { label: '', value: '0', icon: markRaw(Trophy) },
// { label: '', value: '0', icon: markRaw(Coin) },
// { label: '', value: '0', icon: markRaw(Wallet) },
{ label: '冻结点差佣金', value: '0', icon: markRaw(Lock) },
{ label: '服务费', value: '0', icon: markRaw(DataAnalysis) },
// { label: '', value: '0', icon: markRaw(DataAnalysis) },
{ label: '保证金', value: '0', icon: markRaw(TrendCharts) }
])
@ -198,11 +198,11 @@ const fetchWalletData = async () => {
if (res) {
cardData.value = [
{ label: '总金额', value: res.amount ?? 0, icon: markRaw(Money) },
{ label: '盈利', value: res.closing_profit ?? 0, icon: markRaw(Trophy) },
{ label: '手续费佣金', value: res.commission_fee_handling ?? 0, icon: markRaw(Coin) },
{ label: '可提现点差佣金', value: ((res.commission_point_diff || 0) - (res.freeze || 0)) , icon: markRaw(Wallet) },
// { label: '', value: res.closing_profit ?? 0, icon: markRaw(Trophy) },
// { label: '', value: res.commission_fee_handling ?? 0, icon: markRaw(Coin) },
// { label: '', value: ((res.commission_point_diff || 0) - (res.freeze || 0)) , icon: markRaw(Wallet) },
{ label: '冻结点差佣金', value: res.freeze ?? 0, icon: markRaw(Lock) },
{ label: '服务费', value: res.service ?? 0, icon: markRaw(DataAnalysis) },
// { label: '', value: res.service ?? 0, icon: markRaw(DataAnalysis) },
{ label: '保证金', value: res.bail ?? 0, icon: markRaw(TrendCharts) }
]
}

View File

@ -112,16 +112,10 @@
<AnimatedNumber :value="walletCapital.amount || 0" :decimals="2" />
</span>
</div>
<template v-if="isAgent">
<div class="detail-item">
<span class="label">点差</span>
<span class="value">{{ walletCapital.commission_point_diff || '0.00' }}</span>
<span class="label">冻结点差</span>
<span class="value">{{ walletCapital.freeze || '0.00' }}</span>
</div>
<div class="detail-item">
<span class="label">手续费</span>
<span class="value">{{ walletCapital.commission_fee_handling || '0.00' }}</span>
</div>
</template>
</div>
</div>
<div class="wallet-actions">
@ -142,9 +136,9 @@
</section>
</div>
<!-- {{ userInfo.role_id }} -->
<!-- 个人账户 -->
<section class="section my-accounts">
<section class="section my-accounts" v-if="(userInfo.type*1 !== 1 && userInfo.role_id * 1 === 5) || userInfo.role_id * 1 === 6" >
<h2 class="section-title">
<el-icon><User /></el-icon>
个人账户
@ -310,7 +304,6 @@ import AnimatedNumber from '@/views/agent/user/AnimatedNumber.vue'
const userStore = useUserStore()
// role_id === 5
const isAgent = computed(() => userStore.userInfo?.role_id === 5)
//
const startSteps = ref([

View File

@ -11,11 +11,12 @@
</header>
<div class="table-container">
<div class="table-container-left">
<Table ref="singleTableRef" :show-column-setting="false" :table-data="tableData" :columns="tableColumns" row-key="id" :loading="loading"
:highlight-current-row="true" @current-change="handleCurrentChange" />
<Table ref="singleTableRef" :show-column-setting="false" :table-data="tableData" :columns="tableColumns"
row-key="id" :loading="loading" :highlight-current-row="true" @current-change="handleCurrentChange" />
</div>
<div class="table-container-right">
<Table :show-column-setting="false" row-key="id" :table-data="tableDataDetail" :columns="tableColumnsDetail" :loading="detailLoading" />
<Table :show-column-setting="false" row-key="id" :table-data="tableDataDetail" :columns="tableColumnsDetail"
:loading="detailLoading" />
</div>
</div>
<el-dialog v-model="dialogVisible" :title="dialogTitleType === 1 ? '添加手续费模板' : '编辑手续费模板'" width="500">
@ -94,7 +95,8 @@ const { buttonLoading: submitDetailLoading, startButtonLoading: startSubmitDetai
const tableData = ref<any[]>([])
const tableColumns = [
{ prop: 'name', label: '名称' },
{ prop: 'type', label: '状态' },
{ prop: 'typeName', label: '状态' },
{ prop: 'statusName', label: '是否默认' },
]
const currentRow = ref<Record<string, any>>({})
const singleTableRef = ref()
@ -117,6 +119,7 @@ const setCurrent = (row: any) => {
//
const handleCurrentChange = (row: any) => {
currentRow.value = row
console.log('currentRow.value:', currentRow.value);
fetchItemDetail(row.id)
}
@ -133,7 +136,13 @@ const getTableData = async () => {
startLoading()
try {
const res = await getFeeSettingList()
tableData.value = Array.isArray(res) ? res : []
tableData.value = Array.isArray(res) ? res.map((item) => {
return {
...item,
typeName: item.type === 1 ? '是' : "否",
statusName: item.type === 1 ? '正常' : "封禁"
}
}) : []
handleTableDataAfterLoad()
} finally {
stopLoading()
@ -152,8 +161,8 @@ const handleTableDataAfterLoad = () => {
const targetRow = savedId ? tableData.value.find((item) => item.id === savedId) : null
const rowToSelect = targetRow || tableData.value[0]
// el-table current-change handleCurrentChange
setCurrent(rowToSelect)
handleCurrentChange(rowToSelect)
}
//
@ -182,6 +191,7 @@ const editFee = () => {
id: currentRow.value.id,
name: currentRow.value.name,
type: currentRow.value.type,
status: currentRow.value.status * 1,
description: currentRow.value.description,
}
}
@ -277,4 +287,3 @@ header {
}
}
</style>

View File

@ -1,9 +1,8 @@
<template>
<div class="position-stat table_form-container">
<!-- 搜索 -->
<PositionStatSearch
:buttonLoading="loading" :search-form="searchForm" :search-options="searchOptions" @search="handleSearch"
@reset="handleReset">
<PositionStatSearch :buttonLoading="loading" :search-form="searchForm" :search-options="searchOptions"
@search="handleSearch" @reset="handleReset" :isShowReset="false">
<!-- <template #button="{ form }">-->
<!-- <el-button type="primary" @click="handleExport()">-->
<!-- 导出-->
@ -55,6 +54,9 @@ const tableColumnsOptions = ref(tableColumns)
* @description: 定义搜索方法
*/
const handleSearch = async () => {
if (!searchForm.value.account_id) {
return ElMessage.warning('请输入账户ID')
}
try {
startLoading()
const data = await checkAccountIdIsSonForUser({ account_id: searchForm.value.account_id })
@ -66,6 +68,7 @@ const handleSearch = async () => {
} finally { stopLoading() }
}
const handleReset = () => {
searchForm.value.account_id = ''
console.log('重置搜索')
}
const handleExport = () => {

View File

@ -42,12 +42,12 @@ export const tableColumns = [
{ prop: 'real_currency_symbol', label: '到账币种', align: 'center' as const, width: 100 },
{ prop: 'real_amount', label: '到账金额', align: 'center' as const, width: 120, isNumber: true },
{ prop: 'channel_name', label: '渠道', align: 'center' as const, width: 140 },
{ prop: 'withdraw_service_fee', label: '服务费', align: 'center' as const, width: 100, isNumber: true },
{ prop: 'withdraw_head_fee', label: '头寸', align: 'center' as const, width: 120, isNumber: true },
{ prop: 'withdraw_fee_handle', label: '代理手续费', align: 'center' as const, width: 120, isNumber: true },
{ prop: 'withdraw_point_diff', label: '点差', align: 'center' as const, width: 100, isNumber: true },
{ prop: 'withdraw_risk_fee', label: '风控费', width: 140, align: 'center' as const, isNumber: true },
{ prop: 'withdraw_blance', label: '余额费用', align: 'center' as const, width: 180},
// { prop: 'withdraw_service_fee', label: '服务费', align: 'center' as const, width: 100, isNumber: true },
// { prop: 'withdraw_head_fee', label: '头寸', align: 'center' as const, width: 120, isNumber: true },
// { prop: 'withdraw_fee_handle', label: '代理手续费', align: 'center' as const, width: 120, isNumber: true },
// { prop: 'withdraw_point_diff', label: '点差', align: 'center' as const, width: 100, isNumber: true },
// { prop: 'withdraw_risk_fee', label: '风控费', width: 140, align: 'center' as const, isNumber: true },
// { prop: 'withdraw_blance', label: '余额费用', align: 'center' as const, width: 180},
{ prop: 'withdraw_address', label: '提现地址', width: 140, align: 'center' as const },
{
prop: 'status', label: '状态', align: 'center' as const, width: 140, options: [{

View File

@ -42,6 +42,9 @@
<template #pointSpread="{ row }">
<el-button type="primary" size="small" @click="handleViewPointDiff(row)"> 查看 </el-button>
</template>
<template #ratio="{ row }">
<span :style="getRatioStyle(row.ratio)">{{ row.ratio }}</span>
</template>
</MarketTable>
<!-- 行右键菜单 -->
<context-menu v-model:show="menuVisible" :options="menuOptions">
@ -406,6 +409,25 @@ const getMarketFloatProfit = (accountId: string | number): string => {
return parts[0] + '.' + (parts[1] + '00').slice(0, 2)
}
/**
* @description 获取风险率样式
* @param ratio 风险率字符串, "100%" "--"
* @returns 颜色样式对象
*/
const getRatioStyle = (ratio: string | number | undefined | null) => {
// '--'
if (ratio === undefined || ratio === null || ratio === '' || ratio === '--') {
return { color: '' }
}
//
const num = Number(String(ratio).replace('%', ''))
if (isNaN(num)) return { color: '' }
// 20 ,20-30 , 30 绿
if (num <= 20) return { color: '#f56c6c' }
if (num > 20 && num <= 30) return { color: '#e6a23c' }
return { color: '#67c23a' }
}
/**
* @description 获取做市商的平仓盈亏值
*/

View File

@ -21,7 +21,7 @@ export const marketTableColumns = [
{ label: '级别', prop: 'level', align: 'center' as const, width: '120px' },
{ label: '邮箱', prop: 'email', align: 'center' as const, width: '160px' },
{ label: '手机号', prop: 'mobile', align: 'center' as const, width: '180' },
{ label: '风险率', prop: 'ratio', align: 'center' as const, width: '120px' },
{ label: '风险率', prop: 'ratio', align: 'center' as const, width: '120px', slotName: 'ratio' },
{ label: '接单状态', prop: 'market_status', align: 'center' as const, width: '120px' },
//基本账户
{ label: '基本账户', prop: 'basicAccount', align: 'center' as const, isNumber: true , width: '200px' },
@ -41,21 +41,21 @@ export const marketTableColumns = [
//头寸比率
{ label: '头寸比率', prop: 'positionRatio', align: 'center' as const, width: '150px', isNumber: true },
//点差返佣
{ label: '点差返佣', prop: 'pointSpreadCommission', align: 'center' as const, width: '200px', isNumber: true },
// { label: '点差返佣', prop: 'pointSpreadCommission', align: 'center' as const, width: '200px', isNumber: true },
//点差
{ label: '点差', slotName: 'pointSpread', align: 'center' as const, width: '150px' },
//手续费比例
{ label: '手续费比例', prop: 'commissionRatio', align: 'center' as const, width: '150px', isNumber: true },
//手续费返佣
{ label: '手续费返佣', prop: 'commissionReturn', align: 'center' as const, width: '150px', isNumber: true },
// { label: '手续费返佣', prop: 'commissionReturn', align: 'center' as const, width: '150px', isNumber: true },
//浮动盈亏
{ label: '浮动盈亏', slotName: 'floatProfitLoss', align: 'center' as const, width: '100px', isNumber: true },
//平仓盈亏
{ label: '平仓盈亏', prop: 'closeProfitLoss', align: 'center' as const, width: '150px', isNumber: true },
//风险金
{ label: '风险金', prop: 'riskMargin', align: 'center' as const, width: '150px', isNumber: true },
//服务费
{ label: '服务费', prop: 'serviceFee', align: 'center' as const, width: '150px', isNumber: true },
// { label: '风险金', prop: 'riskMargin', align: 'center' as const, width: '150px', isNumber: true },
// //服务费
// { label: '服务费', prop: 'serviceFee', align: 'center' as const, width: '150px', isNumber: true },
]
//做市商添加配置

View File

@ -0,0 +1,285 @@
<template>
<div class="system table_form-container">
<!-- 搜索 -->
<WorkerSearch
:search-form="searchForm"
:buttonLoading="loading"
:search-options="searchOptions"
@search="handleSearch"
@reset="handleReset"
>
<template #button>
<el-button type="primary" @click="handleAdd" v-auth="'worker_addWorker'">新增员工</el-button>
</template>
</WorkerSearch>
<!-- 表格 -->
<WorkerTable
:table-data="workerList"
:columns="tableColumnsOptions"
row-key="id"
:loading="loading"
>
<template #status="{ row }">
<el-tag :type="row.status === 1 ? 'success' : 'danger'">
{{ row.status === 1 ? '正常' : '封禁' }}
</el-tag>
</template>
<template #action="{ row }">
<el-button link type="primary" size="small" @click="handleEdit(row)" v-auth="'worker_editWorker'">
编辑
</el-button>
</template>
</WorkerTable>
<!-- 新增/编辑弹窗 -->
<WorkerDialog
:visible="dialogVisible"
:title="dialogTitle"
:type="dialogType"
:button-loading="submitLoading"
@confirm="handleSubmit"
@cancel="handleCancel"
@close="handleClose"
>
<WorkerForm
:form-data="workerForm"
:form-rules="workerFormRules"
:form-items="workerFormItemOptions"
:options-map="workerFormOptionsMap"
ref="workerFormRef"
:key="formKey"
/>
</WorkerDialog>
</div>
</template>
<script setup lang="ts">
defineOptions({
name: 'Worder'
})
import type { FormInstance } from 'element-plus'
import { usePageLoading, useButtonLoading } from '@/composables/useLoading'
const { loading, startLoading, stopLoading } = usePageLoading()
const { buttonLoading: submitLoading, startButtonLoading: startSubmitLoading, stopButtonLoading: stopSubmitLoading } = useButtonLoading()
//
import WorkerSearch from '@/components/common/Search.vue'
import WorkerTable from '@/components/common/Table.vue'
import WorkerDialog from '@/components/common/Dialog.vue'
import WorkerForm from '@/components/common/Form.vue'
//
import { search, tableColumns, addFormItem, editFormItem } from './options'
import { addRules, editRules } from './rules'
//
import {
getWorkerListApi,
getWorkerRoleIdOptionApi,
addWorkerApi,
editWorkerApi,
} from '@/api/modules/system/worker'
/**
* @description: 定义搜索数据
*/
const searchForm = ref({
username: '',
})
const searchOptions = ref(search)
/**
* @description: 定义表格数据
*/
const workerList = ref<any[]>([])
const tableColumnsOptions = ref(tableColumns)
/**
* @description: 定义弹窗数据
*/
const dialogVisible = ref(false)
const dialogTitle = ref('')
const dialogType = ref<'add' | 'edit'>('add')
//
const formKey = ref(0)
/**
* @description: 定义表单数据
*/
const workerForm = ref<any>({
user_id: 0,
username: '',
email: '',
role_id: null as number | null,
status: 1,
})
const workerFormRef = ref<FormInstance>()
const workerFormRules = ref<any>({})
const workerFormItemOptions = ref<any[]>([])
// /
const workerFormOptionsMap = ref<Record<string, { label: string; value: number }[]>>({
role_id: [],
status: [
{ label: '正常', value: 1 },
{ label: '封禁', value: 2 },
],
})
/**
* @description: 角色下拉数据加载
*/
const fetchRoleOptions = async () => {
try {
const data: any = await getWorkerRoleIdOptionApi()
const list = Array.isArray(data) ? data : (data?.data || [])
workerFormOptionsMap.value.role_id = list.map((item: any) => ({
label: item.title,
value: item.id,
}))
} catch (err) {
console.error('获取员工角色选项失败', err)
}
}
/**
* @description: 获取员工列表
*/
const fetchWorkerList = async () => {
startLoading()
try {
const params: any = {
username: searchForm.value.username || undefined,
}
const data: any = await getWorkerListApi(params)
const list = Array.isArray(data) ? data : (data?.data || [])
workerList.value = list.map((item: any) => ({
...item,
roleTitle: item.role?.title || '-',
}))
} catch (err) {
console.error('获取员工列表失败', err)
} finally {
stopLoading()
}
}
/**
* @description: 页面挂载
*/
onMounted(async () => {
await Promise.all([fetchRoleOptions(), fetchWorkerList()])
})
/**
* @description: 搜索 / 重置
*/
const handleSearch = () => {
fetchWorkerList()
}
const handleReset = () => {
searchForm.value = { username: '' }
fetchWorkerList()
}
/**
* @description: 新增
* 入参字段emailrole_id
*/
const handleAdd = () => {
dialogVisible.value = true
dialogTitle.value = '新增员工'
dialogType.value = 'add'
workerFormItemOptions.value = addFormItem as any
workerFormRules.value = addRules()
formKey.value++
workerForm.value = {
user_id: 0,
email: '',
role_id: null,
}
}
/**
* @description: 编辑
* 入参字段usernameemailstatus
*/
const handleEdit = (row: any) => {
dialogVisible.value = true
dialogTitle.value = '编辑员工'
dialogType.value = 'edit'
workerFormItemOptions.value = editFormItem as any
workerFormRules.value = editRules()
formKey.value++
workerForm.value = {
user_id: row.id,
username: row.username,
email: row.email,
status: row.status,
}
}
/**
* @description: 提交表单
*/
const handleSubmit = async () => {
startSubmitLoading()
try {
await workerFormRef.value?.validate()
if (dialogType.value === 'add') {
const params = {
email: workerForm.value.email,
role_id: workerForm.value.role_id,
}
await addWorkerApi(params)
ElNotification({
message: '新增成功',
type: 'success',
duration: 2000,
customClass: 'global-notification',
})
} else {
const params = {
user_id: workerForm.value.user_id,
username: workerForm.value.username,
email: workerForm.value.email,
status: workerForm.value.status,
}
await editWorkerApi(params)
ElNotification({
message: '编辑成功',
type: 'success',
duration: 2000,
customClass: 'global-notification',
})
}
dialogVisible.value = false
await fetchWorkerList()
} catch (err: any) {
if (err?.message) {
ElNotification({
message: err.message || '操作失败',
type: 'error',
duration: 2000,
customClass: 'global-notification',
})
}
} finally {
stopSubmitLoading()
}
}
/**
* @description: 取消 / 关闭弹窗
*/
const handleCancel = () => {
dialogVisible.value = false
}
const handleClose = () => {
dialogVisible.value = false
}
</script>
<style scoped lang="scss"></style>

View File

@ -0,0 +1,73 @@
/**
* @description:
*/
export const search = [
{
prop: 'username',
label: '用户名',
type: 'input' as const,
placeholder: '请输入用户名',
width: '220px',
},
]
/**
* @description:
*/
export const tableColumns = [
{ prop: 'username', label: '用户名' },
{ prop: 'email', label: '邮箱' },
{ prop: 'roleTitle', label: '角色' },
{ slotName: 'status', label: '状态' },
{ prop: 'created_at', label: '创建时间' },
{ slotName: 'action', label: '操作' },
]
/**
* @description:
* emailrole_id
*/
export const addFormItem = [
{
prop: 'email',
label: '邮箱',
type: 'input' as const,
placeholder: '请输入邮箱',
required: true,
},
{
prop: 'role_id',
label: '角色',
type: 'select' as const,
placeholder: '请选择角色',
required: true,
},
]
/**
* @description:
* usernameemailstatus
*/
export const editFormItem = [
{
prop: 'username',
label: '用户名',
type: 'input' as const,
placeholder: '请输入用户名',
required: true,
},
{
prop: 'email',
label: '邮箱',
type: 'input' as const,
placeholder: '请输入邮箱',
required: true,
},
{
prop: 'status',
label: '状态',
type: 'radio' as const,
placeholder: '请选择状态',
required: true,
},
]

View File

@ -0,0 +1,54 @@
import type { FormRules } from 'element-plus'
/** 邮箱格式校验 */
const emailValidator = (rule: any, value: any, callback: any) => {
if (!value) {
callback()
return
}
const emailReg = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
if (!emailReg.test(value)) {
callback(new Error('邮箱格式不正确'))
return
}
callback()
}
/**
* @description:
* emailrole_id
*/
export const addRules = (): FormRules => {
return {
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
{ validator: emailValidator, trigger: 'blur' },
],
role_id: [
{ required: true, message: '请选择角色', trigger: 'change' },
],
}
}
/**
* @description:
* usernameemailstatus
*/
export const editRules = (): FormRules => {
return {
username: [
{ required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 2, max: 50, message: '用户名长度在 2 到 50 个字符', trigger: 'blur' },
],
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
{ validator: emailValidator, trigger: 'blur' },
],
status: [
{ required: true, message: '请选择状态', trigger: 'change' },
],
}
}
/** 兼容旧引用 */
export const rules = (): FormRules => editRules()

View File

@ -1,5 +1,5 @@
<template>
<div class="download-wrapper table_form-container">
<div class="download-wrapper table_formcontainer">
<!-- PC端 -->
<div class="download-item">
<div class="item-left">
@ -45,7 +45,7 @@
</div>
<!-- IOS -->
<div class="download-item" v-if="false">
<div class="download-item" v-if="iosUploadUrl">
<div class="item-left">
<div class="icon-box ios">
<svg viewBox="0 0 1024 1024" width="32" height="32">
@ -58,11 +58,11 @@
</div>
</div>
<div class="item-center">
<span class="desc">前往App Store搜索 InTrade 安装</span>
<span class="desc">点击跳转至iOS下载页安装</span>
</div>
<div class="item-right">
<el-button type="warning" :icon="Link" @click="handleDownload('ios')">
前往商店
<el-button type="warning" :icon="Link" :loading="iosLoading" @click="handleDownload('ios')">
前往下载
</el-button>
</div>
</div>
@ -71,6 +71,8 @@
<script setup lang="ts">
import { Monitor, Download, Link } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { getConfigApi } from '@/api/modules/config'
defineOptions({ name: 'Exe' })
type DownloadType = 'pc' | 'android' | 'ios'
@ -86,10 +88,51 @@ const androidApkName = isTestEnv ? 'app-production-debug.apk' : 'app-production-
const downloadUrlMap: Record<DownloadType, string> = {
pc: `${exeBaseUrl}/pc/Apim Capital-1.0.27.exe`,
android: `${exeBaseUrl}/app/${androidApkName}`,
ios: `${exeBaseUrl}/app/xxxx.apk`
ios: ''
}
// config.json ios.upload_url
// config.json /prod/test /config.json
const iosUploadUrl = ref<string>('')
const iosLoading = ref(false)
/**
* 调用统一封装在 src/api/modules/config.ts 的接口获取 /config.json
* 从中读取 ios.upload_url 作为 iOS 下载跳转地址
*/
const fetchIosUploadUrl = async (): Promise<string> => {
try {
const data = await getConfigApi()
console.log('data:', data);
const url = data?.ios?.upload_url
if (typeof url === 'string' && url.trim()) {
return url.trim()
}
console.warn('[Exe] /config.json 中未找到 ios.upload_url 字段')
return ''
} catch (err) {
console.error('[Exe] 请求 /config.json 出错:', err)
return ''
}
}
onMounted(async () => {
iosLoading.value = true
iosUploadUrl.value = await fetchIosUploadUrl()
iosLoading.value = false
})
const handleDownload = (type: DownloadType) => {
if (type === 'ios') {
if (!iosUploadUrl.value) {
//
return
}
// iOS App Store /
window.open(iosUploadUrl.value, '_blank', 'noopener,noreferrer')
return
}
const url: string = downloadUrlMap[type]
// 使 window.open ,
// a.download SPA
@ -114,6 +157,7 @@ const handleDownload = (type: DownloadType) => {
display: flex;
flex-direction: column;
gap: 16px;
padding: 10px 20px 0;
width: 100%;
.download-item {

View File

@ -0,0 +1,145 @@
<template>
<div class="profit-statistics table_form-container">
<!-- 搜索 -->
<ProfitStatisticsSearch
:search-form="searchForm"
:button-loading="loading"
:search-options="searchOptions"
@search="handleSearch"
@reset="handleReset"
>
<!-- 操作按钮导出 -->
<template #button>
<el-button
type="primary"
:loading="exportLoading"
:disabled="!tableData.length"
v-auth="'trade_profitStatistics_export'"
@click="handleExport"
>
导出
</el-button>
</template>
</ProfitStatisticsSearch>
<!-- 表格 -->
<ProfitStatisticsTable
:table-data="tableData"
:columns="tableColumnsOptions"
:loading="loading"
row-key="id"
border
highlight-current-row
>
<!-- 赢率后端返回 0~1 的小数这里转换为百分比 -->
<template #winRate="{ row }">
<span>{{ formatWinRate(row.winRate) }}</span>
</template>
</ProfitStatisticsTable>
</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import ProfitStatisticsSearch from '@/components/common/Search.vue'
import ProfitStatisticsTable from '@/components/common/Table.vue'
import { searchOptions, tableColumns } from './options'
import { rules as _rules } from './rules'
import { getProfitStatisticsList } from '@/api/modules/trade/profitStatistics'
import { exportToExcel } from '@/utils/exportToExcel'
//
const searchForm = ref({
mainAccountName: '',
subAccountName: '',
dateRange: [], // [startDate, endDate]
})
//
const tableData = ref<any[]>([])
const tableColumnsOptions = ref<any[]>(tableColumns)
//
const loading = ref(false)
const exportLoading = ref(false)
/**
* 搜索
*/
const handleSearch = async () => {
try {
loading.value = true
const [startDate = '', endDate = ''] = (searchForm.value.dateRange as string[]) || []
const { data } = await getProfitStatisticsList({
mainAccountName: searchForm.value.mainAccountName || undefined,
subAccountName: searchForm.value.subAccountName || undefined,
startDate: startDate || undefined,
endDate: endDate || undefined,
})
tableData.value = Array.isArray(data) ? data : (data as any)?.list || (data as any)?.records || []
} catch (e: any) {
ElMessage.error(e?.message || '查询失败')
tableData.value = []
} finally {
loading.value = false
}
}
/**
* 重置
*/
const handleReset = () => {
searchForm.value.mainAccountName = ''
searchForm.value.subAccountName = ''
searchForm.value.dateRange = []
}
/**
* 导出
* 复用项目通用导出工具导出当前查询结果
*/
const handleExport = async () => {
if (!tableData.value.length) {
ElMessage.warning('当前没有可导出的数据')
return
}
try {
exportLoading.value = true
await exportToExcel({
tableData: tableData.value,
columns: tableColumnsOptions.value,
title: '账户盈利统计',
filename: `账户盈利统计_${new Date().getTime()}`,
})
} catch (e: any) {
ElMessage.error(e?.message || '导出失败')
} finally {
exportLoading.value = false
}
}
/**
* 赢率格式化为百分比0.62 -> 62.00%
*/
const formatWinRate = (val: any) => {
if (val === null || val === undefined || val === '') return '-'
const num = Number(val)
if (Number.isNaN(num)) return '-'
// 0~100 0~1
const rate = num > 1 ? num : num * 100
return `${rate.toFixed(2)}%`
}
onMounted(() => {
// ""
})
</script>
<style scoped lang="scss">
.profit-statistics {
.cell-content {
display: inline-block;
}
}
</style>

View File

@ -0,0 +1,88 @@
/**
* - /
*/
import type { Ref } from 'vue'
/**
* Search
* - / input
* - daterange
*/
export const searchOptions: Ref<any[]> | any[] = [
// 主账户名
{
prop: 'mainAccountName',
label: '主账户名',
type: 'input' as const,
placeholder: '请输入主账户名',
clearable: true,
width: '200px',
},
// 子账户名
{
prop: 'subAccountName',
label: '子账户名',
type: 'input' as const,
placeholder: '请输入子账户名',
clearable: true,
width: '200px',
},
// 时间范围
{
prop: 'dateRange',
label: '时间日期',
type: 'date' as const,
dateType: 'daterange' as const,
rangeSeparator: '至',
startPlaceholder: '开始日期',
endPlaceholder: '结束日期',
valueFormat: 'YYYY-MM-DD',
format: 'YYYY-MM-DD',
width: '320px',
clearable: true,
},
]
/**
* Table
*/
export const tableColumns = [
// 序号列
{ type: 'index', label: '序号', align: 'center' as const, width: 60 },
// 主账户名
{ prop: 'mainAccountName', label: '主账户名', align: 'center' as const, minWidth: 140 },
// 子账户名
{ prop: 'subAccountName', label: '子账户名', align: 'center' as const, minWidth: 140 },
// 盈利金额
{
prop: 'profitAmount',
label: '盈利金额',
align: 'right' as const,
minWidth: 140,
isNumber: true,
},
// 单数
{
prop: 'orderCount',
label: '单数',
align: 'center' as const,
minWidth: 100,
isNumber: true,
},
// 手数
{
prop: 'lotCount',
label: '手数',
align: 'center' as const,
minWidth: 100,
isNumber: true,
},
// 赢率(百分比展示)
{
prop: 'winRate',
label: '赢率',
align: 'center' as const,
minWidth: 120,
slotName: 'winRate',
},
]

View File

@ -0,0 +1,7 @@
/**
* -
*
* /
* 便
*/
export const rules = {}

View File

@ -115,6 +115,12 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
// 将 /config.json 代理到 h5 域名,避免开发环境跨域
'/config.json': {
target: env.VITE_EXE_DOWNLOAD_BASE_URL || env.VITE_UPDATE_URL,
changeOrigin: true,
secure: true,
},
},
},
}