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
a5cf0678
Commit
a5cf0678
authored
Nov 20, 2020
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物流方式从商品中获取
parent
3061edce
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
11 deletions
+91
-11
useBusinessEffects.ts
.../bills/components/BillsForm/effects/useBusinessEffects.ts
+71
-3
index.tsx
...ion/stockSellStorage/bills/components/BillsForm/index.tsx
+8
-1
index.ts
...ockSellStorage/bills/components/BillsForm/schema/index.ts
+12
-7
No files found.
src/pages/transaction/stockSellStorage/bills/components/BillsForm/effects/useBusinessEffects.ts
View file @
a5cf0678
...
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-11-20 1
6:25:08
* @LastEditTime: 2020-11-20 1
9:01:57
* @Description: 联动逻辑相关
*/
import
{
Modal
}
from
'antd'
;
...
...
@@ -321,14 +321,12 @@ export const useBusinessEffects = (context, actions) => {
setFieldValue
(
'supplyMembersName'
,
first
?
first
.
supplyMembersName
:
''
);
setFieldValue
(
'relevanceInvoicesId'
,
first
?
first
.
id
:
null
);
setFieldValue
(
'address'
,
first
?
`
${
first
.
fullAddress
}
${
first
.
receiverName
}
/
${
first
.
phone
}
`
:
''
);
setFieldValue
(
'transport'
,
first
&&
first
.
deliveryType
?
DELIVERY_TYPE
[
first
.
deliveryType
]
:
''
);
// 以下数据只用于收集,不用于展示
setFieldValue
(
'deliveryAddresId'
,
first
?
first
.
deliveryAddresId
:
null
);
setFieldValue
(
'receiverName'
,
first
?
first
.
receiverName
:
''
);
setFieldValue
(
'fullAddress'
,
first
?
first
.
fullAddress
:
''
);
setFieldValue
(
'phone'
,
first
?
first
.
phone
:
''
);
setFieldValue
(
'deliveryType'
,
first
?
first
.
deliveryType
:
null
);
setFieldValue
(
'isDefault'
,
first
?
first
.
isDefault
:
false
);
if
(
!
first
)
{
...
...
@@ -389,6 +387,17 @@ export const useBusinessEffects = (context, actions) => {
setFieldValue
(
'invoicesDetailsRequests'
,
[]);
});
// 关联明细
onFieldInputChange$
(
'invoicesDetailsRequests'
).
subscribe
(
fieldState
=>
{
const
{
value
}
=
fieldState
;
if
(
!
value
.
length
)
{
// 明细数据为空,或者明细每项数据的 商品 未选,物流方式都设置成 ''
setFieldValue
(
'transport'
,
''
);
setFieldValue
(
'deliveryType'
,
null
);
}
});
// 关联明细 商品下拉框 联动商品ID、单价
onFieldInputChange$
(
'invoicesDetailsRequests.*.product'
).
subscribe
(
fieldState
=>
{
const
{
name
,
originAsyncData
,
value
}
=
fieldState
;
...
...
@@ -436,6 +445,25 @@ export const useBusinessEffects = (context, actions) => {
state
.
value
=
`¥0.00`
;
}
);
// 配送方式,一个单据只能有一个配送方式
setFieldState
(
FormPath
.
transform
(
name
,
/
\d
/
,
$1
=>
{
return
`invoicesDetailsRequests.
${
$1
}
.deliveryType`
}),
state
=>
{
state
.
value
=
undefined
;
}
);
const
invoicesDetailsRequestsValue
=
getFieldValue
(
'invoicesDetailsRequests'
);
// 明细每项数据的 商品 未选中,物流方式设置成 ''
if
(
invoicesDetailsRequestsValue
.
every
(
item
=>
!
item
.
product
)
)
{
setFieldValue
(
'transport'
,
''
);
setFieldValue
(
'deliveryType'
,
null
);
}
}
if
(
!
current
)
{
...
...
@@ -482,6 +510,46 @@ export const useBusinessEffects = (context, actions) => {
state
.
value
=
`¥
${(
current
.
purchaseCount
*
current
.
price
).
toFixed
(
2
)}
`
;
}
);
// 配送方式,一个单据只能有一个配送方式
setFieldState
(
FormPath
.
transform
(
name
,
/
\d
/
,
$1
=>
{
return
`invoicesDetailsRequests.
${
$1
}
.deliveryType`
}),
state
=>
{
state
.
value
=
current
.
logistics
&&
current
.
logistics
.
deliveryType
?
current
.
logistics
.
deliveryType
:
undefined
;
}
);
setTimeout
(()
=>
{
const
invoicesDetailsRequestsValue
=
getFieldValue
(
'invoicesDetailsRequests'
);
// 配送方式,一个单据只能有一个配送方式
setFieldState
(
FormPath
.
transform
(
name
,
/
\d
/
,
$1
=>
{
return
`invoicesDetailsRequests.
${
$1
}
.product`
}),
state
=>
{
if
(
current
.
logistics
&&
invoicesDetailsRequestsValue
.
some
(
item
=>
item
.
deliveryType
&&
item
.
deliveryType
!==
current
.
logistics
.
deliveryType
)
)
{
state
.
errors
=
'商品配送方式不一致,请保持一次性'
;
}
else
{
state
.
errors
=
''
;
}
}
);
// 明细每项数据的 商品 选中,物流方式设置成 为对应商品的物流方式
if
(
current
.
logistics
&&
current
.
logistics
.
deliveryType
&&
invoicesDetailsRequestsValue
.
every
(
item
=>
item
.
deliveryType
===
current
.
logistics
.
deliveryType
)
)
{
setFieldValue
(
'transport'
,
DELIVERY_TYPE
[
current
.
logistics
.
deliveryType
]);
setFieldValue
(
'deliveryType'
,
current
.
logistics
.
deliveryType
);
}
},
0
);
});
// 关联明细 商品数量 联动计算商品金额
...
...
src/pages/transaction/stockSellStorage/bills/components/BillsForm/index.tsx
View file @
a5cf0678
...
...
@@ -33,6 +33,8 @@ import {
DOC_TYPE_RETURN_RECEIPT
,
DOC_TYPE_EXCHANGE_INVOICE
,
DOC_TYPE_EXCHANGE_RECEIPT
,
DELIVERY_TYPE
,
}
from
'@/constants'
;
import
{
addBillSchema
,
goodsSearchSchema
}
from
'./schema'
;
import
{
createEffects
}
from
'./effects'
;
...
...
@@ -141,6 +143,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
deliveryType
,
isDefault
,
invoicesDetailsList
,
transport
,
...
rest
}
=
res
.
data
;
...
...
@@ -148,6 +151,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
...
item
,
product
:
item
.
productId
,
amount
:
`¥
${(
+
item
.
productCount
*
item
.
price
).
toFixed
(
2
)}
`
,
deliveryType
,
}))
:
[];
addSchemaAction
.
setFieldState
(
...
...
@@ -170,7 +174,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
fullAddress
:
fullAddress
||
''
,
receiverName
:
receiverName
||
''
,
phone
:
phone
||
''
,
deliveryType
,
//
deliveryType,
isDefault
,
}
]
:
...
...
@@ -178,6 +182,8 @@ const BillsForm: React.FC<BillsFormProps> = ({
,
invoicesDetailsRequests
:
details
,
...
rest
,
deliveryType
,
transport
:
DELIVERY_TYPE
[
deliveryType
],
});
}).
finally
(()
=>
{
setInfoLoading
(
false
);
...
...
@@ -375,6 +381,7 @@ const BillsForm: React.FC<BillsFormProps> = ({
const
newInvoicesDetailsRequests
=
invoicesDetailsRequests
.
map
(({
product
,
productCount
,
deliveryType
,
...
rest
})
=>
({
productCount
:
+
productCount
,
...
...
src/pages/transaction/stockSellStorage/bills/components/BillsForm/schema/index.ts
View file @
a5cf0678
...
...
@@ -340,7 +340,7 @@ export const addBillSchema: ISchema = {
type
:
'string'
,
'x-component'
:
'Text'
,
title
:
'物流方式'
,
default
:
''
,
// default: '', // 奇了怪了,initialValues 覆盖不了 default,就这个字段会
},
// 不用于展示,只用于收集值
deliveryAddresId
:
{
...
...
@@ -450,7 +450,7 @@ export const addBillSchema: ISchema = {
'x-component-props'
:
{
allowClear
:
true
,
style
:
{
width
:
1
0
0
,
width
:
1
8
0
,
},
},
'x-rules'
:
[
...
...
@@ -460,11 +460,6 @@ export const addBillSchema: ISchema = {
},
],
},
// 不用于展示,只收集值
productName
:
{
type
:
'string'
,
display
:
false
,
},
productId
:
{
type
:
'string'
,
title
:
'商品ID'
,
...
...
@@ -497,6 +492,16 @@ export const addBillSchema: ISchema = {
title
:
'金额'
,
'x-component'
:
'Text'
,
},
// 不用于展示,只收集值
productName
:
{
type
:
'string'
,
display
:
false
,
},
// 配送方式,不用于展示,只收集值
deliveryType
:
{
type
:
'string'
,
display
:
false
,
},
},
}
},
...
...
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