feat: 门店列表首批接口切换真实后端
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
/** 门店营业状态 */
|
||||
export enum StoreBusinessStatus {
|
||||
/** 强制关闭 */
|
||||
ForceClosed = 3,
|
||||
ForceClosed = 2,
|
||||
/** 营业中 */
|
||||
Operating = 1,
|
||||
Operating = 0,
|
||||
/** 休息中 */
|
||||
Resting = 2,
|
||||
Resting = 1,
|
||||
}
|
||||
|
||||
/** 门店审核状态 */
|
||||
export enum StoreAuditStatus {
|
||||
/** 已通过 */
|
||||
Approved = 1,
|
||||
/** 草稿 */
|
||||
Draft = 0,
|
||||
/** 待审核 */
|
||||
Pending = 0,
|
||||
Pending = 1,
|
||||
/** 已通过 */
|
||||
Approved = 2,
|
||||
/** 已拒绝 */
|
||||
Rejected = 2,
|
||||
Rejected = 3,
|
||||
}
|
||||
|
||||
/** 服务方式 */
|
||||
|
||||
@@ -117,13 +117,13 @@ function generateStores(count: number) {
|
||||
const stores = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
// 1. 按索引分配营业状态,模拟真实分布
|
||||
let businessStatus = 1;
|
||||
let businessStatus = 0;
|
||||
if (i >= 21) {
|
||||
businessStatus = Random.pick([1, 2, 3]);
|
||||
businessStatus = Random.pick([0, 1, 2]);
|
||||
} else if (i >= 18) {
|
||||
businessStatus = 3;
|
||||
} else if (i >= 14) {
|
||||
businessStatus = 2;
|
||||
} else if (i >= 14) {
|
||||
businessStatus = 1;
|
||||
}
|
||||
|
||||
// 2. 按索引分配审核状态
|
||||
@@ -200,54 +200,58 @@ function parseUrlParams(url: string): StoreFilterParams {
|
||||
return params;
|
||||
}
|
||||
|
||||
// 门店列表
|
||||
Mock.mock(/\/store\/list/, 'get', (options: MockRequestOptions) => {
|
||||
const params = parseUrlParams(options.url);
|
||||
const enableStoreCrudMock = import.meta.env.VITE_STORE_CRUD_MOCK === 'true';
|
||||
|
||||
const page = Number(params.page) || 1;
|
||||
const pageSize = Number(params.pageSize) || 10;
|
||||
const filtered = filterStores(params);
|
||||
const start = (page - 1) * pageSize;
|
||||
const items = filtered.slice(start, start + pageSize);
|
||||
if (enableStoreCrudMock) {
|
||||
// 门店列表
|
||||
Mock.mock(/\/store\/list/, 'get', (options: MockRequestOptions) => {
|
||||
const params = parseUrlParams(options.url);
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
items,
|
||||
total: filtered.length,
|
||||
page,
|
||||
pageSize,
|
||||
},
|
||||
};
|
||||
});
|
||||
const page = Number(params.page) || 1;
|
||||
const pageSize = Number(params.pageSize) || 10;
|
||||
const filtered = filterStores(params);
|
||||
const start = (page - 1) * pageSize;
|
||||
const items = filtered.slice(start, start + pageSize);
|
||||
|
||||
// 门店统计
|
||||
Mock.mock(/\/store\/stats/, 'get', () => {
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
total: storePool.length,
|
||||
operating: storePool.filter((s) => s.businessStatus === 1).length,
|
||||
resting: storePool.filter((s) => s.businessStatus === 2).length,
|
||||
pendingAudit: storePool.filter((s) => s.auditStatus === 0).length,
|
||||
},
|
||||
};
|
||||
});
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
items,
|
||||
total: filtered.length,
|
||||
page,
|
||||
pageSize,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// 创建门店
|
||||
Mock.mock(/\/store\/create/, 'post', () => {
|
||||
return { code: 200, data: null };
|
||||
});
|
||||
// 门店统计
|
||||
Mock.mock(/\/store\/stats/, 'get', () => {
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
total: storePool.length,
|
||||
operating: storePool.filter((s) => s.businessStatus === 0).length,
|
||||
resting: storePool.filter((s) => s.businessStatus === 1).length,
|
||||
pendingAudit: storePool.filter((s) => s.auditStatus === 1).length,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// 更新门店
|
||||
Mock.mock(/\/store\/update/, 'post', () => {
|
||||
return { code: 200, data: null };
|
||||
});
|
||||
// 创建门店
|
||||
Mock.mock(/\/store\/create/, 'post', () => {
|
||||
return { code: 200, data: null };
|
||||
});
|
||||
|
||||
// 删除门店
|
||||
Mock.mock(/\/store\/delete/, 'post', () => {
|
||||
return { code: 200, data: null };
|
||||
});
|
||||
// 更新门店
|
||||
Mock.mock(/\/store\/update/, 'post', () => {
|
||||
return { code: 200, data: null };
|
||||
});
|
||||
|
||||
// 删除门店
|
||||
Mock.mock(/\/store\/delete/, 'post', () => {
|
||||
return { code: 200, data: null };
|
||||
});
|
||||
}
|
||||
|
||||
// 设置 mock 响应延迟
|
||||
Mock.setup({ timeout: '200-400' });
|
||||
|
||||
@@ -85,6 +85,7 @@ export const businessStatusMap: Record<number, StatusTagMeta> = {
|
||||
};
|
||||
|
||||
export const auditStatusMap: Record<number, StatusTagMeta> = {
|
||||
[StoreAuditStatusEnum.Draft]: { color: 'default', text: '草稿' },
|
||||
[StoreAuditStatusEnum.Approved]: { color: 'green', text: '已通过' },
|
||||
[StoreAuditStatusEnum.Pending]: { color: 'orange', text: '待审核' },
|
||||
[StoreAuditStatusEnum.Rejected]: { color: 'red', text: '已拒绝' },
|
||||
@@ -103,6 +104,7 @@ export const businessStatusOptions: SelectOptionItem<StoreBusinessStatus>[] = [
|
||||
];
|
||||
|
||||
export const auditStatusOptions: SelectOptionItem<StoreAuditStatus>[] = [
|
||||
{ label: '草稿', value: StoreAuditStatusEnum.Draft },
|
||||
{ label: '待审核', value: StoreAuditStatusEnum.Pending },
|
||||
{ label: '已通过', value: StoreAuditStatusEnum.Approved },
|
||||
{ label: '已拒绝', value: StoreAuditStatusEnum.Rejected },
|
||||
|
||||
Reference in New Issue
Block a user