-
+ :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,7 +112,7 @@ defineOptions({
// 组件
import CustomerListSearch from '@/components/common/Search.vue'
import CustomerListTable from '@/components/common/Table.vue'
-import { usePageLoading } from '@/composables/useLoading'
+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'
@@ -147,6 +147,9 @@ 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: 定义表格数据
*/
@@ -442,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()
}
}
// 取消
@@ -531,6 +538,7 @@ const handleAdjustAmountInput = () => {
// 提交调整金额
const handleAdjustAmountSubmit = async () => {
+ startAdjustAmountLoading()
try {
await adjustAmountFormRef.value?.validate()
await updateCapitalApi({
@@ -541,6 +549,8 @@ const handleAdjustAmountSubmit = async () => {
adjustAmountVisible.value = false
} catch (err) {
console.error('调整金额表单验证失败', err)
+ } finally {
+ stopAdjustAmountLoading()
}
}
@@ -602,6 +612,7 @@ const handleEditCustomer = async (row: any) => {
// 提交修改客户
const handleEditCustomerSubmit = async () => {
+ startEditCustomerLoading()
try {
await editCustomerFormRef.value?.validate()
await editUserApi({
@@ -616,6 +627,8 @@ const handleEditCustomerSubmit = async () => {
editCustomerVisible.value = false
} catch (err) {
console.error('修改客户表单验证失败', err)
+ } finally {
+ stopEditCustomerLoading()
}
}
diff --git a/src/views/profile/business/index.vue b/src/views/profile/business/index.vue
index c3f8e41..f00f08e 100644
--- a/src/views/profile/business/index.vue
+++ b/src/views/profile/business/index.vue
@@ -3,6 +3,7 @@
{
//提交
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/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 @@
-