feat: 门店列表首批接口切换真实后端
This commit is contained in:
@@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 服务方式 */
|
/** 服务方式 */
|
||||||
|
|||||||
@@ -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,8 +200,11 @@ 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) => {
|
|
||||||
|
if (enableStoreCrudMock) {
|
||||||
|
// 门店列表
|
||||||
|
Mock.mock(/\/store\/list/, 'get', (options: MockRequestOptions) => {
|
||||||
const params = parseUrlParams(options.url);
|
const params = parseUrlParams(options.url);
|
||||||
|
|
||||||
const page = Number(params.page) || 1;
|
const page = Number(params.page) || 1;
|
||||||
@@ -219,35 +222,36 @@ Mock.mock(/\/store\/list/, 'get', (options: MockRequestOptions) => {
|
|||||||
pageSize,
|
pageSize,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 门店统计
|
// 门店统计
|
||||||
Mock.mock(/\/store\/stats/, 'get', () => {
|
Mock.mock(/\/store\/stats/, 'get', () => {
|
||||||
return {
|
return {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: {
|
data: {
|
||||||
total: storePool.length,
|
total: storePool.length,
|
||||||
operating: storePool.filter((s) => s.businessStatus === 1).length,
|
operating: storePool.filter((s) => s.businessStatus === 0).length,
|
||||||
resting: storePool.filter((s) => s.businessStatus === 2).length,
|
resting: storePool.filter((s) => s.businessStatus === 1).length,
|
||||||
pendingAudit: storePool.filter((s) => s.auditStatus === 0).length,
|
pendingAudit: storePool.filter((s) => s.auditStatus === 1).length,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 创建门店
|
// 创建门店
|
||||||
Mock.mock(/\/store\/create/, 'post', () => {
|
Mock.mock(/\/store\/create/, 'post', () => {
|
||||||
return { code: 200, data: null };
|
return { code: 200, data: null };
|
||||||
});
|
});
|
||||||
|
|
||||||
// 更新门店
|
// 更新门店
|
||||||
Mock.mock(/\/store\/update/, 'post', () => {
|
Mock.mock(/\/store\/update/, 'post', () => {
|
||||||
return { code: 200, data: null };
|
return { code: 200, data: null };
|
||||||
});
|
});
|
||||||
|
|
||||||
// 删除门店
|
// 删除门店
|
||||||
Mock.mock(/\/store\/delete/, 'post', () => {
|
Mock.mock(/\/store\/delete/, 'post', () => {
|
||||||
return { code: 200, data: null };
|
return { code: 200, data: null };
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 设置 mock 响应延迟
|
// 设置 mock 响应延迟
|
||||||
Mock.setup({ timeout: '200-400' });
|
Mock.setup({ timeout: '200-400' });
|
||||||
|
|||||||
@@ -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 },
|
||||||
|
|||||||
Reference in New Issue
Block a user