Commit fe42fa5b authored by Bill's avatar Bill

fix: 修改组合促销活动数据结构

parent a8ad047f
......@@ -75,7 +75,7 @@ module.exports = {
SITE_ID: '1',
BACK_GATEWAY: 'http://10.0.0.17:8100',
USE_ROUTE_CONFIG: true,
SOCKET_URL: 'ws://10.0.0.17:8100',
SOCKET_URL: 'ws://10.0.0.17:9880',
YAPI_URL: 'http://10.0.0.25:4000/',
// 注 交付中心同事可不使用下面的ssh配置
ssh: JSON.stringify({
......
......@@ -80,10 +80,26 @@ const useGetSameKeys = () => {
result[dataIndex] = [];
}
if (dataIndex === 'combination') {
/** combination 单独处理, 这里不使用递归了 */
childNodes?.forEach((_son, _index) => {
const sonElement = pageConfig[_son];
result[`combination_${_index}`] = [];
sonElement?.childNodes?.forEach((_row) => {
const rowData = pageConfig[_row];
result[`combination_${_index}`].push(
`${rowData?.props?.id}_${rowData?.props?.activityId}`
);
});
});
return;
}
if (dataIndex !== 'suggestProduct') {
childNodes?.forEach((_son) => {
const sonElement = pageConfig[_son];
const formatedData = formatProps[dataIndex]?.(sonElement.props);
const formatedData = formatProps[dataIndex]?.(sonElement?.props || {});
if (formatProps) {
result[dataIndex].push(formatedData);
}
......
import { ACTIVITY_LIST } from '@/constants/activity';
import { postTemplateWebActivityPageAdorn } from '@/services/TemplateV2Api';
import { CodeSandboxCircleFilled } from '@ant-design/icons';
import { message } from 'antd';
import { omit, pick } from 'lodash';
import { useState } from 'react';
import { history } from 'umi';
......@@ -101,7 +102,7 @@ function useSaveData(options: Options) {
childrenData: childrenData
}
});
} else if (ACTIVITY_LIST.includes( dataIndex as ACTIVITY_KEYS )) {
} else if (ACTIVITY_LIST.includes( dataIndex as ACTIVITY_KEYS ) && dataIndex !== 'combination') {
const { ...otherProps } = props || {};
const childrenData = childNodes.map((_record) => {
const childTargetProps = pageConfig[_record].props;
......@@ -116,31 +117,36 @@ function useSaveData(options: Options) {
childrenData: childrenData
}
});
} else if (dataIndex === 'suggestProduct') {
} else if (dataIndex === 'suggestProduct' || dataIndex === 'combination') {
const { ...otherProps } = props || {};
const { childNodes } = target;
const temp = {
sort: sort,
props: {
visible: otherProps.status ?? true,
title: otherProps.title,
childrenData: childNodes?.filter((_record) => /\d+-\d+/.test(_record)).map((_row) => {
const childrenNodeTarget = pageConfig[_row];
const { ...childRestProps } = childrenNodeTarget?.props;
const childrenData = childrenNodeTarget.childNodes?.map((_listItem) => {
const sonNodeTarget = pageConfig[_listItem];
if (dataIndex === 'suggestProduct') {
return {
id: sonNodeTarget?.props.id,
label: sonNodeTarget?.props?.label || []
};
}
return sonNodeTarget?.props.id
})
return {
title: childRestProps.title,
theme: childRestProps.theme || 0,
childrenData: childrenNodeTarget.childNodes?.map((_listItem) => {
const sonNodeTarget = pageConfig[_listItem];
return {
id: sonNodeTarget?.props.id,
label: sonNodeTarget?.props?.label || []
};
})
childrenData: childrenData
};
})
}
};
result = generaterData(result, 'suggestProduct', temp);
result = generaterData(result, dataIndex, temp);
}
});
const withThemeStyle = {
......@@ -152,13 +158,16 @@ function useSaveData(options: Options) {
}
}
}
// console.log(withThemeStyle);
// return;
const { data, code } = await postTemplateWebActivityPageAdorn({
id: +id,
adornContent: withThemeStyle
} as any);
setSaving(false);
if (code === 1000) {
history.goBack();
// history.goBack();
message.success("修改成功")
}
}
......
......@@ -116,7 +116,11 @@ const EditPanelForm = () => {
},
};
/** 如果是活动子集, 那么现实选择活动商品 */
if(activityListItem.includes(componentType) || componentType === 'hotItem' || componentType === 'suggestProductItem') {
if(
activityListItem.includes(componentType) ||
componentType === 'hotItem' ||
componentType === 'suggestProductItem'
) {
setFormValue({
product: {
...selectedInfo.props,
......@@ -146,10 +150,15 @@ const EditPanelForm = () => {
// console.log(hotItem".substring(0, 1));
formActions.setFieldState('product', (fieldState) => {
const [, parentKey] = selectedInfo.parentKey.split('-');
const disabledKeys = componentType === 'suggestProductItem'
? sameKeys[`suggestProduct_${parseInt(parentKey) - 1}`]
: componentType === 'combinationItem'
? sameKeys[`combination_${parseInt(parentKey) - 1}`]
: sameKeys[`${componentType?.substring(0, componentType.length - 4)}`] || [];
FormPath.setIn(fieldState, 'props.x-component-props', {
activityImage: activityImage,
...activityType,
disabledKeys: componentType === 'suggestProductItem' ? sameKeys[`suggestProduct_${parseInt(parentKey) - 1}`] : sameKeys[`${componentType?.substring(0, componentType.length - 4)}`] || [],
disabledKeys: disabledKeys,
...isWithLabels,
minType: isWithMinType,
// fetchOptions: fetchMemberOptions,
......
.combiantion {
margin-top: 24px;
padding: 0 8px;
margin-bottom: 12px;
padding: 0 0px;
.title {
font-size: 20px;
color: #fff;
......
......@@ -17,6 +17,11 @@ interface Iprops {
const Combination: React.FC<Iprops> & { Item: typeof CombinationItem } = (props: Iprops) => {
const { children, className, title, theme, status = true, ...other } = props;
const visible = status
const { onClick, onMouseOver, getOperateState } = props as any;
const divProps = {
onClick, onMouseOver
};
const classNameStr = cx(styles.combiantion, className, { [styles.hide]: !visible });
const omitGetOperateState = omit(other, 'getOperateState')
......@@ -38,8 +43,8 @@ const Combination: React.FC<Iprops> & { Item: typeof CombinationItem } = (props:
};
return (
<div className={classNameStr} {...omitGetOperateState}>
<p className={styles.title}>{title}</p>
<div className={classNameStr} {...divProps}>
{/* <p className={styles.title}>{title}</p> */}
<div className={styles.container}>
<div className={styles['container-title']}>以下商品认选2件,只需800元</div>
{renderChildren()}
......
......@@ -125,7 +125,10 @@ const CommodityItem: React.FC<Iprops> = (props: Iprops) => {
...otherRestProps
} = rest as any;
const activityLabel = activityList?.find((_item) => _item.id === activityId);
const withLabel = activityLabel && activityLabel.label ? {tags: [activityLabel.label]} : {};
const tags = {
tags: otherRestProps?.label || []
}
const withLabel = activityLabel && activityLabel.label ? {tags: [activityLabel.label, ...tags.tags]} : tags;
const horizontalData = {
name,
image,
......
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