Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
d35603ab
Commit
d35603ab
authored
Feb 16, 2022
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2' of
http://10.0.0.22:3000/lingxi/lingxi-business-paltform
into v2
parents
d8f93c3e
2b3f2fb3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
408 additions
and
227 deletions
+408
-227
env.js
env.js
+1
-1
index.tsx
src/pages/transaction/components/orderPayTabs/index.tsx
+6
-0
useGetLayout.ts
...nagement/activePage/fixtures/common/hooks/useGetLayout.ts
+340
-207
useGetSameKeys.tsx
...ement/activePage/fixtures/common/hooks/useGetSameKeys.tsx
+17
-1
useSaveData.ts
...anagement/activePage/fixtures/common/hooks/useSaveData.ts
+20
-11
editPanelForm.tsx
...ctivePage/fixtures/components/EditPanel/editPanelForm.tsx
+11
-2
index.less
...vePage/fixtures/components/Layouts/Combination/index.less
+2
-2
index.tsx
...ivePage/fixtures/components/Layouts/Combination/index.tsx
+7
-2
index.tsx
...ePage/fixtures/components/Layouts/CommodityList/index.tsx
+4
-1
No files found.
env.js
View file @
d35603ab
...
...
@@ -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:
810
0'
,
SOCKET_URL
:
'ws://10.0.0.17:
988
0'
,
YAPI_URL
:
'http://10.0.0.25:4000/'
,
// 注 交付中心同事可不使用下面的ssh配置
ssh
:
JSON
.
stringify
({
...
...
src/pages/transaction/components/orderPayTabs/index.tsx
View file @
d35603ab
...
...
@@ -185,6 +185,12 @@ const OrderPayTabs: React.FC<OrderPayTabsProps> = () => {
key
:
'outerStatusName'
,
},
{
title
:
intl
.
formatMessage
({
id
:
'transaction_components.neibuzhuangtai'
}),
dataIndex
:
'innerStatusName'
,
align
:
'center'
,
key
:
'innerStatusName'
,
},
{
title
:
intl
.
formatMessage
({
id
:
'transaction_components.zhifubili'
}),
key
:
'payRate'
,
dataIndex
:
'payRate'
,
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/common/hooks/useGetLayout.ts
View file @
d35603ab
...
...
@@ -4,10 +4,11 @@ import { updatePageConfig } from '@linkseeks/design-react';
import
DEFAULT_DATA
from
'../mock/index.json'
;
import
{
GetTemplateWebActivityPageGetResponse
}
from
'@/services/TemplateV2Api'
;
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
;
import
{
arrayToMap
}
from
'@/utils'
;
import
{
arrayToMap
,
omit
}
from
'@/utils'
;
import
{
getMarketingAdornActivityGoodsAdorn
,
postMarketingCouponActivityPageSelectDetail
}
from
'@/services/MarketingV2Api'
;
import
{
getTemplateWebActivityPageGet
}
from
'@/services/TemplateV2Api'
;
import
{
getIntl
}
from
'umi'
import
{
ACTIVITY_LIST
}
from
'@/constants/activity'
;
const
intl
=
getIntl
();
type
DataSourceItemType
=
{
...
...
@@ -28,39 +29,6 @@ type DetailType = Omit<GetTemplateWebActivityPageGetResponse, "adornContent"> &
adornContent
:
DataSourceType
}
/** 请求钱处理 */
const
formatData
=
{
coupon
:
(
data
:
{
id
:
number
,
type
:
1
|
2
|
number
&
{}
}[])
=>
{
return
{
couponList
:
data
.
map
((
_item
)
=>
({
belongType
:
_item
.
type
,
couponId
:
_item
.
id
}))
};
},
hot
:
(
data
:
number
[])
=>
({
ids
:
data
}),
specialOffer
:
(
data
:
number
[])
=>
({
ids
:
data
}),
plummet
:
(
data
:
number
[])
=>
({
ids
:
data
}),
discount
:
(
data
:
number
[])
=>
({
ids
:
data
}),
fullQuantitySub
:
(
data
:
number
[])
=>
({
ids
:
data
}),
fullQuantityDiscount
:
(
data
:
number
[])
=>
({
ids
:
data
}),
fullMoneySub
:
(
data
:
number
[])
=>
({
ids
:
data
}),
fullMoneyDiscount
:
(
data
:
number
[])
=>
({
ids
:
data
}),
giveProduct
:
(
data
:
number
[])
=>
({
ids
:
data
}),
giveCoupon
:
(
data
:
number
[])
=>
({
ids
:
data
}),
morePiece
:
(
data
:
number
[])
=>
({
ids
:
data
}),
combination
:
(
data
:
number
[])
=>
({
ids
:
data
}),
groupPurchase
:
(
data
:
number
[])
=>
({
ids
:
data
}),
bargain
:
(
data
:
number
[])
=>
({
ids
:
data
}),
secKill
:
(
data
:
number
[])
=>
({
ids
:
data
}),
fullSwap
:
(
data
:
number
[])
=>
({
ids
:
data
}),
buySwap
:
(
data
:
number
[])
=>
({
ids
:
data
}),
preSale
:
(
data
:
number
[])
=>
({
ids
:
data
}),
setMeal
:
(
data
:
number
[])
=>
({
ids
:
data
}),
attempt
:
(
data
:
number
[])
=>
({
ids
:
data
}),
// suggestProductItem: (data: number[]) => ({ids: data.map((_item))}),
};
/** key 对应组件名 */
const
COMPONENT_NAME
=
{
top
:
'Advertisement'
,
...
...
@@ -76,7 +44,7 @@ const COMPONENT_NAME = {
giveProduct
:
"CommodityList"
,
giveCoupon
:
"CommodityList"
,
morePiece
:
"CommodityList"
,
combination
:
"Com
bination
"
,
combination
:
"Com
modityList
"
,
groupPurchase
:
"CommodityList"
,
bargain
:
"CommodityList"
,
secKill
:
"CommodityList"
,
...
...
@@ -102,7 +70,7 @@ const CHILD_COMPONENT_NAME = {
giveProduct
:
"CommodityList.SwapProduct"
,
giveCoupon
:
"CommodityList.SwapCoupon"
,
morePiece
:
"CommodityList.Item"
,
combination
:
"Combination
.Item
"
,
combination
:
"Combination"
,
groupPurchase
:
"CommodityList.Item"
,
bargain
:
"CommodityList.Item"
,
secKill
:
"CommodityList.Item"
,
...
...
@@ -114,68 +82,6 @@ const CHILD_COMPONENT_NAME = {
suggestProduct
:
"CommodityList"
,
};
/**
* key 对应接口
*/
const
service
=
{
coupon
:
postMarketingCouponActivityPageSelectDetail
,
hot
:
getMarketingAdornActivityGoodsAdorn
,
specialOffer
:
getMarketingAdornActivityGoodsAdorn
,
plummet
:
getMarketingAdornActivityGoodsAdorn
,
discount
:
getMarketingAdornActivityGoodsAdorn
,
fullQuantitySub
:
getMarketingAdornActivityGoodsAdorn
,
fullQuantityDiscount
:
getMarketingAdornActivityGoodsAdorn
,
fullMoneySub
:
getMarketingAdornActivityGoodsAdorn
,
fullMoneyDiscount
:
getMarketingAdornActivityGoodsAdorn
,
giveProduct
:
getMarketingAdornActivityGoodsAdorn
,
giveCoupon
:
getMarketingAdornActivityGoodsAdorn
,
morePiece
:
getMarketingAdornActivityGoodsAdorn
,
combination
:
getMarketingAdornActivityGoodsAdorn
,
groupPurchase
:
getMarketingAdornActivityGoodsAdorn
,
bargain
:
getMarketingAdornActivityGoodsAdorn
,
secKill
:
getMarketingAdornActivityGoodsAdorn
,
fullSwap
:
getMarketingAdornActivityGoodsAdorn
,
buySwap
:
getMarketingAdornActivityGoodsAdorn
,
preSale
:
getMarketingAdornActivityGoodsAdorn
,
setMeal
:
getMarketingAdornActivityGoodsAdorn
,
attempt
:
getMarketingAdornActivityGoodsAdorn
,
suggestProductItem
:
getMarketingAdornActivityGoodsAdorn
,
};
const
DEFAULT_RES
=
[];
const
COMMON_FORMAT
=
({
code
,
data
})
=>
{
if
(
code
===
1000
)
{
return
data
;
}
return
DEFAULT_RES
;
};
/**
* 请求后处理
*/
const
afterRequestFormat
=
{
coupon
:
COMMON_FORMAT
,
hot
:
COMMON_FORMAT
,
specialOffer
:
COMMON_FORMAT
,
plummet
:
COMMON_FORMAT
,
discount
:
COMMON_FORMAT
,
fullQuantitySub
:
COMMON_FORMAT
,
fullQuantityDiscount
:
COMMON_FORMAT
,
fullMoneySub
:
COMMON_FORMAT
,
fullMoneyDiscount
:
COMMON_FORMAT
,
giveProduct
:
COMMON_FORMAT
,
giveCoupon
:
COMMON_FORMAT
,
morePiece
:
COMMON_FORMAT
,
combination
:
COMMON_FORMAT
,
groupPurchase
:
COMMON_FORMAT
,
bargain
:
COMMON_FORMAT
,
secKill
:
COMMON_FORMAT
,
fullSwap
:
COMMON_FORMAT
,
buySwap
:
COMMON_FORMAT
,
preSale
:
COMMON_FORMAT
,
setMeal
:
COMMON_FORMAT
,
suggestProductItem
:
COMMON_FORMAT
,
};
const
title
=
{
top
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.guanggaotu'
})}
`
,
coupon
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.youhuiquan'
})}
`
,
...
...
@@ -183,6 +89,137 @@ const title = {
suggestProduct
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.zidingyiquyu'
})}
`
};
type
ComponentConfigType
<
T
=
any
>
=
{
props
:
T
,
title
:
string
,
componentName
:
string
,
otherProps
:
{
/** 组件类型, 做区别用, 可以用组件名 */
type
:
string
},
childNodes
:
string
[],
rest
?:
any
,
}
const
createComponentConfig
=
(
{
props
,
title
,
componentName
,
otherProps
,
childNodes
,
rest
,
}:
ComponentConfigType
)
=>
{
return
{
componentName
:
componentName
,
title
:
title
,
props
:
props
,
otherProps
:
otherProps
,
childNodes
:
childNodes
,
...
rest
,
}
}
type
ComponentParamsType
=
{
/** 组件名, 数组的一项代表的是递归深度所创建的component */
componentName
:
string
[],
/**
* 如果childrenDataItem 包含childrenData 且为数组,那么符合进入递归条件
* 两种表示方式 [1, 2, 3] 活动商品id,
* [
* {title: string, childrenData: [1,2,3]}
* ]
* */
childrenData
:
any
[],
/** 这是活动商品或者是优惠券请求回来的数据, 已经做key/value 转换对应 */
dataSource
:
any
,
/** 生成pageConfig 的startKey, 1 / 1-1 这样表示, 递归会变成 1-1-1 */
startKey
:
string
|
number
,
/** 主键, childrenData[i][primaryKey], */
primaryKey
:
string
|
null
,
otherProps
:
{
/** 组件类型, 做区别用, 可以用组件名 */
type
:
string
}[],
/** 用于给suggestProduct, 添加label用 */
specialKey
:
string
,
/** suggestProduct 的label */
labels
:
any
,
}
/** 根据childrenData 递归创建子元素 */
const
createComponent
=
(
{
componentName
,
childrenData
,
startKey
,
dataSource
,
primaryKey
,
otherProps
,
specialKey
,
labels
,
}:
ComponentParamsType
)
=>
{
const
childNodesKeys
=
[];
let
result
=
{};
const
floor
=
`
${
startKey
}
`
.
split
(
"-"
).
length
;
for
(
let
i
=
0
;
i
<
childrenData
.
length
;
i
++
)
{
const
keyNum
=
`
${
startKey
}
-
${
i
+
1
}
`
;
const
current
=
childrenData
[
i
];
const
isDept
=
typeof
current
.
childrenData
!==
'undefined'
&&
Array
.
isArray
(
current
.
childrenData
);
let
parentChildKeys
=
[];
let
parentChildConfig
=
{};
let
configRest
=
{};
console
.
log
(
isDept
,
"isDept: "
+
isDept
);
if
(
isDept
)
{
const
sonConfig
=
createComponent
(
{
componentName
,
childrenData
:
current
.
childrenData
,
startKey
:
keyNum
,
dataSource
,
primaryKey
,
otherProps
,
specialKey
,
labels
}
);
parentChildKeys
=
sonConfig
.
keys
;
parentChildConfig
=
sonConfig
.
config
configRest
=
{
childComponentName
:
componentName
[
floor
],
addBtnText
:
'添加子节点'
,
childProps
:
{
otherProps
:
otherProps
[
floor
],
}
}
}
const
key
=
primaryKey
?
current
[
primaryKey
]
:
current
childNodesKeys
.
push
(
keyNum
);
let
childProps
=
dataSource
[
key
]
const
[
startString
,
...
rest
]
=
keyNum
.
split
(
"-"
);
const
config
=
createComponentConfig
({
componentName
:
componentName
[
floor
-
1
],
title
:
childProps
?.
name
||
childProps
?.
productName
||
`子集
${
keyNum
}
`
,
props
:
isDept
?
omit
(
current
,
[
'childrenData'
])
:
specialKey
&&
specialKey
===
otherProps
[
floor
-
1
].
type
?
{
label
:
labels
[
`
${
childProps
}
-
${
rest
.
join
(
"-"
)}
`
]
||
[]
,
...
childProps
}
:
childProps
,
otherProps
:
otherProps
[
floor
-
1
],
childNodes
:
parentChildKeys
,
rest
:
configRest
})
result
=
{
...
result
,
[
keyNum
]:
config
,
...
parentChildConfig
}
}
return
{
config
:
result
,
keys
:
childNodesKeys
}
}
function
useGetLayout
()
{
const
{
id
}
=
usePageStatus
();
const
[
detail
,
setDetail
]
=
useState
<
DetailType
|
null
>
(
null
);
...
...
@@ -236,41 +273,136 @@ function useGetLayout() {
});
});
const
sortedList
=
dataSourceList
.
sort
((
a
,
b
)
=>
a
.
sort
-
b
.
sort
).
filter
((
_item
)
=>
_item
.
key
!==
'themeStyle'
);
/** 优惠券请求体 */
const
couponRequestData
=
adornContent
.
coupon
.
props
.
childrenData
||
[];
/** 获取自定义区域请求体 */
const
customizeAreaRequestData
=
adornContent
.
suggestProduct
.
props
.
childrenData
.
reduce
((
prev
,
next
,
_index
)
=>
{
const
labelsWithId
=
{};
const
result
=
next
.
childrenData
.
map
((
_item
,
_key
)
=>
{
labelsWithId
[
`
${
_index
+
1
}
-
${
_key
+
1
}
-
${
_item
.
id
}
`
]
=
_item
.
label
;
return
_item
.
id
});
prev
=
{
ids
:
[...
prev
.
ids
,
...
result
],
labelsWithId
:
labelsWithId
,
}
return
prev
},
{
ids
:
[],
label
:
{}
})
/** 获取组合促销请求体 */
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'
)
{
all
=
[...
all
,
...((
adornContent
[
_item
]
as
any
).
props
.
childrenData
)]
}
return
all
;
},
[]);
const
getCouponData
=
async
(
couponData
)
=>
{
if
(
couponData
.
length
===
0
)
{
return
[];
}
const
formated
=
couponData
.
map
((
_item
)
=>
({
belongType
:
_item
.
type
,
couponId
:
_item
.
id
}))
const
{
code
,
data
}
=
await
postMarketingCouponActivityPageSelectDetail
({
couponList
:
formated
});
return
data
;
}
const
getActivityData
=
async
(
datas
)
=>
{
const
{
code
,
data
}
=
await
getMarketingAdornActivityGoodsAdorn
({
ids
:
datas
})
return
data
;
}
const
getResponseData
=
await
Promise
.
all
([
getCouponData
(
couponRequestData
),
getActivityData
(
Array
.
from
(
new
Set
([...
customizeAreaRequestData
.
ids
,
...
activityRequestData
,
...
combinationRequestData
])))
]);
const
activityDataResponse
=
arrayToMap
(
getResponseData
[
1
]
||
[],
"id"
);
const
couponResponseData
=
arrayToMap
(
getResponseData
[
0
]
||
[],
"id"
)
for
(
const
_row
of
sortedList
)
{
startKey
=
startKey
+
1
;
firstChildKeys
.
push
(
startKey
.
toString
());
const
target
=
adornContent
[
_row
.
key
];
const
currentProps
=
target
.
props
;
const
childrenData
=
currentProps
.
childrenData
||
[];
const
props
=
_row
.
key
===
'top'
?
{
imageUrl
:
currentProps
.
imageUrl
}
:
{
/** 当前组件的props */
let
props
=
{};
/** 设置左边菜单栏 属性,是否允许隐藏,是否允许删除,添加子节点信息等等 */
let
sideControllerData
=
{}
/** 点击左侧菜单添加按钮时, 创建子节点的组件信息 */
let
childrenComponentInfo
=
{}
/** 如果为顶部活动图 */
if
(
_row
.
key
===
'top'
)
{
props
=
{
imageUrl
:
currentProps
.
imageUrl
}
}
else
{
/** 优惠券,活动等等 */
props
=
{
/** 是否显示 */
status
:
currentProps
.
visible
??
true
,
theme
:
currentProps
.
theme
||
0
,
title
:
currentProps
.
title
,
};
const
suggestProductSonProps
=
_row
.
key
===
'suggestProduct'
?
{
hideAction
:
true
,
childComponentName
:
`CommodityList.Item`
,
addBtnText
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.tianjiashangpinjiedian'
})}
`
,
childProps
:
{
otherProps
:
{
type
:
`suggestProductItem`
},
}
}
:
{};
const
childPropsData
=
_row
.
key
===
'top'
?
{}
:
{
childComponentName
:
`
${
CHILD_COMPONENT_NAME
[
_row
.
key
]}
`
,
addBtnText
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.tianjiazijiedian'
})}
`
,
childProps
:
{
otherProps
:
{
type
:
_row
.
key
===
'suggestProduct'
?
'suggestProduct'
:
`
${
_row
.
key
}
Item`
/** 第三层节点信息 */
let
thirdFloorData
=
{};
if
(
_row
.
key
===
'suggestProduct'
)
{
thirdFloorData
=
{
hideAction
:
true
,
childComponentName
:
`CommodityList.Item`
,
addBtnText
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.tianjiashangpinjiedian'
})}
`
,
childProps
:
{
otherProps
:
{
type
:
`suggestProductItem`
},
}
}
}
else
if
(
_row
.
key
===
'combination'
)
{
thirdFloorData
=
{
hideAction
:
true
,
childComponentName
:
`Combination.Item`
,
addBtnText
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.tianjiashangpinjiedian'
})}
`
,
childProps
:
{
otherProps
:
{
type
:
`combinationItem`
},
}
}
}
/** 组件类型,selectInfo 时判断显示的装修类容 */
const
otherPropsType
=
_row
.
key
===
'suggestProduct'
?
'suggestProduct'
:
_row
.
key
===
'combination'
?
'combinationItemProduct'
:
`
${
_row
.
key
}
Item`
/** 点击左侧菜单添加按钮时, 创建子节点的组件信息 */
childrenComponentInfo
=
{
/** 儿子组件 */
childComponentName
:
`
${
CHILD_COMPONENT_NAME
[
_row
.
key
]}
`
,
addBtnText
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.tianjiazijiedian'
})}
`
,
childProps
:
{
otherProps
:
{
type
:
otherPropsType
},
...
thirdFloorData
,
},
...
suggestProductSonProps
,
},
};
let
tempConfig
=
{
}
// console.log(sideControllerData, "sideControllerData")
}
/** 设置左边菜单栏属性 */
sideControllerData
=
{
hideAction
:
true
,
/** 当前组件名, 需要注册schema, 以及组件 */
componentName
:
COMPONENT_NAME
[
_row
.
key
],
title
:
title
[
_row
.
key
]
||
currentProps
.
title
,
props
:
props
,
...
...
@@ -278,96 +410,97 @@ function useGetLayout() {
type
:
_row
.
key
},
canDelete
:
false
,
...
childPropsData
,
childNodes
:
[],
};
const
childNodesKeys
:
string
[]
=
[];
if
(
childrenData
.
length
>
0
&&
_row
.
key
!==
'suggestProduct'
)
{
const
formatedData
=
formatData
[
_row
.
key
]?.(
childrenData
.
filter
(
Boolean
));
const
length
=
typeof
formatedData
.
ids
!==
'undefined'
?
formatedData
?.
ids
?.
length
:
formatedData
?.
couponList
.
length
;
if
(
length
>
0
)
{
const
requestData
=
await
service
[
_row
.
key
]?.(
formatedData
,
{
ctlType
:
'none'
});
const
afterRequestFormatedData
=
afterRequestFormat
[
_row
.
key
]?.(
requestData
);
afterRequestFormatedData
?.
forEach
((
_item
,
_index
)
=>
{
const
keyNum
=
`
${
startKey
}
-
${
_index
+
1
}
`
;
childNodesKeys
.
push
(
keyNum
);
const
sonConfig
=
{
componentName
:
`
${
CHILD_COMPONENT_NAME
[
_row
.
key
]}
`
,
title
:
_item
?.
productName
||
_item
.
name
,
props
:
{
...
_item
,
},
otherProps
:
{
type
:
`
${
_row
.
key
}
Item`
},
childNodes
:
[]
};
pageConfig
[
keyNum
]
=
sonConfig
;
});
...
childrenComponentInfo
}
// 创建当前组件内容
pageConfig
[
startKey
]
=
sideControllerData
/** 创建子节点信息 */
let
childNodesKeys
:
string
[]
=
[];
if
(
childrenData
.
length
===
0
)
{
continue
;
}
if
(
_row
.
key
===
'coupon'
)
{
const
{
config
,
keys
}
=
createComponent
({
componentName
:
[
`
${
CHILD_COMPONENT_NAME
[
_row
.
key
]}
`
],
childrenData
:
childrenData
,
startKey
:
startKey
,
dataSource
:
couponResponseData
,
primaryKey
:
"id"
,
otherProps
:
[{
type
:
`
${
_row
.
key
}
Item`
}],
specialKey
:
null
,
labels
:
{},
})
childNodesKeys
=
[...
childNodesKeys
,
...
keys
];
pageConfig
=
{
...
pageConfig
,
...
config
,
}
}
else
if
(
_row
.
key
===
'suggestProduct'
)
{
// const suggestDataKeys: string[] = [];
let
_index
=
0
;
for
(
const
_item
of
childrenData
)
{
const
keyNum
=
`
${
startKey
}
-
${
++
_index
}
`
;
childNodesKeys
.
push
(
keyNum
);
const
suggestConfig
=
{
componentName
:
'CommodityList'
,
title
:
_item
.
title
,
props
:
{
title
:
_item
.
title
,
theme
:
_item
.
theme
,
},
otherProps
:
{
type
:
_row
.
key
},
childNodes
:
[],
childComponentName
:
`CommodityList.Item`
,
addBtnText
:
`
${
intl
.
formatMessage
({
id
:
'marketingAbility.tianjiazijiedian'
})}
`
,
childProps
:
{
otherProps
:
{
type
:
`suggestProductItem`
},
}
};
const
suggestSonKeys
:
string
[]
=
[];
if
(
_item
.
childrenData
?.
length
>
0
)
{
const
requestData
=
await
service
[
"suggestProductItem"
]?.({
ids
:
_item
.
childrenData
.
map
((
_u
)
=>
_u
.
id
)});
const
arrayToMapData
=
arrayToMap
(
_item
.
childrenData
,
"id"
);
// console.log(requestData, _item.childrenData, arrayToMapData);
const
afterRequestFormatedData
=
afterRequestFormat
[
"suggestProductItem"
]?.(
requestData
);
// console.log(afterRequestFormatedData, arrayToMapData);
afterRequestFormatedData
?.
forEach
((
_item
,
_itemIndex
)
=>
{
const
sonKeyNum
=
`
${
keyNum
}
-
${
_itemIndex
+
1
}
`
;
suggestSonKeys
.
push
(
sonKeyNum
);
const
sonConfig
=
{
componentName
:
`CommodityList.Item`
,
title
:
_item
?.
productName
||
_item
.
name
,
props
:
{
...
_item
,
label
:
arrayToMapData
[
_item
.
id
]?.
label
},
otherProps
:
{
type
:
`suggestProductItem`
},
childNodes
:
[]
};
pageConfig
[
sonKeyNum
]
=
sonConfig
;
});
}
pageConfig
[
keyNum
]
=
{
...
suggestConfig
,
childNodes
:
suggestSonKeys
,
};
}
else
if
(
_row
.
key
===
'combination'
)
{
// 组合促销时
const
{
config
,
keys
}
=
createComponent
({
componentName
:
[
`Combination`
,
`Combination.Item`
],
childrenData
:
childrenData
,
startKey
:
startKey
,
dataSource
:
activityDataResponse
,
primaryKey
:
null
,
otherProps
:
[
{
type
:
`combinationItemProduct`
},
{
type
:
`
${
_row
.
key
}
Item`
}
],
specialKey
:
null
,
labels
:
{},
})
childNodesKeys
=
[...
childNodesKeys
,
...
keys
];
pageConfig
=
{
...
pageConfig
,
...
config
,
}
// childNodesKeys
}
tempConfig
=
{
...
tempConfig
,
childNodes
:
childNodesKeys
};
pageConfig
[
startKey
]
=
tempConfig
;
}
else
if
(
_row
.
key
!==
'suggestProduct'
)
{
const
{
config
,
keys
}
=
createComponent
({
componentName
:
[
`
${
CHILD_COMPONENT_NAME
[
_row
.
key
]}
`
],
childrenData
:
childrenData
,
startKey
:
startKey
,
dataSource
:
activityDataResponse
,
primaryKey
:
null
,
otherProps
:
[{
type
:
`
${
_row
.
key
}
Item`
}],
specialKey
:
null
,
labels
:
{},
})
childNodesKeys
=
[...
childNodesKeys
,
...
keys
];
pageConfig
=
{
...
pageConfig
,
...
config
,
}
}
else
{
const
{
config
,
keys
}
=
createComponent
({
componentName
:
[
`CommodityList`
,
'CommodityList.Item'
],
childrenData
:
childrenData
,
startKey
:
startKey
,
dataSource
:
activityDataResponse
,
primaryKey
:
"id"
,
otherProps
:
[
{
type
:
`
${
_row
.
key
}
`
},
{
type
:
`
${
_row
.
key
}
Item`
}
],
specialKey
:
`
${
_row
.
key
}
Item`
,
labels
:
customizeAreaRequestData
.
labelsWithId
,
})
childNodesKeys
=
[...
childNodesKeys
,
...
keys
];
pageConfig
=
{
...
pageConfig
,
...
config
,
}
}
pageConfig
[
startKey
].
childNodes
=
childNodesKeys
}
pageConfig
=
{
0
:
{
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/common/hooks/useGetSameKeys.tsx
View file @
d35603ab
...
...
@@ -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);
}
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/common/hooks/useSaveData.ts
View file @
d35603ab
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
(
"修改成功"
)
}
}
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/components/EditPanel/editPanelForm.tsx
View file @
d35603ab
...
...
@@ -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,
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/components/Layouts/Combination/index.less
View file @
d35603ab
.combiantion {
margin-
top: 24
px;
padding: 0
8
px;
margin-
bottom: 12
px;
padding: 0
0
px;
.title {
font-size: 20px;
color: #fff;
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/components/Layouts/Combination/index.tsx
View file @
d35603ab
...
...
@@ -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
()
}
...
...
src/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/components/Layouts/CommodityList/index.tsx
View file @
d35603ab
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment