feat: 1:1还原加料管理页面与交互
This commit is contained in:
@@ -58,6 +58,7 @@ interface AddonItemRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
price: number;
|
||||
stock: number;
|
||||
sort: number;
|
||||
status: ProductSwitchStatus;
|
||||
}
|
||||
@@ -378,6 +379,7 @@ function toAddonGroupItem(
|
||||
id: addon.id,
|
||||
name: addon.name,
|
||||
price: addon.price,
|
||||
stock: addon.stock,
|
||||
sort: addon.sort,
|
||||
status: addon.status,
|
||||
})),
|
||||
@@ -517,6 +519,7 @@ function createDefaultState(storeId: string): ProductExtensionStoreState {
|
||||
id: createId('addon-item', storeId),
|
||||
name: '加鸡蛋',
|
||||
price: 2,
|
||||
stock: 160,
|
||||
sort: 1,
|
||||
status: 'enabled',
|
||||
},
|
||||
@@ -524,6 +527,7 @@ function createDefaultState(storeId: string): ProductExtensionStoreState {
|
||||
id: createId('addon-item', storeId),
|
||||
name: '加饭',
|
||||
price: 3,
|
||||
stock: 80,
|
||||
sort: 2,
|
||||
status: 'enabled',
|
||||
},
|
||||
@@ -1067,6 +1071,7 @@ Mock.mock(
|
||||
id: normalizeText(current.id, createId('addon-item', storeId)),
|
||||
name: itemName,
|
||||
price: Number(normalizeNumber(current.price, 0, 0).toFixed(2)),
|
||||
stock: normalizeInt(current.stock, 999, 0),
|
||||
sort: normalizeInt(current.sort, index + 1, 1),
|
||||
status: normalizeSwitchStatus(current.status, 'enabled'),
|
||||
};
|
||||
@@ -1177,6 +1182,29 @@ Mock.mock(
|
||||
},
|
||||
);
|
||||
|
||||
Mock.mock(
|
||||
/\/product\/addon\/group\/products\/bind/,
|
||||
'post',
|
||||
(options: MockRequestOptions) => {
|
||||
const body = parseBody(options);
|
||||
const storeId = normalizeText(body.storeId);
|
||||
const groupId = normalizeText(body.groupId);
|
||||
if (!storeId || !groupId) {
|
||||
return { code: 400, data: null, message: '参数不完整' };
|
||||
}
|
||||
|
||||
const state = ensureStoreState(storeId);
|
||||
const target = state.addonGroups.find((item) => item.id === groupId);
|
||||
if (!target) return { code: 404, data: null, message: '加料组不存在' };
|
||||
|
||||
target.productIds = normalizeIdList(body.productIds).filter((productId) =>
|
||||
state.products.some((item) => item.id === productId),
|
||||
);
|
||||
target.updatedAt = toDateTimeText(new Date());
|
||||
return { code: 200, data: toAddonGroupItem(state, target) };
|
||||
},
|
||||
);
|
||||
|
||||
Mock.mock(
|
||||
/\/product\/label\/list(?:\?|$)/,
|
||||
'get',
|
||||
|
||||
Reference in New Issue
Block a user