docs(Sku): add docs and change the usage of properties (#5563)

This commit is contained in:
Waiter
2020-01-14 17:08:58 +08:00
committed by neverland
parent 0223258a01
commit 89900bbcfd
6 changed files with 206 additions and 62 deletions
+23 -1
View File
@@ -120,12 +120,33 @@ export const getSelectedPropValues = (propList, selectedProp) => {
const normalizeProp = normalizePropList(propList);
return Object.keys(selectedProp).reduce((acc, cur) => {
selectedProp[cur].forEach(it => {
acc.push(normalizeProp[cur][it]);
acc.push({
...normalizeProp[cur][it],
});
});
return acc;
}, []);
};
export const getSelectedProperties = (propList, selectedProp) => {
const list = [];
(propList || []).forEach(prop => {
if (selectedProp[prop.k_id] && selectedProp[prop.k_id].length > 0) {
const v = [];
prop.v.forEach(it => {
if (selectedProp[prop.k_id].indexOf(it.id) > -1) {
v.push({ ...it });
}
});
list.push({
...prop,
v,
});
}
});
return list;
};
export default {
normalizeSkuTree,
getSkuComb,
@@ -133,4 +154,5 @@ export default {
isAllSelected,
isSkuChoosable,
getSelectedPropValues,
getSelectedProperties,
};