Commit 0d4af2b5 authored by Bill's avatar Bill

fix: 修改装修内容未null时报错,以及组合促销已选择时,过滤其余活动

parent 9f5aab62
......@@ -171,7 +171,6 @@ const createComponent = (
let parentChildKeys = [];
let parentChildConfig = {};
let configRest = {};
console.log(isDept, "isDept: " + isDept);
if (isDept) {
const sonConfig = createComponent(
{
......@@ -289,10 +288,10 @@ function useGetLayout() {
return prev
}, { ids: [], label: {} })
/** 获取组合促销请求体 */
const combinationRequestData = adornContent.combination.props.childrenData.reduce((prev, next, _index) => {
prev = [...prev, ...next.childrenData]
const combinationRequestData = adornContent.combination?.props?.childrenData?.reduce((prev, next, _index) => {
prev = [...prev, ...(next.childrenData || [])]
return prev
}, [])
}, []) || []
/** 获取其他活动的请求体 */
const activityRequestData = Object.keys(adornContent).reduce((all, _item) => {
if (ACTIVITY_LIST.includes(_item as any) && _item !== 'combination') {
......
......@@ -107,7 +107,7 @@ function useSaveData(options: Options) {
const childrenData = childNodes.map((_record) => {
const childTargetProps = pageConfig[_record].props;
return childTargetProps.id;
});
}).filter(Boolean);
// const childrenData = products?.map((_item) => _item.id) || [];
result = generaterData(result, dataIndex, {
sort: sort,
......
......@@ -88,7 +88,6 @@ const EditPanelForm = () => {
clearSelectedStatus();
setVisible(false);
};
console.log(selectedInfo);
useEffect(() => {
if (selectedInfo === null) {
......@@ -96,6 +95,10 @@ const EditPanelForm = () => {
return;
}
const componentType = (selectedInfo as any)?.otherProps?.type;
if (componentType === 'combinationItemProduct') {
handleOnClose();
return;
}
const propsMapToValue = {
top: {
......@@ -124,7 +127,9 @@ const EditPanelForm = () => {
setFormValue({
product: {
...selectedInfo.props,
}
},
/** 当selectedInfo.props 未空对象的时候就不会更新当前value, 所有添加uuid */
uuid: Math.random()
});
setSchema(activityProducts);
} else {
......@@ -141,34 +146,43 @@ const EditPanelForm = () => {
: propsMapToValue?.[componentType];
setSchema(tempSchema);
setFormValue(tempFormValue);
setFormValue({...tempFormValue, uuid: Math.random() });
}
/** 16 种活动,请求是需要带上活动类型 */
const activityType = ACTIVITY_MAP[componentType] ? { activityType: ACTIVITY_MAP[componentType] } : {};
const isWithLabels = componentType === 'suggestProductItem' ? { isWithLabels: true } : { isWithLabels: false };
const isWithMinType = minTypeToOne.includes(componentType) ? 1 : minTypeToTwo.includes(componentType) ? 2 : null
// console.log(hotItem".substring(0, 1));
formActions.setFieldState('product', (fieldState) => {
const [, parentKey] = selectedInfo.parentKey.split('-');
const isCombination = componentType === 'combinationItem';
/** 如果是组合促销, 要是已经选择了一个组合促销数据,那么搜索活动商品列表时需要添加当前活动id */
let withActivityId = {};
if (isCombination) {
const [,currentCombinationActivityId] = sameKeys[`combination_${+(parentKey) - 1}`][0].split('_');
withActivityId = currentCombinationActivityId === 'undefined' ? {} : { id: currentCombinationActivityId }
}
const disabledKeys = componentType === 'suggestProductItem'
? sameKeys[`suggestProduct_${parseInt(parentKey) - 1}`]
: componentType === 'combinationItem'
? sameKeys[`combination_${parseInt(parentKey) - 1}`]
? sameKeys[`suggestProduct_${+(parentKey) - 1}`]
: isCombination
? sameKeys[`combination_${+(parentKey) - 1}`]
: sameKeys[`${componentType?.substring(0, componentType.length - 4)}`] || [];
FormPath.setIn(fieldState, 'props.x-component-props', {
activityImage: activityImage,
...activityType,
disabledKeys: disabledKeys,
...isWithLabels,
...withActivityId,
activityImage: activityImage,
disabledKeys: disabledKeys,
minType: isWithMinType,
// fetchOptions: fetchMemberOptions,
});
});
setVisible(true);
}, [selectedInfo]);
const handleSubmit = (values) => {
console.log(values);
console.log("Submit", values);
const componentType = (selectedInfo as any)?.otherProps?.type;
const valueMapToProps = {
top: {
......@@ -185,7 +199,11 @@ const EditPanelForm = () => {
}
};
let currentProps = {};
if (activityListItem.includes(componentType) || componentType === 'suggestProductItem' || componentType === 'hotItem') {
if (
activityListItem.includes(componentType)
|| componentType === 'suggestProductItem'
|| componentType === 'hotItem'
) {
currentProps = values.product;
} else if (activityList.includes(componentType)) {
currentProps = {
......@@ -203,7 +221,7 @@ const EditPanelForm = () => {
title: (currentProps as any)?.title || (currentProps as any)?.productName || (currentProps as any)?.name
});
handleOnClose();
formActions.reset();
// formActions.reset();
};
const renderUploadChild = (value) => {
......
......@@ -78,11 +78,13 @@ const FormilyActivityProduct: React.FC<Iprops> & { isFieldComponent: boolean } =
const fetchData = async (params: GetMarketingAdornPlatformActivityListAdornRequest) => {
const withActivityType = componentProps?.activityType ? { activityType: componentProps?.activityType } : {};
const minType = componentProps?.minType ? { minType: componentProps.minType } : {};
const withActivityId = componentProps?.id ? { id: componentProps.id } : {}
const common = {
...params,
shopId: shopId?.toString(),
...params,
...minType,
...withActivityType
...withActivityType,
...withActivityId,
};
const isWithActivityType = common;
return await getMarketingAdornMerchantActivityListAdorn(isWithActivityType as any);
......
......@@ -67,7 +67,7 @@
.simple {
width: 33.3%;
height: 150px;
min-height: 150px;
padding-right: 12px;
// background-color: red;
display: flex;
......
......@@ -14,6 +14,22 @@ interface Iprops {
theme: number
}
function parseChildrenList(children: React.ReactNode) {
const elements = React.Children.map(children, (node) => {
if (React.isValidElement(node)) {
const key = node.key !== undefined ? String(node.key) : undefined;
return {
key,
...node.props,
node,
};
}
return null
});
return elements || [];
}
const Combination: React.FC<Iprops> & { Item: typeof CombinationItem } = (props: Iprops) => {
const { children, className, title, theme, status = true, ...other } = props;
const visible = status
......@@ -21,11 +37,12 @@ const Combination: React.FC<Iprops> & { Item: typeof CombinationItem } = (props:
const divProps = {
onClick, onMouseOver
};
const classNameStr = cx(styles.combiantion, className, { [styles.hide]: !visible });
const childrenList = parseChildrenList(children);
const containerTitle = childrenList.length === 0
? `以下商品认选n件,只需m元`
: childrenList[0]?.activityList?.find((_item) => _item.id === childrenList[0]?.activityId)?.label;
const omitGetOperateState = omit(other, 'getOperateState')
// const { onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver, getOperateState } = other as any;
const classNameStr = cx(styles.combiantion, className, { [styles.hide]: !visible });
const count = React.Children.count(children);
const renderChildren = () => {
return (
......@@ -46,7 +63,7 @@ const Combination: React.FC<Iprops> & { Item: typeof CombinationItem } = (props:
<div className={classNameStr} {...divProps}>
{/* <p className={styles.title}>{title}</p> */}
<div className={styles.container}>
<div className={styles['container-title']}>以下商品认选2件,只需800元</div>
<div className={styles['container-title']}>{containerTitle}</div>
{renderChildren()}
{
count > 0 && (
......@@ -64,10 +81,10 @@ const Combination: React.FC<Iprops> & { Item: typeof CombinationItem } = (props:
}
const CombinationItem: React.FC<any> = (props: any) => {
const { productImgUrl, discount, price, footer, sale, productName, id, activityPrice } = props as any;
const { onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver, getOperateState, className } = props as any;
const { productImgUrl, discount, price, footer, sale, productName, id, activityPrice, activityList } = props as any;
const { onClick, onMouseOver, getOperateState, className } = props as any;
const divProps = {
onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver
onClick, onMouseOver
};
// const wrapClass = cx(styles.simple);
const wrapClass = cx(styles.section, className)
......@@ -89,7 +106,11 @@ const CombinationItem: React.FC<any> = (props: any) => {
<img src={productImgUrl} className={styles['simple-product-image']}/>
<div className={styles['simple-product-name']}>{productName}</div>
<div className={styles['simple-product-label']}>
<CustomizeTag>800元2件</CustomizeTag>
{activityList.map((_item) => {
return (
<CustomizeTag>{_item.label}</CustomizeTag>
)
})}
</div>
</div>
</div>
......
......@@ -26,6 +26,7 @@
background: #fff;
padding: 12px;
border-radius: 8px;
margin-bottom: 12px;
.commodityGroupEmpty {
min-height: 430px;
......@@ -43,6 +44,7 @@
display: flex;
flex-direction: row;
margin-right: -12px;
flex-wrap: wrap;
}
.groupCommodityItem {
......
......@@ -22,7 +22,7 @@ const SwapCoupon = (props) => {
const { onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver, getOperateState } = other as any;
const divProps = {
onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver,
onClick, onMouseOver,
};
const handleTabChange = (key: string) => {
setActiveKey(key);
......@@ -67,7 +67,7 @@ const SwapCoupon = (props) => {
<span className={styles.num}>{_row.denomination}</span>
</div>
<div className={styles.condition}>{`${intl.formatMessage({ id: 'activityPage.fill' })}${_row.useConditionMoney}${intl.formatMessage({ id: 'activityPage.available' })}`}</div>
<div className={styles.couponType}>{_row.couponName}</div>
<div className={styles.couponType}>{_row.typeName}</div>
</div>
);
})
......
......@@ -160,7 +160,11 @@ const Product: React.FC<Iprops> = (props: Iprops) => {
</div>
<div className={styles.container}>
<div className={styles.product}>
<img className={styles.img} src={productImgUrl} />
{
productImgUrl && (
<img className={styles.img} src={productImgUrl} />
) || <div className={styles.img} />
}
<div className={styles.info}>
<span className={styles.name}>{productName}</span>
<span className={styles.price}>{priceFormat(price)}</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment