feat(shop): 新增仓库管理功能

- 创建仓库数据模型定义接口
- 实现仓库CRUD API接口包括分页查询、新增、修改、删除等功能
- 开发仓库搜索组件提供添加按钮
- 构建仓库编辑弹窗支持表单验证和数据回填
- 集成仓库列表页面实现表格展示和操作功能
- 添加地区选择器集成省市区联动选择
- 实现批量删除和单个删除确认功能
- 完成页面标题设置和路由返回功能
This commit is contained in:
2026-01-30 18:07:17 +08:00
parent 14f90c22c5
commit c6805c1154
5 changed files with 719 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { ShopWarehouse, ShopWarehouseParam } from './model';
/**
* 分页查询仓库
*/
export async function pageShopWarehouse(params: ShopWarehouseParam) {
const res = await request.get<ApiResult<PageResult<ShopWarehouse>>>(
'/shop/shop-warehouse/page',
{
params
}
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 查询仓库列表
*/
export async function listShopWarehouse(params?: ShopWarehouseParam) {
const res = await request.get<ApiResult<ShopWarehouse[]>>(
'/shop/shop-warehouse',
{
params
}
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 添加仓库
*/
export async function addShopWarehouse(data: ShopWarehouse) {
const res = await request.post<ApiResult<unknown>>(
'/shop/shop-warehouse',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 修改仓库
*/
export async function updateShopWarehouse(data: ShopWarehouse) {
const res = await request.put<ApiResult<unknown>>(
'/shop/shop-warehouse',
data
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 删除仓库
*/
export async function removeShopWarehouse(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
'/shop/shop-warehouse/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 批量删除仓库
*/
export async function removeBatchShopWarehouse(data: (number | undefined)[]) {
const res = await request.delete<ApiResult<unknown>>(
'/shop/shop-warehouse/batch',
{
data
}
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 根据id查询仓库
*/
export async function getShopWarehouse(id: number) {
const res = await request.get<ApiResult<ShopWarehouse>>(
'/shop/shop-warehouse/' + id
);
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -0,0 +1,51 @@
import type { PageParam } from '@/api';
/**
* 仓库
*/
export interface ShopWarehouse {
// 自增ID
id?: number;
// 仓库名称
name?: string;
// 唯一标识
code?: string;
// 类型 中心仓,区域仓,门店仓
type?: string;
// 仓库地址
address?: string;
// 真实姓名
realName?: string;
// 联系电话
phone?: string;
// 省份
province?: string;
// 城市
city: undefined,
// 区域
region: undefined,
// 经纬度
lngAndLat?: string;
// 用户ID
userId?: number;
// 备注
comments?: string;
// 排序号
sortNumber?: number;
// 是否删除
isDelete?: number;
// 租户id
tenantId?: number;
// 创建时间
createTime?: string;
// 修改时间
updateTime?: string;
}
/**
* 仓库搜索条件
*/
export interface ShopWarehouseParam extends PageParam {
id?: number;
keywords?: string;
}