diff --git a/src/api/mall/trade/brokerage/user/index.ts b/src/api/mall/trade/brokerage/user/index.ts
index 95f3a6a1..213a6cbd 100644
--- a/src/api/mall/trade/brokerage/user/index.ts
+++ b/src/api/mall/trade/brokerage/user/index.ts
@@ -8,6 +8,8 @@ export interface BrokerageUserVO {
brokerageTime: Date
price: number
frozenPrice: number
+
+ nickname: string
}
// 查询分销用户列表
@@ -19,3 +21,18 @@ export const getBrokerageUserPage = async (params: any) => {
export const getBrokerageUser = async (id: number) => {
return await request.get({ url: `/trade/brokerage-user/get?id=` + id })
}
+
+// 修改推广员
+export const updateBindUser = async (data: any) => {
+ return await request.put({ url: `/trade/brokerage-user/update-bind-user`, data })
+}
+
+// 清除推广员
+export const clearBindUser = async (data: any) => {
+ return await request.put({ url: `/trade/brokerage-user/clear-bind-user`, data })
+}
+
+// 修改推广资格
+export const updateBrokerageEnabled = async (data: any) => {
+ return await request.put({ url: `/trade/brokerage-user/update-brokerage-enable`, data })
+}
diff --git a/src/views/mall/trade/brokerage/user/index.vue b/src/views/mall/trade/brokerage/user/index.vue
index db59c52d..4e67cc8c 100644
--- a/src/views/mall/trade/brokerage/user/index.vue
+++ b/src/views/mall/trade/brokerage/user/index.vue
@@ -104,8 +104,8 @@
active-text="有"
inactive-text="无"
inline-prompt
- :disabled="!checkPermi(['trade:brokerage-user:update-brokerage-user'])"
- @change="handleBrokerageEnabledChange(scope.row.id, !scope.row.brokerageEnabled)"
+ :disabled="!checkPermi(['trade:brokerage-user:update-bind-user'])"
+ @change="handleBrokerageEnabledChange(scope.row)"
/>
@@ -131,10 +131,14 @@
v-hasPermi="[
'trade:brokerage-user:user-query',
'trade:brokerage-user:order-query',
- 'trade:brokerage-user:update-brokerage-user',
- 'trade:brokerage-user:clear-brokerage-user'
+ 'trade:brokerage-user:update-bind-user',
+ 'trade:brokerage-user:clear-bind-user'
]"
>
+
+
+ 更多
+
修改上级推广人
清除上级推广人
@@ -186,7 +192,6 @@ import { fenToYuanFormat } from '@/utils/formatter'
defineOptions({ name: 'TradeBrokerageUser' })
const message = useMessage() // 消息弹窗
-const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
@@ -235,8 +240,8 @@ const handleCommand = (command: string, row: BrokerageUserApi.BrokerageUserVO) =
case 'openUpdateBindUser':
openUpdateBindUser(row.id)
break
- case 'openClearBindUser':
- openClearBindUser(row.id)
+ case 'handleClearBindUser':
+ handleClearBindUser(row)
break
}
}
@@ -249,12 +254,47 @@ const openBrokerageOrderTable = (id: number) => {}
/** 打开表单:修改上级推广人 */
const openUpdateBindUser = (id: number) => {}
+/** 修改上级推广人 */
+const handleUpdateBindUser = async (row: BrokerageUserApi.BrokerageUserVO) => {
+ try {
+ // 二次确认
+ await message.confirm(`确认要修改"${row.nickname}"的上级推广人吗?`)
+ // 发起修改
+ await BrokerageUserApi.updateBindUser({ id: row.id })
+ // 刷新列表
+ await getList()
+ } catch {}
+}
-/** 打开表单:清除上级推广人 */
-const openClearBindUser = (id: number) => {}
+/** 清除上级推广人 */
+const handleClearBindUser = async (row: BrokerageUserApi.BrokerageUserVO) => {
+ try {
+ // 二次确认
+ await message.confirm(`确认要清除"${row.nickname}"的上级推广人吗?`)
+ // 发起修改
+ await BrokerageUserApi.clearBindUser({ id: row.id })
+ message.success('清除成功')
+ // 刷新列表
+ await getList()
+ } catch {}
+}
/** 推广资格 开通/关闭 */
-const handleBrokerageEnabledChange = (id: number, enabled: boolean) => {}
+const handleBrokerageEnabledChange = async (row: BrokerageUserApi.BrokerageUserVO) => {
+ try {
+ // 二次确认
+ const text = row.brokerageEnabled ? '开通' : '关闭'
+ await message.confirm(`确认要${text}"${row.nickname}"的推广资格吗?`)
+ // 发起修改
+ await BrokerageUserApi.updateBrokerageEnabled({ id: row.id, enabled: row.brokerageEnabled })
+ message.success(text + '成功')
+ // 刷新列表
+ await getList()
+ } catch {
+ // 异常时,需要重置回之前的值
+ row.brokerageEnabled = !row.brokerageEnabled
+ }
+}
/** 初始化 **/
onMounted(() => {