commit
7ee8cb89a8
|
@ -13,6 +13,11 @@ export interface BrokerageUserVO {
|
|||
avatar: string
|
||||
}
|
||||
|
||||
// 创建分销用户
|
||||
export const createBrokerageUser = (data: any) => {
|
||||
return request.post({ url: '/trade/brokerage-user/create', data })
|
||||
}
|
||||
|
||||
// 查询分销用户列表
|
||||
export const getBrokerageUserPage = async (params: any) => {
|
||||
return await request.get({ url: `/trade/brokerage-user/page`, params })
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
<template>
|
||||
<Dialog v-model="dialogVisible" title="创建分销员" width="800">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="80"
|
||||
>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="可用佣金" prop="price">
|
||||
<el-input-number v-model="formData.price" :min="0" class="w-1/1!" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="冻结佣金" prop="price">
|
||||
<el-input-number v-model="formData.frozenPrice" :min="0" class="w-1/1!" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="推广人" prop="bindUserId">
|
||||
<el-input
|
||||
v-model="formData.bindUserId"
|
||||
v-loading="formLoading"
|
||||
placeholder="请输入推广员编号"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="handleGetUser(formData.bindUserId, '推广员')">
|
||||
<Icon class="mr-5px" icon="ep:search" />
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<!-- 展示上级推广人的信息 -->
|
||||
<el-descriptions v-if="userInfo.bindUser" :column="1" border>
|
||||
<el-descriptions-item label="头像">
|
||||
<el-avatar :src="userInfo.bindUser?.avatar" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="昵称"
|
||||
>{{ userInfo.bindUser?.nickname }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="推广资格">
|
||||
<el-tag v-if="userInfo.bindUser?.brokerageEnabled">有</el-tag>
|
||||
<el-tag v-else type="info">无</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="成为推广员的时间">
|
||||
{{ formatDate(userInfo.bindUser?.brokerageTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-col>
|
||||
<el-col :span="12" :xs="24">
|
||||
<el-form-item label="分销员" prop="userId">
|
||||
<el-input
|
||||
v-model="formData.userId"
|
||||
v-loading="formLoading"
|
||||
placeholder="请输入分销员编号"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="handleGetUser(formData.userId, '分销员')">
|
||||
<Icon class="mr-5px" icon="ep:search" />
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<!-- 展示分销员的信息 -->
|
||||
<el-descriptions v-if="userInfo.user" :column="1" border>
|
||||
<el-descriptions-item label="头像">
|
||||
<el-avatar :src="userInfo.user?.avatar" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="昵称">{{ userInfo.user?.nickname }}</el-descriptions-item>
|
||||
<el-descriptions-item label="推广资格">
|
||||
<el-switch
|
||||
v-model="formData.brokerageEnabled"
|
||||
:disabled="!checkPermi(['trade:brokerage-user:update-bind-user'])"
|
||||
active-text="有"
|
||||
inactive-text="无"
|
||||
inline-prompt
|
||||
/>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="成为推广员的时间">
|
||||
{{ formatDate(userInfo.user?.brokerageTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<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 * as UserApi from '@/api/member/user'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
|
||||
defineOptions({ name: 'CreateUserForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
userId: undefined,
|
||||
bindUserId: undefined,
|
||||
brokerageEnabled: false,
|
||||
price: 0,
|
||||
frozenPrice: 0
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const formRules = reactive({
|
||||
userId: [{ required: true, message: '分销员不能为空', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async () => {
|
||||
resetForm()
|
||||
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
|
||||
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
// 发起修改
|
||||
await BrokerageUserApi.createBrokerageUser(formData.value)
|
||||
message.success(t('common.createSuccess'))
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formRef.value?.resetFields()
|
||||
formData.value = {
|
||||
userId: undefined,
|
||||
bindUserId: undefined,
|
||||
brokerageEnabled: false,
|
||||
price: 0,
|
||||
frozenPrice: 0
|
||||
}
|
||||
|
||||
userInfo.bindUser = undefined
|
||||
userInfo.user = undefined
|
||||
}
|
||||
|
||||
/** 查询推广员和分销员 */
|
||||
const userInfo = reactive<{
|
||||
bindUser: BrokerageUserApi.BrokerageUserVO | undefined
|
||||
user: BrokerageUserApi.BrokerageUserVO | undefined
|
||||
}>({
|
||||
bindUser: undefined,
|
||||
user: undefined
|
||||
})
|
||||
const handleGetUser = async (id: any, userType: string) => {
|
||||
if (!id) {
|
||||
message.warning(`请先输入${userType}编号后重试!!!`)
|
||||
return
|
||||
}
|
||||
if (userType === '推广员' && formData.value.bindUserId == formData.value.userId) {
|
||||
message.error('不能绑定自己为推广人')
|
||||
return
|
||||
}
|
||||
const user =
|
||||
userType === '推广员' ? await BrokerageUserApi.getBrokerageUser(id) : await UserApi.getUser(id)
|
||||
userType === '推广员' ? (userInfo.bindUser = user) : (userInfo.user = user)
|
||||
if (!user) {
|
||||
message.warning(`${userType}不存在`)
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -4,19 +4,19 @@
|
|||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
:model="queryParams"
|
||||
class="-mb-15px"
|
||||
label-width="85px"
|
||||
>
|
||||
<el-form-item label="推广员编号" prop="bindUserId">
|
||||
<el-input
|
||||
v-model="queryParams.bindUserId"
|
||||
placeholder="请输入推广员编号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
clearable
|
||||
placeholder="请输入推广员编号"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="推广资格" prop="brokerageEnabled">
|
||||
|
@ -26,111 +26,126 @@
|
|||
clearable
|
||||
placeholder="请选择推广资格"
|
||||
>
|
||||
<el-option label="有" :value="true" />
|
||||
<el-option label="无" :value="false" />
|
||||
<el-option :value="true" label="有" />
|
||||
<el-option :value="false" label="无" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
end-placeholder="结束日期"
|
||||
start-placeholder="开始日期"
|
||||
type="daterange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button @click="handleQuery">
|
||||
<Icon class="mr-5px" icon="ep:search" />
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button @click="resetQuery">
|
||||
<Icon class="mr-5px" icon="ep:refresh" />
|
||||
重置
|
||||
</el-button>
|
||||
<el-button
|
||||
v-hasPermi="['trade:brokerage-user:create']"
|
||||
plain
|
||||
type="primary"
|
||||
@click="openCreateUserForm"
|
||||
>
|
||||
<Icon class="mr-5px" icon="ep:plus" />
|
||||
新增
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="用户编号" align="center" prop="id" min-width="80px" />
|
||||
<el-table-column label="头像" align="center" prop="avatar" width="70px">
|
||||
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
|
||||
<el-table-column align="center" label="用户编号" min-width="80px" prop="id" />
|
||||
<el-table-column align="center" label="头像" prop="avatar" width="70px">
|
||||
<template #default="scope">
|
||||
<el-avatar :src="scope.row.avatar" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="昵称" align="center" prop="nickname" min-width="80px" />
|
||||
<el-table-column label="推广人数" align="center" prop="brokerageUserCount" width="80px" />
|
||||
<el-table-column align="center" label="昵称" min-width="80px" prop="nickname" />
|
||||
<el-table-column align="center" label="推广人数" prop="brokerageUserCount" width="80px" />
|
||||
<el-table-column
|
||||
align="center"
|
||||
label="推广订单数量"
|
||||
align="center"
|
||||
min-width="110px"
|
||||
prop="brokerageOrderCount"
|
||||
min-width="110px"
|
||||
/>
|
||||
<el-table-column
|
||||
:formatter="fenToYuanFormat"
|
||||
align="center"
|
||||
label="推广订单金额"
|
||||
align="center"
|
||||
prop="brokerageOrderPrice"
|
||||
min-width="110px"
|
||||
:formatter="fenToYuanFormat"
|
||||
prop="brokerageOrderPrice"
|
||||
/>
|
||||
<el-table-column
|
||||
:formatter="fenToYuanFormat"
|
||||
align="center"
|
||||
label="已提现金额"
|
||||
align="center"
|
||||
min-width="100px"
|
||||
prop="withdrawPrice"
|
||||
min-width="100px"
|
||||
:formatter="fenToYuanFormat"
|
||||
/>
|
||||
<el-table-column label="已提现次数" align="center" prop="withdrawCount" min-width="100px" />
|
||||
<el-table-column align="center" label="已提现次数" min-width="100px" prop="withdrawCount" />
|
||||
<el-table-column
|
||||
:formatter="fenToYuanFormat"
|
||||
align="center"
|
||||
label="未提现金额"
|
||||
align="center"
|
||||
prop="price"
|
||||
min-width="100px"
|
||||
:formatter="fenToYuanFormat"
|
||||
prop="price"
|
||||
/>
|
||||
<el-table-column
|
||||
label="冻结中佣金"
|
||||
align="center"
|
||||
prop="frozenPrice"
|
||||
min-width="100px"
|
||||
:formatter="fenToYuanFormat"
|
||||
align="center"
|
||||
label="冻结中佣金"
|
||||
min-width="100px"
|
||||
prop="frozenPrice"
|
||||
/>
|
||||
<el-table-column label="推广资格" align="center" prop="brokerageEnabled" min-width="80px">
|
||||
<el-table-column align="center" label="推广资格" min-width="80px" prop="brokerageEnabled">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.brokerageEnabled"
|
||||
:disabled="!checkPermi(['trade:brokerage-user:update-bind-user'])"
|
||||
active-text="有"
|
||||
inactive-text="无"
|
||||
inline-prompt
|
||||
:disabled="!checkPermi(['trade:brokerage-user:update-bind-user'])"
|
||||
@change="handleBrokerageEnabledChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:formatter="dateFormatter"
|
||||
align="center"
|
||||
label="成为推广员时间"
|
||||
align="center"
|
||||
prop="brokerageTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="上级推广员编号" align="center" prop="bindUserId" width="150px" />
|
||||
<el-table-column align="center" label="上级推广员编号" prop="bindUserId" width="150px" />
|
||||
<el-table-column
|
||||
label="推广员绑定时间"
|
||||
align="center"
|
||||
prop="bindUserTime"
|
||||
:formatter="dateFormatter"
|
||||
align="center"
|
||||
label="推广员绑定时间"
|
||||
prop="bindUserTime"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" width="150px" fixed="right">
|
||||
<el-table-column align="center" fixed="right" label="操作" width="150px">
|
||||
<template #default="scope">
|
||||
<el-dropdown
|
||||
@command="(command) => handleCommand(command, scope.row)"
|
||||
v-hasPermi="[
|
||||
'trade:brokerage-user:user-query',
|
||||
'trade:brokerage-user:order-query',
|
||||
'trade:brokerage-user:update-bind-user',
|
||||
'trade:brokerage-user:clear-bind-user'
|
||||
]"
|
||||
@command="(command) => handleCommand(command, scope.row)"
|
||||
>
|
||||
<el-button link type="primary">
|
||||
<Icon icon="ep:d-arrow-right" />
|
||||
|
@ -139,28 +154,28 @@
|
|||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
command="openBrokerageUserTable"
|
||||
v-if="checkPermi(['trade:brokerage-user:user-query'])"
|
||||
command="openBrokerageUserTable"
|
||||
>
|
||||
推广人
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
command="openBrokerageOrderTable"
|
||||
v-if="checkPermi(['trade:brokerage-user:order-query'])"
|
||||
command="openBrokerageOrderTable"
|
||||
>
|
||||
推广订单
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
command="openUpdateBindUserForm"
|
||||
v-if="checkPermi(['trade:brokerage-user:update-bind-user'])"
|
||||
command="openUpdateBindUserForm"
|
||||
>
|
||||
修改上级推广人
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
command="handleClearBindUser"
|
||||
v-if="
|
||||
scope.row.bindUserId && checkPermi(['trade:brokerage-user:clear-bind-user'])
|
||||
"
|
||||
command="handleClearBindUser"
|
||||
>
|
||||
清除上级推广人
|
||||
</el-dropdown-item>
|
||||
|
@ -172,9 +187,9 @@
|
|||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
@ -184,9 +199,11 @@
|
|||
<BrokerageUserListDialog ref="brokerageUserListDialogRef" />
|
||||
<!-- 推广订单列表 -->
|
||||
<BrokerageOrderListDialog ref="brokerageOrderListDialogRef" />
|
||||
<!-- 创建分销员 -->
|
||||
<CreateUserForm ref="createUserFormRef" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as BrokerageUserApi from '@/api/mall/trade/brokerage/user'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
|
@ -194,6 +211,7 @@ import { fenToYuanFormat } from '@/utils/formatter'
|
|||
import UpdateBindUserForm from '@/views/mall/trade/brokerage/user/UpdateBindUserForm.vue'
|
||||
import BrokerageUserListDialog from '@/views/mall/trade/brokerage/user/BrokerageUserListDialog.vue'
|
||||
import BrokerageOrderListDialog from '@/views/mall/trade/brokerage/user/BrokerageOrderListDialog.vue'
|
||||
import CreateUserForm from '@/views/mall/trade/brokerage/user/CreateUserForm.vue'
|
||||
|
||||
defineOptions({ name: 'TradeBrokerageUser' })
|
||||
|
||||
|
@ -270,6 +288,12 @@ const openUpdateBindUserForm = (row: BrokerageUserApi.BrokerageUserVO) => {
|
|||
updateBindUserFormRef.value.open(row)
|
||||
}
|
||||
|
||||
/** 创建分销员 */
|
||||
const createUserFormRef = ref<InstanceType<typeof CreateUserForm>>()
|
||||
const openCreateUserForm = () => {
|
||||
createUserFormRef.value?.open()
|
||||
}
|
||||
|
||||
/** 清除上级推广人 */
|
||||
const handleClearBindUser = async (row: BrokerageUserApi.BrokerageUserVO) => {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue