Commit fe42fa5b authored by Bill's avatar Bill

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

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