feat: 门店列表首批接口切换真实后端

This commit is contained in:
2026-02-17 11:10:49 +08:00
parent becef7e6cb
commit af21caf2a7
3 changed files with 61 additions and 53 deletions

View File

@@ -1,21 +1,23 @@
/** 门店营业状态 */ /** 门店营业状态 */
export enum StoreBusinessStatus { export enum StoreBusinessStatus {
/** 强制关闭 */ /** 强制关闭 */
ForceClosed = 3, ForceClosed = 2,
/** 营业中 */ /** 营业中 */
Operating = 1, Operating = 0,
/** 休息中 */ /** 休息中 */
Resting = 2, Resting = 1,
} }
/** 门店审核状态 */ /** 门店审核状态 */
export enum StoreAuditStatus { export enum StoreAuditStatus {
/** 已通过 */ /** 草稿 */
Approved = 1, Draft = 0,
/** 待审核 */ /** 待审核 */
Pending = 0, Pending = 1,
/** 已通过 */
Approved = 2,
/** 已拒绝 */ /** 已拒绝 */
Rejected = 2, Rejected = 3,
} }
/** 服务方式 */ /** 服务方式 */

View File

@@ -117,13 +117,13 @@ function generateStores(count: number) {
const stores = []; const stores = [];
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
// 1. 按索引分配营业状态,模拟真实分布 // 1. 按索引分配营业状态,模拟真实分布
let businessStatus = 1; let businessStatus = 0;
if (i >= 21) { if (i >= 21) {
businessStatus = Random.pick([1, 2, 3]); businessStatus = Random.pick([0, 1, 2]);
} else if (i >= 18) { } else if (i >= 18) {
businessStatus = 3;
} else if (i >= 14) {
businessStatus = 2; businessStatus = 2;
} else if (i >= 14) {
businessStatus = 1;
} }
// 2. 按索引分配审核状态 // 2. 按索引分配审核状态
@@ -200,54 +200,58 @@ function parseUrlParams(url: string): StoreFilterParams {
return params; return params;
} }
// 门店列表 const enableStoreCrudMock = import.meta.env.VITE_STORE_CRUD_MOCK === 'true';
Mock.mock(/\/store\/list/, 'get', (options: MockRequestOptions) => {
const params = parseUrlParams(options.url);
const page = Number(params.page) || 1; if (enableStoreCrudMock) {
const pageSize = Number(params.pageSize) || 10; // 门店列表
const filtered = filterStores(params); Mock.mock(/\/store\/list/, 'get', (options: MockRequestOptions) => {
const start = (page - 1) * pageSize; const params = parseUrlParams(options.url);
const items = filtered.slice(start, start + pageSize);
return { const page = Number(params.page) || 1;
code: 200, const pageSize = Number(params.pageSize) || 10;
data: { const filtered = filterStores(params);
items, const start = (page - 1) * pageSize;
total: filtered.length, const items = filtered.slice(start, start + pageSize);
page,
pageSize,
},
};
});
// 门店统计 return {
Mock.mock(/\/store\/stats/, 'get', () => { code: 200,
return { data: {
code: 200, items,
data: { total: filtered.length,
total: storePool.length, page,
operating: storePool.filter((s) => s.businessStatus === 1).length, pageSize,
resting: storePool.filter((s) => s.businessStatus === 2).length, },
pendingAudit: storePool.filter((s) => s.auditStatus === 0).length, };
}, });
};
});
// 创建门店 // 门店统计
Mock.mock(/\/store\/create/, 'post', () => { Mock.mock(/\/store\/stats/, 'get', () => {
return { code: 200, data: null }; 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', () => { Mock.mock(/\/store\/create/, 'post', () => {
return { code: 200, data: null }; return { code: 200, data: null };
}); });
// 删除门店 // 更新门店
Mock.mock(/\/store\/delete/, 'post', () => { Mock.mock(/\/store\/update/, 'post', () => {
return { code: 200, data: null }; return { code: 200, data: null };
}); });
// 删除门店
Mock.mock(/\/store\/delete/, 'post', () => {
return { code: 200, data: null };
});
}
// 设置 mock 响应延迟 // 设置 mock 响应延迟
Mock.setup({ timeout: '200-400' }); Mock.setup({ timeout: '200-400' });

View File

@@ -85,6 +85,7 @@ export const businessStatusMap: Record<number, StatusTagMeta> = {
}; };
export const auditStatusMap: Record<number, StatusTagMeta> = { export const auditStatusMap: Record<number, StatusTagMeta> = {
[StoreAuditStatusEnum.Draft]: { color: 'default', text: '草稿' },
[StoreAuditStatusEnum.Approved]: { color: 'green', text: '已通过' }, [StoreAuditStatusEnum.Approved]: { color: 'green', text: '已通过' },
[StoreAuditStatusEnum.Pending]: { color: 'orange', text: '待审核' }, [StoreAuditStatusEnum.Pending]: { color: 'orange', text: '待审核' },
[StoreAuditStatusEnum.Rejected]: { color: 'red', text: '已拒绝' }, [StoreAuditStatusEnum.Rejected]: { color: 'red', text: '已拒绝' },
@@ -103,6 +104,7 @@ export const businessStatusOptions: SelectOptionItem<StoreBusinessStatus>[] = [
]; ];
export const auditStatusOptions: SelectOptionItem<StoreAuditStatus>[] = [ export const auditStatusOptions: SelectOptionItem<StoreAuditStatus>[] = [
{ label: '草稿', value: StoreAuditStatusEnum.Draft },
{ label: '待审核', value: StoreAuditStatusEnum.Pending }, { label: '待审核', value: StoreAuditStatusEnum.Pending },
{ label: '已通过', value: StoreAuditStatusEnum.Approved }, { label: '已通过', value: StoreAuditStatusEnum.Approved },
{ label: '已拒绝', value: StoreAuditStatusEnum.Rejected }, { label: '已拒绝', value: StoreAuditStatusEnum.Rejected },