refactor(sdy): 重构经销商申请相关组件

- 修改了 shopDealerApply 组件的搜索和导入功能
- 新增了 shopDealerApplyEdit 组件用于编辑申请信息
- 删除了未使用的 Import组件
- 调整了表单验证规则和数据处理逻辑
This commit is contained in:
2025-09-16 23:40:23 +08:00
parent a67162ee06
commit 77f3686e0f
10 changed files with 862 additions and 863 deletions

View File

@@ -24,6 +24,7 @@
allow-clear allow-clear
placeholder="请输入年级" placeholder="请输入年级"
v-model:value="form.name" v-model:value="form.name"
@pressEnter="save"
/> />
</a-form-item> </a-form-item>
<a-form-item label="排序" name="sortNumber"> <a-form-item label="排序" name="sortNumber">

View File

@@ -79,7 +79,7 @@ import { useRoute, useRouter } from 'vue-router';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { UserOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { UserOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { confirmQrLogin, scanQrCode, type QrLoginConfirmRequest } from '@/api/passport/qrLogin'; import { confirmQrLogin, scanQrCode, type QrLoginConfirmRequest } from '@/api/passport/qrLogin';
import { getUserInfo } from '@/api/system/user'; import { getUserInfo } from '@/api/layout';
import { getToken } from '@/utils/token-util'; import { getToken } from '@/utils/token-util';
const route = useRoute(); const route = useRoute();

View File

@@ -115,7 +115,7 @@ const datasource: DatasourceFunction = ({
if (filters) { if (filters) {
where.status = filters.status; where.status = filters.status;
} }
where.type = 0; where.type = 4;
return pageShopDealerApply({ return pageShopDealerApply({
...where, ...where,
...orders, ...orders,

View File

@@ -23,7 +23,7 @@
<div class="ele-text-center"> <div class="ele-text-center">
<span>只能上传xlsxlsx文件</span> <span>只能上传xlsxlsx文件</span>
<a <a
href="http://127.0.0.1:9200/api/shop/shop-dealer-apply/import/template" href="https://cms-api.websoft.top/api/shop/shop-dealer-apply/import/template"
download="经销商申请导入模板.xlsx" download="经销商申请导入模板.xlsx"
> >
下载导入模板 下载导入模板

View File

@@ -1,100 +0,0 @@
# 分销商用户管理模块
## 功能说明
本模块提供了完整的分销商用户管理功能,包括:
### 基础功能
- ✅ 用户列表查看
- ✅ 用户信息编辑
- ✅ 用户详情查看
- ✅ 用户删除(单个/批量)
- ✅ 关键词搜索
### 导入导出功能
- ✅ 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)
- ✅ 实现基础的导入导出功能
- ✅ 添加数据验证和错误处理
- ✅ 优化用户体验和界面交互
- ✅ 完善文档说明

View File

@@ -1,110 +0,0 @@
<!-- 分销商用户导入弹窗 -->
<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>只能上传xlsxlsx文件导入模板和导出模板格式一致</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>

View File

@@ -1,206 +1,219 @@
<!-- 搜索表单 --> <!-- 搜索表单 -->
<template> <template>
<a-space :size="10" style="flex-wrap: wrap"> <div class="search-container">
<a-button type="primary" class="ele-btn-icon" @click="add"> <!-- 搜索表单 -->
<a-form
:model="searchForm"
layout="inline"
class="search-form"
@finish="handleSearch"
>
<a-form-item label="申请人姓名">
<a-input
v-model:value="searchForm.realName"
placeholder="请输入申请人姓名"
allow-clear
style="width: 160px"
/>
</a-form-item>
<a-form-item label="手机号码">
<a-input
v-model:value="searchForm.mobile"
placeholder="请输入手机号码"
allow-clear
style="width: 160px"
/>
</a-form-item>
<a-form-item label="申请方式">
<a-select
v-model:value="searchForm.applyType"
placeholder="全部方式"
allow-clear
style="width: 120px"
>
<a-select-option :value="10">需要审核</a-select-option>
<a-select-option :value="20">免审核</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="审核状态">
<a-select
v-model:value="searchForm.applyStatus"
placeholder="全部状态"
allow-clear
style="width: 120px"
>
<a-select-option :value="10">待审核</a-select-option>
<a-select-option :value="20">审核通过</a-select-option>
<a-select-option :value="30">审核驳回</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> <template #icon>
<PlusOutlined /> <SearchOutlined />
</template> </template>
<span>添加</span> 搜索
</a-button> </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 <a-button
danger
type="primary" type="primary"
ghost
:disabled="!selection?.length"
@click="batchApprove"
class="ele-btn-icon" class="ele-btn-icon"
:disabled="selection?.length === 0"
@click="removeBatch"
> >
<template #icon> <template #icon>
<DeleteOutlined/> <CheckOutlined />
</template> </template>
<span>批量删除</span> 批量通过
</a-button>
<a-button
:disabled="!selection?.length"
@click="exportData"
class="ele-btn-icon"
>
<template #icon>
<ExportOutlined />
</template>
导出数据
</a-button> </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> </a-space>
</div>
<!-- 导入弹窗 --> </div>
<import v-model:visible="showImport" @done="reload"/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {DeleteOutlined, PlusOutlined} from '@ant-design/icons-vue'; import { reactive } from 'vue';
import {ref} from 'vue'; import {
import {message} from 'ant-design-vue'; PlusOutlined,
import {utils, writeFile} from 'xlsx'; SearchOutlined,
import {listShopDealerUser} from '@/api/shop/shopDealerUser'; CheckOutlined,
import type {ShopDealerUser, ShopDealerUserParam} from '@/api/shop/shopDealerUser/model'; ExportOutlined
import useSearch from '@/utils/use-search'; } from '@ant-design/icons-vue';
import type { ShopDealerApplyParam } from '@/api/shop/shopDealerApply/model';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import Import from "./Import.vue";
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
// 选中的数据 // 选中的数据
selection?: ShopDealerUser[]; selection?: any[];
}>(), }>(),
{} {
selection: () => []
}
); );
// 请求状态 const emit = defineEmits<{
const loading = ref(false); (e: 'search', where?: ShopDealerApplyParam): void;
const dealerUserList = ref<ShopDealerUser[]>([]); (e: 'add'): void;
// 是否显示导入弹窗 (e: 'batchApprove'): void;
const showImport = ref(false); (e: 'export'): void;
}>();
// 表单数据 // 搜索表单
const {where, resetFields} = useSearch<ShopDealerUserParam>({ const searchForm = reactive<any>({
id: undefined, realName: '',
keywords: '' mobile: '',
applyType: undefined,
applyStatus: undefined,
dateRange: undefined
}); });
const emit = defineEmits<{ // 搜索
(e: 'search', where?: ShopDealerUserParam): void; const handleSearch = () => {
(e: 'add'): void; const searchParams: ShopDealerApplyParam = {};
(e: 'remove'): void;
(e: 'batchMove'): void; if (searchForm.realName) {
}>(); searchParams.realName = searchForm.realName;
}
if (searchForm.mobile) {
searchParams.mobile = searchForm.mobile;
}
if (searchForm.applyType) {
searchParams.applyType = searchForm.applyType;
}
if (searchForm.applyStatus) {
searchParams.applyStatus = searchForm.applyStatus;
}
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.realName = '';
searchForm.mobile = '';
searchForm.applyType = undefined;
searchForm.applyStatus = undefined;
searchForm.dateRange = undefined;
emit('search', {});
};
// 新增 // 新增
const add = () => { const add = () => {
emit('add'); emit('add');
}; };
// 批量删除 // 批量通过
const removeBatch = () => { const batchApprove = () => {
emit('remove'); emit('batchApprove');
}; };
// 批量更新 // 导出数据
const updateBatch = () => { const exportData = () => {
emit('batchMove'); emit('export');
}
/* 打开导入弹窗 */
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> </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>

View File

@@ -0,0 +1,407 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="900"
: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="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<!-- 申请人信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">申请人信息</span>
</a-divider>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="用户ID" name="userId">
<a-input-number
:min="1"
placeholder="请输入用户ID"
:disabled="isUpdate"
v-model:value="form.userId"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="真实姓名" name="realName">
<a-input
placeholder="请输入真实姓名"
v-model:value="form.realName"
:disabled="isUpdate"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="手机号码" name="mobile">
<a-input
placeholder="请输入手机号码"
:disabled="isUpdate"
v-model:value="form.mobile"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="推荐人ID" name="refereeId">
<a-input-number
:min="1"
placeholder="请输入推荐人用户ID"
:disabled="isUpdate"
v-model:value="form.refereeId"
style="width: 100%"
/>
</a-form-item>
</a-col>
</a-row>
<!-- 审核信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">审核信息</span>
</a-divider>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="审核状态" name="applyStatus">
<a-select v-model:value="form.applyStatus" placeholder="请选择审核状态" @change="handleStatusChange">
<a-select-option :value="10">
<a-tag color="processing">待审核</a-tag>
<span style="margin-left: 8px;">等待审核</span>
</a-select-option>
<a-select-option :value="20">
<a-tag color="success">审核通过</a-tag>
<span style="margin-left: 8px;">申请通过</span>
</a-select-option>
<a-select-option :value="30">
<a-tag color="error">审核驳回</a-tag>
<span style="margin-left: 8px;">申请驳回</span>
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<!-- <a-col :span="12">-->
<!-- <a-form-item label="审核时间" name="auditTime" v-if="form.applyStatus === 20 || form.applyStatus === 30">-->
<!-- <a-date-picker-->
<!-- v-model:value="form.auditTime"-->
<!-- show-time-->
<!-- format="YYYY-MM-DD HH:mm:ss"-->
<!-- placeholder="请选择审核时间"-->
<!-- style="width: 100%"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
</a-row>
<a-row :gutter="16" v-if="form.applyStatus === 30">
<a-col :span="24">
<a-form-item label="驳回原因" name="rejectReason">
<a-textarea
v-model:value="form.rejectReason"
placeholder="请输入驳回原因"
style="width: 100%"
:rows="3"
:maxlength="200"
show-count
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import dayjs from 'dayjs';
import { assignObject, uuid } from 'ele-admin-pro';
import { addShopDealerApply, updateShopDealerApply } from '@/api/shop/shopDealerApply';
import { ShopDealerApply } from '@/api/shop/shopDealerApply/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?: ShopDealerApply | 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<ShopDealerApply>({
applyId: undefined,
userId: undefined,
realName: '',
mobile: '',
refereeId: undefined,
applyType: 10,
applyTime: undefined,
applyStatus: 10,
auditTime: undefined,
rejectReason: '',
tenantId: undefined,
createTime: undefined,
updateTime: undefined
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userId: [
{
required: true,
message: '请输入用户ID',
trigger: 'blur'
}
],
realName: [
{
required: true,
message: '请输入真实姓名',
trigger: 'blur'
},
{
min: 2,
max: 20,
message: '姓名长度应在2-20个字符之间',
trigger: 'blur'
}
],
mobile: [
{
required: true,
message: '请输入手机号码',
trigger: 'blur'
},
{
pattern: /^1[3-9]\d{9}$/,
message: '请输入正确的手机号码',
trigger: 'blur'
}
],
applyType: [
{
required: true,
message: '请选择申请方式',
trigger: 'change'
}
],
applyStatus: [
{
required: true,
message: '请选择审核状态',
trigger: 'change'
}
],
rejectReason: [
{
required: true,
message: '驳回时必须填写驳回原因',
trigger: 'blur'
}
],
auditTime: [
{
required: true,
message: '审核时请选择审核时间',
trigger: 'change'
}
]
});
const { resetFields } = useForm(form, rules);
/* 处理审核状态变化 */
const handleStatusChange = (value: number) => {
// 当状态改为审核通过或驳回时,自动设置审核时间为当前时间
if ((value === 20 || value === 30) && !form.auditTime) {
form.auditTime = dayjs();
}
// 当状态改为待审核时,清空审核时间和驳回原因
if (value === 10) {
form.auditTime = undefined;
form.rejectReason = '';
}
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
// 动态验证规则
const validateFields: string[] = ['userId', 'realName', 'mobile', 'applyStatus'];
// 如果是驳回状态,需要验证驳回原因
if (form.applyStatus === 30) {
validateFields.push('rejectReason');
}
// 如果是审核通过或驳回状态,需要验证审核时间
if (form.applyStatus === 20 || form.applyStatus === 30) {
validateFields.push('auditTime');
}
formRef.value
.validate(validateFields)
.then(() => {
loading.value = true;
const formData = {
...form
};
// 处理时间字段转换 - 转换为ISO字符串格式
if (formData.applyTime) {
if (dayjs.isDayjs(formData.applyTime)) {
formData.applyTime = formData.applyTime.format('YYYY-MM-DD HH:mm:ss');
} else if (typeof formData.applyTime === 'number') {
formData.applyTime = dayjs(formData.applyTime).format('YYYY-MM-DD HH:mm:ss');
}
}
if (formData.auditTime) {
if (dayjs.isDayjs(formData.auditTime)) {
formData.auditTime = formData.auditTime.format('YYYY-MM-DD HH:mm:ss');
} else if (typeof formData.auditTime === 'number') {
formData.auditTime = dayjs(formData.auditTime).format('YYYY-MM-DD HH:mm:ss');
}
}
// 当审核状态为通过或驳回时,确保有审核时间
if ((formData.applyStatus === 20 || formData.applyStatus === 30) && !formData.auditTime) {
formData.auditTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
}
// 当状态为待审核时,清空审核时间
if (formData.applyStatus === 10) {
formData.auditTime = undefined;
}
const saveOrUpdate = isUpdate.value ? updateShopDealerApply : addShopDealerApply;
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) {
if (props.data) {
assignObject(form, props.data);
// 处理时间字段 - 确保转换为dayjs对象
if (props.data.applyTime) {
form.applyTime = dayjs(props.data.applyTime);
}
if (props.data.auditTime) {
form.auditTime = dayjs(props.data.auditTime);
}
isUpdate.value = true;
} else {
// 重置为默认值
Object.assign(form, {
applyId: undefined,
userId: undefined,
realName: '',
mobile: '',
refereeId: undefined,
applyType: 10,
applyTime: dayjs(),
applyStatus: 10,
auditTime: undefined,
rejectReason: '',
tenantId: undefined,
createTime: undefined,
updateTime: undefined
});
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>
<style lang="less" scoped>
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
margin: 24px 0 16px 0;
.ant-divider-inner-text {
padding: 0 16px 0 0;
}
}
:deep(.ant-form-item) {
margin-bottom: 16px;
}
:deep(.ant-radio) {
display: flex;
align-items: center;
margin-bottom: 8px;
.ant-radio-inner {
margin-right: 8px;
}
}
:deep(.ant-select-selection-item) {
display: flex;
align-items: center;
}
</style>

View File

@@ -1,363 +0,0 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="900"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑客户' : '添加客户'"
:body-style="{ paddingBottom: '28px', maxHeight: '70vh', overflowY: 'auto' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
layout="horizontal"
>
<!-- 基本信息 -->
<a-divider orientation="left">基本信息</a-divider>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item
label="姓名"
name="realName"
:label-col="{ span: 8 }"
:wrapper-col="{ span: 16 }"
>
<a-input
allow-clear
placeholder="请输入真实姓名"
v-model:value="form.realName"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
label="客户名称"
name="dealerName"
:label-col="{ span: 8 }"
:wrapper-col="{ span: 16 }"
>
<a-input
allow-clear
placeholder="请输入客户名称"
v-model:value="form.dealerName"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item
label="用电户号"
name="qrcode"
:label-col="{ span: 8 }"
:wrapper-col="{ span: 16 }"
>
<a-input
allow-clear
placeholder="用电户号"
v-model:value="form.qrcode"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
label="手机号"
name="mobile"
:label-col="{ span: 8 }"
:wrapper-col="{ span: 16 }"
>
<a-input
allow-clear
placeholder="请输入手机号"
v-model:value="form.mobile"
:disabled="isUpdate"
/>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :span="8">
<a-form-item
label="电量"
name="money"
:label-col="{ span: 12 }"
:wrapper-col="{ span: 12 }"
>
<a-input-number
:min="0"
placeholder="0"
v-model:value="form.money"
style="width: 100%"
>
<template #addonAfter></template>
</a-input-number>
</a-form-item>
</a-col>
</a-row>
</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 { addShopDealerUser, updateShopDealerUser } from '@/api/shop/shopDealerUser';
import { ShopDealerUser } from '@/api/shop/shopDealerUser/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?: ShopDealerUser | 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<ShopDealerUser>({
id: undefined,
userId: undefined,
realName: undefined,
mobile: undefined,
payPassword: undefined,
money: undefined,
freezeMoney: undefined,
totalMoney: undefined,
refereeId: undefined,
firstNum: undefined,
secondNum: undefined,
thirdNum: undefined,
qrcode: undefined,
isDelete: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
shopDealerUserId: undefined,
shopDealerUserName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userId: [
{
required: true,
message: '请输入用户ID',
trigger: 'blur'
}
],
realName: [
{
required: true,
message: '请输入真实姓名',
trigger: 'blur'
},
{
min: 2,
max: 20,
message: '姓名长度应在2-20个字符之间',
trigger: 'blur'
}
],
mobile: [
{
required: true,
message: '请输入手机号',
trigger: 'blur'
},
{
pattern: /^1[3-9]\d{9}$/,
message: '请输入正确的手机号格式',
trigger: 'blur'
}
],
money: [
{
type: 'number',
min: 0,
message: '可提现佣金不能小于0',
trigger: 'blur'
}
],
freezeMoney: [
{
type: 'number',
min: 0,
message: '冻结佣金不能小于0',
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 selectReferee = () => {
message.info('推荐人选择功能待开发');
// 这里可以打开用户选择器
};
/* 生成二维码 */
const generateQrcode = () => {
if (!form.userId) {
message.error('请先填写用户ID');
return;
}
// 生成二维码逻辑
const qrcode = `DEALER_${form.userId}_${Date.now()}`;
form.qrcode = qrcode;
message.success('二维码生成成功');
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
// 数据处理
const formData = {
...form
};
// 确保数值类型正确
if (formData.userId) formData.userId = Number(formData.userId);
if (formData.refereeId) formData.refereeId = Number(formData.refereeId);
if (formData.money !== undefined) formData.money = Number(formData.money);
if (formData.freezeMoney !== undefined) formData.freezeMoney = Number(formData.freezeMoney);
if (formData.totalMoney !== undefined) formData.totalMoney = Number(formData.totalMoney);
if (formData.firstNum !== undefined) formData.firstNum = Number(formData.firstNum);
if (formData.secondNum !== undefined) formData.secondNum = Number(formData.secondNum);
if (formData.thirdNum !== undefined) formData.thirdNum = Number(formData.thirdNum);
if (formData.isDelete !== undefined) formData.isDelete = Number(formData.isDelete);
console.log('提交的数据:', formData);
const saveOrUpdate = isUpdate.value ? updateShopDealerUser : addShopDealerUser;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg || '操作成功');
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
console.error('保存失败:', e);
message.error(e.message || '操作失败');
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>
<style lang="less" scoped>
:deep(.ant-form-item-label) {
text-align: left !important;
}
:deep(.ant-form-item-label > label) {
text-align: left !important;
}
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
margin: 24px 0 16px 0;
.ant-divider-inner-text {
color: #1890ff;
font-weight: 600;
}
}
:deep(.ant-input-group-addon) {
padding: 0 8px;
}
:deep(.ant-input-number-disabled) {
background-color: #f5f5f5;
color: #999;
}
</style>

View File

@@ -3,7 +3,7 @@
<a-card :bordered="false" :body-style="{ padding: '16px' }"> <a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table <ele-pro-table
ref="tableRef" ref="tableRef"
row-key="id" row-key="applyId"
:columns="columns" :columns="columns"
:datasource="datasource" :datasource="datasource"
:customRow="customRow" :customRow="customRow"
@@ -16,26 +16,36 @@
@search="reload" @search="reload"
:selection="selection" :selection="selection"
@add="openEdit" @add="openEdit"
@remove="removeBatch" @batchApprove="batchApprove"
@batchMove="openMove" @export="exportData"
/> />
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'userStatus'"> <template v-if="column.key === 'applyStatus'">
<a-tag v-if="record.isDelete === 1" color="red">已删除</a-tag> <a-tag v-if="record.applyStatus === 10" color="orange">待审核</a-tag>
<a-tag v-else color="green">正常</a-tag> <a-tag v-if="record.applyStatus === 20" color="green">已通过</a-tag>
</template> <a-tag v-if="record.applyStatus === 30" color="red">已驳回</a-tag>
<template v-if="column.key === 'money'">
{{ record.money }}
</template> </template>
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<a @click="openEdit(record)" class="ele-text-primary"> <a @click="openEdit(record)" class="ele-text-primary">
<EditOutlined/> <EditOutlined/>
编辑 编辑
</a> </a>
<template v-if="record.applyStatus !== 20">
<a-divider type="vertical"/>
<a @click="approveApply(record)" class="ele-text-success">
<CheckOutlined/>
通过
</a>
<a-divider type="vertical"/>
<a @click="rejectApply(record)" class="ele-text-warning">
<CloseOutlined/>
驳回
</a>
<a-divider type="vertical"/> <a-divider type="vertical"/>
<a-popconfirm <a-popconfirm
title="确定要删除此分销商用户吗?" v-if="record.applyStatus != 20"
title="确定要删除此申请记录吗?"
@confirm="remove(record)" @confirm="remove(record)"
placement="topRight" placement="topRight"
> >
@@ -46,11 +56,12 @@
</a-popconfirm> </a-popconfirm>
</template> </template>
</template> </template>
</template>
</ele-pro-table> </ele-pro-table>
</a-card> </a-card>
<!-- 编辑弹窗 --> <!-- 编辑弹窗 -->
<ShopDealerUserEdit v-model:visible="showEdit" :data="current" @done="reload"/> <ShopDealerApplyEdit v-model:visible="showEdit" :data="current" @done="reload"/>
</a-page-header> </a-page-header>
</template> </template>
@@ -59,32 +70,37 @@ import {createVNode, ref} from 'vue';
import {message, Modal} from 'ant-design-vue'; import {message, Modal} from 'ant-design-vue';
import { import {
ExclamationCircleOutlined, ExclamationCircleOutlined,
CheckOutlined,
CloseOutlined,
EditOutlined, EditOutlined,
DeleteOutlined DeleteOutlined
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro'; import type {EleProTable} from 'ele-admin-pro';
import {toDateString} from 'ele-admin-pro';
import type { import type {
DatasourceFunction, DatasourceFunction,
ColumnItem ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types'; } from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue'; import Search from './components/search.vue';
import {getPageTitle} from '@/utils/common'; import {getPageTitle} from '@/utils/common';
import ShopDealerUserEdit from './components/shopDealerUserEdit.vue'; import ShopDealerApplyEdit from './components/shopDealerApplyEdit.vue';
import {pageShopDealerUser, removeShopDealerUser, removeBatchShopDealerUser} from '@/api/shop/shopDealerUser'; import {
import type {ShopDealerUser, ShopDealerUserParam} from '@/api/shop/shopDealerUser/model'; pageShopDealerApply,
removeShopDealerApply,
removeBatchShopDealerApply,
batchApproveShopDealerApply,
updateShopDealerApply
} from '@/api/shop/shopDealerApply';
import type {ShopDealerApply, ShopDealerApplyParam} from '@/api/shop/shopDealerApply/model';
// 表格实例 // 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null); const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据 // 表格选中数据
const selection = ref<ShopDealerUser[]>([]); const selection = ref<ShopDealerApply[]>([]);
// 当前编辑数据 // 当前编辑数据
const current = ref<ShopDealerUser | null>(null); const current = ref<ShopDealerApply | null>(null);
// 是否显示编辑弹窗 // 是否显示编辑弹窗
const showEdit = ref(false); const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态 // 加载状态
const loading = ref(true); const loading = ref(true);
@@ -99,8 +115,9 @@ const datasource: DatasourceFunction = ({
if (filters) { if (filters) {
where.status = filters.status; where.status = filters.status;
} }
where.type = 0; where.type = 4;
return pageShopDealerUser({ where.applyStatus = 20;
return pageShopDealerApply({
...where, ...where,
...orders, ...orders,
page, page,
@@ -111,114 +128,185 @@ const datasource: DatasourceFunction = ({
// 表格列配置 // 表格列配置
const columns = ref<ColumnItem[]>([ const columns = ref<ColumnItem[]>([
{ {
title: '用户ID', title: 'ID',
dataIndex: 'userId', dataIndex: 'applyId',
key: 'userId', key: 'applyId',
align: 'center', align: 'center',
width: 80, width: 80,
fixed: 'left' fixed: 'left'
}, },
{ {
title: '用电户号', title: '申请人信息',
dataIndex: 'qrcode', key: 'applicantInfo',
key: 'qrcode', align: 'left',
fixed: 'left',
customRender: ({record}) => {
return `${record.realName || '-'} (${record.mobile || '-'})`;
}
},
{
title: '申请方式',
dataIndex: 'applyType',
key: 'applyType',
align: 'center',
width: 120,
customRender: ({text}) => {
const typeMap = {
10: {text: '需审核', color: 'orange'},
20: {text: '免审核', color: 'green'}
};
const type = typeMap[text] || {text: '未知', color: 'default'};
return {type: 'tag', props: {color: type.color}, children: type.text};
}
},
{
title: '审核状态',
dataIndex: 'applyStatus',
key: 'applyStatus',
align: 'center', align: 'center',
width: 120 width: 120
}, },
{ {
title: '单位名称', title: '推荐人',
key: 'userInfo', dataIndex: 'refereeId',
align: 'left', key: 'refereeId',
width: 200,
fixed: 'left',
customRender: ({record}) => {
return `${record.realName || ''} (${record.mobile || ''})`;
}
},
{
title: '电量',
key: 'money',
align: 'center',
width: 180
},
{
title: '供电局',
key: 'money4',
align: 'center'
},
{
title: '供电分局',
key: 'money3',
align: 'center'
},
{
title: '供电所',
key: 'money2',
align: 'center'
},
{
title: '渠道负责人',
key: 'comments',
align: 'center'
},
{
title: '状态',
key: 'userStatus',
align: 'center', align: 'center',
width: 100, width: 100,
customRender: ({record}) => { customRender: ({text}) => text ? `ID: ${text}` : '无'
if (record.isDelete === 1) { },
return {type: 'tag', props: {color: 'red'}, children: '已删除'}; // {
} // title: '申请时间',
return {type: 'tag', props: {color: 'green'}, children: '正常'}; // dataIndex: 'applyTime',
} // key: 'applyTime',
// align: 'center',
// width: 120,
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
// },
// {
// title: '审核时间',
// dataIndex: 'auditTime',
// key: 'auditTime',
// align: 'center',
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
// },
{
title: '驳回原因',
dataIndex: 'rejectReason',
key: 'rejectReason',
align: 'left',
ellipsis: true,
customRender: ({text}) => text || '-'
}, },
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
key: 'createTime', key: 'createTime',
align: 'center', align: 'center',
width: 120,
sorter: true, sorter: true,
ellipsis: true, ellipsis: true
customRender: ({text}) => text ? toDateString(text, 'yyyy-MM-dd') : '-'
}, },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 220,
fixed: 'right', fixed: 'right',
align: 'center', align: 'center',
width: 380,
hideInSetting: true hideInSetting: true
} }
]); ]);
/* 搜索 */ /* 搜索 */
const reload = (where?: ShopDealerUserParam) => { const reload = (where?: ShopDealerApplyParam) => {
selection.value = []; selection.value = [];
tableRef?.value?.reload({where: where}); tableRef?.value?.reload({where: where});
}; };
/* 审核通过 */
const approveApply = (row: ShopDealerApply) => {
Modal.confirm({
title: '审核通过确认',
content: `确定要通过 ${row.realName} 的经销商申请吗?`,
icon: createVNode(CheckOutlined),
okText: '确认通过',
okType: 'primary',
cancelText: '取消',
onOk: async () => {
const hide = message.loading('正在处理审核...', 0);
try {
await updateShopDealerApply({
...row,
applyId: row.applyId,
applyStatus: 20
});
hide();
message.success('审核通过成功');
reload();
} catch (error: any) {
hide();
message.error(error.message || '审核失败,请重试');
}
}
});
};
/* 审核驳回 */
const rejectApply = (row: ShopDealerApply) => {
let rejectReason = '';
Modal.confirm({
title: '审核驳回',
content: createVNode('div', null, [
createVNode('p', null, `申请人: ${row.realName} (${row.mobile})`),
createVNode('p', {style: 'margin-top: 12px;'}, '请输入驳回原因:'),
createVNode('textarea', {
placeholder: '请输入驳回原因...',
style: 'width: 100%; height: 80px; margin-top: 8px; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;',
onInput: (e: any) => {
rejectReason = e.target.value;
}
})
]),
icon: createVNode(CloseOutlined),
okText: '确认驳回',
okType: 'danger',
cancelText: '取消',
onOk: async () => {
if (!rejectReason.trim()) {
message.error('请输入驳回原因');
return Promise.reject();
}
const hide = message.loading('正在处理审核...', 0);
try {
await updateShopDealerApply({
...row,
applyStatus: 30,
rejectReason: rejectReason.trim()
});
hide();
message.success('审核驳回成功');
reload();
} catch (error: any) {
hide();
message.error(error.message || '审核失败,请重试');
}
}
});
};
/* 打开编辑弹窗 */ /* 打开编辑弹窗 */
const openEdit = (row?: ShopDealerUser) => { const openEdit = (row?: ShopDealerApply) => {
current.value = row ?? null; current.value = row ?? null;
showEdit.value = true; showEdit.value = true;
}; };
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */ /* 删除单个 */
const remove = (row: ShopDealerUser) => { const remove = (row: ShopDealerApply) => {
if (!row.id) { if (!row.applyId) {
message.error('删除失败:缺少必要参数'); message.error('删除失败:缺少必要参数');
return; return;
} }
const hide = message.loading('正在删除分销商用户...', 0); const hide = message.loading('正在删除申请记录...', 0);
removeShopDealerUser(row.id) removeShopDealerApply(row.applyId)
.then((msg) => { .then((msg) => {
hide(); hide();
message.success(msg || '删除成功'); message.success(msg || '删除成功');
@@ -237,7 +325,7 @@ const removeBatch = () => {
return; return;
} }
const validIds = selection.value.filter(d => d.id).map(d => d.id); const validIds = selection.value.filter(d => d.applyId).map(d => d.applyId);
if (!validIds.length) { if (!validIds.length) {
message.error('选中的数据中没有有效的ID'); message.error('选中的数据中没有有效的ID');
return; return;
@@ -245,7 +333,7 @@ const removeBatch = () => {
Modal.confirm({ Modal.confirm({
title: '批量删除确认', title: '批量删除确认',
content: `确定要删除选中的 ${validIds.length}分销商用户记录吗?此操作不可恢复。`, content: `确定要删除选中的 ${validIds.length}申请记录吗?此操作不可恢复。`,
icon: createVNode(ExclamationCircleOutlined), icon: createVNode(ExclamationCircleOutlined),
maskClosable: true, maskClosable: true,
okText: '确认删除', okText: '确认删除',
@@ -253,7 +341,7 @@ const removeBatch = () => {
cancelText: '取消', cancelText: '取消',
onOk: () => { onOk: () => {
const hide = message.loading(`正在删除 ${validIds.length} 条记录...`, 0); const hide = message.loading(`正在删除 ${validIds.length} 条记录...`, 0);
removeBatchShopDealerUser(validIds) removeBatchShopDealerApply(validIds)
.then((msg) => { .then((msg) => {
hide(); hide();
message.success(msg || `成功删除 ${validIds.length} 条记录`); message.success(msg || `成功删除 ${validIds.length} 条记录`);
@@ -268,13 +356,60 @@ const removeBatch = () => {
}); });
}; };
/* 批量通过 */
const batchApprove = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
const pendingApplies = selection.value.filter(item => item.applyStatus === 10);
if (!pendingApplies.length) {
message.error('所选申请中没有待审核的记录');
return;
}
Modal.confirm({
title: '批量通过确认',
content: `确定要通过选中的 ${pendingApplies.length} 个申请吗?`,
icon: createVNode(ExclamationCircleOutlined),
okText: '确认通过',
okType: 'primary',
cancelText: '取消',
onOk: async () => {
const hide = message.loading('正在批量通过...', 0);
try {
const ids = pendingApplies.map(item => item.applyId);
await batchApproveShopDealerApply(ids);
hide();
message.success(`成功通过 ${pendingApplies.length} 个申请`);
selection.value = [];
reload();
} catch (error: any) {
hide();
message.error(error.message || '批量审核失败,请重试');
}
}
});
};
/* 导出数据 */
const exportData = () => {
const hide = message.loading('正在导出申请数据...', 0);
// 这里调用导出API
setTimeout(() => {
hide();
message.success('申请数据导出成功');
}, 2000);
};
/* 查询 */ /* 查询 */
const query = () => { const query = () => {
loading.value = true; loading.value = true;
}; };
/* 自定义行属性 */ /* 自定义行属性 */
const customRow = (record: ShopDealerUser) => { const customRow = (record: ShopDealerApply) => {
return { return {
// 行点击事件 // 行点击事件
onClick: () => { onClick: () => {
@@ -291,7 +426,7 @@ query();
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'ShopDealerUser' name: 'ShopDealerApply'
}; };
</script> </script>
@@ -335,6 +470,22 @@ export default {
} }
} }
.ele-text-success {
color: #52c41a;
&:hover {
color: #73d13d;
}
}
.ele-text-warning {
color: #faad14;
&:hover {
color: #ffc53d;
}
}
.ele-text-danger { .ele-text-danger {
color: #ff4d4f; color: #ff4d4f;