|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <cwg-popup :title="t('Ib.Report.Title5')" :visible="visible" @close="closeDia" @confirm="confirmDia">
|
|
|
+ <cwg-popup :title="t(title)" :visible="visible" @close="closeDia" @confirm="confirmDia">
|
|
|
<view class="dia-content">
|
|
|
<uni-forms ref="formRef" labelWidth="200">
|
|
|
<uni-forms-item v-if="isFormApplyIb" :label="t('Ib.Custom.Manage3')+':'" prop="customerId">
|
|
|
@@ -99,6 +99,14 @@
|
|
|
import { lang } from '@/composables/config'
|
|
|
|
|
|
const props = defineProps({
|
|
|
+ paramsType: {
|
|
|
+ type: String,
|
|
|
+ default: 'vietnam'
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ default: 'Ib.Report.Title5',
|
|
|
+ },
|
|
|
// 是否显示弹窗
|
|
|
visible: {
|
|
|
type: Boolean,
|
|
|
@@ -106,9 +114,10 @@
|
|
|
},
|
|
|
// 详情tableData
|
|
|
detail: { type: Array, default: () => ({}) },
|
|
|
+ // 是否需要选择客户
|
|
|
isFormApplyIb: {
|
|
|
type: Boolean,
|
|
|
- default: true,
|
|
|
+ default: false,
|
|
|
},
|
|
|
})
|
|
|
const { Code, Host80 } = Config
|
|
|
@@ -132,7 +141,7 @@
|
|
|
const emit = defineEmits(['close', 'confirm'])
|
|
|
|
|
|
onMounted(() => {
|
|
|
- initCommissionTemplateData(29634)
|
|
|
+ // initCommissionTemplateData(29634)
|
|
|
})
|
|
|
|
|
|
watch(() => props.visible, (val) => {
|
|
|
@@ -141,7 +150,15 @@
|
|
|
|
|
|
// initCommissionTemplateData(29634)
|
|
|
if (props.detail.id) {
|
|
|
- initCommissionTemplateData(val.id)
|
|
|
+ let params = {
|
|
|
+ customerId: props.detail.id,
|
|
|
+ }
|
|
|
+ if (props.paramsType == 'vietnam') {
|
|
|
+ params = {
|
|
|
+ agentId: 91886//props.params.id,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ initCommissionTemplateData(params)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -185,9 +202,9 @@
|
|
|
group.isOpen = e.detail.value
|
|
|
}
|
|
|
|
|
|
- const initCommissionTemplateData = async (customId: string | number) => {
|
|
|
+ const initCommissionTemplateData = async (params) => {
|
|
|
try {
|
|
|
- const res = await ibApi.getVietnamPoints({ customId })
|
|
|
+ const res = await ibApi.getVietnamPoints(params)
|
|
|
|
|
|
if (res.code == Code.StatusOK && res.data && Array.isArray(res.data)) {
|
|
|
const groupedData: Record<string, any[]> = {}
|
|
|
@@ -329,7 +346,7 @@
|
|
|
customerList.value = res.data.map(item => ({
|
|
|
label: `${item.name || ''}-${item.cId}`,
|
|
|
value: item.id || '',
|
|
|
- cId: item.cId // 保存 cId 供后续提交使用
|
|
|
+ cId: item.cId, // 保存 cId 供后续提交使用
|
|
|
})) || []
|
|
|
} else {
|
|
|
uni.showToast({ title: res.msg, icon: 'none' })
|
|
|
@@ -345,8 +362,8 @@
|
|
|
// 客户选择改变时触发
|
|
|
const changeCustomer = (val) => {
|
|
|
if (val) {
|
|
|
- initCommissionTemplateData(val)
|
|
|
- }else {
|
|
|
+ initCommissionTemplateData({ customId: val })
|
|
|
+ } else {
|
|
|
commissionTemplateTableData.value = []
|
|
|
}
|
|
|
}
|
|
|
@@ -365,7 +382,7 @@
|
|
|
groupCategoryId: groupId,
|
|
|
commissions: [],
|
|
|
rebates: [],
|
|
|
- valid: groupObj.isOpen ? 1 : 0,
|
|
|
+ valid: groupObj.isOpen ? 1 : 0,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -420,56 +437,70 @@
|
|
|
}
|
|
|
|
|
|
const confirmDia = async () => {
|
|
|
+ // 越南分配也用,看怎么调整提交接口
|
|
|
let customId, cId
|
|
|
|
|
|
- if (!props.isFormApplyIb) {
|
|
|
- if (!props.detail.id) {
|
|
|
- uni.showToast({ title: t('Ib.Custom.CustomerNotExist'), icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
- const applyIbRowData: any = props.detail || {}
|
|
|
- customId = applyIbRowData.id
|
|
|
- cId = applyIbRowData.cId
|
|
|
- } else {
|
|
|
- // 从其他地方打开,需要选择客户
|
|
|
- if (!addAgentForm.value.customerId) {
|
|
|
- uni.showToast({ title: t('placeholder.choose'), icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
+ // 越南佣金分配不用判断customId
|
|
|
+ if (props.paramsType !== 'vietnam') {
|
|
|
+ if (!props.isFormApplyIb) {
|
|
|
+ if (!props.detail.id) {
|
|
|
+ uni.showToast({ title: t('Ib.Custom.CustomerNotExist'), icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const applyIbRowData: any = props.detail || {}
|
|
|
+ customId = applyIbRowData.id
|
|
|
+ cId = applyIbRowData.cId
|
|
|
+ } else {
|
|
|
+ // 从其他地方打开,需要选择客户
|
|
|
+ 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
|
|
|
+ // 从客户列表中找到选中的客户对象
|
|
|
+ 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
|
|
|
}
|
|
|
- customId = selectedCustomer.value
|
|
|
- cId = selectedCustomer.cId
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
// 构建points数据
|
|
|
const points = buildCommissionTemplatePoints()
|
|
|
- console.log(points)
|
|
|
+ // console.log(points)
|
|
|
// 调用新增代理申请接口
|
|
|
- const res = await ibApi.agentApplyAddPoint({
|
|
|
+ let params = {
|
|
|
customId: customId,
|
|
|
cId: cId,
|
|
|
points: points,
|
|
|
- })
|
|
|
+ }
|
|
|
+ if (props.paramsType === 'vietnam') {
|
|
|
+ params = {
|
|
|
+ agentId: props.detail.id,
|
|
|
+ points: points,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 越南分配和新增代理
|
|
|
+ const res = props.paramsType === 'vietnam' ?await ibApi.saveVietnamPoints(params):await ibApi.agentApplyAddPoint(params)
|
|
|
|
|
|
if (res.code == Code.StatusOK) {
|
|
|
- uni.showToast({ title: res.msg || t('Ib.Custom.SubmitSuccess'), icon: 'success' })
|
|
|
+ uni.showToast({ title: res.msg || props.paramsType?t("Ib.Custom.SaveSuccess"):t('Ib.Custom.SubmitSuccess'), icon: 'success' })
|
|
|
closeDia()
|
|
|
- emit('confirm') // 刷新列表
|
|
|
+ emit('confirm')
|
|
|
+
|
|
|
} else {
|
|
|
- uni.showToast({ title: res.msg || t('Ib.Custom.SubmitFailed'), icon: 'none' })
|
|
|
+ uni.showToast({ title: res.msg || props.paramsType?t("Ib.Custom.SaveFailed"):t('Ib.Custom.SubmitFailed'), icon: 'none' })
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('新增代理失败:', error)
|
|
|
- uni.showToast({ title: t('Ib.Custom.SubmitFailed'), icon: 'none' })
|
|
|
+ console.error('新增代理失败或保存越南分配数据失败:', error)
|
|
|
+ uni.showToast({ title: props.paramsType?t("Ib.Custom.SaveFailed"):t('Ib.Custom.SubmitFailed'), icon: 'none' })
|
|
|
}
|
|
|
}
|
|
|
</script>
|