Commit 0d4af2b5 authored by Bill's avatar Bill

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

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