trade: 分销业务后台功能:修改上级推广人

This commit is contained in:
owen 2023-09-09 19:20:12 +08:00
parent 7ea3571356
commit 5ed909263a
3 changed files with 137 additions and 14 deletions

View File

@ -10,6 +10,7 @@ export interface BrokerageUserVO {
frozenPrice: number
nickname: string
avatar: string
}
// 查询分销用户列表

View 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) // 12
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>

View File

@ -154,7 +154,7 @@
推广订单
</el-dropdown-item>
<el-dropdown-item
command="openUpdateBindUser"
command="openUpdateBindUserForm"
v-if="checkPermi(['trade:brokerage-user:update-bind-user'])"
>
修改上级推广人
@ -181,6 +181,8 @@
@pagination="getList"
/>
</ContentWrap>
<!-- 修改上级推广人表单 -->
<UpdateBindUserForm ref="updateBindUserFormRef" @success="getList" />
</template>
<script setup lang="ts">
@ -188,6 +190,7 @@ import { dateFormatter } from '@/utils/formatTime'
import * as BrokerageUserApi from '@/api/mall/trade/brokerage/user'
import { checkPermi } from '@/utils/permission'
import { fenToYuanFormat } from '@/utils/formatter'
import UpdateBindUserForm from '@/views/mall/trade/brokerage/user/UpdateBindUserForm.vue'
defineOptions({ name: 'TradeBrokerageUser' })
@ -237,8 +240,8 @@ const handleCommand = (command: string, row: BrokerageUserApi.BrokerageUserVO) =
case 'openBrokerageOrderTable':
openBrokerageOrderTable(row.id)
break
case 'openUpdateBindUser':
openUpdateBindUser(row.id)
case 'openUpdateBindUserForm':
openUpdateBindUserForm(row)
break
case 'handleClearBindUser':
handleClearBindUser(row)
@ -253,17 +256,9 @@ const openBrokerageUserTable = (id: number) => {}
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 updateBindUserFormRef = ref()
const openUpdateBindUserForm = (row: BrokerageUserApi.BrokerageUserVO) => {
updateBindUserFormRef.value.open(row)
}
/** 清除上级推广人 */