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
shenshaokai
jinfa-platform
Commits
09899393
Commit
09899393
authored
Dec 11, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:处理订单详情无法获取支付方式
parent
483bdb21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
104 deletions
+103
-104
useOrderDetail.tsx
...ages/transaction/_public/order/effects/useOrderDetail.tsx
+103
-104
No files found.
src/pages/transaction/_public/order/effects/useOrderDetail.tsx
View file @
09899393
import
React
,
{
useRef
}
from
'react'
import
{
useCallback
,
useState
,
useEffect
}
from
'react'
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
import
{
PublicApi
}
from
'@/services/api'
import
{
Link
}
from
'umi'
import
{
GlobalConfig
}
from
'@/global/config'
import
{
orderTypeLabel
}
from
'../constant'
import
{
formatTimeString
}
from
'@/utils'
import
StatusColors
from
'../../../components/StatusColors'
import
{
message
}
from
'antd'
interface
OrderDetailHookProps
{
// 采购、销售
type
:
'purchaseOrder'
|
'saleOrder'
}
// 订单详情, 支持两种订单模式
export
const
useOrderDetail
=
(
options
:
OrderDetailHookProps
)
=>
{
// 订单详情内容
const
[
formData
,
setFormData
]
=
useState
<
any
>
(
null
)
// 当前的支付信息id 默认第一个
const
[
currentPayInfoId
,
setCurrentPayInfoId
]
=
useState
<
any
>
(
null
)
// 支付信息列表
const
[
payList
,
setPaylist
]
=
useState
<
any
[]
>
([])
const
{
id
}
=
usePageStatus
()
const
{
type
}
=
options
const
dataRef
=
useRef
<
any
>
([
{
label
:
'对应报价单号'
,
name
:
'quotationNo'
,
span
:
8
,
render
:
text
=>
<
Link
to=
{
'/'
}
>
{
text
}
</
Link
>
},
{
label
:
'订单摘要'
,
name
:
'orderThe'
,
span
:
8
},
{
label
:
type
===
'saleOrder'
?
'采购会员'
:
'供应会员'
,
name
:
type
===
'saleOrder'
?
'createMemberName'
:
'supplyMembersName'
,
span
:
8
},
{
label
:
'下单模式'
,
name
:
'orderModel'
,
span
:
8
,
render
:
text
=>
GlobalConfig
.
web
.
orderMode
.
find
(
v
=>
v
.
value
===
text
)?.
label
||
''
},
{
label
:
'订单类型'
,
name
:
'type'
,
span
:
8
,
render
:
text
=>
orderTypeLabel
[
text
]
},
{
label
:
'下单时间'
,
name
:
'createTime'
,
span
:
8
,
render
:
text
=>
formatTimeString
(
text
)
},
{
label
:
'外部状态'
,
name
:
'externalState'
,
span
:
8
,
render
:
text
=>
<
StatusColors
type=
'out'
status=
{
text
}
/>
},
{
label
:
'内部状态'
,
name
:
type
===
'saleOrder'
?
'purchaseOrderInteriorState'
:
'interiorState'
,
span
:
8
,
render
:
text
=>
<
StatusColors
type=
{
type
===
'saleOrder'
?
'saleInside'
:
'inside'
}
status=
{
text
}
/>
},
])
useEffect
(()
=>
{
reloadFormData
()
// reloadPayList()
},
[])
const
reloadFormData
=
useCallback
(()
=>
{
if
(
id
)
{
const
fn
=
type
===
'purchaseOrder'
?
PublicApi
.
getOrderProcurementOrderDetails
:
PublicApi
.
getOrderPurchaseOrderDetails
fn
({
id
},
{
ctlType
:
"none"
}).
then
(
res
=>
{
const
{
code
,
data
,
message
:
msg
}
=
res
if
(
code
===
1000
)
{
setFormData
(
data
)
if
(
data
.
paymentInformationResponses
.
length
>
0
){
setCurrentPayInfoId
(
data
.
paymentInformationResponses
[
0
].
id
)
}
reloadPayList
(
data
.
supplyMembersId
)
}
else
{
message
.
error
(
msg
)
}
})
}
},
[
id
])
const
reloadPayList
=
(
memberId
)
=>
{
PublicApi
.
getPayPayWayList
({
memberId
}).
then
(
res
=>
{
const
{
code
,
data
}
=
res
if
(
code
===
1000
)
{
setPaylist
(
data
)
}
else
{
message
.
error
(
res
.
message
)
}
})
}
// const reloadPayList = useCallback(() => {
// PublicApi.getPayPayWayList().then(res => {
// const { code, data } = res
// if (code === 1000) {
// setPaylist(data)
// }
// })
// }, [id])
// 需共享的状态
const
formContext
=
{
data
:
formData
,
currentPayInfoId
,
payList
,
ctl
:
{
setData
:
setFormData
,
setPayId
:
setCurrentPayInfoId
,
},
reloadFormData
}
return
{
formContext
,
id
,
detailList
:
dataRef
.
current
}
}
\ No newline at end of file
import
React
,
{
useRef
}
from
'react'
import
{
useCallback
,
useState
,
useEffect
}
from
'react'
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
import
{
PublicApi
}
from
'@/services/api'
import
{
Link
}
from
'umi'
import
{
GlobalConfig
}
from
'@/global/config'
import
{
orderTypeLabel
}
from
'../constant'
import
{
formatTimeString
}
from
'@/utils'
import
StatusColors
from
'../../../components/StatusColors'
import
{
message
}
from
'antd'
interface
OrderDetailHookProps
{
// 采购、销售
type
:
'purchaseOrder'
|
'saleOrder'
}
// 订单详情, 支持两种订单模式
export
const
useOrderDetail
=
(
options
:
OrderDetailHookProps
)
=>
{
// 订单详情内容
const
[
formData
,
setFormData
]
=
useState
<
any
>
(
null
)
// 当前的支付信息id 默认第一个
const
[
currentPayInfoId
,
setCurrentPayInfoId
]
=
useState
<
any
>
(
null
)
// 支付信息列表
const
[
payList
,
setPaylist
]
=
useState
<
any
[]
>
([])
const
{
id
}
=
usePageStatus
()
const
{
type
}
=
options
const
dataRef
=
useRef
<
any
>
([
{
label
:
'对应报价单号'
,
name
:
'quotationNo'
,
span
:
8
,
render
:
text
=>
<
Link
to=
{
'/'
}
>
{
text
}
</
Link
>
},
{
label
:
'订单摘要'
,
name
:
'orderThe'
,
span
:
8
},
{
label
:
type
===
'saleOrder'
?
'采购会员'
:
'供应会员'
,
name
:
type
===
'saleOrder'
?
'createMemberName'
:
'supplyMembersName'
,
span
:
8
},
{
label
:
'下单模式'
,
name
:
'orderModel'
,
span
:
8
,
render
:
text
=>
GlobalConfig
.
web
.
orderMode
.
find
(
v
=>
v
.
value
===
text
)?.
label
||
''
},
{
label
:
'订单类型'
,
name
:
'type'
,
span
:
8
,
render
:
text
=>
orderTypeLabel
[
text
]
},
{
label
:
'下单时间'
,
name
:
'createTime'
,
span
:
8
,
render
:
text
=>
formatTimeString
(
text
)
},
{
label
:
'外部状态'
,
name
:
'externalState'
,
span
:
8
,
render
:
text
=>
<
StatusColors
type=
'out'
status=
{
text
}
/>
},
{
label
:
'内部状态'
,
name
:
type
===
'saleOrder'
?
'purchaseOrderInteriorState'
:
'interiorState'
,
span
:
8
,
render
:
text
=>
<
StatusColors
type=
{
type
===
'saleOrder'
?
'saleInside'
:
'inside'
}
status=
{
text
}
/>
},
])
useEffect
(()
=>
{
reloadFormData
()
// reloadPayList()
},
[])
const
reloadFormData
=
useCallback
(()
=>
{
if
(
id
)
{
const
fn
=
type
===
'purchaseOrder'
?
PublicApi
.
getOrderProcurementOrderDetails
:
PublicApi
.
getOrderPurchaseOrderDetails
fn
({
id
},
{
ctlType
:
"none"
}).
then
(
res
=>
{
const
{
code
,
data
,
message
:
msg
}
=
res
if
(
code
===
1000
)
{
setFormData
(
data
)
if
(
data
.
paymentInformationResponses
.
length
>
0
){
setCurrentPayInfoId
(
data
.
paymentInformationResponses
[
0
].
id
)
}
reloadPayList
(
data
.
supplyMembersId
,
data
.
supplyMembersRoleId
)
}
else
{
message
.
error
(
msg
)
}
})
}
},
[
id
])
const
reloadPayList
=
(
memberId
,
memberRoleId
)
=>
{
PublicApi
.
getPayPayWayList
({
memberId
,
memberRoleId
}).
then
(
res
=>
{
const
{
code
,
data
}
=
res
if
(
code
===
1000
)
{
setPaylist
(
data
)
}
else
{
message
.
error
(
res
.
message
)
}
})
}
// const reloadPayList = useCallback(() => {
// PublicApi.getPayPayWayList().then(res => {
// const { code, data } = res
// if (code === 1000) {
// setPaylist(data)
// }
// })
// }, [id])
// 需共享的状态
const
formContext
=
{
data
:
formData
,
currentPayInfoId
,
payList
,
ctl
:
{
setData
:
setFormData
,
setPayId
:
setCurrentPayInfoId
,
},
reloadFormData
}
return
{
formContext
,
id
,
detailList
:
dataRef
.
current
}
}
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