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
57859ea4
Commit
57859ea4
authored
Feb 19, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复货品+商品可以重复选择的问题
parent
eafd3910
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
useBusinessEffects.ts
.../bills/components/BillsForm/effects/useBusinessEffects.ts
+28
-13
No files found.
src/pages/transaction/stockSellStorage/bills/components/BillsForm/effects/useBusinessEffects.ts
View file @
57859ea4
...
...
@@ -2,10 +2,10 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-02-19
17:42:55
* @LastEditTime: 2021-02-19
20:24:47
* @Description: 联动逻辑相关
*/
import
{
Modal
}
from
'antd'
;
import
{
Modal
,
message
}
from
'antd'
;
import
{
FormEffectHooks
,
FormPath
}
from
'@formily/antd'
;
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
;
import
{
useStateFilterSearchLinkageEffect
}
from
'@/formSchema/effects/useFilterSearch'
;
...
...
@@ -317,7 +317,6 @@ export const useBusinessEffects = (context, actions) => {
// 关联单据改变
onFieldValueChange$
(
'orderNo'
).
subscribe
(
fieldState
=>
{
const
invoicesTypeIdVal
=
getFieldValue
(
'invoicesTypeId'
);
const
invoicesDetailsRequestsValue
=
getFieldValue
(
'invoicesDetailsRequests'
);
const
first
=
fieldState
.
value
&&
fieldState
.
value
[
0
];
// 设置单据公用的数据相关
...
...
@@ -353,7 +352,6 @@ export const useBusinessEffects = (context, actions) => {
const
goodOptions
=
res
.
data
.
map
(
item
=>
({
label
:
item
.
productName
,
value
:
item
.
id
,
disabled
:
!!
invoicesDetailsRequestsValue
.
find
(
val
=>
val
.
product
===
item
.
id
),
}));
setFieldState
(
'invoicesDetailsRequests.*.product'
,
state
=>
{
FormPath
.
setIn
(
state
,
'originAsyncData'
,
res
.
data
);
...
...
@@ -383,7 +381,6 @@ export const useBusinessEffects = (context, actions) => {
const
goodOptions
=
details
.
map
(
item
=>
({
label
:
`
${
item
.
productName
}${
item
.
orderNo
?
'---'
+
item
.
orderNo
:
''
}
`
,
value
:
item
.
id
,
disabled
:
!!
invoicesDetailsRequestsValue
.
find
(
val
=>
val
.
product
===
item
.
id
),
}));
setFieldState
(
'invoicesDetailsRequests.*.product'
,
state
=>
{
FormPath
.
setIn
(
state
,
'originAsyncData'
,
details
.
map
(
item
=>
({
...
...
@@ -417,7 +414,6 @@ export const useBusinessEffects = (context, actions) => {
const
goodOptions
=
details
.
map
(
item
=>
({
label
:
`
${
item
.
productName
}${
item
.
orderNo
?
'---订单号:'
+
item
.
orderNo
:
''
}
`
,
value
:
item
.
id
,
disabled
:
!!
invoicesDetailsRequestsValue
.
find
(
val
=>
val
.
product
===
item
.
id
),
}));
setFieldState
(
'invoicesDetailsRequests.*.product'
,
state
=>
{
FormPath
.
setIn
(
state
,
'originAsyncData'
,
details
);
...
...
@@ -454,7 +450,6 @@ export const useBusinessEffects = (context, actions) => {
const
goodOptions
=
data
.
map
(
item
=>
({
label
:
`
${
item
.
productName
}
---订单号:
${
item
.
orderNo
}
`
,
value
:
item
.
orderRecordId
,
disabled
:
!!
invoicesDetailsRequestsValue
.
find
(
val
=>
val
.
product
===
item
.
orderRecordId
),
}));
setFieldState
(
'invoicesDetailsRequests.*.product'
,
state
=>
{
FormPath
.
setIn
(
state
,
'originAsyncData'
,
data
.
map
(
item
=>
({
...
...
@@ -491,7 +486,6 @@ export const useBusinessEffects = (context, actions) => {
const
goodOptions
=
data
.
map
(
item
=>
({
label
:
`
${
item
.
productName
}
---订单号:
${
item
.
orderNo
}
`
,
value
:
item
.
orderRecordId
,
disabled
:
!!
invoicesDetailsRequestsValue
.
find
(
val
=>
val
.
product
===
item
.
orderRecordId
),
}));
setFieldState
(
'invoicesDetailsRequests.*.product'
,
state
=>
{
FormPath
.
setIn
(
state
,
'originAsyncData'
,
data
.
map
(
item
=>
({
...
...
@@ -529,17 +523,38 @@ export const useBusinessEffects = (context, actions) => {
setFieldValue
(
'transport'
,
''
);
setFieldValue
(
'deliveryType'
,
null
);
}
// 已选的数据需要禁用掉,不可以重复选择
setFieldState
(
'invoicesDetailsRequests.*.product'
,
state
=>
{
state
.
props
.
enum
=
state
.
props
.
enum
.
map
((
item
)
=>
({...
item
,
disabled
:
!!
value
.
find
(
val
=>
val
.
product
===
item
.
value
)}));
});
});
// 关联明细 商品下拉框 联动商品ID、单价
onFieldInputChange$
(
'invoicesDetailsRequests.*.product'
).
subscribe
(
fieldState
=>
{
const
{
name
,
originAsyncData
,
value
,
props
}
=
fieldState
;
const
{
name
,
originAsyncData
,
value
}
=
fieldState
;
const
current
=
originAsyncData
.
find
(
item
=>
item
.
id
===
value
);
const
invoicesTypeIdVal
=
getFieldValue
(
'invoicesTypeId'
);
const
invoicesDetailsRequestsValue
=
getFieldValue
(
'invoicesDetailsRequests'
);
const
itemNoValue
=
getFieldValue
(
FormPath
.
transform
(
name
,
/
\d
/
,
$1
=>
{
return
`invoicesDetailsRequests.
${
$1
}
.itemNo`
}));
// 这里判断是否货品 跟 商品 都已经选择过了,不可重复选择
const
sameGood
=
invoicesDetailsRequestsValue
.
find
(
item
=>
item
.
itemNo
===
itemNoValue
);
if
(
invoicesDetailsRequestsValue
.
length
>
1
&&
sameGood
&&
sameGood
.
product
===
value
)
{
message
.
warning
(
'存在相同货号+商品的组合,请重新选择'
);
setTimeout
(()
=>
{
setFieldState
(
FormPath
.
transform
(
name
,
/
\d
/
,
$1
=>
{
return
`invoicesDetailsRequests.
${
$1
}
.product`
}),
state
=>
{
state
.
value
=
undefined
;
}
);
},
0
);
return
;
}
// 取消选择
if
(
!
value
)
{
...
...
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