feat(port): 实现智能端口管理系统
- 新增端口管理器类,支持端口分配、验证和缓存管理 - 实现环境优先级策略,根据环境自动选择合适的端口范围 - 集成租户识别系统,为每个租户分配独立端口 - 添加端口分配结果统计和历史记录查询功能 - 优化端口缓存机制,自动清理过期绑定
This commit is contained in:
100
src/views/shop/shopDealerUser/README.md
Normal file
100
src/views/shop/shopDealerUser/README.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# 分销商用户管理模块
|
||||
|
||||
## 功能说明
|
||||
|
||||
本模块提供了完整的分销商用户管理功能,包括:
|
||||
|
||||
### 基础功能
|
||||
- ✅ 用户列表查看
|
||||
- ✅ 用户信息编辑
|
||||
- ✅ 用户详情查看
|
||||
- ✅ 用户删除(单个/批量)
|
||||
- ✅ 关键词搜索
|
||||
|
||||
### 导入导出功能
|
||||
- ✅ Excel 数据导出
|
||||
- ✅ Excel 数据导入
|
||||
- ✅ 导入数据验证
|
||||
- ✅ 错误处理
|
||||
|
||||
## 导入导出使用说明
|
||||
|
||||
### 导出功能
|
||||
1. 点击"导出xls"按钮
|
||||
2. 系统会根据当前搜索条件导出数据
|
||||
3. 导出的Excel文件包含以下字段:
|
||||
- 用户ID
|
||||
- 姓名
|
||||
- 手机号
|
||||
- 可提现佣金
|
||||
- 冻结佣金
|
||||
- 累计提现
|
||||
- 推荐人ID
|
||||
- 一级成员数
|
||||
- 二级成员数
|
||||
- 三级成员数
|
||||
- 专属二维码
|
||||
- 状态
|
||||
- 创建时间
|
||||
- 更新时间
|
||||
|
||||
### 导入功能
|
||||
1. 点击"导入xls"按钮
|
||||
2. 拖拽或选择Excel文件(支持.xls和.xlsx格式)
|
||||
3. 文件大小限制:10MB以内
|
||||
4. 导入格式要求:
|
||||
- 必填字段:用户ID、姓名、手机号
|
||||
- 佣金字段请填写数字,不要包含货币符号
|
||||
- 状态字段:正常 或 已删除
|
||||
- 推荐人ID必须是已存在的用户ID
|
||||
|
||||
### 数据格式示例
|
||||
|
||||
| 用户ID | 姓名 | 手机号 | 可提现佣金 | 冻结佣金 | 累计提现 | 推荐人ID | 一级成员数 | 二级成员数 | 三级成员数 | 专属二维码 | 状态 |
|
||||
|--------|------|--------|------------|----------|----------|----------|------------|------------|------------|------------|------|
|
||||
| 1001 | 张三 | 13800138000 | 100.50 | 50.00 | 200.00 | 1000 | 5 | 3 | 2 | DEALER_1001_xxx | 正常 |
|
||||
| 1002 | 李四 | 13900139000 | 200.00 | 0.00 | 150.00 | | 2 | 1 | 0 | | 正常 |
|
||||
|
||||
## 技术实现
|
||||
|
||||
### 文件结构
|
||||
```
|
||||
src/views/shop/shopDealerUser/
|
||||
├── index.vue # 主页面
|
||||
├── components/
|
||||
│ ├── search.vue # 搜索组件(包含导入导出功能)
|
||||
│ ├── Import.vue # 导入弹窗组件
|
||||
│ └── shopDealerUserEdit.vue # 编辑弹窗组件
|
||||
└── README.md # 说明文档
|
||||
```
|
||||
|
||||
### API 接口
|
||||
```typescript
|
||||
// 导入接口
|
||||
POST /shop/shop-dealer-user/import
|
||||
Content-Type: multipart/form-data
|
||||
|
||||
// 导出接口
|
||||
GET /shop/shop-dealer-user/export
|
||||
Response-Type: blob
|
||||
```
|
||||
|
||||
### 依赖库
|
||||
- `xlsx`: Excel文件处理
|
||||
- `dayjs`: 日期格式化
|
||||
- `ant-design-vue`: UI组件库
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **数据安全**:导入功能会直接操作数据库,请确保导入的数据准确无误
|
||||
2. **性能考虑**:大量数据导入时可能需要较长时间,请耐心等待
|
||||
3. **错误处理**:导入失败时会显示具体错误信息,请根据提示修正数据
|
||||
4. **权限控制**:确保用户有相应的导入导出权限
|
||||
|
||||
## 更新日志
|
||||
|
||||
### v1.0.0 (2024-12-19)
|
||||
- ✅ 实现基础的导入导出功能
|
||||
- ✅ 添加数据验证和错误处理
|
||||
- ✅ 优化用户体验和界面交互
|
||||
- ✅ 完善文档说明
|
||||
110
src/views/shop/shopDealerUser/components/Import.vue
Normal file
110
src/views/shop/shopDealerUser/components/Import.vue
Normal file
@@ -0,0 +1,110 @@
|
||||
<!-- 分销商用户导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="分销商用户批量导入"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-upload-dragger
|
||||
accept=".xls,.xlsx"
|
||||
:show-upload-list="false"
|
||||
:customRequest="doUpload"
|
||||
style="padding: 24px 0; margin-bottom: 16px"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<cloud-upload-outlined />
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
</a-spin>
|
||||
<div class="ele-text-center">
|
||||
<span>只能上传xls、xlsx文件,导入模板和导出模板格式一致</span>
|
||||
</div>
|
||||
<div class="import-tips" style="margin-top: 16px;">
|
||||
<a-alert
|
||||
message="导入说明"
|
||||
type="info"
|
||||
show-icon
|
||||
>
|
||||
<template #description>
|
||||
<div>
|
||||
<p>1. 请按照导出的Excel格式准备数据</p>
|
||||
<p>2. 必填字段:用户ID、姓名、手机号</p>
|
||||
<p>3. 佣金字段请填写数字,不要包含货币符号</p>
|
||||
<p>4. 状态字段:正常 或 已删除</p>
|
||||
<p>5. 推荐人ID必须是已存在的用户ID</p>
|
||||
</div>
|
||||
</template>
|
||||
</a-alert>
|
||||
</div>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import {importShopDealerUsers} from "@/api/shop/shopDealerUser";
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
defineProps<{
|
||||
// 是否打开弹窗
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
// 导入请求状态
|
||||
const loading = ref(false);
|
||||
|
||||
/* 上传 */
|
||||
const doUpload = ({ file }) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importShopDealerUsers(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
/* 更新 visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.import-tips {
|
||||
:deep(.ant-alert-description) {
|
||||
p {
|
||||
margin: 4px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -7,36 +7,200 @@
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection?.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined/>
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词搜索"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
/>
|
||||
<a-button type="text" @click="reset">重置</a-button>
|
||||
<a-button type="text" @click="handleExport">导出xls</a-button>
|
||||
<a-button type="text" @click="openImport">导入xls</a-button>
|
||||
</a-space>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<import v-model:visible="showImport" @done="reload"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
import {DeleteOutlined, PlusOutlined} from '@ant-design/icons-vue';
|
||||
import {ref} from 'vue';
|
||||
import {message} from 'ant-design-vue';
|
||||
import {utils, writeFile} from 'xlsx';
|
||||
import {listShopDealerUser} from '@/api/shop/shopDealerUser';
|
||||
import type {ShopDealerUser, ShopDealerUserParam} from '@/api/shop/shopDealerUser/model';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import dayjs from 'dayjs';
|
||||
import Import from "./Import.vue";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: ShopDealerUser[];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
// 请求状态
|
||||
const loading = ref(false);
|
||||
const dealerUserList = ref<ShopDealerUser[]>([]);
|
||||
// 是否显示导入弹窗
|
||||
const showImport = ref(false);
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
// 表单数据
|
||||
const {where, resetFields} = useSearch<ShopDealerUserParam>({
|
||||
id: undefined,
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerUserParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
// 批量更新
|
||||
const updateBatch = () => {
|
||||
emit('batchMove');
|
||||
}
|
||||
|
||||
/* 打开导入弹窗 */
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
if (loading.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
message.loading('正在准备导出数据...', 0);
|
||||
|
||||
try {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'用户ID',
|
||||
'姓名',
|
||||
'手机号',
|
||||
'可提现佣金',
|
||||
'冻结佣金',
|
||||
'累计提现',
|
||||
'推荐人ID',
|
||||
'一级成员数',
|
||||
'二级成员数',
|
||||
'三级成员数',
|
||||
'专属二维码',
|
||||
'状态',
|
||||
'创建时间',
|
||||
'更新时间'
|
||||
]
|
||||
];
|
||||
|
||||
// 按搜索结果导出
|
||||
const list = await listShopDealerUser(where);
|
||||
dealerUserList.value = list;
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
message.warning('没有数据可以导出');
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
list.forEach((d: ShopDealerUser) => {
|
||||
array.push([
|
||||
`${d.userId || ''}`,
|
||||
`${d.realName || ''}`,
|
||||
`${d.mobile || ''}`,
|
||||
`${d.money || '0'}`,
|
||||
`${d.freezeMoney || '0'}`,
|
||||
`${d.totalMoney || '0'}`,
|
||||
`${d.refereeId || ''}`,
|
||||
`${d.firstNum || 0}`,
|
||||
`${d.secondNum || 0}`,
|
||||
`${d.thirdNum || 0}`,
|
||||
`${d.qrcode || ''}`,
|
||||
`${d.isDelete === 1 ? '已删除' : '正常'}`,
|
||||
`${d.createTime || ''}`,
|
||||
`${d.updateTime || ''}`
|
||||
]);
|
||||
});
|
||||
|
||||
const sheetName = `导出分销商用户列表${dayjs(new Date()).format('YYYYMMDD')}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{wch: 10}, // 用户ID
|
||||
{wch: 15}, // 姓名
|
||||
{wch: 15}, // 手机号
|
||||
{wch: 12}, // 可提现佣金
|
||||
{wch: 12}, // 冻结佣金
|
||||
{wch: 12}, // 累计提现
|
||||
{wch: 10}, // 推荐人ID
|
||||
{wch: 10}, // 一级成员数
|
||||
{wch: 10}, // 二级成员数
|
||||
{wch: 10}, // 三级成员数
|
||||
{wch: 20}, // 专属二维码
|
||||
{wch: 8}, // 状态
|
||||
{wch: 20}, // 创建时间
|
||||
{wch: 20} // 更新时间
|
||||
];
|
||||
|
||||
message.destroy();
|
||||
message.loading('正在生成Excel文件...', 0);
|
||||
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
loading.value = false;
|
||||
message.destroy();
|
||||
message.success(`成功导出 ${list.length} 条记录`);
|
||||
}, 1000);
|
||||
|
||||
} catch (error: any) {
|
||||
loading.value = false;
|
||||
message.destroy();
|
||||
message.error(error.message || '导出失败,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
const reset = () => {
|
||||
resetFields();
|
||||
reload();
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="shopDealerUserId"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
v-model:selection="selection"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@@ -126,7 +127,7 @@ const columns = ref<ColumnItem[]>([
|
||||
width: 200,
|
||||
fixed: 'left',
|
||||
customRender: ({record}) => {
|
||||
return `${record.realName || '-'} (${record.mobile || '-'})`;
|
||||
return `${record.realName || ''} (${record.mobile || ''})`;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user