YunaiV 2024-12-31 12:38:14 +08:00
commit 1b2c7ceb90
12 changed files with 457 additions and 203 deletions

View File

@ -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 })

View File

@ -2,17 +2,17 @@
<div class="h-40px flex items-center justify-center">
<MagicCubeEditor
v-model="cellList"
class="m-b-16px"
:rows="1"
:cols="cellCount"
:cube-size="38"
:rows="1"
class="m-b-16px"
@hot-area-selected="handleHotAreaSelected"
/>
<img src="@/assets/imgs/diy/app-nav-bar-mp.png" alt="" class="h-30px w-76px" v-if="isMp" />
<img v-if="isMp" alt="" class="h-30px w-76px" src="@/assets/imgs/diy/app-nav-bar-mp.png" />
</div>
<template v-for="(cell, cellIndex) in cellList" :key="cellIndex">
<template v-if="selectedHotAreaIndex === cellIndex">
<el-form-item label="类型" :prop="`cell[${cellIndex}].type`">
<el-form-item :prop="`cell[${cellIndex}].type`" label="类型">
<el-radio-group v-model="cell.type">
<el-radio value="text">文字</el-radio>
<el-radio value="image">图片</el-radio>
@ -21,37 +21,40 @@
</el-form-item>
<!-- 1. 文字 -->
<template v-if="cell.type === 'text'">
<el-form-item label="内容" :prop="`cell[${cellIndex}].text`">
<el-form-item :prop="`cell[${cellIndex}].text`" label="内容">
<el-input v-model="cell!.text" maxlength="10" show-word-limit />
</el-form-item>
<el-form-item label="颜色" :prop="`cell[${cellIndex}].text`">
<el-form-item :prop="`cell[${cellIndex}].text`" label="颜色">
<ColorInput v-model="cell!.textColor" />
</el-form-item>
<el-form-item :prop="`cell[${cellIndex}].url`" label="链接">
<AppLinkInput v-model="cell.url" />
</el-form-item>
</template>
<!-- 2. 图片 -->
<template v-else-if="cell.type === 'image'">
<el-form-item label="图片" :prop="`cell[${cellIndex}].imgUrl`">
<el-form-item :prop="`cell[${cellIndex}].imgUrl`" label="图片">
<UploadImg v-model="cell.imgUrl" :limit="1" height="56px" width="56px">
<template #tip>建议尺寸 56*56</template>
</UploadImg>
</el-form-item>
<el-form-item label="链接" :prop="`cell[${cellIndex}].url`">
<el-form-item :prop="`cell[${cellIndex}].url`" label="链接">
<AppLinkInput v-model="cell.url" />
</el-form-item>
</template>
<!-- 3. 搜索框 -->
<template v-else>
<el-form-item label="提示文字" :prop="`cell[${cellIndex}].placeholder`">
<el-form-item :prop="`cell[${cellIndex}].placeholder`" label="提示文字">
<el-input v-model="cell.placeholder" maxlength="10" show-word-limit />
</el-form-item>
<el-form-item label="圆角" :prop="`cell[${cellIndex}].borderRadius`">
<el-form-item :prop="`cell[${cellIndex}].borderRadius`" label="圆角">
<el-slider
v-model="cell.borderRadius"
:max="100"
:min="0"
show-input
input-size="small"
:show-input-controls="false"
input-size="small"
show-input
/>
</el-form-item>
</template>
@ -59,7 +62,7 @@
</template>
</template>
<script setup lang="ts">
<script lang="ts" setup>
import { NavigationBarCellProperty } from '../config'
import { usePropertyForm } from '@/components/DiyEditor/util'
//
@ -87,4 +90,4 @@ const handleHotAreaSelected = (cellValue: NavigationBarCellProperty, index: numb
}
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped></style>

View File

@ -1,9 +1,7 @@
import { ComponentStyle, DiyComponent } from '@/components/DiyEditor/util'
import {ComponentStyle, DiyComponent} from '@/components/DiyEditor/util'
/** 标题栏属性 */
export interface TitleBarProperty {
// 背景图
bgImgUrl: string
// 偏移
marginLeft: number
// 显示位置

View File

@ -1,21 +1,30 @@
<template>
<div class="title-bar">
<el-image v-if="property.bgImgUrl" :src="property.bgImgUrl" fit="cover" class="w-full" />
<div class="absolute left-0 top-0 w-full">
<div
:style="{
background:
property.style.bgType === 'color' ? property.style.bgColor : `url(${property.style.bgImg})`,
backgroundSize: '100% 100%',
backgroundRepeat: 'no-repeat'
}"
class="title-bar"
>
<!-- 内容 -->
<div>
<!-- 标题 -->
<div
v-if="property.title"
:style="{
fontSize: `${property.titleSize}px`,
fontWeight: property.titleWeight,
color: property.titleColor,
textAlign: property.textAlign
}"
v-if="property.title"
>
{{ property.title }}
</div>
<!-- 副标题 -->
<div
v-if="property.description"
:style="{
fontSize: `${property.descriptionSize}px`,
fontWeight: property.descriptionWeight,
@ -23,25 +32,24 @@
textAlign: property.textAlign
}"
class="m-t-8px"
v-if="property.description"
>
{{ property.description }}
</div>
</div>
<!-- 更多 -->
<div
class="more"
v-show="property.more.show"
:style="{
color: property.descriptionColor
}"
class="more"
>
<span v-if="property.more.type !== 'icon'"> {{ property.more.text }} </span>
<Icon icon="ep:arrow-right" v-if="property.more.type !== 'text'" />
<Icon v-if="property.more.type !== 'text'" icon="ep:arrow-right" />
</div>
</div>
</template>
<script setup lang="ts">
<script lang="ts" setup>
import { TitleBarProperty } from './config'
/** 标题栏 */
@ -49,7 +57,7 @@ defineOptions({ name: 'TitleBar' })
defineProps<{ property: TitleBarProperty }>()
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
.title-bar {
position: relative;
width: 100%;

View File

@ -1,12 +1,7 @@
<template>
<ComponentContainerProperty v-model="formData.style">
<el-form label-width="85px" :model="formData" :rules="rules">
<el-card header="风格" class="property-group" shadow="never">
<el-form-item label="背景图片" prop="bgImgUrl">
<UploadImg v-model="formData.bgImgUrl" width="100%" height="40px">
<template #tip>建议尺寸 750*80</template>
</UploadImg>
</el-form-item>
<el-form :model="formData" :rules="rules" label-width="85px">
<el-card class="property-group" header="风格" shadow="never">
<el-form-item label="标题位置" prop="textAlign">
<el-radio-group v-model="formData!.textAlign">
<el-tooltip content="居左" placement="top">
@ -22,65 +17,65 @@
</el-radio-group>
</el-form-item>
</el-card>
<el-card header="主标题" class="property-group" shadow="never">
<el-form-item label="文字" prop="title" label-width="40px">
<el-card class="property-group" header="主标题" shadow="never">
<el-form-item label="文字" label-width="40px" prop="title">
<InputWithColor
v-model="formData.title"
v-model:color="formData.titleColor"
show-word-limit
maxlength="20"
show-word-limit
/>
</el-form-item>
<el-form-item label="大小" prop="titleSize" label-width="40px">
<el-form-item label="大小" label-width="40px" prop="titleSize">
<el-slider
v-model="formData.titleSize"
:max="60"
:min="10"
show-input
input-size="small"
show-input
/>
</el-form-item>
<el-form-item label="粗细" prop="titleWeight" label-width="40px">
<el-form-item label="粗细" label-width="40px" prop="titleWeight">
<el-slider
v-model="formData.titleWeight"
:min="100"
:max="900"
:min="100"
:step="100"
show-input
input-size="small"
show-input
/>
</el-form-item>
</el-card>
<el-card header="副标题" class="property-group" shadow="never">
<el-form-item label="文字" prop="description" label-width="40px">
<el-card class="property-group" header="副标题" shadow="never">
<el-form-item label="文字" label-width="40px" prop="description">
<InputWithColor
v-model="formData.description"
v-model:color="formData.descriptionColor"
show-word-limit
maxlength="50"
show-word-limit
/>
</el-form-item>
<el-form-item label="大小" prop="descriptionSize" label-width="40px">
<el-form-item label="大小" label-width="40px" prop="descriptionSize">
<el-slider
v-model="formData.descriptionSize"
:max="60"
:min="10"
show-input
input-size="small"
show-input
/>
</el-form-item>
<el-form-item label="粗细" prop="descriptionWeight" label-width="40px">
<el-form-item label="粗细" label-width="40px" prop="descriptionWeight">
<el-slider
v-model="formData.descriptionWeight"
:min="100"
:max="900"
:min="100"
:step="100"
show-input
input-size="small"
show-input
/>
</el-form-item>
</el-card>
<el-card header="查看更多" class="property-group" shadow="never">
<el-card class="property-group" header="查看更多" shadow="never">
<el-form-item label="是否显示" prop="more.show">
<el-checkbox v-model="formData.more.show" />
</el-form-item>
@ -93,7 +88,7 @@
<el-radio value="all">文字+图标</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="更多文字" prop="more.text" v-show="formData.more.type !== 'icon'">
<el-form-item v-show="formData.more.type !== 'icon'" label="更多文字" prop="more.text">
<el-input v-model="formData.more.text" />
</el-form-item>
<el-form-item label="跳转链接" prop="more.url">
@ -104,7 +99,7 @@
</el-form>
</ComponentContainerProperty>
</template>
<script setup lang="ts">
<script lang="ts" setup>
import { TitleBarProperty } from './config'
import { usePropertyForm } from '@/components/DiyEditor/util'
//
@ -118,4 +113,4 @@ const { formData } = usePropertyForm(props.modelValue, emit)
const rules = {}
</script>
<style scoped lang="scss"></style>
<style lang="scss" scoped></style>

View File

@ -12,17 +12,17 @@
<el-button-group class="header-right">
<el-tooltip content="重置">
<el-button @click="handleReset">
<Icon icon="system-uicons:reset-alt" :size="24" />
<Icon :size="24" icon="system-uicons:reset-alt" />
</el-button>
</el-tooltip>
<el-tooltip content="预览" v-if="previewUrl">
<el-tooltip v-if="previewUrl" content="预览">
<el-button @click="handlePreview">
<Icon icon="ep:view" :size="24" />
<Icon :size="24" icon="ep:view" />
</el-button>
</el-tooltip>
<el-tooltip content="保存">
<el-button @click="handleSave">
<Icon icon="ep:check" :size="24" />
<Icon :size="24" icon="ep:check" />
</el-button>
</el-tooltip>
</el-button-group>
@ -31,21 +31,21 @@
<!-- 中心区域 -->
<el-container class="editor-container">
<!-- 左侧组件库ComponentLibrary -->
<ComponentLibrary ref="componentLibrary" :list="libs" v-if="libs && libs.length > 0" />
<ComponentLibrary v-if="libs && libs.length > 0" ref="componentLibrary" :list="libs" />
<!-- 中心设计区域ComponentContainer -->
<div class="editor-center page-prop-area" @click="handlePageSelected">
<!-- 手机顶部 -->
<div class="editor-design-top">
<!-- 手机顶部状态栏 -->
<img src="@/assets/imgs/diy/statusBar.png" alt="" class="status-bar" />
<img alt="" class="status-bar" src="@/assets/imgs/diy/statusBar.png" />
<!-- 手机顶部导航栏 -->
<ComponentContainer
v-if="showNavigationBar"
:active="selectedComponent?.id === navigationBarComponent.id"
:component="navigationBarComponent"
:show-toolbar="false"
:active="selectedComponent?.id === navigationBarComponent.id"
@click="handleNavigationBarSelected"
class="cursor-pointer!"
@click="handleNavigationBarSelected"
/>
</div>
<!-- 绝对定位的组件例如 弹窗浮动按钮等 -->
@ -55,43 +55,43 @@
@click="handleComponentSelected(component, index)"
>
<component
v-if="component.position === 'fixed' && selectedComponent?.uid === component.uid"
:is="component.id"
v-if="component.position === 'fixed' && selectedComponent?.uid === component.uid"
:property="component.property"
/>
</div>
<!-- 手机页面编辑区域 -->
<el-scrollbar
height="100%"
wrap-class="editor-design-center page-prop-area"
view-class="phone-container"
:view-style="{
backgroundColor: pageConfigComponent.property.backgroundColor,
backgroundImage: `url(${pageConfigComponent.property.backgroundImage})`
}"
height="100%"
view-class="phone-container"
wrap-class="editor-design-center page-prop-area"
>
<draggable
class="page-prop-area drag-area"
v-model="pageComponents"
item-key="index"
:animation="200"
:force-fallback="true"
class="page-prop-area drag-area"
filter=".component-toolbar"
ghost-class="draggable-ghost"
:force-fallback="true"
group="component"
item-key="index"
@change="handleComponentChange"
>
<template #item="{ element, index }">
<ComponentContainer
v-if="!element.position || element.position === 'center'"
:component="element"
:active="selectedComponentIndex === index"
:can-move-up="index > 0"
:can-move-down="index < pageComponents.length - 1"
@move="(direction) => handleMoveComponent(index, direction)"
:can-move-up="index > 0"
:component="element"
@click="handleComponentSelected(element, index)"
@copy="handleCopyComponent(index)"
@delete="handleDeleteComponent(index)"
@click="handleComponentSelected(element, index)"
@move="(direction) => handleMoveComponent(index, direction)"
/>
</template>
</draggable>
@ -99,9 +99,9 @@
<!-- 手机底部导航 -->
<div v-if="showTabBar" :class="['editor-design-bottom', 'component', 'cursor-pointer!']">
<ComponentContainer
:active="selectedComponent?.id === tabBarComponent.id"
:component="tabBarComponent"
:show-toolbar="false"
:active="selectedComponent?.id === tabBarComponent.id"
@click="handleTabBarSelected"
/>
</div>
@ -109,9 +109,9 @@
<div class="fixed-component-action-group">
<el-tag
v-if="showPageConfig"
size="large"
:effect="selectedComponent?.uid === pageConfigComponent.uid ? 'dark' : 'plain'"
:type="selectedComponent?.uid === pageConfigComponent.uid ? '' : 'info'"
size="large"
@click="handleComponentSelected(pageConfigComponent)"
>
<Icon :icon="pageConfigComponent.icon" :size="12" />
@ -120,10 +120,10 @@
<template v-for="(component, index) in pageComponents" :key="index">
<el-tag
v-if="component.position === 'fixed'"
size="large"
closable
:effect="selectedComponent?.uid === component.uid ? 'dark' : 'plain'"
:type="selectedComponent?.uid === component.uid ? '' : 'info'"
closable
size="large"
@click="handleComponentSelected(component)"
@close="handleDeleteComponent(index)"
>
@ -134,11 +134,11 @@
</div>
</div>
<!-- 右侧属性面板ComponentContainerProperty -->
<el-aside class="editor-right" width="350px" v-if="selectedComponent?.property">
<el-aside v-if="selectedComponent?.property" class="editor-right" width="350px">
<el-card
shadow="never"
body-class="h-[calc(100%-var(--el-card-padding)-var(--el-card-padding))]"
class="h-full"
shadow="never"
>
<!-- 组件名称 -->
<template #header>
@ -152,8 +152,8 @@
view-class="p-[var(--el-card-padding)] p-b-[calc(var(--el-card-padding)+var(--el-card-padding))] property"
>
<component
:key="selectedComponent?.uid || selectedComponent?.id"
:is="selectedComponent?.id + 'Property'"
:key="selectedComponent?.uid || selectedComponent?.id"
v-model="selectedComponent.property"
/>
</el-scrollbar>
@ -166,8 +166,8 @@
<Dialog v-model="previewDialogVisible" title="预览" width="700">
<div class="flex justify-around">
<IFrame
class="w-375px border-4px border-rounded-8px border-solid p-2px h-667px!"
:src="previewUrl"
class="w-375px border-4px border-rounded-8px border-solid p-2px h-667px!"
/>
<div class="flex flex-col">
<el-text>手机扫码预览</el-text>
@ -179,6 +179,7 @@
<script lang="ts">
//
import { components } from './components/mobile/index'
export default {
components: { ...components }
}
@ -257,6 +258,11 @@ watch(
//
const handleSave = () => {
//
emits('save')
}
//
const pageConfigChange = () => {
const pageConfig = {
page: pageConfigComponent.value.property,
navigationBar: navigationBarComponent.value.property,
@ -272,10 +278,19 @@ const handleSave = () => {
//
const modelValue = isString(props.modelValue) ? JSON.stringify(pageConfig) : pageConfig
emits('update:modelValue', modelValue)
//
emits('save', pageConfig)
}
watch(
() => [
pageConfigComponent.value.property,
navigationBarComponent.value.property,
tabBarComponent.value.property,
pageComponents.value
],
() => {
pageConfigChange()
},
{ deep: true }
)
//
const handlePageSelected = (event: any) => {
if (!props.showPageConfig) return
@ -547,6 +562,7 @@ $toolbar-height: 42px;
:deep(.el-tag) {
box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
border: none;
.el-tag__content {
width: 100%;
display: flex;

View File

@ -99,6 +99,8 @@ onUnmounted(() => {
// ctrl + k
function listenKey(event) {
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
//
event.preventDefault()
showSearch.value = !showSearch.value
//
}

View File

@ -2,18 +2,18 @@
<DiyEditor
v-if="formData && !formLoading"
v-model="currentFormData!.property"
:title="templateItems[selectedTemplateItem].name"
:libs="libs"
:preview-url="previewUrl"
:show-navigation-bar="selectedTemplateItem !== 0"
:show-page-config="selectedTemplateItem !== 0"
:show-tab-bar="selectedTemplateItem === 0"
:show-navigation-bar="selectedTemplateItem !== 0"
:preview-url="previewUrl"
@save="submitForm"
:title="templateItems[selectedTemplateItem].name"
@reset="handleEditorReset"
@save="submitForm"
>
<template #toolBarLeft>
<el-radio-group
v-model="selectedTemplateItem"
:model-value="selectedTemplateItem"
class="h-full!"
@change="handleTemplateItemChange"
>
@ -26,13 +26,14 @@
</template>
</DiyEditor>
</template>
<script setup lang="ts">
<script lang="ts" setup>
// TODO @ decorate index.vue
import * as DiyTemplateApi from '@/api/mall/promotion/diy/template'
import * as DiyPageApi from '@/api/mall/promotion/diy/page'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { DiyComponentLibrary, PAGE_LIBS } from '@/components/DiyEditor/util' // DIY DiyEditor
import { toNumber } from 'lodash-es'
import { isEmpty } from '@/utils/is'
/** 装修模板表单 */
defineOptions({ name: 'DiyTemplateDecorate' })
@ -52,6 +53,10 @@ const formData = ref<DiyTemplateApi.DiyTemplatePropertyVO>()
const formRef = ref() // Ref
//
const currentFormData = ref<DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO>()
// templateItem
const currentFormDataMap = ref<
Map<string, DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO>
>(new Map())
// H5
const previewUrl = ref('')
@ -60,8 +65,6 @@ const getPageDetail = async (id: any) => {
formLoading.value = true
try {
formData.value = await DiyTemplateApi.getDiyTemplateProperty(id)
currentFormData.value = formData.value
//
const domain = import.meta.env.VITE_MALL_H5_DOMAIN
previewUrl.value = `${domain}/#/pages/index/index?templateId=${formData.value.id}`
@ -75,19 +78,31 @@ const templateLibs = [] as DiyComponentLibrary[]
//
const libs = ref<DiyComponentLibrary[]>(templateLibs)
//
const handleTemplateItemChange = () => {
const handleTemplateItemChange = (val: number) => {
//
currentFormDataMap.value.set(
templateItems[selectedTemplateItem.value].name,
currentFormData.value!
)
//
const data = currentFormDataMap.value.get(templateItems[val].name)
//
selectedTemplateItem.value = val
//
if (selectedTemplateItem.value === 0) {
if (val === 0) {
libs.value = templateLibs
currentFormData.value = formData.value
currentFormData.value = isEmpty(data) ? formData.value : data
return
}
//
libs.value = PAGE_LIBS
currentFormData.value = formData.value!.pages.find(
(page: DiyPageApi.DiyPageVO) => page.name === templateItems[selectedTemplateItem.value].name
)
currentFormData.value = isEmpty(data)
? formData.value!.pages.find(
(page: DiyPageApi.DiyPageVO) => page.name === templateItems[val].name
)
: data
}
//
@ -97,12 +112,25 @@ const submitForm = async () => {
//
formLoading.value = true
try {
if (selectedTemplateItem.value === 0) {
//
await DiyTemplateApi.updateDiyTemplateProperty(unref(formData)!)
} else {
// templateItems templateItem
for (let i = 0; i < templateItems.length; i++) {
const data = currentFormDataMap.value.get(templateItems[i].name) as any
//
if (i === 0) {
//
await DiyTemplateApi.updateDiyTemplateProperty(isEmpty(data) ? unref(formData)! : data)
continue
}
//
await DiyPageApi.updateDiyPageProperty(unref(currentFormData)!)
//
if (currentFormData.value?.name.includes(templateItems[i].name)) {
await DiyPageApi.updateDiyPageProperty(unref(currentFormData)!)
continue
}
//
if (!isEmpty(data)) {
await DiyPageApi.updateDiyPageProperty(data!)
}
}
message.success('保存成功')
} finally {
@ -140,10 +168,16 @@ const recoverPageIndex = () => {
const pageIndex = toNumber(sessionStorage.getItem(DIY_PAGE_INDEX_KEY)) || 0
//
sessionStorage.removeItem(DIY_PAGE_INDEX_KEY)
//
currentFormData.value = formData.value
currentFormDataMap.value = new Map<
string,
DiyTemplateApi.DiyTemplatePropertyVO | DiyPageApi.DiyPageVO
>()
//
if (pageIndex !== selectedTemplateItem.value) {
selectedTemplateItem.value = pageIndex
handleTemplateItemChange()
handleTemplateItemChange(pageIndex)
}
}
//#endregion

View File

@ -1,27 +1,27 @@
<template>
<Dialog v-model="dialogVisible" title="推广列表" width="75%">
<Dialog v-model="dialogVisible" title="推广订单列表" width="75%">
<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="level">
<el-radio-group v-model="queryParams.level" @change="handleQuery">
<el-radio-button checked>全部</el-radio-button>
<el-radio-button value="1">一级推广人</el-radio-button>
<el-radio-button value="2">二级推广人</el-radio-button>
<el-form-item label="用户类型" prop="sourceUserLevel">
<el-radio-group v-model="queryParams.sourceUserLevel" @change="handleQuery">
<el-radio-button :value="0">全部</el-radio-button>
<el-radio-button :value="1">一级推广人</el-radio-button>
<el-radio-button :value="2">二级推广人</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="请选择状态"
clearable
class="!w-240px"
clearable
placeholder="请选择状态"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_RECORD_STATUS)"
@ -34,64 +34,70 @@
<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-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="bizId" min-width="80px" />
<el-table-column label="用户编号" align="center" prop="sourceUserId" min-width="80px" />
<el-table-column label="头像" align="center" prop="sourceUserAvatar" 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="bizId" />
<el-table-column align="center" label="用户编号" min-width="80px" prop="sourceUserId" />
<el-table-column align="center" label="头像" prop="sourceUserAvatar" width="70px">
<template #default="scope">
<el-avatar :src="scope.row.sourceUserAvatar" />
</template>
</el-table-column>
<el-table-column label="昵称" align="center" prop="sourceUserNickname" min-width="80px" />
<el-table-column align="center" label="昵称" min-width="80px" prop="sourceUserNickname" />
<el-table-column
label="佣金"
align="center"
prop="price"
min-width="100px"
:formatter="fenToYuanFormat"
align="center"
label="佣金"
min-width="100px"
prop="price"
/>
<el-table-column label="状态" align="center" prop="status" min-width="85">
<el-table-column align="center" label="状态" min-width="85" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.BROKERAGE_RECORD_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
</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>
</Dialog>
</template>
<script setup lang="ts">
<script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime'
import * as BrokerageRecordApi from '@/api/mall/trade/brokerage/record'
import { BrokerageRecordBizTypeEnum } from '@/utils/constants'
@ -101,8 +107,6 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
/** 推广订单列表 */
defineOptions({ name: 'BrokerageOrderListDialog' })
const message = useMessage() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
@ -111,7 +115,7 @@ const queryParams = reactive({
pageSize: 10,
userId: null,
bizType: BrokerageRecordBizTypeEnum.ORDER.type,
level: '',
sourceUserLevel: 0,
createTime: [],
status: null
})
@ -130,7 +134,11 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
const getList = async () => {
loading.value = true
try {
const data = await BrokerageRecordApi.getBrokerageRecordPage(queryParams)
//
const data = await BrokerageRecordApi.getBrokerageRecordPage({
...queryParams,
sourceUserLevel: queryParams.sourceUserLevel === 0 ? undefined : queryParams.sourceUserLevel
})
list.value = data.list
total.value = data.total
} finally {

View File

@ -0,0 +1,161 @@
<template>
<Dialog v-model="dialogVisible" title="创建分销员" width="800">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="90"
>
<el-row :gutter="20">
<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>
</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-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'
defineOptions({ name: 'BrokerageUserCreateForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
userId: undefined,
bindUserId: undefined
})
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
}
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>

View File

@ -43,8 +43,8 @@
import * as BrokerageUserApi from '@/api/mall/trade/brokerage/user'
import { formatDate } from '@/utils/formatTime'
/** 修改上级推广人表单 */
defineOptions({ name: 'UpdateBindUserForm' })
/** 修改分销用户 */
defineOptions({ name: 'BrokerageUserUpdateForm' })
const { t } = useI18n() //
const message = useMessage() //

View File

@ -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,28 +187,31 @@
</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>
<!-- 修改上级推广人表单 -->
<UpdateBindUserForm ref="updateBindUserFormRef" @success="getList" />
<BrokerageUserUpdateForm ref="updateFormRef" @success="getList" />
<!-- 推广人列表 -->
<BrokerageUserListDialog ref="brokerageUserListDialogRef" />
<BrokerageUserListDialog ref="listDialogRef" />
<!-- 推广订单列表 -->
<BrokerageOrderListDialog ref="brokerageOrderListDialogRef" />
<BrokerageOrderListDialog ref="orderDialogRef" />
<!-- 创建分销员 -->
<BrokerageUserCreateForm ref="createFormRef" @success="getList" />
</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'
import { fenToYuanFormat } from '@/utils/formatter'
import UpdateBindUserForm from '@/views/mall/trade/brokerage/user/UpdateBindUserForm.vue'
import BrokerageUserUpdateForm from '@/views/mall/trade/brokerage/user/BrokerageUserUpdateForm.vue'
import BrokerageUserListDialog from '@/views/mall/trade/brokerage/user/BrokerageUserListDialog.vue'
import BrokerageOrderListDialog from '@/views/mall/trade/brokerage/user/BrokerageOrderListDialog.vue'
import BrokerageUserCreateForm from '@/views/mall/trade/brokerage/user/BrokerageUserCreateForm.vue'
defineOptions({ name: 'TradeBrokerageUser' })
@ -253,21 +271,27 @@ const handleCommand = (command: string, row: BrokerageUserApi.BrokerageUserVO) =
}
/** 打开推广人列表 */
const brokerageUserListDialogRef = ref()
const listDialogRef = ref()
const openBrokerageUserTable = (id: number) => {
brokerageUserListDialogRef.value.open(id)
listDialogRef.value.open(id)
}
/** 打开推广订单列表 */
const brokerageOrderListDialogRef = ref()
const orderDialogRef = ref()
const openBrokerageOrderTable = (id: number) => {
brokerageOrderListDialogRef.value.open(id)
orderDialogRef.value.open(id)
}
/** 打开表单:修改上级推广人 */
const updateBindUserFormRef = ref()
const updateFormRef = ref()
const openUpdateBindUserForm = (row: BrokerageUserApi.BrokerageUserVO) => {
updateBindUserFormRef.value.open(row)
updateFormRef.value.open(row)
}
/** 创建分销员 */
const createFormRef = ref<InstanceType<typeof CreateUserForm>>()
const openCreateUserForm = () => {
createFormRef.value?.open()
}
/** 清除上级推广人 */