trade: 分销业务后台功能:修改上级推广人
This commit is contained in:
parent
7ea3571356
commit
5ed909263a
@ -10,6 +10,7 @@ export interface BrokerageUserVO {
|
|||||||
frozenPrice: number
|
frozenPrice: number
|
||||||
|
|
||||||
nickname: string
|
nickname: string
|
||||||
|
avatar: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询分销用户列表
|
// 查询分销用户列表
|
||||||
|
127
src/views/mall/trade/brokerage/user/UpdateBindUserForm.vue
Normal file
127
src/views/mall/trade/brokerage/user/UpdateBindUserForm.vue
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog v-model="dialogVisible" title="修改上级推广人" width="500">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
v-loading="formLoading"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="80px"
|
||||||
|
>
|
||||||
|
<el-form-item label="推广人" prop="bindUserId">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.bindUserId"
|
||||||
|
placeholder="请输入推广员编号"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="handleGetUser"><Icon icon="ep:search" class="mr-5px" /></el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<el-descriptions v-if="bindUser" :column="1" border>
|
||||||
|
<el-descriptions-item label="头像">
|
||||||
|
<el-avatar :src="bindUser.avatar" />
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="昵称">{{ bindUser.nickname }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="推广资格">
|
||||||
|
<el-tag v-if="bindUser.brokerageEnabled">有</el-tag>
|
||||||
|
<el-tag v-else type="info">无</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="成为推广员的时间">
|
||||||
|
{{ formatDate(bindUser.brokerageTime) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<template #footer>
|
||||||
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import * as BrokerageUserApi from '@/api/mall/trade/brokerage/user'
|
||||||
|
import { formatDate } from '@/utils/formatTime'
|
||||||
|
|
||||||
|
/** 修改上级推广人表单 */
|
||||||
|
defineOptions({ name: 'UpdateBindUserForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formData = ref()
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
const formRules = reactive({
|
||||||
|
bindUserId: [{ required: true, message: '推广员人不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (row: BrokerageUserApi.BrokerageUserVO) => {
|
||||||
|
resetForm()
|
||||||
|
// 设置数据
|
||||||
|
formData.value.id = row.id
|
||||||
|
formData.value.bindUserId = row.bindUserId
|
||||||
|
// 反显上级推广人
|
||||||
|
if (row.bindUserId) {
|
||||||
|
await handleGetUser()
|
||||||
|
}
|
||||||
|
dialogVisible.value = true
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
/** 修改上级推广人 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
if (formLoading.value) return
|
||||||
|
// 校验表单
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.validate()
|
||||||
|
if (!valid) return
|
||||||
|
|
||||||
|
if (!bindUser.value) {
|
||||||
|
message.error('请先查询并确认推广人')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交请求
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
// 发起修改
|
||||||
|
await BrokerageUserApi.updateBindUser(formData.value)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success', true)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: 0,
|
||||||
|
bindUserId: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
bindUser.value = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询推广员 */
|
||||||
|
const bindUser = ref<BrokerageUserApi.BrokerageUserVO>()
|
||||||
|
const handleGetUser = async () => {
|
||||||
|
if (formData.value.bindUserId == formData.value.id) {
|
||||||
|
message.error('不能绑定自己为推广人')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
formLoading.value = true
|
||||||
|
bindUser.value = await BrokerageUserApi.getBrokerageUser(formData.value.bindUserId)
|
||||||
|
if (!bindUser.value) {
|
||||||
|
message.warning('推广员不存在')
|
||||||
|
}
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
</script>
|
@ -154,7 +154,7 @@
|
|||||||
推广订单
|
推广订单
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
command="openUpdateBindUser"
|
command="openUpdateBindUserForm"
|
||||||
v-if="checkPermi(['trade:brokerage-user:update-bind-user'])"
|
v-if="checkPermi(['trade:brokerage-user:update-bind-user'])"
|
||||||
>
|
>
|
||||||
修改上级推广人
|
修改上级推广人
|
||||||
@ -181,6 +181,8 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
<!-- 修改上级推广人表单 -->
|
||||||
|
<UpdateBindUserForm ref="updateBindUserFormRef" @success="getList" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -188,6 +190,7 @@ import { dateFormatter } from '@/utils/formatTime'
|
|||||||
import * as BrokerageUserApi from '@/api/mall/trade/brokerage/user'
|
import * as BrokerageUserApi from '@/api/mall/trade/brokerage/user'
|
||||||
import { checkPermi } from '@/utils/permission'
|
import { checkPermi } from '@/utils/permission'
|
||||||
import { fenToYuanFormat } from '@/utils/formatter'
|
import { fenToYuanFormat } from '@/utils/formatter'
|
||||||
|
import UpdateBindUserForm from '@/views/mall/trade/brokerage/user/UpdateBindUserForm.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'TradeBrokerageUser' })
|
defineOptions({ name: 'TradeBrokerageUser' })
|
||||||
|
|
||||||
@ -237,8 +240,8 @@ const handleCommand = (command: string, row: BrokerageUserApi.BrokerageUserVO) =
|
|||||||
case 'openBrokerageOrderTable':
|
case 'openBrokerageOrderTable':
|
||||||
openBrokerageOrderTable(row.id)
|
openBrokerageOrderTable(row.id)
|
||||||
break
|
break
|
||||||
case 'openUpdateBindUser':
|
case 'openUpdateBindUserForm':
|
||||||
openUpdateBindUser(row.id)
|
openUpdateBindUserForm(row)
|
||||||
break
|
break
|
||||||
case 'handleClearBindUser':
|
case 'handleClearBindUser':
|
||||||
handleClearBindUser(row)
|
handleClearBindUser(row)
|
||||||
@ -253,17 +256,9 @@ const openBrokerageUserTable = (id: number) => {}
|
|||||||
const openBrokerageOrderTable = (id: number) => {}
|
const openBrokerageOrderTable = (id: number) => {}
|
||||||
|
|
||||||
/** 打开表单:修改上级推广人 */
|
/** 打开表单:修改上级推广人 */
|
||||||
const openUpdateBindUser = (id: number) => {}
|
const updateBindUserFormRef = ref()
|
||||||
/** 修改上级推广人 */
|
const openUpdateBindUserForm = (row: BrokerageUserApi.BrokerageUserVO) => {
|
||||||
const handleUpdateBindUser = async (row: BrokerageUserApi.BrokerageUserVO) => {
|
updateBindUserFormRef.value.open(row)
|
||||||
try {
|
|
||||||
// 二次确认
|
|
||||||
await message.confirm(`确认要修改"${row.nickname}"的上级推广人吗?`)
|
|
||||||
// 发起修改
|
|
||||||
await BrokerageUserApi.updateBindUser({ id: row.id })
|
|
||||||
// 刷新列表
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 清除上级推广人 */
|
/** 清除上级推广人 */
|
||||||
|
Loading…
Reference in New Issue
Block a user