feat(special-zone): 优化专区白名单弹窗及添加/移除功能
- 修复白名单弹窗复选框不显示的问题,替换 ele-pro-table 为 antd a-table 实现 - 实现弹窗打开即加载已选用户并勾选,完善分页及搜索功能 - 解决弹窗搜索事件传参错误导致后端参数异常的问题 - 修复保存白名单时报唯一键冲突异常,改用物理删除规避逻辑删除死锁 - 重构白名单弹窗为商品式交互,支持即时单条添加和移除,无需覆盖式保存 - 后端新增接口支持白名单用户追加和删除,前端调用对应新增接口 - 统一用户模型字段,优化查询及展示,提升用户体验 - 清理前端无用代码,简化白名单弹窗调用逻辑,减少页面复杂度
This commit is contained in:
@@ -4,9 +4,9 @@ import type {
|
||||
HomeSection,
|
||||
HomeSectionParam,
|
||||
SectionPermission,
|
||||
SectionGoods,
|
||||
SectionUser
|
||||
SectionGoods
|
||||
} from './model';
|
||||
import type { User } from '@/api/system/user/model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
@@ -96,10 +96,10 @@ export async function removeHomeSection(id?: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询专区白名单用户
|
||||
* 查询专区白名单用户(返回用户详情:userId/realName/mobile/nickname/organizationName)
|
||||
*/
|
||||
export async function listSectionUsers(id: number) {
|
||||
const res = await request.get<ApiResult<SectionUser[]>>(
|
||||
const res = await request.get<ApiResult<User[]>>(
|
||||
MODULES_API_URL + '/shop/shop-home-section/' + id + '/users'
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
@@ -109,7 +109,7 @@ export async function listSectionUsers(id: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存专区白名单用户(覆盖式)
|
||||
* 保存专区白名单用户(覆盖式,保留以备兼容)
|
||||
*/
|
||||
export async function setSectionUsers(id: number, userIds: number[]) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
@@ -122,6 +122,34 @@ export async function setSectionUsers(id: number, userIds: number[]) {
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加白名单用户到专区(单条/批量追加)
|
||||
*/
|
||||
export async function addSectionUsers(id: number, userIds: number[]) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-home-section/' + id + '/users',
|
||||
userIds
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从专区移除白名单用户(单条/批量)
|
||||
*/
|
||||
export async function removeSectionUsers(id: number, userIds: number[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-home-section/' + id + '/users',
|
||||
{ data: userIds }
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询专区商品分页
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user