-
+ :default-sort="{ prop: 'createTime', order: 'descending' }" :loading="loading" @expand-change="handleGetSubList">
@@ -37,7 +37,7 @@
@pagination-change="handlePaginationChange" />
+ :show-footer="dialogType !== 'view'" :button-loading="submitLoading" @confirm="handleSubmit" @cancel="handleCancel" @close="handleClose">
@@ -54,7 +54,7 @@
-
@@ -78,7 +78,7 @@
+ :button-loading="editCustomerLoading" @confirm="handleEditCustomerSubmit" @cancel="handleEditCustomerCancel" @close="handleEditCustomerClose">
@@ -112,6 +112,7 @@ defineOptions({
// 组件
import CustomerListSearch from '@/components/common/Search.vue'
import CustomerListTable from '@/components/common/Table.vue'
+import { usePageLoading, useButtonLoading } from '@/composables/useLoading'
import CustomerListPagination from '@/components/common/Pagination.vue'
import CustomerListDialog from '@/components/common/Dialog.vue'
import CustomerListForm from '@/components/common/Form.vue'
@@ -145,6 +146,10 @@ const searchForm = ref({
const searchOptions = ref(search)
const tableColumnsOptions = ref(tableColumns)
+const { loading, startLoading, stopLoading } = usePageLoading()
+const { buttonLoading: submitLoading, startButtonLoading: startSubmitLoading, stopButtonLoading: stopSubmitLoading } = useButtonLoading()
+const { buttonLoading: adjustAmountLoading, startButtonLoading: startAdjustAmountLoading, stopButtonLoading: stopAdjustAmountLoading } = useButtonLoading()
+const { buttonLoading: editCustomerLoading, startButtonLoading: startEditCustomerLoading, stopButtonLoading: stopEditCustomerLoading } = useButtonLoading()
/**
* @description: 定义表格数据
*/
@@ -291,6 +296,7 @@ const roleMap: any = {
*/
// 获取客户列表
const getCustomerList = async () => {
+ startLoading()
const params = {
page: currentPage.value,
page_size: pageSize.value,
@@ -315,6 +321,8 @@ const getCustomerList = async () => {
//分页数据
total.value = data.total
+
+ stopLoading()
currentPage.value = data.current_page
pageSize.value = Number(data.per_page)
}
@@ -437,54 +445,58 @@ const handlePaginationChange = (page: { currentPage: number; pageSize: number })
/**
* @description: 定义弹窗方法
*/
-//提交
const handleSubmit = async () => {
- const params = {
- user_id: selectId.value,
- toucun_percent: '',
- point_diffs_json: '',
- fee_handling_percent: '',
- fee_setting_id: '',
- risk_control_id: '',
- }
- if (dialogType.value === 'editMarginRatio') {
- // 逐行验证
- for (const row of marginRatioTree.value) {
- const form = formRefs.value[(row as any).id]
- if (!form) continue
+ startSubmitLoading()
+ try {
+ const params = {
+ user_id: selectId.value,
+ toucun_percent: '',
+ point_diffs_json: '',
+ fee_handling_percent: '',
+ fee_setting_id: '',
+ risk_control_id: '',
+ }
+ if (dialogType.value === 'editMarginRatio') {
+ // 逐行验证
+ for (const row of marginRatioTree.value) {
+ const form = formRefs.value[(row as any).id]
+ if (!form) continue
+ try {
+ await form.validate()
+ } catch (err) {
+ console.error(`第 ${(row as any).id} 行验证不通过,请检查`)
+ return
+ }
+ }
+ //转换为接口需要的格式 { id: assignedPointDifference }
+ const marginRatioJSON = marginRatioTree.value.reduce((acc: any, cur: any) => {
+ acc[cur.id] = cur.assignedPointDifference * 1
+ return acc
+ }, {})
+
+ // 调用接口
try {
- await form.validate()
+ await editCustomerApi({ ...params, point_diffs_json: JSON.stringify(marginRatioJSON) })
+ dialogVisible.value = false
} catch (err) {
- console.error(`第 ${(row as any).id} 行验证不通过,请检查`)
- return
+ console.log('提交失败:', err)
}
}
- //转换为接口需要的格式 { id: assignedPointDifference }
- const marginRatioJSON = marginRatioTree.value.reduce((acc: any, cur: any) => {
- acc[cur.id] = cur.assignedPointDifference * 1
- return acc
- }, {})
-
- // 调用接口
- try {
- await editCustomerApi({ ...params, point_diffs_json: JSON.stringify(marginRatioJSON) })
- dialogVisible.value = false
- } catch (err) {
- console.log('提交失败:', err)
- }
- }
- if (dialogType.value === 'editCommissionRatio') {
- await commissionRatioFormRef.value.validate()
- try {
- await editCustomerApi({
- ...params,
- fee_handling_percent: commissionRatioForm.value.commissionRatio,
- })
- dialogVisible.value = false
- await getCustomerList()
- } catch (err) {
- console.log('提交失败:', err)
+ if (dialogType.value === 'editCommissionRatio') {
+ await commissionRatioFormRef.value.validate()
+ try {
+ await editCustomerApi({
+ ...params,
+ fee_handling_percent: commissionRatioForm.value.commissionRatio,
+ })
+ dialogVisible.value = false
+ await getCustomerList()
+ } catch (err) {
+ console.log('提交失败:', err)
+ }
}
+ } finally {
+ stopSubmitLoading()
}
}
// 取消
@@ -526,6 +538,7 @@ const handleAdjustAmountInput = () => {
// 提交调整金额
const handleAdjustAmountSubmit = async () => {
+ startAdjustAmountLoading()
try {
await adjustAmountFormRef.value?.validate()
await updateCapitalApi({
@@ -536,6 +549,8 @@ const handleAdjustAmountSubmit = async () => {
adjustAmountVisible.value = false
} catch (err) {
console.error('调整金额表单验证失败', err)
+ } finally {
+ stopAdjustAmountLoading()
}
}
@@ -597,6 +612,7 @@ const handleEditCustomer = async (row: any) => {
// 提交修改客户
const handleEditCustomerSubmit = async () => {
+ startEditCustomerLoading()
try {
await editCustomerFormRef.value?.validate()
await editUserApi({
@@ -611,6 +627,8 @@ const handleEditCustomerSubmit = async () => {
editCustomerVisible.value = false
} catch (err) {
console.error('修改客户表单验证失败', err)
+ } finally {
+ stopEditCustomerLoading()
}
}
diff --git a/src/views/profile/agent/options.ts b/src/views/profile/agent/options.ts
index 3e1321b..2ac7cfb 100644
--- a/src/views/profile/agent/options.ts
+++ b/src/views/profile/agent/options.ts
@@ -38,7 +38,7 @@ export const tableColumns = [
{ prop: 'role', label: '账号角色' },
// 账号数量
{ prop: 'accountQty', label: '账号数量' },
- { prop: 'wallet_capital.amount', label: '资金', align: 'center' as const },
+ { prop: 'wallet_capital.amount', label: '资金', align: 'center' as const, isNumber: true },
// 点差分配比例
{ prop: 'marginRatio', label: '点差分配比例', slotName: 'marginRatio' },
// 手续费分成比例
diff --git a/src/views/profile/business/index.vue b/src/views/profile/business/index.vue
index 1107d5f..6c77cbf 100644
--- a/src/views/profile/business/index.vue
+++ b/src/views/profile/business/index.vue
@@ -3,6 +3,7 @@
@@ -167,7 +169,7 @@
@@ -195,6 +197,7 @@ defineOptions({
// 组件
import MarketSearch from '@/components/common/Search.vue'
import MarketTable from '@/components/common/Table.vue'
+import { usePageLoading, useButtonLoading } from '@/composables/useLoading'
import MarketPagination from '@/components/common/Pagination.vue'
import MarketDialog from '@/components/common/Dialog.vue'
import MarketForm from '@/components/common/Form.vue'
@@ -239,6 +242,8 @@ const marketSearchForm = ref({
})
const marketSearchOptions = ref(marketSearch)
+const { loading, startLoading, stopLoading } = usePageLoading()
+const { buttonLoading: submitLoading, startButtonLoading: startSubmitLoading, stopButtonLoading: stopSubmitLoading } = useButtonLoading()
/**
* @description 定义表格数据
*/
@@ -565,6 +570,7 @@ const handleMarketFormLinkage = async (type: 'level' | 'parentAccountName', valu
*/
//获取做市商列表
const getMarketList = async () => {
+ startLoading()
const params = {
page: currentPage.value,
page_size: pageSize.value,
@@ -573,8 +579,10 @@ const getMarketList = async () => {
const data = await getMarketListApi(params)
// 表格数据
marketTree.value = mapMarketTree(data.data)
+ total.value = data.total
+
//分页数据
- total.value = data.total
+ stopLoading()
currentPage.value = data.current_page
pageSize.value = Number(data.per_page)
}
@@ -795,55 +803,60 @@ const formatPointDiffToObject = () => {
//提交
const handleSubmit = async () => {
- // console.log('提交', marketPointTree.value);
- await marketFormRef.value?.validate()
- const pointDiffObj = formatPointDiffToObject()
- console.log('pointDiffObj', pointDiffObj)
- if (!pointDiffObj) return
- if (dialogType.value === 'add') {
- const params: Record = {
- role_id: marketForm.value.level,
- reg_type: activeTab.value === 'email' ? '1' : '2',
- username: marketForm.value.accountName,
- par_user_id: marketForm.value.parentAccountName,
- mobile: activeTab.value === 'phone' ? marketForm.value.phone : '',
- email: activeTab.value === 'email' ? marketForm.value.email : '',
- password: '888888',
- toucun_percent: marketForm.value.positionRatio,
- fee_handling_percent: marketForm.value.commissionRatio,
- point_diffs_json: JSON.stringify(pointDiffObj),
- risk_control_id: marketForm.value.riskControlTemplate,
- fee_setting_id: '',
+ startSubmitLoading()
+ try {
+ // console.log('提交', marketPointTree.value);
+ await marketFormRef.value?.validate()
+ const pointDiffObj = formatPointDiffToObject()
+ console.log('pointDiffObj', pointDiffObj)
+ if (!pointDiffObj) return
+ if (dialogType.value === 'add') {
+ const params: Record = {
+ role_id: marketForm.value.level,
+ reg_type: activeTab.value === 'email' ? '1' : '2',
+ username: marketForm.value.accountName,
+ par_user_id: marketForm.value.parentAccountName,
+ mobile: activeTab.value === 'phone' ? marketForm.value.phone : '',
+ email: activeTab.value === 'email' ? marketForm.value.email : '',
+ password: '888888',
+ toucun_percent: marketForm.value.positionRatio,
+ fee_handling_percent: marketForm.value.commissionRatio,
+ point_diffs_json: JSON.stringify(pointDiffObj),
+ risk_control_id: marketForm.value.riskControlTemplate,
+ fee_setting_id: '',
+ }
+ if (marketForm.value.level === '5') params.flag = 1
+ if (marketForm.value.level === '6') {
+ params.flag = 2
+ params.role_id = '5'
+ }
+ await addMarketApi(params)
+ // 5. 刷新表格数据
+ await getMarketList()
+ dialogVisible.value = false
+ marketForm.value = { ...initMarketForm }
+ } else if (dialogType.value === 'edit') {
+ let flag = null
+ if (selectedRow.value.role_id * 1 === 5 && selectedRow.value.type * 1 === 1) flag = 1
+ if (selectedRow.value.role_id * 1 === 6 && selectedRow.value.type * 1 === 2) flag = 2
+ const params = {
+ user_id: selectedRow.value.id,
+ toucun_percent: marketForm.value.positionRatio,
+ point_diffs_json: JSON.stringify(pointDiffObj),
+ risk_control_id: marketForm.value.riskControlTemplate,
+ fee_handling_percent: marketForm.value.commissionRatio,
+ flag: flag,
+ fee_setting_id: '',
+ }
+ // 4. 调用编辑接口
+ await editMarketApi(params)
+ // 5. 刷新表格数据
+ await getMarketList()
+ dialogVisible.value = false
+ marketForm.value = { ...initMarketForm }
}
- if (marketForm.value.level === '5') params.flag = 1
- if (marketForm.value.level === '6') {
- params.flag = 2
- params.role_id = '5'
- }
- await addMarketApi(params)
- // 5. 刷新表格数据
- await getMarketList()
- dialogVisible.value = false
- marketForm.value = { ...initMarketForm }
- } else if (dialogType.value === 'edit') {
- let flag = null
- if (selectedRow.value.role_id * 1 === 5 && selectedRow.value.type * 1 === 1) flag = 1
- if (selectedRow.value.role_id * 1 === 6 && selectedRow.value.type * 1 === 2) flag = 2
- const params = {
- user_id: selectedRow.value.id,
- toucun_percent: marketForm.value.positionRatio,
- point_diffs_json: JSON.stringify(pointDiffObj),
- risk_control_id: marketForm.value.riskControlTemplate,
- fee_handling_percent: marketForm.value.commissionRatio,
- flag: flag,
- fee_setting_id: '',
- }
- // 4. 调用编辑接口
- await editMarketApi(params)
- // 5. 刷新表格数据
- await getMarketList()
- dialogVisible.value = false
- marketForm.value = { ...initMarketForm }
+ } finally {
+ stopSubmitLoading()
}
}
diff --git a/src/views/profile/business/options.ts b/src/views/profile/business/options.ts
index e701315..f0186ae 100644
--- a/src/views/profile/business/options.ts
+++ b/src/views/profile/business/options.ts
@@ -25,34 +25,35 @@ export const marketTableColumns = [
//基本账户
{ label: '基本账户', prop: 'basicAccount', align: 'center' as const, width: '200px' },
//保证金
- { label: '保证金', prop: 'margin', align: 'center' as const, width: '200px' },
+ { label: '保证金', prop: 'margin', align: 'center' as const, width: '200px', isNumber: true },
//停止接单保证金
- { label: '停止接单保证金', prop: 'stopOrderMargin', align: 'center' as const, width: '200px' },
+ { label: '停止接单保证金', prop: 'stopOrderMargin', align: 'center' as const, width: '200px', isNumber: true },
//持仓转移保证金
{
label: '持仓转移保证金',
prop: 'positionTransferMargin',
align: 'center' as const,
width: '200px',
+ isNumber: true,
},
//头寸比率
- { label: '头寸比率', prop: 'positionRatio', align: 'center' as const, width: '150px' },
+ { label: '头寸比率', prop: 'positionRatio', align: 'center' as const, width: '150px', isNumber: true },
//点差返佣
- { label: '点差返佣', prop: 'pointSpreadCommission', align: 'center' as const, width: '200px' },
+ { 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' },
+ { label: '手续费比例', prop: 'commissionRatio', align: 'center' as const, width: '150px', isNumber: true },
//手续费返佣
- { label: '手续费返佣', prop: 'commissionReturn', align: 'center' as const, width: '150px' },
+ { label: '手续费返佣', prop: 'commissionReturn', align: 'center' as const, width: '150px', isNumber: true },
//浮动盈亏
- { label: '浮动盈亏', prop: 'floatProfitLoss', align: 'center' as const, width: '100px' },
+ { label: '浮动盈亏', prop: 'floatProfitLoss', align: 'center' as const, width: '100px', isNumber: true },
//平仓盈亏
- { label: '平仓盈亏', prop: 'closeProfitLoss', align: 'center' as const, width: '150px' },
+ { label: '平仓盈亏', prop: 'closeProfitLoss', align: 'center' as const, width: '150px', isNumber: true },
//风险金
- { label: '风险金', prop: 'riskMargin', align: 'center' as const, width: '150px' },
+ { label: '风险金', prop: 'riskMargin', align: 'center' as const, width: '150px', isNumber: true },
//服务费
- { label: '服务费', prop: 'serviceFee', align: 'center' as const, width: '150px' },
+ { label: '服务费', prop: 'serviceFee', align: 'center' as const, width: '150px', isNumber: true },
]
//做市商添加配置
diff --git a/src/views/profile/personalCenter/index.vue b/src/views/profile/personalCenter/index.vue
index dd53598..6d276c1 100644
--- a/src/views/profile/personalCenter/index.vue
+++ b/src/views/profile/personalCenter/index.vue
@@ -69,7 +69,7 @@
-