|
@@ -4,7 +4,7 @@
|
|
|
<uni-forms ref="formRef" labelWidth="200">
|
|
<uni-forms ref="formRef" labelWidth="200">
|
|
|
<uni-forms-item v-if="isFormApplyIb" :label="t('Ib.Custom.Manage3')+':'" prop="customerId">
|
|
<uni-forms-item v-if="isFormApplyIb" :label="t('Ib.Custom.Manage3')+':'" prop="customerId">
|
|
|
<cwg-combox v-model:value="addAgentForm.customerId" :options="customerList"
|
|
<cwg-combox v-model:value="addAgentForm.customerId" :options="customerList"
|
|
|
- :placeholder="t('placeholder.choose')" filterable/>
|
|
|
|
|
|
|
+ :placeholder="t('placeholder.choose')" filterable @change="changeCustomer" />
|
|
|
</uni-forms-item>
|
|
</uni-forms-item>
|
|
|
<view class="commission-groups">
|
|
<view class="commission-groups">
|
|
|
<view v-for="(group, gIndex) in commissionTemplateTableData" :key="gIndex" class="group-card">
|
|
<view v-for="(group, gIndex) in commissionTemplateTableData" :key="gIndex" class="group-card">
|
|
@@ -14,7 +14,8 @@
|
|
|
<text class="title-text">{{ group.accountGroup }}</text>
|
|
<text class="title-text">{{ group.accountGroup }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="group-switch" @click.stop>
|
|
<view class="group-switch" @click.stop>
|
|
|
- <switch :checked="group.isOpen" @change="(e) => onGroupSwitchChange(e, group)" color="#2b5aed" style="transform:scale(0.8)"/>
|
|
|
|
|
|
|
+ <switch :checked="group.isOpen" @change="(e) => onGroupSwitchChange(e, group)" color="#2b5aed"
|
|
|
|
|
+ style="transform:scale(0.8)" />
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -22,58 +23,58 @@
|
|
|
<view v-show="group.isOpen" class="group-body">
|
|
<view v-show="group.isOpen" class="group-body">
|
|
|
<view v-for="(item, iIndex) in group.items" :key="iIndex" class="item-row">
|
|
<view v-for="(item, iIndex) in group.items" :key="iIndex" class="item-row">
|
|
|
<view class="item-title">
|
|
<view class="item-title">
|
|
|
- <text class="type-badge">{{ item.dataType === 'rebates' ? 'Rebates' : 'Commissions' }}</text>
|
|
|
|
|
|
|
+ <!-- <text class="type-badge">{{ item.dataType === 'rebates' ? 'Rebates' : 'Commissions' }}</text>-->
|
|
|
<text class="type-text">{{ item.type }}</text>
|
|
<text class="type-text">{{ item.type }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<view class="item-fields">
|
|
<view class="item-fields">
|
|
|
<!-- METAL -->
|
|
<!-- METAL -->
|
|
|
<view class="field-col">
|
|
<view class="field-col">
|
|
|
<text class="field-label">METAL</text>
|
|
<text class="field-label">METAL</text>
|
|
|
- <cwg-combox
|
|
|
|
|
- v-model:value="item.energy"
|
|
|
|
|
- :options="formatOptions(item.energyOptions)"
|
|
|
|
|
- :placeholder="t('placeholder.choose')"
|
|
|
|
|
|
|
+ <cwg-combox
|
|
|
|
|
+ v-model:value="item.energy"
|
|
|
|
|
+ :options="formatOptions(item.energyOptions)"
|
|
|
|
|
+ :placeholder="t('placeholder.choose')"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<!-- FX -->
|
|
<!-- FX -->
|
|
|
<view class="field-col">
|
|
<view class="field-col">
|
|
|
<text class="field-label">FX</text>
|
|
<text class="field-label">FX</text>
|
|
|
- <cwg-combox
|
|
|
|
|
- v-model:value="item.forex"
|
|
|
|
|
- :options="formatOptions(item.forexOptions)"
|
|
|
|
|
- :placeholder="t('placeholder.choose')"
|
|
|
|
|
|
|
+ <cwg-combox
|
|
|
|
|
+ v-model:value="item.forex"
|
|
|
|
|
+ :options="formatOptions(item.forexOptions)"
|
|
|
|
|
+ :placeholder="t('placeholder.choose')"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<!-- ENERGY -->
|
|
<!-- ENERGY -->
|
|
|
<view class="field-col">
|
|
<view class="field-col">
|
|
|
<text class="field-label">ENERGY</text>
|
|
<text class="field-label">ENERGY</text>
|
|
|
- <cwg-combox
|
|
|
|
|
- v-model:value="item.energy2"
|
|
|
|
|
- :options="formatOptions(item.energy2Options)"
|
|
|
|
|
- :placeholder="t('placeholder.choose')"
|
|
|
|
|
|
|
+ <cwg-combox
|
|
|
|
|
+ v-model:value="item.energy2"
|
|
|
|
|
+ :options="formatOptions(item.energy2Options)"
|
|
|
|
|
+ :placeholder="t('placeholder.choose')"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<!-- CFD -->
|
|
<!-- CFD -->
|
|
|
<view class="field-col">
|
|
<view class="field-col">
|
|
|
<text class="field-label">CFD</text>
|
|
<text class="field-label">CFD</text>
|
|
|
- <cwg-combox
|
|
|
|
|
- v-model:value="item.index"
|
|
|
|
|
- :options="formatOptions(item.indexOptions)"
|
|
|
|
|
- :placeholder="t('placeholder.choose')"
|
|
|
|
|
|
|
+ <cwg-combox
|
|
|
|
|
+ v-model:value="item.index"
|
|
|
|
|
+ :options="formatOptions(item.indexOptions)"
|
|
|
|
|
+ :placeholder="t('placeholder.choose')"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<!-- INDEX -->
|
|
<!-- INDEX -->
|
|
|
<view class="field-col">
|
|
<view class="field-col">
|
|
|
<text class="field-label">INDEX</text>
|
|
<text class="field-label">INDEX</text>
|
|
|
- <cwg-combox
|
|
|
|
|
- v-model:value="item.metal"
|
|
|
|
|
- :options="formatOptions(item.metalOptions)"
|
|
|
|
|
- :placeholder="t('placeholder.choose')"
|
|
|
|
|
|
|
+ <cwg-combox
|
|
|
|
|
+ v-model:value="item.metal"
|
|
|
|
|
+ :options="formatOptions(item.metalOptions)"
|
|
|
|
|
+ :placeholder="t('placeholder.choose')"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -104,7 +105,7 @@
|
|
|
default: false,
|
|
default: false,
|
|
|
},
|
|
},
|
|
|
// 详情tableData
|
|
// 详情tableData
|
|
|
- detail: { type: Array, default: () => ([]) },
|
|
|
|
|
|
|
+ detail: { type: Array, default: () => ({}) },
|
|
|
isFormApplyIb: {
|
|
isFormApplyIb: {
|
|
|
type: Boolean,
|
|
type: Boolean,
|
|
|
default: true,
|
|
default: true,
|
|
@@ -134,16 +135,14 @@
|
|
|
initCommissionTemplateData(29634)
|
|
initCommissionTemplateData(29634)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- watch(() => props.detail, (val) => {
|
|
|
|
|
|
|
+ watch(() => props.visible, (val) => {
|
|
|
if (val) {
|
|
if (val) {
|
|
|
- const { cId, id, comPoint1, hide1 } = val
|
|
|
|
|
- dialogForm.value = {
|
|
|
|
|
- cId, id, comPoint1, hide1,
|
|
|
|
|
|
|
+ loadCustomerList()
|
|
|
|
|
+
|
|
|
|
|
+ // initCommissionTemplateData(29634)
|
|
|
|
|
+ if (props.detail.id) {
|
|
|
|
|
+ initCommissionTemplateData(val.id)
|
|
|
}
|
|
}
|
|
|
- initCommissionTemplateData(29634)
|
|
|
|
|
- // if (val.id) {
|
|
|
|
|
- // initCommissionTemplateData(val.id)
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -165,11 +164,11 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const generateOptions = (currentValue) => {
|
|
const generateOptions = (currentValue) => {
|
|
|
- const options = [];
|
|
|
|
|
|
|
+ const options = []
|
|
|
for (let i = 0; i <= currentValue; i++) {
|
|
for (let i = 0; i <= currentValue; i++) {
|
|
|
- options.push(i);
|
|
|
|
|
|
|
+ options.push(i)
|
|
|
}
|
|
}
|
|
|
- return options;
|
|
|
|
|
|
|
+ return options
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 格式化 options 为 combox 期望的格式
|
|
// 格式化 options 为 combox 期望的格式
|
|
@@ -196,7 +195,7 @@
|
|
|
res.data.forEach((group: any) => {
|
|
res.data.forEach((group: any) => {
|
|
|
const accountGroup = group.groupCategoryName || '--'
|
|
const accountGroup = group.groupCategoryName || '--'
|
|
|
const valid = group.valid !== undefined ? group.valid : 1
|
|
const valid = group.valid !== undefined ? group.valid : 1
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!groupedData[accountGroup]) {
|
|
if (!groupedData[accountGroup]) {
|
|
|
groupedData[accountGroup] = []
|
|
groupedData[accountGroup] = []
|
|
|
}
|
|
}
|
|
@@ -303,7 +302,7 @@
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- console.log('tableData',finalData)
|
|
|
|
|
|
|
+ console.log('tableData', finalData)
|
|
|
commissionTemplateTableData.value = finalData
|
|
commissionTemplateTableData.value = finalData
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -319,45 +318,159 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 加载客户列表
|
|
|
|
|
+ const loadCustomerList = async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ let res = await ibApi.customerSubsList({
|
|
|
|
|
+ ibStatus: 1,
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.code == Code.StatusOK) {
|
|
|
|
|
+ customerList.value = res.data.map(item => ({
|
|
|
|
|
+ label: `${item.name || ''}-${item.cId}`,
|
|
|
|
|
+ value: item.id || '',
|
|
|
|
|
+ cId: item.cId // 保存 cId 供后续提交使用
|
|
|
|
|
+ })) || []
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({ title: res.msg, icon: 'none' })
|
|
|
|
|
+ customerList.value = []
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('加载客户列表失败:', error)
|
|
|
|
|
+ customerList.value = []
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 客户选择改变时触发
|
|
|
|
|
+ const changeCustomer = (val) => {
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ initCommissionTemplateData(val)
|
|
|
|
|
+ }else {
|
|
|
|
|
+ commissionTemplateTableData.value = []
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 构建佣金模板points数据
|
|
|
|
|
+ const buildCommissionTemplatePoints = () => {
|
|
|
|
|
+ const points: any[] = []
|
|
|
|
|
+ const groupedData: Record<string, any> = {}
|
|
|
|
|
+
|
|
|
|
|
+ // 由于现在的 commissionTemplateTableData 是 { accountGroup, isOpen, items } 嵌套结构,需要双层遍历提取
|
|
|
|
|
+ commissionTemplateTableData.value.forEach((groupObj) => {
|
|
|
|
|
+ groupObj.items.forEach((row: any) => {
|
|
|
|
|
+ const groupId = row.groupCategoryId
|
|
|
|
|
+ if (!groupedData[groupId]) {
|
|
|
|
|
+ groupedData[groupId] = {
|
|
|
|
|
+ groupCategoryId: groupId,
|
|
|
|
|
+ commissions: [],
|
|
|
|
|
+ rebates: [],
|
|
|
|
|
+ valid: groupObj.isOpen ? 1 : 0,
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 根据dataType添加到对应的数组
|
|
|
|
|
+ const pointList = row.dataType === 'commissions'
|
|
|
|
|
+ ? groupedData[groupId].commissions
|
|
|
|
|
+ : groupedData[groupId].rebates
|
|
|
|
|
+
|
|
|
|
|
+ // 添加各个symbolCategory的数据
|
|
|
|
|
+ if (row.forex !== undefined && row.forex !== null) {
|
|
|
|
|
+ pointList.push({ symbolCategory: 1, point: row.forex }) // FX
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.index !== undefined && row.index !== null) {
|
|
|
|
|
+ pointList.push({ symbolCategory: 2, point: row.index }) // CFD
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.metal !== undefined && row.metal !== null) {
|
|
|
|
|
+ pointList.push({ symbolCategory: 3, point: row.metal }) // INDEX
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.energy !== undefined && row.energy !== null) {
|
|
|
|
|
+ pointList.push({ symbolCategory: 4, point: row.energy }) // METAL
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.energy2 !== undefined && row.energy2 !== null) {
|
|
|
|
|
+ pointList.push({ symbolCategory: 5, point: row.energy2 }) // Energy
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为数组格式
|
|
|
|
|
+ Object.keys(groupedData).forEach((groupId) => {
|
|
|
|
|
+ const group = groupedData[groupId]
|
|
|
|
|
+ if (group.commissions.length > 0 || group.rebates.length > 0) {
|
|
|
|
|
+ points.push({
|
|
|
|
|
+ groupCategoryId: group.groupCategoryId,
|
|
|
|
|
+ commissions: group.commissions.length > 0 ? group.commissions : undefined,
|
|
|
|
|
+ rebates: group.rebates.length > 0 ? group.rebates : undefined,
|
|
|
|
|
+ valid: group.valid,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ return points
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const toVerified = () => {
|
|
const toVerified = () => {
|
|
|
// 确认按钮点击事件
|
|
// 确认按钮点击事件
|
|
|
emit('confirm')
|
|
emit('confirm')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const cancel = () => {
|
|
|
|
|
- // 取消按钮点击事件
|
|
|
|
|
- emit('close')
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
const closeDia = () => {
|
|
const closeDia = () => {
|
|
|
|
|
+ commissionTemplateTableData.value = []
|
|
|
emit('close')
|
|
emit('close')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const confirmDia = async () => {
|
|
const confirmDia = async () => {
|
|
|
- // 确认按钮点击事件
|
|
|
|
|
- const loginConfig = []
|
|
|
|
|
- Object.keys(commissionAccountTypeSettings.value).forEach((key) => {
|
|
|
|
|
- const setting = commissionAccountTypeSettings.value[key]
|
|
|
|
|
- if (setting.selectedItem) {
|
|
|
|
|
- loginConfig.push(setting.selectedItem)
|
|
|
|
|
|
|
+ let customId, cId
|
|
|
|
|
+
|
|
|
|
|
+ if (!props.isFormApplyIb) {
|
|
|
|
|
+ if (!props.detail.id) {
|
|
|
|
|
+ uni.showToast({ title: t('Ib.Custom.CustomerNotExist'), icon: 'none' })
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- let res = await ibApi.customCommissionPoint({
|
|
|
|
|
- id: dialogForm.value.id,
|
|
|
|
|
- loginConfig,
|
|
|
|
|
- })
|
|
|
|
|
- if (res.code == Code.StatusOK) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: t('Msg.ModifySuccess'),
|
|
|
|
|
- })
|
|
|
|
|
- cancel()
|
|
|
|
|
|
|
+ const applyIbRowData: any = props.detail || {}
|
|
|
|
|
+ customId = applyIbRowData.id
|
|
|
|
|
+ cId = applyIbRowData.cId
|
|
|
} else {
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
|
|
- title: res.msg,
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
|
|
+ // 从其他地方打开,需要选择客户
|
|
|
|
|
+ if (!addAgentForm.value.customerId) {
|
|
|
|
|
+ uni.showToast({ title: t('placeholder.choose'), icon: 'none' })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 从客户列表中找到选中的客户对象
|
|
|
|
|
+ const selectedCustomer: any = customerList.value.find(
|
|
|
|
|
+ (item: any) => item.value === addAgentForm.value.customerId
|
|
|
|
|
+ )
|
|
|
|
|
+ if (!selectedCustomer) {
|
|
|
|
|
+ uni.showToast({ title: t('Ib.Custom.CustomerNotFound'), icon: 'none' })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ customId = selectedCustomer.value
|
|
|
|
|
+ cId = selectedCustomer.cId
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 构建points数据
|
|
|
|
|
+ const points = buildCommissionTemplatePoints()
|
|
|
|
|
+ console.log(points)
|
|
|
|
|
+ // 调用新增代理申请接口
|
|
|
|
|
+ const res = await ibApi.agentApplyAddPoint({
|
|
|
|
|
+ customId: customId,
|
|
|
|
|
+ cId: cId,
|
|
|
|
|
+ points: points,
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ if (res.code == Code.StatusOK) {
|
|
|
|
|
+ uni.showToast({ title: res.msg || t('Ib.Custom.SubmitSuccess'), icon: 'success' })
|
|
|
|
|
+ closeDia()
|
|
|
|
|
+ emit('confirm') // 刷新列表
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({ title: res.msg || t('Ib.Custom.SubmitFailed'), icon: 'none' })
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('新增代理失败:', error)
|
|
|
|
|
+ uni.showToast({ title: t('Ib.Custom.SubmitFailed'), icon: 'none' })
|
|
|
}
|
|
}
|
|
|
- emit('confirm')
|
|
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|