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
94402b84
Commit
94402b84
authored
Nov 26, 2020
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:1.修复进货单会员折扣价显示问题;2,商品详情交易评价图片显示问题
parent
0d99cc6c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
195 additions
and
163 deletions
+195
-163
config.ts
config/config.ts
+3
-2
index.tsx
src/components/InputNumber/index.tsx
+13
-8
index.tsx
...ngsPanel/propsSettings/components/AdvertSetting/index.tsx
+1
-1
index.tsx
...omponents/ProductDescription/components/Comment/index.tsx
+5
-5
index.tsx
...nts/ProductDescription/components/ImageViewList/index.tsx
+2
-7
index.tsx
src/pages/lxMall/commodityDetail/index.tsx
+53
-52
index.tsx
src/pages/lxMall/purchaseOrder/index.tsx
+118
-88
No files found.
config/config.ts
View file @
94402b84
...
...
@@ -4,6 +4,7 @@ import proxy from './proxy'
import
theme
from
'./lingxi.theme.config'
const
OPEN_THEME_BUILD
=
process
.
env
.
NODE_ENV
===
'production'
?
true
:
false
// 是否开启动态主题
const
isProduction
=
process
.
env
.
NODE_ENV
===
'production'
?
true
:
false
const
config
:
any
=
{
// 如需写入环境变量 需在config中先写入
...
...
@@ -49,9 +50,9 @@ const config: any = {
defaultSizes
:
'parsed'
,
// stat // gzip
},
inlineLimit
:
10000
,
chunks
:
[
'vendors'
,
'umi'
],
chunks
:
isProduction
&&
[
'vendors'
,
'umi'
],
chainWebpack
:
function
(
config
,
{
webpack
})
{
config
.
merge
({
isProduction
&&
config
.
merge
({
optimization
:
{
minimize
:
true
,
splitChunks
:
{
...
...
src/components/InputNumber/index.tsx
View file @
94402b84
...
...
@@ -21,13 +21,13 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
if
(
min
||
min
===
0
)
{
setMinCount
(
min
)
if
(
value
<
min
)
{
onChange
(
min
)
onChange
(
min
,
'blur'
)
}
}
if
(
max
||
max
===
0
)
{
setMaxCount
(
max
)
if
(
value
>
max
)
{
onChange
(
max
)
onChange
(
max
,
'blur'
)
}
}
},
[
min
,
max
])
...
...
@@ -35,14 +35,14 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
const
handleReduce
=
(
e
)
=>
{
e
.
stopPropagation
()
if
(
value
>
minCount
)
{
onChange
(
Number
(
value
)
-
1
)
onChange
(
Number
(
value
)
-
1
,
'click'
)
}
}
const
handleAdd
=
(
e
)
=>
{
e
.
stopPropagation
()
if
(
value
<
maxCount
)
{
onChange
(
Number
(
value
)
+
1
)
onChange
(
Number
(
value
)
+
1
,
'click'
)
}
}
...
...
@@ -50,17 +50,22 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
const
{
value
}
=
e
.
target
;
const
reg
=
/^
\d
*
?
$/
;
if
(
reg
.
test
(
value
))
{
onChange
(
value
)
onChange
(
value
,
'change'
)
}
}
const
handleBlur
=
(
e
)
=>
{
const
{
value
}
=
e
.
target
;
if
(
value
===
""
)
{
onChange
(
minCount
)
onChange
(
minCount
,
'blur'
)
}
else
{
Number
(
value
)
<
minCount
&&
onChange
(
minCount
)
Number
(
value
)
>
maxCount
&&
onChange
(
maxCount
)
if
(
Number
(
value
)
<
minCount
)
{
onChange
(
minCount
,
'blur'
)
}
else
if
(
Number
(
value
)
>
maxCount
)
{
onChange
(
maxCount
,
'blur'
)
}
else
{
onChange
(
value
,
'blur'
)
}
}
}
...
...
src/pages/editor/settingsPanel/propsSettings/components/AdvertSetting/index.tsx
View file @
94402b84
...
...
@@ -195,7 +195,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
setConfirmLoading
(
true
)
let
newParam
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
newProps
))
newParam
.
advertList
=
newParam
.
advertList
.
map
((
item
)
=>
{
if
(
!
item
.
link
.
startsWith
(
'http://'
)
&&
!
item
.
link
.
startsWith
(
'https://'
))
{
if
(
!
item
.
link
&&
!
item
.
link
.
startsWith
(
'http://'
)
&&
!
item
.
link
.
startsWith
(
'https://'
))
{
item
.
link
=
`http://
${
item
.
link
}
`
}
return
item
...
...
src/pages/lxMall/commodityDetail/components/ProductDescription/components/Comment/index.tsx
View file @
94402b84
...
...
@@ -42,7 +42,7 @@ const Comment: React.FC<CommentPropsType> = (props) => {
},
[
current
])
const
fetchCommentList
=
(
type
=
''
)
=>
{
le
t
param
:
any
=
{
cons
t
param
:
any
=
{
current
,
pageSize
,
productIds
:
productIds
.
toString
()
// '2339'
...
...
@@ -55,7 +55,7 @@ const Comment: React.FC<CommentPropsType> = (props) => {
param
.
starLevel
=
1
}
setSpinLoading
(
true
)
//@ts-ignore
PublicApi
.
getMemberCommentMallTradeHistoryPage
(
param
).
then
(
res
=>
{
setSpinLoading
(
false
)
if
(
res
.
code
===
1000
)
{
...
...
@@ -85,7 +85,7 @@ const Comment: React.FC<CommentPropsType> = (props) => {
let
middleCount
=
0
let
badCount
=
0
if
(
data
)
{
for
(
le
t
item
of
data
)
{
for
(
cons
t
item
of
data
)
{
switch
(
item
.
star
)
{
case
1
:
case
2
:
...
...
@@ -103,9 +103,9 @@ const Comment: React.FC<CommentPropsType> = (props) => {
}
}
}
le
t
allCount
=
goodCount
+
middleCount
+
badCount
cons
t
allCount
=
goodCount
+
middleCount
+
badCount
le
t
result
=
[{
cons
t
result
=
[{
title
:
'全部评价'
,
sum
:
allCount
,
sumText
:
allCount
>
200
?
`(200+)`
:
`(
${
allCount
}
)`
,
...
...
src/pages/lxMall/commodityDetail/components/ProductDescription/components/ImageViewList/index.tsx
View file @
94402b84
...
...
@@ -8,15 +8,10 @@ interface ImageViewListPropsType {
}
const
ImageViewList
:
React
.
FC
<
ImageViewListPropsType
>
=
(
props
)
=>
{
const
{
imgList
=
[]}
=
props
const
[
previewImage
,
setPreviewImage
]
=
useState
<
number
>
(
-
1
)
const
[
rotateZ
,
setRotateZ
]
=
useState
<
number
>
(
0
)
const
imgList
=
[
"https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1.jpg"
,
"https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-5.jpg"
,
"https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-3.jpg"
]
const
handlePreviewImg
=
(
index
:
number
)
=>
{
if
(
previewImage
!==
index
)
{
setPreviewImage
(
index
)
...
...
@@ -39,7 +34,7 @@ const ImageViewList: React.FC<ImageViewListPropsType> = (props) => {
setRotateZ
(
0
)
break
case
'preview'
:
le
t
el
=
document
.
createElement
(
'a'
)
cons
t
el
=
document
.
createElement
(
'a'
)
el
.
href
=
imgList
[
previewImage
];
el
.
target
=
'_blank'
;
el
.
click
()
...
...
src/pages/lxMall/commodityDetail/index.tsx
View file @
94402b84
...
...
@@ -31,12 +31,12 @@ const Logistics_Type = {
3
:
'无需配送'
}
interface
s
electAttrValType
{
interface
S
electAttrValType
{
attrId
:
number
;
attrValId
:
number
;
}
interface
i
mgItemType
{
interface
I
mgItemType
{
id
:
number
;
commodityPic
:
string
;
}
...
...
@@ -65,9 +65,9 @@ const CommodityDetail = (props) => {
const
[
attributeList
,
setAttributeList
]
=
useState
([])
const
[
commodityDetail
,
setCommodityDetail
]
=
useState
<
GetSearchShopStoreGetCommodityDetailResponse
&
GetSearchShopChannelGetCommodityDetailResponse
>
()
const
[
attrAndValList
,
setAttrAndValList
]
=
useState
<
any
>
({})
const
[
selectAttrVal
,
setSelectAttrVal
]
=
useState
<
s
electAttrValType
[]
>
([])
const
[
selectAttrVal
,
setSelectAttrVal
]
=
useState
<
S
electAttrValType
[]
>
([])
const
[
stockCount
,
setStockCount
]
=
useState
<
number
>
(
0
)
const
[
commodityImgList
,
setCommodityImgList
]
=
useState
<
i
mgItemType
[]
>
([])
const
[
commodityImgList
,
setCommodityImgList
]
=
useState
<
I
mgItemType
[]
>
([])
const
[
commodityPriceInfo
,
setCommodityPriceInfo
]
=
useState
([])
const
[
parameter
,
setParameter
]
=
useState
<
number
>
()
// 权益参数
const
[
selectCommodityId
,
setSelectCommodityId
]
=
useState
<
number
>
()
...
...
@@ -91,7 +91,7 @@ const CommodityDetail = (props) => {
* @param priceType
*/
const
fetchCommonCategoryCommodityList
=
(
categoryId
:
number
,
priceType
:
number
)
=>
{
le
t
param
:
any
=
{
cons
t
param
:
any
=
{
current
:
1
,
pageSize
:
10
,
categoryId
...
...
@@ -162,7 +162,7 @@ const CommodityDetail = (props) => {
*/
const
fetchDetail
=
()
=>
{
let
getDetailFn
le
t
params
:
any
=
{
cons
t
params
:
any
=
{
commodityId
:
id
}
let
headers
=
{}
...
...
@@ -217,8 +217,10 @@ const CommodityDetail = (props) => {
if
(
!
memberId
)
{
return
}
//@ts-ignore
PublicApi
.
getPayPayWayList
({
memberId
}).
then
(
res
=>
{
const
param
:
any
=
{
memberId
}
PublicApi
.
getPayPayWayList
(
param
).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
initPayWayList
(
res
.
data
)
}
...
...
@@ -234,7 +236,7 @@ const CommodityDetail = (props) => {
return
[]
}
let
result
=
[]
for
(
le
t
item
of
data
)
{
for
(
cons
t
item
of
data
)
{
if
(
result
.
some
(
tempItem
=>
tempItem
.
payType
===
item
.
payType
))
{
result
=
result
.
map
(
resItem
=>
{
if
(
resItem
.
payType
===
item
.
payType
)
{
...
...
@@ -274,7 +276,7 @@ const CommodityDetail = (props) => {
* @param memberRoleId
*/
const
getMemberCredit
=
(
memberId
,
memberRoleId
)
=>
{
le
t
param
=
{
cons
t
param
=
{
parentMemberId
:
memberId
,
parentMemberRoleId
:
memberRoleId
}
...
...
@@ -299,9 +301,9 @@ const CommodityDetail = (props) => {
const
getCommodityPriceRange
=
()
=>
{
if
(
commodityDetail
?.
unitPricePicList
)
{
for
(
le
t
item
of
commodityDetail
?.
unitPricePicList
)
{
for
(
cons
t
item
of
commodityDetail
?.
unitPricePicList
)
{
le
t
temp
=
item
.
attributeAndValueList
.
map
(
attrItem
=>
{
cons
t
temp
=
item
.
attributeAndValueList
.
map
(
attrItem
=>
{
return
{
attrId
:
attrItem
.
customerAttribute
.
id
,
attrValId
:
attrItem
.
customerAttributeValue
.
id
...
...
@@ -320,7 +322,7 @@ const CommodityDetail = (props) => {
const
judgeArrisCommon
=
(
list
,
otherList
)
=>
{
if
(
list
.
length
===
otherList
.
length
)
{
le
t
result
=
list
.
every
(
listItem
=>
{
cons
t
result
=
list
.
every
(
listItem
=>
{
return
otherList
.
some
(
item
=>
{
return
JSON
.
stringify
(
item
)
===
JSON
.
stringify
(
listItem
)
})
...
...
@@ -352,7 +354,7 @@ const CommodityDetail = (props) => {
if
(
clickFlag
)
{
clickFlag
=
false
le
t
param
:
any
=
{
cons
t
param
:
any
=
{
commodityUnitPriceId
:
selectCommodityId
,
count
:
buyCount
}
...
...
@@ -482,11 +484,10 @@ const CommodityDetail = (props) => {
if
(
clickFlag
)
{
clickFlag
=
false
//@ts-ignore
PublicApi
.
postOrderDirectPayment
({
productId
:
selectCommodityId
,
memberId
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
message
.
destroy
()
le
t
buyCommodityInfo
=
{
cons
t
buyCommodityInfo
=
{
id
:
selectCommodityId
,
count
:
buyCount
,
unitName
:
commodityDetail
.
unitName
,
...
...
@@ -503,9 +504,9 @@ const CommodityDetail = (props) => {
attribute
:
attrAndValList
.
attributeAndValueList
}
le
t
sessionKey
=
`
${
commodityDetail
.
id
}${
new
Date
().
getTime
()}
`
cons
t
sessionKey
=
`
${
commodityDetail
.
id
}${
new
Date
().
getTime
()}
`
le
t
buyOrderInfo
:
any
=
{
cons
t
buyOrderInfo
:
any
=
{
logistics
:
commodityDetail
.
logistics
,
payWayList
:
priceType
===
COMMODITY_TYPE
.
integral
?
integralPayWay
:
payWayList
,
supplyMembersName
:
commodityDetail
.
memberName
,
...
...
@@ -547,7 +548,7 @@ const CommodityDetail = (props) => {
})
const
JoinValue
=
values
.
reverse
().
join
(
'/'
);
le
t
inquiryParam
=
{
cons
t
inquiryParam
=
{
id
:
selectCommodityId
,
brand
:
commodityDetail
.
brand
,
logistics
:
commodityDetail
.
logistics
,
...
...
@@ -562,7 +563,7 @@ const CommodityDetail = (props) => {
category
:
commodityDetail
.
customerCategory
.
name
}
le
t
sessionKey
=
`inquiry
${
selectCommodityId
}${
new
Date
().
getTime
()}
`
cons
t
sessionKey
=
`inquiry
${
selectCommodityId
}${
new
Date
().
getTime
()}
`
updateOrderInfo
(
inquiryParam
,
sessionKey
).
then
(()
=>
{
window
.
location
.
href
=
`/memberCenter/tranactionAbility/goodsOffer/addEnquiryOrder/rfq?id=
${
id
}
&memberId=
${
memberId
}
&spam_id=
${
sessionKey
}
`
})
...
...
@@ -598,8 +599,8 @@ const CommodityDetail = (props) => {
* @param addList
*/
const
deleteRepeatImg
=
(
list
,
addList
)
=>
{
le
t
result
=
[...
list
]
for
(
le
t
addItem
of
addList
)
{
cons
t
result
=
[...
list
]
for
(
cons
t
addItem
of
addList
)
{
if
(
list
.
every
(
item
=>
item
.
commodityPic
!==
addItem
.
commodityPic
))
{
result
.
push
(
addItem
)
}
...
...
@@ -612,19 +613,19 @@ const CommodityDetail = (props) => {
* @param unitPricePicList
*/
const
initAttributeAndValueList
=
(
dataInfo
:
any
)
=>
{
le
t
unitPricePicList
=
dataInfo
?.
unitPricePicList
cons
t
unitPricePicList
=
dataInfo
?.
unitPricePicList
if
(
!
unitPricePicList
)
{
return
}
le
t
tempAttrList
=
[]
cons
t
tempAttrList
=
[]
let
tempImgList
:
any
=
[{
id
:
dataInfo
.
id
,
commodityPic
:
dataInfo
.
mainPic
}]
for
(
le
t
item
of
unitPricePicList
)
{
for
(
cons
t
item
of
unitPricePicList
)
{
// 初始化商品图片-》 商品主图加上商品属性图片
if
(
item
.
commodityPic
)
{
le
t
tempCommodityPic
=
item
.
commodityPic
.
map
((
picItem
,
picIndex
)
=>
{
cons
t
tempCommodityPic
=
item
.
commodityPic
.
map
((
picItem
,
picIndex
)
=>
{
return
{
id
:
`
${
item
.
id
}
-
${
picIndex
}
`
,
commodityPic
:
picItem
...
...
@@ -633,7 +634,7 @@ const CommodityDetail = (props) => {
tempImgList
=
deleteRepeatImg
(
tempImgList
,
tempCommodityPic
)
}
for
(
le
t
attrListItem
of
item
.
attributeAndValueList
)
{
for
(
cons
t
attrListItem
of
item
.
attributeAndValueList
)
{
if
(
judgeAttrInList
(
tempAttrList
,
attrListItem
.
customerAttribute
.
id
))
{
let
tempAttrListIndex
=
0
tempAttrList
.
map
((
item
,
index
)
=>
{
...
...
@@ -648,7 +649,7 @@ const CommodityDetail = (props) => {
tempAttrList
[
tempAttrListIndex
].
customerAttributeValueList
=
[...
tempAttrList
[
tempAttrListIndex
].
customerAttributeValueList
,
attrListItem
.
customerAttributeValue
]
}
}
else
{
le
t
temp
:
any
=
{}
cons
t
temp
:
any
=
{}
temp
.
id
=
attrListItem
.
id
temp
.
customerAttribute
=
attrListItem
.
customerAttribute
...
...
@@ -674,7 +675,7 @@ const CommodityDetail = (props) => {
return
}
let
total
=
0
for
(
le
t
item
of
unitPricePicList
)
{
for
(
cons
t
item
of
unitPricePicList
)
{
total
+=
item
.
stockCount
}
setStockCount
(
total
)
...
...
@@ -691,7 +692,7 @@ const CommodityDetail = (props) => {
if
(
Object
.
keys
(
priceObj
).
length
<=
1
)
{
return
priceObj
}
le
t
tempList
=
[]
cons
t
tempList
=
[]
Object
.
keys
(
priceObj
).
forEach
(
key
=>
{
tempList
.
push
({
key
,
...
...
@@ -700,13 +701,13 @@ const CommodityDetail = (props) => {
})
for
(
let
i
=
0
;
i
<
tempList
.
length
;
i
++
)
{
if
(
tempList
[
i
+
1
]
&&
tempList
[
i
].
value
<
tempList
[
i
+
1
].
value
)
{
le
t
temp
=
tempList
[
i
]
cons
t
temp
=
tempList
[
i
]
tempList
[
i
]
=
tempList
[
i
+
1
]
tempList
[
i
+
1
]
=
temp
}
}
le
t
result
=
{}
for
(
le
t
tempItem
of
tempList
)
{
cons
t
result
=
{}
for
(
cons
t
tempItem
of
tempList
)
{
result
[
tempItem
.
key
]
=
tempItem
.
value
}
return
result
...
...
@@ -717,12 +718,12 @@ const CommodityDetail = (props) => {
* @param uniPrice
*/
const
setCurrentPriceRange
=
(
uniPrice
)
=>
{
le
t
initPriceRange
=
uniPrice
le
t
tempPriceRange
=
[]
cons
t
initPriceRange
=
uniPrice
cons
t
tempPriceRange
=
[]
Object
.
keys
(
initPriceRange
).
forEach
((
key
)
=>
{
le
t
keyArr
=
key
.
split
(
'-'
)
le
t
min
=
keyArr
[
0
]
le
t
max
=
keyArr
[
1
]
cons
t
keyArr
=
key
.
split
(
'-'
)
cons
t
min
=
keyArr
[
0
]
cons
t
max
=
keyArr
[
1
]
tempPriceRange
.
push
({
range
:
key
,
min
,
...
...
@@ -755,13 +756,13 @@ const CommodityDetail = (props) => {
// return
// }
if
(
judgeSelectAttrInList
(
selectAttrVal
,
attrId
,
'attrId'
))
{
le
t
result
=
[]
for
(
le
t
item
of
selectAttrVal
)
{
cons
t
result
=
[]
for
(
cons
t
item
of
selectAttrVal
)
{
if
(
item
.
attrId
===
attrId
&&
item
.
attrValId
!==
attrValId
)
{
item
.
attrValId
=
attrValId
result
.
push
(
item
)
}
else
if
(
item
.
attrId
===
attrId
&&
item
.
attrValId
===
attrValId
)
{
console
.
log
(
''
)
}
else
{
result
.
push
(
item
)
}
...
...
@@ -784,11 +785,11 @@ const CommodityDetail = (props) => {
if
(
commodityPriceInfo
.
length
<=
1
)
{
unitPrice
=
commodityPriceInfo
[
0
]?.
price
}
else
{
le
t
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
cons
t
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<=
Number
(
item
.
max
)
})
if
(
isEmpty
(
temp
))
{
le
t
maxItem
=
getMaxCountRange
()
cons
t
maxItem
=
getMaxCountRange
()
unitPrice
=
maxItem
.
price
}
else
{
unitPrice
=
temp
[
0
]?.
price
...
...
@@ -807,8 +808,8 @@ const CommodityDetail = (props) => {
* 获取合计金额
*/
const
getAmount
=
(
state
=
true
)
=>
{
le
t
unitPrice
=
getUnitPrice
()
le
t
amount
=
unitPrice
*
(
Number
(
buyCount
)
||
0
)
cons
t
unitPrice
=
getUnitPrice
()
cons
t
amount
=
unitPrice
*
(
Number
(
buyCount
)
||
0
)
return
state
?
priceFormat
(
amount
)
:
amount
}
...
...
@@ -817,7 +818,7 @@ const CommodityDetail = (props) => {
*/
const
getMaxCountRange
=
()
=>
{
let
maxItem
:
any
=
{}
for
(
le
t
item
of
commodityPriceInfo
)
{
for
(
cons
t
item
of
commodityPriceInfo
)
{
if
(
Number
(
item
.
max
)
>
Number
(
maxItem
.
max
||
0
))
{
maxItem
=
item
}
...
...
@@ -830,13 +831,13 @@ const CommodityDetail = (props) => {
*/
const
judgeHasAttr
=
(
attrId
:
number
,
attrValId
:
number
)
=>
{
let
result
=
true
le
t
newSelectAttrVal
=
JSON
.
parse
(
JSON
.
stringify
(
selectAttrVal
))
cons
t
newSelectAttrVal
=
JSON
.
parse
(
JSON
.
stringify
(
selectAttrVal
))
if
(
selectAttrVal
.
length
>
0
)
{
// newSelectAttrVal.pop()
if
(
commodityDetail
?.
unitPricePicList
)
{
le
t
tempList
=
[]
for
(
le
t
item
of
commodityDetail
?.
unitPricePicList
)
{
le
t
temp
=
item
.
attributeAndValueList
.
map
(
attrItem
=>
{
cons
t
tempList
=
[]
for
(
cons
t
item
of
commodityDetail
?.
unitPricePicList
)
{
cons
t
temp
=
item
.
attributeAndValueList
.
map
(
attrItem
=>
{
return
{
attrId
:
attrItem
.
customerAttribute
.
id
,
attrValId
:
attrItem
.
customerAttributeValue
.
id
...
...
@@ -859,8 +860,8 @@ const CommodityDetail = (props) => {
* 判断选的的数组是有在商品属性数组中
*/
const
judegeListInList
=
(
mainList
,
subList
)
=>
{
le
t
result
=
subList
.
every
(
listItem
=>
{
le
t
subRes
=
mainList
.
some
(
item
=>
{
cons
t
result
=
subList
.
every
(
listItem
=>
{
cons
t
subRes
=
mainList
.
some
(
item
=>
{
return
JSON
.
stringify
(
item
)
===
JSON
.
stringify
(
listItem
)
})
return
subRes
...
...
src/pages/lxMall/purchaseOrder/index.tsx
View file @
94402b84
...
...
@@ -48,7 +48,11 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
},
[
categoryIds
])
const
fetchPurchaseList
=
(
initState
=
false
)
=>
{
/**
* 获取进货单数据
* @param initState
*/
const
fetchPurchaseList
=
()
=>
{
let
getFn
switch
(
layoutType
)
{
case
LAYOUT_TYPE
.
channel
:
...
...
@@ -62,7 +66,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
getFn
&&
getFn
().
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
initPurchaseList
(
res
.
data
,
initState
)
initPurchaseList
(
res
.
data
)
getCategoryIds
(
res
.
data
)
}
})
...
...
@@ -73,9 +77,9 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
* @param purchaseList
*/
const
getCategoryIds
=
(
purchaseList
)
=>
{
le
t
ids
=
[]
for
(
le
t
item
of
purchaseList
)
{
le
t
categoryId
=
item
.
commodityUnitPrice
.
commodity
.
customerCategory
.
id
cons
t
ids
=
[]
for
(
cons
t
item
of
purchaseList
)
{
cons
t
categoryId
=
item
.
commodityUnitPrice
.
commodity
.
customerCategory
.
id
if
(
!
ids
.
includes
(
categoryId
))
{
ids
.
push
(
categoryId
)
}
...
...
@@ -83,54 +87,71 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
setCategoryIds
(
ids
)
}
const
initPurchaseList
=
(
list
:
GetSearchShopPurchaseGetPurchaseListResponse
,
initState
)
=>
{
/**
* 初始化进货单数据
* @param list
* @param initState
*/
const
initPurchaseList
=
async
(
list
:
GetSearchShopPurchaseGetPurchaseListResponse
)
=>
{
let
result
=
[]
for
(
le
t
item
of
list
)
{
for
(
cons
t
item
of
list
)
{
// 判断店铺id是否已存在数组中
if
(
result
.
some
(
resItem
=>
resItem
.
id
===
item
.
commodityUnitPrice
.
commodity
.
storeId
))
{
result
=
result
.
map
(
tempItem
=>
{
const
tempResult
=
[]
for
(
const
tempItem
of
result
)
{
if
(
tempItem
.
id
===
item
.
commodityUnitPrice
.
commodity
.
storeId
)
{
let
tempPriceRange
=
[]
let
unitPrice
=
item
.
commodityUnitPrice
.
unitPrice
const
tempPriceRange
=
[]
const
unitPrice
=
item
.
commodityUnitPrice
.
unitPrice
let
parameter
:
any
=
1
const
isMemberPrice
=
item
.
commodityUnitPrice
.
commodity
.
isMemberPrice
// 如果可以使用会员折扣
if
(
isMemberPrice
)
{
parameter
=
await
getMemberCredit
(
item
.
commodityUnitPrice
.
commodity
.
memberId
,
item
.
commodityUnitPrice
.
commodity
.
memberRoleId
)
}
Object
.
keys
(
unitPrice
).
forEach
(
key
=>
{
le
t
keyArr
=
key
.
split
(
'-'
)
le
t
min
=
keyArr
[
0
]
le
t
max
=
keyArr
[
1
]
cons
t
keyArr
=
key
.
split
(
'-'
)
cons
t
min
=
keyArr
[
0
]
cons
t
max
=
keyArr
[
1
]
tempPriceRange
.
push
({
range
:
key
,
min
,
max
,
price
:
unitPrice
[
key
]
price
:
isMemberPrice
?
Number
(
unitPrice
[
key
])
*
Number
(
parameter
)
:
unitPrice
[
key
]
})
})
// TODO 暂时给个库存数量
item
.
stockCount
=
item
.
stockCount
item
.
commodityUnitPrice
[
'priceRange'
]
=
tempPriceRange
tempItem
.
orderList
=
[...
tempItem
.
orderList
,
item
]
tempResult
.
push
(
tempItem
)
}
return
tempItem
})
}
result
=
tempResult
}
else
{
le
t
temp
:
any
=
{}
cons
t
temp
:
any
=
{}
temp
.
id
=
item
.
commodityUnitPrice
.
commodity
.
storeId
temp
.
memberId
=
item
.
commodityUnitPrice
.
commodity
.
memberId
temp
.
memberRoleId
=
item
.
commodityUnitPrice
.
commodity
.
memberRoleId
temp
.
shopname
=
item
.
commodityUnitPrice
.
commodity
.
memberName
let
tempPriceRange
=
[]
let
unitPrice
=
item
.
commodityUnitPrice
.
unitPrice
const
tempPriceRange
=
[]
const
unitPrice
=
item
.
commodityUnitPrice
.
unitPrice
let
parameter
:
any
=
1
const
isMemberPrice
=
item
.
commodityUnitPrice
.
commodity
.
isMemberPrice
// 如果可以使用会员折扣
if
(
isMemberPrice
)
{
parameter
=
await
getMemberCredit
(
item
.
commodityUnitPrice
.
commodity
.
memberId
,
item
.
commodityUnitPrice
.
commodity
.
memberRoleId
)
}
Object
.
keys
(
unitPrice
).
forEach
(
key
=>
{
le
t
keyArr
=
key
.
split
(
'-'
)
le
t
min
=
keyArr
[
0
]
le
t
max
=
keyArr
[
1
]
cons
t
keyArr
=
key
.
split
(
'-'
)
cons
t
min
=
keyArr
[
0
]
cons
t
max
=
keyArr
[
1
]
tempPriceRange
.
push
({
range
:
key
,
min
,
max
,
price
:
unitPrice
[
key
]
price
:
isMemberPrice
?
Number
(
unitPrice
[
key
])
*
Number
(
parameter
)
:
unitPrice
[
key
]
})
})
item
.
stockCount
=
item
.
stockCount
item
.
commodityUnitPrice
[
'priceRange'
]
=
tempPriceRange
temp
.
orderList
=
[
item
]
result
.
push
(
temp
)
...
...
@@ -140,7 +161,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
const
initData
=
(
list
:
any
,
initChecked
?:
any
)
=>
{
le
t
result
=
list
.
map
(
item
=>
{
cons
t
result
=
list
.
map
(
item
=>
{
return
Object
.
assign
(
item
,
{
checkedList
:
initChecked
?
initChecked
:
item
.
orderList
.
map
(
item
=>
item
.
id
),
defaultCheckedList
:
item
.
orderList
.
map
(
item
=>
item
.
id
)
...
...
@@ -167,10 +188,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const
handleChildGroupChange
=
(
list
,
id
:
number
)
=>
{
let
flag
=
false
le
t
result
=
orderList
.
map
(
item
=>
{
cons
t
result
=
orderList
.
map
(
item
=>
{
if
(
item
.
id
===
id
)
{
if
(
list
.
length
===
item
.
defaultCheckedList
.
length
)
{
le
t
temp
=
[...
checkedList
,
id
]
cons
t
temp
=
[...
checkedList
,
id
]
setCheckedList
(
temp
)
if
(
temp
.
length
===
getAllKeys
().
length
)
{
setIndeterminate
(
false
)
...
...
@@ -190,7 +211,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
if
(
list
.
length
===
0
)
{
le
t
index
=
checkedList
.
indexOf
(
id
)
cons
t
index
=
checkedList
.
indexOf
(
id
)
checkedList
.
splice
(
index
,
1
)
setCheckedList
(
checkedList
)
}
...
...
@@ -201,7 +222,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
const
onCheckChildAllChange
=
(
e
:
any
,
id
:
number
)
=>
{
le
t
result
=
orderList
.
map
((
item
:
any
)
=>
{
cons
t
result
=
orderList
.
map
((
item
:
any
)
=>
{
if
(
item
.
id
===
id
)
{
return
e
.
target
.
checked
?
Object
.
assign
(
item
,
{
checkedList
:
item
.
defaultCheckedList
})
:
Object
.
assign
(
item
,
{
checkedList
:
[]
})
}
else
{
...
...
@@ -216,41 +237,48 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
* @param count
* @param id
*/
const
handleCountChange
=
(
count
:
number
,
id
:
number
)
=>
{
if
(
countState
)
{
countState
=
false
let
param
:
any
=
{
id
,
count
}
let
postFn
switch
(
layoutType
)
{
case
LAYOUT_TYPE
.
channel
:
case
LAYOUT_TYPE
.
ichannel
:
param
.
commodityType
=
2
postFn
=
PublicApi
.
postSearchShopPurchaseChannelSaveOrUpdatePurchase
break
default
:
postFn
=
PublicApi
.
postSearchShopPurchaseSaveOrUpdatePurchase
break
;
}
const
handleCountChange
=
(
count
:
number
,
id
:
number
,
type
:
string
)
=>
{
handleChangeFinishCount
(
count
,
id
)
if
(
type
===
'click'
||
type
===
'blur'
)
{
if
(
countState
)
{
countState
=
false
const
param
:
any
=
{
id
,
count
:
Number
(
count
)
}
postFn
&&
postFn
(
param
).
then
(
res
=>
{
countState
=
true
if
(
res
.
code
===
1000
)
{
message
.
destroy
()
// fetchPurchaseList()
handleChangeFinishCount
(
count
,
id
)
let
postFn
switch
(
layoutType
)
{
case
LAYOUT_TYPE
.
channel
:
case
LAYOUT_TYPE
.
ichannel
:
param
.
commodityType
=
2
postFn
=
PublicApi
.
postSearchShopPurchaseChannelSaveOrUpdatePurchase
break
default
:
postFn
=
PublicApi
.
postSearchShopPurchaseSaveOrUpdatePurchase
break
;
}
}).
catch
(()
=>
{
countState
=
true
})
postFn
&&
postFn
(
param
).
then
(
res
=>
{
countState
=
true
if
(
res
.
code
===
1000
)
{
message
.
destroy
()
}
}).
catch
(()
=>
{
countState
=
true
})
}
}
}
const
handleBlur
=
(
count
:
number
,
id
:
number
)
=>
{
console
.
log
(
countState
,
count
,
"handleBlur"
)
}
const
handleChangeFinishCount
=
(
count
,
id
)
=>
{
le
t
result
=
orderList
.
map
(
item
=>
{
cons
t
result
=
orderList
.
map
(
item
=>
{
item
.
orderList
=
item
.
orderList
.
map
(
childItem
=>
{
if
(
childItem
.
id
===
id
)
{
childItem
.
count
=
count
...
...
@@ -273,7 +301,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return
parseFloat
(
priceRange
[
0
].
price
)
*
count
}
else
{
let
priceItem
:
any
=
{}
for
(
le
t
item
of
priceRange
)
{
for
(
cons
t
item
of
priceRange
)
{
if
(
Number
(
item
.
min
)
<=
count
&&
count
<=
Number
(
item
.
max
))
{
priceItem
=
item
}
...
...
@@ -330,7 +358,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const
handleBatchDelete
=
()
=>
{
let
idList
=
[]
for
(
le
t
item
of
orderList
)
{
for
(
cons
t
item
of
orderList
)
{
idList
=
[...
idList
,
...
item
.
checkedList
]
}
if
(
idList
.
length
<=
0
)
{
...
...
@@ -364,10 +392,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
* @param ids
*/
const
deleteListItems
=
(
ids
:
number
[])
=>
{
le
t
newOrderList
=
JSON
.
parse
(
JSON
.
stringify
(
orderList
))
le
t
result
=
[]
for
(
le
t
item
of
newOrderList
)
{
le
t
newItem
=
item
cons
t
newOrderList
=
JSON
.
parse
(
JSON
.
stringify
(
orderList
))
cons
t
result
=
[]
for
(
cons
t
item
of
newOrderList
)
{
cons
t
newItem
=
item
newItem
.
orderList
=
newItem
.
orderList
.
filter
(
orderItem
=>
!
ids
.
includes
(
orderItem
.
id
))
if
(
newItem
.
orderList
.
length
>
0
)
{
result
.
push
(
newItem
)
...
...
@@ -381,8 +409,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const
handleComputeSelectCount
=
()
=>
{
let
count
=
0
for
(
le
t
item
of
orderList
)
{
for
(
le
t
orderItem
of
item
.
orderList
)
{
for
(
cons
t
item
of
orderList
)
{
for
(
cons
t
orderItem
of
item
.
orderList
)
{
if
(
item
.
checkedList
.
includes
(
orderItem
.
id
))
{
count
+=
orderItem
.
count
}
...
...
@@ -397,10 +425,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const
handleComputeSelectPrice
=
()
=>
{
let
price
=
0
for
(
le
t
item
of
orderList
)
{
for
(
le
t
orderItem
of
item
.
orderList
)
{
for
(
cons
t
item
of
orderList
)
{
for
(
cons
t
orderItem
of
item
.
orderList
)
{
if
(
item
.
checkedList
.
includes
(
orderItem
.
id
))
{
le
t
commodityPrice
=
computeItemPrice
(
orderItem
.
commodityUnitPrice
.
priceRange
,
orderItem
.
count
)
cons
t
commodityPrice
=
computeItemPrice
(
orderItem
.
commodityUnitPrice
.
priceRange
,
orderItem
.
count
)
price
+=
commodityPrice
}
}
...
...
@@ -415,7 +443,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const
getMemberCredit
=
(
memberId
,
memberRoleId
)
=>
{
return
new
Promise
((
resolve
)
=>
{
le
t
param
=
{
cons
t
param
=
{
parentMemberId
:
memberId
,
parentMemberRoleId
:
memberRoleId
}
...
...
@@ -433,8 +461,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
resolve
([])
return
}
//@ts-ignore
PublicApi
.
getPayPayWayList
({
memberId
}).
then
(
res
=>
{
const
param
:
any
=
{
memberId
}
PublicApi
.
getPayPayWayList
(
param
).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
resolve
(
initPayWayList
(
res
.
data
))
}
...
...
@@ -447,7 +477,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return
[]
}
let
result
=
[]
for
(
le
t
item
of
data
)
{
for
(
cons
t
item
of
data
)
{
if
(
result
.
some
(
tempItem
=>
tempItem
.
payType
===
item
.
payType
))
{
result
=
result
.
map
(
resItem
=>
{
if
(
resItem
.
payType
===
item
.
payType
)
{
...
...
@@ -495,18 +525,18 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const
selectList
=
orderList
.
filter
(
item
=>
item
.
checkedList
.
length
>
0
)
const
selectItem
=
selectList
[
0
]
le
t
productIds
=
[]
le
t
buyOrderlist
=
[]
cons
t
productIds
=
[]
cons
t
buyOrderlist
=
[]
const
selectOrderList
=
selectItem
.
orderList
.
filter
(
item
=>
selectItem
.
checkedList
.
includes
(
item
.
id
))
let
commonLogistics
=
{}
setConfirmLoading
(
true
)
le
t
purchaseIds
=
[]
for
(
le
t
item
of
selectOrderList
)
{
cons
t
purchaseIds
=
[]
for
(
cons
t
item
of
selectOrderList
)
{
purchaseIds
.
push
(
item
.
id
)
productIds
.
push
(
item
.
commodityUnitPrice
.
id
)
commonLogistics
=
item
.
commodityUnitPrice
.
commodity
.
logistics
le
t
buyCommodityInfo
:
any
=
{
cons
t
buyCommodityInfo
:
any
=
{
id
:
item
.
commodityUnitPrice
.
id
,
purchaseId
:
item
.
id
,
count
:
item
.
count
,
...
...
@@ -529,7 +559,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
buyOrderlist
.
push
(
buyCommodityInfo
)
}
le
t
buyOrderInfo
:
any
=
{
cons
t
buyOrderInfo
:
any
=
{
purchaseOrder
:
true
,
// 是否进货单下单
idList
:
purchaseIds
,
productType
:
(
layoutType
===
LAYOUT_TYPE
.
channel
||
layoutType
===
LAYOUT_TYPE
.
ichannel
)
?
2
:
1
,
...
...
@@ -546,7 +576,6 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
buyOrderInfo
.
payWayList
=
await
getPayWayListByMemberId
(
selectItem
.
memberId
)
//@ts-ignore
PublicApi
.
postOrderIsWorkFlow
({
productIds
,
memberId
:
selectItem
.
memberId
}).
then
(
res
=>
{
setConfirmLoading
(
false
)
if
(
res
.
code
===
1000
)
{
...
...
@@ -554,7 +583,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
PublicApi
.
postOrderDirectPayment
({
productId
:
productIds
[
0
],
memberId
:
selectItem
.
memberId
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
message
.
destroy
()
le
t
sessionKey
=
`
${
selectItem
.
id
}${
new
Date
().
getTime
()}
`
cons
t
sessionKey
=
`
${
selectItem
.
id
}${
new
Date
().
getTime
()}
`
updateOrderInfo
(
buyOrderInfo
,
sessionKey
).
then
(()
=>
{
if
(
res
.
data
)
{
...
...
@@ -591,11 +620,11 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
if
(
detail
.
priceRange
.
length
<=
1
)
{
unitPrice
=
detail
.
priceRange
[
0
]?.
price
}
else
{
le
t
temp
=
detail
.
priceRange
.
filter
(
item
=>
{
cons
t
temp
=
detail
.
priceRange
.
filter
(
item
=>
{
return
Number
(
count
)
>=
Number
(
item
.
min
)
&&
Number
(
count
)
<=
Number
(
item
.
max
)
})
if
(
isEmpty
(
temp
))
{
le
t
maxItem
=
getMaxCountRange
(
detail
.
priceRange
)
cons
t
maxItem
=
getMaxCountRange
(
detail
.
priceRange
)
unitPrice
=
maxItem
.
price
}
else
{
unitPrice
=
temp
[
0
]?.
price
...
...
@@ -607,7 +636,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const
getMaxCountRange
=
(
priceRange
)
=>
{
let
maxItem
:
any
=
{}
for
(
le
t
item
of
priceRange
)
{
for
(
cons
t
item
of
priceRange
)
{
if
(
Number
(
item
.
max
)
>
Number
(
maxItem
.
max
||
0
))
{
maxItem
=
item
}
...
...
@@ -647,7 +676,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const
handleCollect
=
(
commodityId
:
number
)
=>
{
le
t
param
:
any
=
{
cons
t
param
:
any
=
{
commodityId
:
commodityId
,
type
:
getLayoutType
()
}
...
...
@@ -736,7 +765,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
</
div
>
<
div
className=
{
cx
(
styles
.
order_list_item_item
,
styles
.
count
)
}
>
<
InputNumber
max=
{
childItem
.
stockCount
||
0
}
disabled=
{
childItem
.
stockCount
===
0
}
min=
{
childItem
.
commodityUnitPrice
.
commodity
.
minOrder
||
1
}
value=
{
childItem
.
count
}
onChange=
{
(
value
)
=>
handleCountChange
(
value
,
childItem
.
id
)
}
/>
<
InputNumber
max=
{
childItem
.
stockCount
||
0
}
disabled=
{
childItem
.
stockCount
===
0
}
min=
{
childItem
.
commodityUnitPrice
.
commodity
.
minOrder
||
1
}
value=
{
childItem
.
count
}
onChange=
{
(
value
,
type
)
=>
handleCountChange
(
value
,
childItem
.
id
,
type
)
}
/>
<
div
className=
{
styles
.
stock
}
>
<
span
>
(库存
{
numFormat
(
childItem
.
stockCount
)
}{
childItem
.
commodityUnitPrice
.
commodity
.
unitName
}
)
</
span
>
</
div
>
...
...
@@ -797,3 +826,4 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
export
default
observer
(
PurchaseOrder
)
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