feat(shop): 添加分销商资金流动管理功能
- 在 shopDealerOrder 模型中新增 title 和 degreePrice 字段 - 优化 request 工具函数,仅在生产环境使用 localStorage 的 ApiUrl - 新增 shopDealerCapital 资金流动记录的完整 CRUD 功能 - 包括搜索组件、编辑弹窗和列表页面 - 支持四种资金流动类型:佣金收入、提现支出、转账收支 - 实现资金流动记录的新增、编辑、删除和批量删除功能 - 在 shopDealerOrder 编辑页调整佣金计算逻辑和显示方式 - 更新订单列表页字段展示,替换 comments 为 title- 调整订单导入提示文案,增加结算确认说明 -优化订单编辑页分销商佣金比例和收益计算显示
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||||
</a-upload-dragger>
|
</a-upload-dragger>
|
||||||
<div class="ant-upload-text text-gray-400">
|
<div class="ant-upload-text text-gray-400">
|
||||||
<div>1、必须按<a href="https://oss.wsdns.cn/20251018/9bddad4def5f4516880836421a91ee8a.xlsx" target="_blank">导入模版</a>的格式上传</div>
|
<div>1、必须按<a href="https://oss.wsdns.cn/20251018/408b805ec3cd4084a4dc686e130af578.xlsx" target="_blank">导入模版</a>的格式上传</div>
|
||||||
<div>2、导入成功确认结算完成佣金的发放</div>
|
<div>2、导入成功确认结算完成佣金的发放</div>
|
||||||
</div>
|
</div>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
|
|||||||
192
src/views/sdy/shopDealerReferee/components/search.vue
Normal file
192
src/views/sdy/shopDealerReferee/components/search.vue
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
<!-- 搜索表单 -->
|
||||||
|
<template>
|
||||||
|
<div class="search-container">
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<a-form
|
||||||
|
:model="searchForm"
|
||||||
|
layout="inline"
|
||||||
|
class="search-form"
|
||||||
|
@finish="handleSearch"
|
||||||
|
>
|
||||||
|
<a-form-item label="推荐人ID">
|
||||||
|
<a-input-number
|
||||||
|
v-model:value="searchForm.dealerId"
|
||||||
|
placeholder="请输入推荐人ID"
|
||||||
|
:min="1"
|
||||||
|
style="width: 160px"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="被推荐人ID">
|
||||||
|
<a-input-number
|
||||||
|
v-model:value="searchForm.userId"
|
||||||
|
placeholder="请输入被推荐人ID"
|
||||||
|
:min="1"
|
||||||
|
style="width: 160px"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="推荐层级">
|
||||||
|
<a-select
|
||||||
|
v-model:value="searchForm.level"
|
||||||
|
placeholder="全部层级"
|
||||||
|
allow-clear
|
||||||
|
style="width: 120px"
|
||||||
|
>
|
||||||
|
<a-select-option :value="1">一级推荐</a-select-option>
|
||||||
|
<a-select-option :value="2">二级推荐</a-select-option>
|
||||||
|
<a-select-option :value="3">三级推荐</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="建立时间">
|
||||||
|
<a-range-picker
|
||||||
|
v-model:value="searchForm.dateRange"
|
||||||
|
style="width: 240px"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item>
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||||
|
<template #icon>
|
||||||
|
<SearchOutlined/>
|
||||||
|
</template>
|
||||||
|
搜索
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="resetSearch">
|
||||||
|
重置
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<div class="action-buttons">
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" @click="add" class="ele-btn-icon">
|
||||||
|
<template #icon>
|
||||||
|
<PlusOutlined/>
|
||||||
|
</template>
|
||||||
|
建立推荐关系
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="viewTree" class="ele-btn-icon">
|
||||||
|
<template #icon>
|
||||||
|
<ApartmentOutlined/>
|
||||||
|
</template>
|
||||||
|
推荐关系树
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="exportData" class="ele-btn-icon">
|
||||||
|
<template #icon>
|
||||||
|
<ExportOutlined/>
|
||||||
|
</template>
|
||||||
|
导出数据
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import {reactive} from 'vue';
|
||||||
|
import {
|
||||||
|
PlusOutlined,
|
||||||
|
SearchOutlined,
|
||||||
|
ApartmentOutlined,
|
||||||
|
ExportOutlined
|
||||||
|
} from '@ant-design/icons-vue';
|
||||||
|
import type {ShopDealerRefereeParam} from '@/api/shop/shopDealerReferee/model';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
// 选中的数据
|
||||||
|
selection?: any[];
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
selection: () => []
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'search', where?: ShopDealerRefereeParam): void;
|
||||||
|
(e: 'add'): void;
|
||||||
|
(e: 'viewTree'): void;
|
||||||
|
(e: 'export'): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
// 搜索表单
|
||||||
|
const searchForm = reactive<any>({
|
||||||
|
dealerId: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
level: undefined,
|
||||||
|
dateRange: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
const handleSearch = () => {
|
||||||
|
const searchParams: ShopDealerRefereeParam = {};
|
||||||
|
|
||||||
|
if (searchForm.dealerId) {
|
||||||
|
searchParams.dealerId = searchForm.dealerId;
|
||||||
|
}
|
||||||
|
if (searchForm.userId) {
|
||||||
|
searchParams.userId = searchForm.userId;
|
||||||
|
}
|
||||||
|
if (searchForm.level) {
|
||||||
|
searchParams.level = searchForm.level;
|
||||||
|
}
|
||||||
|
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||||
|
searchParams.startTime = dayjs(searchForm.dateRange[0]).format('YYYY-MM-DD');
|
||||||
|
searchParams.endTime = dayjs(searchForm.dateRange[1]).format('YYYY-MM-DD');
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('search', searchParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置搜索
|
||||||
|
const resetSearch = () => {
|
||||||
|
searchForm.dealerId = undefined;
|
||||||
|
searchForm.userId = undefined;
|
||||||
|
searchForm.level = undefined;
|
||||||
|
searchForm.dateRange = undefined;
|
||||||
|
emit('search', {});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
const add = () => {
|
||||||
|
emit('add');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 查看推荐树
|
||||||
|
const viewTree = () => {
|
||||||
|
emit('viewTree');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 导出数据
|
||||||
|
const exportData = () => {
|
||||||
|
emit('export');
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.search-container {
|
||||||
|
background: #fff;
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
|
||||||
|
.search-form {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
|
||||||
|
:deep(.ant-form-item) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
border-top: 1px solid #f0f0f0;
|
||||||
|
padding-top: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
:width="800"
|
||||||
|
:visible="visible"
|
||||||
|
:maskClosable="false"
|
||||||
|
:maxable="maxable"
|
||||||
|
:title="isUpdate ? '编辑分销商推荐关系表' : '添加分销商推荐关系表'"
|
||||||
|
:body-style="{ paddingBottom: '28px' }"
|
||||||
|
@update:visible="updateVisible"
|
||||||
|
@ok="save"
|
||||||
|
>
|
||||||
|
<a-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||||
|
:wrapper-col="
|
||||||
|
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<a-form-item label="分销商用户ID" name="dealerId">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入分销商用户ID"
|
||||||
|
v-model:value="form.dealerId"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="用户id(被推荐人)" name="userId">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入用户id(被推荐人)"
|
||||||
|
v-model:value="form.userId"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="推荐关系层级(1,2,3)" name="level">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入推荐关系层级(1,2,3)"
|
||||||
|
v-model:value="form.level"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="修改时间" name="updateTime">
|
||||||
|
<a-input
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入修改时间"
|
||||||
|
v-model:value="form.updateTime"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</ele-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, watch } from 'vue';
|
||||||
|
import { Form, message } from 'ant-design-vue';
|
||||||
|
import { assignObject, uuid } from 'ele-admin-pro';
|
||||||
|
import { addShopDealerReferee, updateShopDealerReferee } from '@/api/shop/shopDealerReferee';
|
||||||
|
import { ShopDealerReferee } from '@/api/shop/shopDealerReferee/model';
|
||||||
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||||
|
import { FormInstance } from 'ant-design-vue/es/form';
|
||||||
|
import { FileRecord } from '@/api/system/file/model';
|
||||||
|
|
||||||
|
// 是否是修改
|
||||||
|
const isUpdate = ref(false);
|
||||||
|
const useForm = Form.useForm;
|
||||||
|
// 是否开启响应式布局
|
||||||
|
const themeStore = useThemeStore();
|
||||||
|
const { styleResponsive } = storeToRefs(themeStore);
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
// 弹窗是否打开
|
||||||
|
visible: boolean;
|
||||||
|
// 修改回显的数据
|
||||||
|
data?: ShopDealerReferee | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'done'): void;
|
||||||
|
(e: 'update:visible', visible: boolean): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
// 提交状态
|
||||||
|
const loading = ref(false);
|
||||||
|
// 是否显示最大化切换按钮
|
||||||
|
const maxable = ref(true);
|
||||||
|
// 表格选中数据
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
const images = ref<ItemType[]>([]);
|
||||||
|
|
||||||
|
// 用户信息
|
||||||
|
const form = reactive<ShopDealerReferee>({
|
||||||
|
id: undefined,
|
||||||
|
dealerId: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
level: undefined,
|
||||||
|
tenantId: undefined,
|
||||||
|
createTime: undefined,
|
||||||
|
updateTime: undefined,
|
||||||
|
status: 0,
|
||||||
|
comments: '',
|
||||||
|
sortNumber: 100
|
||||||
|
});
|
||||||
|
|
||||||
|
/* 更新visible */
|
||||||
|
const updateVisible = (value: boolean) => {
|
||||||
|
emit('update:visible', value);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
const rules = reactive({
|
||||||
|
shopDealerRefereeName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
type: 'string',
|
||||||
|
message: '请填写分销商推荐关系表名称',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const chooseImage = (data: FileRecord) => {
|
||||||
|
images.value.push({
|
||||||
|
uid: data.id,
|
||||||
|
url: data.path,
|
||||||
|
status: 'done'
|
||||||
|
});
|
||||||
|
form.image = data.path;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDeleteItem = (index: number) => {
|
||||||
|
images.value.splice(index, 1);
|
||||||
|
form.image = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const { resetFields } = useForm(form, rules);
|
||||||
|
|
||||||
|
/* 保存编辑 */
|
||||||
|
const save = () => {
|
||||||
|
if (!formRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
loading.value = true;
|
||||||
|
const formData = {
|
||||||
|
...form
|
||||||
|
};
|
||||||
|
const saveOrUpdate = isUpdate.value ? updateShopDealerReferee : addShopDealerReferee;
|
||||||
|
saveOrUpdate(formData)
|
||||||
|
.then((msg) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.success(msg);
|
||||||
|
updateVisible(false);
|
||||||
|
emit('done');
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(visible) => {
|
||||||
|
if (visible) {
|
||||||
|
images.value = [];
|
||||||
|
if (props.data) {
|
||||||
|
assignObject(form, props.data);
|
||||||
|
isUpdate.value = true;
|
||||||
|
} else {
|
||||||
|
isUpdate.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resetFields();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
</script>
|
||||||
490
src/views/sdy/shopDealerReferee/index.vue
Normal file
490
src/views/sdy/shopDealerReferee/index.vue
Normal file
@@ -0,0 +1,490 @@
|
|||||||
|
<template>
|
||||||
|
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||||
|
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||||
|
<ele-pro-table
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="shopDealerRefereeId"
|
||||||
|
:columns="columns"
|
||||||
|
:datasource="datasource"
|
||||||
|
:customRow="customRow"
|
||||||
|
tool-class="ele-toolbar-form"
|
||||||
|
class="sys-org-table"
|
||||||
|
>
|
||||||
|
<template #toolbar>
|
||||||
|
<search
|
||||||
|
@search="reload"
|
||||||
|
:selection="selection"
|
||||||
|
@viewTree="viewRefereeTree"
|
||||||
|
@export="exportData"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'dealerInfo'">
|
||||||
|
<div class="user-info">
|
||||||
|
<div class="user-id">ID: {{ record.dealerId }}</div>
|
||||||
|
<div class="user-role">
|
||||||
|
<a-tag color="blue">推荐人</a-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="column.key === 'userInfo'">
|
||||||
|
<div class="user-info">
|
||||||
|
<div class="user-id">ID: {{ record.userId }}</div>
|
||||||
|
<div class="user-role">
|
||||||
|
<a-tag color="green">被推荐人</a-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="column.key === 'level'">
|
||||||
|
<a-tag
|
||||||
|
:color="getLevelColor(record.level)"
|
||||||
|
class="level-tag"
|
||||||
|
>
|
||||||
|
{{ getLevelText(record.level) }}
|
||||||
|
</a-tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="column.key === 'relationChain'">
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
@click="viewRelationChain(record)"
|
||||||
|
class="chain-btn"
|
||||||
|
>
|
||||||
|
<TeamOutlined /> 查看关系链
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<a-space>
|
||||||
|
<a @click="viewDetail(record)" class="ele-text-info">
|
||||||
|
<EyeOutlined /> 详情
|
||||||
|
</a>
|
||||||
|
<a-divider type="vertical" />
|
||||||
|
<a @click="openEdit(record)" class="ele-text-primary">
|
||||||
|
<EditOutlined /> 编辑
|
||||||
|
</a>
|
||||||
|
<a-divider type="vertical" />
|
||||||
|
<a-popconfirm
|
||||||
|
title="确定要解除此推荐关系吗?"
|
||||||
|
@confirm="remove(record)"
|
||||||
|
placement="topRight"
|
||||||
|
>
|
||||||
|
<a class="ele-text-danger">
|
||||||
|
<DisconnectOutlined /> 解除
|
||||||
|
</a>
|
||||||
|
</a-popconfirm>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</ele-pro-table>
|
||||||
|
</a-card>
|
||||||
|
|
||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<ShopDealerRefereeEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||||
|
</a-page-header>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { createVNode, ref } from 'vue';
|
||||||
|
import { message, Modal } from 'ant-design-vue';
|
||||||
|
import {
|
||||||
|
ExclamationCircleOutlined,
|
||||||
|
TeamOutlined,
|
||||||
|
EyeOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
DisconnectOutlined
|
||||||
|
} from '@ant-design/icons-vue';
|
||||||
|
import type { EleProTable } from 'ele-admin-pro';
|
||||||
|
import { toDateString } from 'ele-admin-pro';
|
||||||
|
import type {
|
||||||
|
DatasourceFunction,
|
||||||
|
ColumnItem
|
||||||
|
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||||
|
import Search from './components/search.vue';
|
||||||
|
import {getPageTitle} from '@/utils/common';
|
||||||
|
import ShopDealerRefereeEdit from './components/shopDealerRefereeEdit.vue';
|
||||||
|
import { pageShopDealerReferee, removeShopDealerReferee, removeBatchShopDealerReferee } from '@/api/shop/shopDealerReferee';
|
||||||
|
import type { ShopDealerReferee, ShopDealerRefereeParam } from '@/api/shop/shopDealerReferee/model';
|
||||||
|
|
||||||
|
// 表格实例
|
||||||
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||||
|
|
||||||
|
// 表格选中数据
|
||||||
|
const selection = ref<ShopDealerReferee[]>([]);
|
||||||
|
// 当前编辑数据
|
||||||
|
const current = ref<ShopDealerReferee | null>(null);
|
||||||
|
// 是否显示编辑弹窗
|
||||||
|
const showEdit = ref(false);
|
||||||
|
// 是否显示批量移动弹窗
|
||||||
|
const showMove = ref(false);
|
||||||
|
// 加载状态
|
||||||
|
const loading = ref(true);
|
||||||
|
|
||||||
|
// 表格数据源
|
||||||
|
const datasource: DatasourceFunction = ({
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
where,
|
||||||
|
orders,
|
||||||
|
filters
|
||||||
|
}) => {
|
||||||
|
if (filters) {
|
||||||
|
where.status = filters.status;
|
||||||
|
}
|
||||||
|
return pageShopDealerReferee({
|
||||||
|
...where,
|
||||||
|
...orders,
|
||||||
|
page,
|
||||||
|
limit
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 表格列配置
|
||||||
|
const columns = ref<ColumnItem[]>([
|
||||||
|
{
|
||||||
|
title: '推荐人信息',
|
||||||
|
key: 'dealerInfo',
|
||||||
|
align: 'left',
|
||||||
|
width: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '被推荐人信息',
|
||||||
|
key: 'userInfo',
|
||||||
|
align: 'left',
|
||||||
|
width: 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '推荐层级',
|
||||||
|
key: 'level',
|
||||||
|
align: 'center',
|
||||||
|
width: 120,
|
||||||
|
filters: [
|
||||||
|
{ text: '一级推荐', value: 1 },
|
||||||
|
{ text: '二级推荐', value: 2 },
|
||||||
|
{ text: '三级推荐', value: 3 }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '关系链',
|
||||||
|
key: 'relationChain',
|
||||||
|
align: 'center',
|
||||||
|
width: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '建立时间',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
key: 'createTime',
|
||||||
|
align: 'center',
|
||||||
|
width: 120,
|
||||||
|
sorter: true,
|
||||||
|
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'right',
|
||||||
|
align: 'center',
|
||||||
|
hideInSetting: true
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
/* 获取层级颜色 */
|
||||||
|
const getLevelColor = (level: number) => {
|
||||||
|
const colors = {
|
||||||
|
1: 'red',
|
||||||
|
2: 'orange',
|
||||||
|
3: 'gold'
|
||||||
|
};
|
||||||
|
return colors[level] || 'default';
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 获取层级文本 */
|
||||||
|
const getLevelText = (level: number) => {
|
||||||
|
const texts = {
|
||||||
|
1: '一级推荐',
|
||||||
|
2: '二级推荐',
|
||||||
|
3: '三级推荐'
|
||||||
|
};
|
||||||
|
return texts[level] || `${level}级推荐`;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 查看详情 */
|
||||||
|
const viewDetail = (record: ShopDealerReferee) => {
|
||||||
|
Modal.info({
|
||||||
|
title: '推荐关系详情',
|
||||||
|
width: 600,
|
||||||
|
content: createVNode('div', { class: 'referee-detail' }, [
|
||||||
|
createVNode('div', { class: 'detail-section' }, [
|
||||||
|
createVNode('h4', null, '推荐关系信息'),
|
||||||
|
createVNode('p', null, `推荐人ID: ${record.dealerId}`),
|
||||||
|
createVNode('p', null, `被推荐人ID: ${record.userId}`),
|
||||||
|
createVNode('p', null, [
|
||||||
|
'推荐层级: ',
|
||||||
|
createVNode('span', {
|
||||||
|
class: 'level-badge',
|
||||||
|
style: `color: ${getLevelColor(record.level)}; font-weight: bold;`
|
||||||
|
}, getLevelText(record.level))
|
||||||
|
]),
|
||||||
|
createVNode('p', null, `建立时间: ${toDateString(record.createTime, 'yyyy-MM-dd HH:mm:ss')}`),
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
okText: '关闭'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 查看关系链 */
|
||||||
|
const viewRelationChain = (record: ShopDealerReferee) => {
|
||||||
|
// 这里可以调用API获取完整的推荐关系链
|
||||||
|
Modal.info({
|
||||||
|
title: '推荐关系链',
|
||||||
|
width: 800,
|
||||||
|
content: createVNode('div', { class: 'relation-chain' }, [
|
||||||
|
createVNode('div', { class: 'chain-item' }, [
|
||||||
|
createVNode('div', { class: 'chain-node dealer' }, [
|
||||||
|
createVNode('div', { class: 'node-title' }, '推荐人'),
|
||||||
|
createVNode('div', { class: 'node-id' }, `用户ID: ${record.dealerId}`),
|
||||||
|
createVNode('div', { class: 'node-level' }, '分销商')
|
||||||
|
]),
|
||||||
|
createVNode('div', { class: 'chain-arrow' }, '→'),
|
||||||
|
createVNode('div', { class: 'chain-node user' }, [
|
||||||
|
createVNode('div', { class: 'node-title' }, '被推荐人'),
|
||||||
|
createVNode('div', { class: 'node-id' }, `用户ID: ${record.userId}`),
|
||||||
|
createVNode('div', { class: 'node-level' }, getLevelText(record.level))
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
createVNode('div', { class: 'chain-info' }, [
|
||||||
|
createVNode('p', null, `推荐关系建立于: ${toDateString(record.createTime, 'yyyy-MM-dd HH:mm:ss')}`),
|
||||||
|
createVNode('p', null, '点击可查看更多上下级关系')
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
okText: '关闭'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 查看推荐树 */
|
||||||
|
const viewRefereeTree = () => {
|
||||||
|
Modal.info({
|
||||||
|
title: '推荐关系树',
|
||||||
|
width: 1000,
|
||||||
|
content: createVNode('div', null, [
|
||||||
|
createVNode('p', null, '推荐关系树功能开发中,将展示完整的推荐网络结构')
|
||||||
|
]),
|
||||||
|
okText: '关闭'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 导出数据 */
|
||||||
|
const exportData = () => {
|
||||||
|
const hide = message.loading('正在导出推荐关系数据...', 0);
|
||||||
|
// 这里调用导出API
|
||||||
|
setTimeout(() => {
|
||||||
|
hide();
|
||||||
|
message.success('推荐关系数据导出成功');
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 搜索 */
|
||||||
|
const reload = (where?: ShopDealerRefereeParam) => {
|
||||||
|
selection.value = [];
|
||||||
|
tableRef?.value?.reload({ where: where });
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 打开编辑弹窗 */
|
||||||
|
const openEdit = (row?: ShopDealerReferee) => {
|
||||||
|
current.value = row ?? null;
|
||||||
|
showEdit.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 打开批量移动弹窗 */
|
||||||
|
const openMove = () => {
|
||||||
|
showMove.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 删除单个 */
|
||||||
|
const remove = (row: ShopDealerReferee) => {
|
||||||
|
const hide = message.loading('请求中..', 0);
|
||||||
|
removeShopDealerReferee(row.shopDealerRefereeId)
|
||||||
|
.then((msg) => {
|
||||||
|
hide();
|
||||||
|
message.success(msg);
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hide();
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 批量删除 */
|
||||||
|
const removeBatch = () => {
|
||||||
|
if (!selection.value.length) {
|
||||||
|
message.error('请至少选择一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除选中的记录吗?',
|
||||||
|
icon: createVNode(ExclamationCircleOutlined),
|
||||||
|
maskClosable: true,
|
||||||
|
onOk: () => {
|
||||||
|
const hide = message.loading('请求中..', 0);
|
||||||
|
removeBatchShopDealerReferee(selection.value.map((d) => d.shopDealerRefereeId))
|
||||||
|
.then((msg) => {
|
||||||
|
hide();
|
||||||
|
message.success(msg);
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hide();
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 查询 */
|
||||||
|
const query = () => {
|
||||||
|
loading.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 自定义行属性 */
|
||||||
|
const customRow = (record: ShopDealerReferee) => {
|
||||||
|
return {
|
||||||
|
// 行点击事件
|
||||||
|
onClick: () => {
|
||||||
|
// console.log(record);
|
||||||
|
},
|
||||||
|
// 行双击事件
|
||||||
|
onDblclick: () => {
|
||||||
|
openEdit(record);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
query();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'ShopDealerReferee'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.user-info {
|
||||||
|
.user-id {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-role {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-tag {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chain-btn {
|
||||||
|
padding: 0;
|
||||||
|
height: auto;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.referee-detail) {
|
||||||
|
.detail-section {
|
||||||
|
h4 {
|
||||||
|
color: #1890ff;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
border-bottom: 1px solid #f0f0f0;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 8px 0;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.level-badge {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.relation-chain) {
|
||||||
|
.chain-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chain-node {
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-align: center;
|
||||||
|
min-width: 120px;
|
||||||
|
|
||||||
|
&.dealer {
|
||||||
|
background: #e6f7ff;
|
||||||
|
border: 2px solid #1890ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.user {
|
||||||
|
background: #f6ffed;
|
||||||
|
border: 2px solid #52c41a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.node-title {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.node-id {
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.node-level {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.chain-arrow {
|
||||||
|
font-size: 24px;
|
||||||
|
color: #1890ff;
|
||||||
|
margin: 0 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chain-info {
|
||||||
|
background: #fafafa;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin-top: 16px;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 4px 0;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-table-tbody > tr > td) {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-tag) {
|
||||||
|
margin: 2px 4px 2px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user