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
linweijiong
jinfa-platform
Commits
68c48c4e
Commit
68c48c4e
authored
Dec 23, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:处理仓位中获取仓位货品数量异常,处理采购询价下单删除商品运费变动异常和支付比例不为0的问题
parent
b93d4c2d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
225 additions
and
224 deletions
+225
-224
PositionSetting.tsx
src/pages/repositories/components/PositionSetting.tsx
+0
-0
index.tsx
src/pages/repositories/effects/index.tsx
+74
-75
index.tsx
...eOrder/orderCollect/components/payInfoTableCell/index.tsx
+147
-147
index.tsx
src/pages/transaction/purchaseOrder/orderCollect/index.tsx
+4
-2
No files found.
src/pages/repositories/components/PositionSetting.tsx
View file @
68c48c4e
This diff is collapsed.
Click to expand it.
src/pages/repositories/effects/index.tsx
View file @
68c48c4e
import
React
,
{
useEffect
}
from
'react'
import
{
ISchemaFormActions
,
FormEffectHooks
,
IFormActions
}
from
'@formily/antd'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
;
const
{
onFieldValueChange$
}
=
FormEffectHooks
export
const
useWarehouseSelect
=
(
context
:
ISchemaFormActions
)
=>
{
onFieldValueChange$
(
'warehouseId'
).
subscribe
(
state
=>
{
// 货品ID
const
goodsId
=
context
.
getFieldValue
(
'productId'
)
const
warehouseId
=
state
.
value
PublicApi
.
getWarehouseInventoryByItemNo
({
warehouseId
,
itemId
:
goodsId
}).
then
(
res
=>
{
const
{
data
}
=
res
context
.
setFieldValue
(
'NO_SUBMIT3'
,
data
.
inventory
)
})
})
}
export
const
createAddRepositoryEffect
=
(
context
:
ISchemaFormActions
)
=>
{
const
fetchWarehouseAll
=
async
()
=>
{
const
{
data
}
=
await
PublicApi
.
getWarehouseWarehouseAll
()
context
.
setFieldState
(
'warehouseId'
,
state
=>
{
state
.
warehouseLists
=
data
})
return
data
.
map
(
v
=>
({
value
:
v
.
id
,
label
:
v
.
name
}))
}
useAsyncSelect
(
'warehouseId'
,
fetchWarehouseAll
)
useWarehouseSelect
(
context
)
}
export
const
useUnitPreview
=
(
initValue
,
context
)
=>
{
useEffect
(()
=>
{
if
(
initValue
)
{
context
.
setFieldState
(
'inventory'
,
state
=>
{
if
(
!
state
.
props
[
'x-props'
])
{
state
.
props
[
'x-props'
]
=
{}
}
state
.
props
[
'x-props'
].
addonAfter
=
<
div
style=
{
{
marginLeft
:
4
}
}
>
{
initValue
.
unit
}
</
div
>
})
context
.
setFieldValue
(
'itemNo'
,
initValue
.
itemNo
)
}
},
[
initValue
])
}
// 高级筛选schema中用于输入搜索品牌的Effect
export
const
searchBrandOptionEffect
=
(
context
:
any
,
fieldName
:
string
)
=>
{
context
.
getFieldState
(
fieldName
,
state
=>
{
PublicApi
.
getProductSelectGetSelectBrand
({
name
:
state
.
props
[
'x-component-props'
].
searchValue
}).
then
(
res
=>
{
context
.
setFieldState
(
fieldName
,
state
=>
{
state
.
props
[
'x-component-props'
].
dataoption
=
res
.
data
})
})
})
}
// 高级筛选schema中用于输入搜索商品品类的Effect
export
const
searchCustomerCategoryOptionEffect
=
(
context
:
any
,
fieldName
:
string
)
=>
{
context
.
getFieldState
(
fieldName
,
state
=>
{
PublicApi
.
getProductSelectGetSelectCustomerCategory
({
name
:
state
.
props
[
'x-component-props'
].
searchValue
}).
then
(
res
=>
{
context
.
setFieldState
(
fieldName
,
state
=>
{
state
.
props
[
'x-component-props'
].
dataoption
=
res
.
data
})
})
})
}
\ No newline at end of file
import
React
,
{
useEffect
}
from
'react'
import
{
ISchemaFormActions
,
FormEffectHooks
,
IFormActions
}
from
'@formily/antd'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
;
const
{
onFieldValueChange$
}
=
FormEffectHooks
export
const
useWarehouseSelect
=
(
context
:
ISchemaFormActions
)
=>
{
onFieldValueChange$
(
'warehouseId'
).
subscribe
(
state
=>
{
// 货品ID
const
goodsId
=
context
.
getFieldValue
(
'goodsId'
)
const
warehouseId
=
state
.
value
PublicApi
.
getWarehouseInventoryByItemNo
({
warehouseId
,
itemId
:
goodsId
}).
then
(
res
=>
{
const
{
data
}
=
res
context
.
setFieldValue
(
'NO_SUBMIT3'
,
data
.
inventory
)
})
})
}
export
const
createAddRepositoryEffect
=
(
context
:
ISchemaFormActions
)
=>
{
const
fetchWarehouseAll
=
async
()
=>
{
const
{
data
}
=
await
PublicApi
.
getWarehouseWarehouseAll
()
context
.
setFieldState
(
'warehouseId'
,
state
=>
{
state
.
warehouseLists
=
data
})
return
data
.
map
(
v
=>
({
value
:
v
.
id
,
label
:
v
.
name
}))
}
useAsyncSelect
(
'warehouseId'
,
fetchWarehouseAll
)
useWarehouseSelect
(
context
)
}
export
const
useUnitPreview
=
(
initValue
,
context
)
=>
{
useEffect
(()
=>
{
if
(
initValue
)
{
context
.
setFieldState
(
'inventory'
,
state
=>
{
if
(
!
state
.
props
[
'x-props'
])
{
state
.
props
[
'x-props'
]
=
{}
}
state
.
props
[
'x-props'
].
addonAfter
=
<
div
style=
{
{
marginLeft
:
4
}
}
>
{
initValue
.
unit
}
</
div
>
})
context
.
setFieldValue
(
'itemNo'
,
initValue
.
itemNo
)
}
},
[
initValue
])
}
// 高级筛选schema中用于输入搜索品牌的Effect
export
const
searchBrandOptionEffect
=
(
context
:
any
,
fieldName
:
string
)
=>
{
context
.
getFieldState
(
fieldName
,
state
=>
{
PublicApi
.
getProductSelectGetSelectBrand
({
name
:
state
.
props
[
'x-component-props'
].
searchValue
}).
then
(
res
=>
{
context
.
setFieldState
(
fieldName
,
state
=>
{
state
.
props
[
'x-component-props'
].
dataoption
=
res
.
data
})
})
})
}
// 高级筛选schema中用于输入搜索商品品类的Effect
export
const
searchCustomerCategoryOptionEffect
=
(
context
:
any
,
fieldName
:
string
)
=>
{
context
.
getFieldState
(
fieldName
,
state
=>
{
PublicApi
.
getProductSelectGetSelectCustomerCategory
({
name
:
state
.
props
[
'x-component-props'
].
searchValue
}).
then
(
res
=>
{
context
.
setFieldState
(
fieldName
,
state
=>
{
state
.
props
[
'x-component-props'
].
dataoption
=
res
.
data
})
})
})
}
src/pages/transaction/purchaseOrder/orderCollect/components/payInfoTableCell/index.tsx
View file @
68c48c4e
import
React
,
{
useState
,
useRef
,
useContext
,
useEffect
}
from
'react'
import
{
Form
,
Input
,
Select
}
from
'antd'
;
export
interface
PayInfoCellProps
{
title
:
React
.
ReactNode
;
editable
:
boolean
;
children
:
React
.
ReactNode
;
dataIndex
:
string
;
record
:
any
;
colIndex
:
number
,
handleChange
(
record
:
any
,
value
:
any
)
handleSave
:
(
record
:
any
)
=>
Promise
<
any
>
;
forceEdit
:
boolean
,
formItem
:
string
,
formItemProps
:
any
}
const
EditableContext
=
React
.
createContext
<
any
>
({});
export
const
EditableRow
:
React
.
FC
<
any
>
=
(
props
)
=>
{
const
[
form
]
=
Form
.
useForm
();
// form.setFieldsValue()
const
{
options
=
[]
}
=
props
?.
children
[
5
]?.
props
.
additionalProps
.
formItemProps
||
{}
const
[
childOptions
,
setChildOptions
]
=
useState
<
any
[]
>
(()
=>
{
const
{
payWay
}
=
props
?.
children
[
5
]?.
props
.
record
||
{}
if
(
payWay
)
{
return
options
.
find
(
v
=>
v
.
payType
===
payWay
)?.
payList
.
map
(
v
=>
({
label
:
v
.
way
,
value
:
v
.
id
}))
||
[]
}
else
{
return
[]
}
})
const
ctx
=
{
form
,
childOptions
,
setChildOptions
,
originOptions
:
options
}
return
(
<
Form
form=
{
form
}
component=
{
false
}
>
<
EditableContext
.
Provider
value=
{
ctx
}
>
<
tr
{
...
props
}
/>
</
EditableContext
.
Provider
>
</
Form
>
);
};
export
const
PayInfoCell
:
React
.
FC
<
PayInfoCellProps
>
=
({
title
,
editable
,
children
,
dataIndex
,
record
,
colIndex
,
handleChange
,
handleSave
,
forceEdit
,
formItem
,
formItemProps
=
{},
...
restProps
})
=>
{
const
formItemRef
=
useRef
<
any
>
();
const
{
form
,
childOptions
,
setChildOptions
,
originOptions
}
=
useContext
(
EditableContext
);
const
save
=
async
e
=>
{
try
{
const
values
=
await
form
.
validateFields
();
handleSave
({
...
record
,
...
values
});
}
catch
(
errInfo
)
{
console
.
log
(
'Save failed:'
,
errInfo
);
}
};
const
handleInputChange
=
(
e
)
=>
{
handleChange
(
record
,
e
.
target
.
value
)
}
const
chooseFormItem
=
(
type
)
=>
{
const
formId
=
dataIndex
+
colIndex
switch
(
type
)
{
case
'input'
:
{
return
<
Input
ref=
{
formItemRef
}
onPressEnter=
{
save
}
onBlur=
{
save
}
onChange=
{
handleInputChange
}
{
...
formItemProps
}
id=
{
formId
}
/>
}
case
'select'
:
{
const
{
options
,
...
rest
}
=
formItemProps
// 支付方式
if
(
dataIndex
===
'payWay'
)
{
return
<
Select
ref=
{
formItemRef
}
options=
{
originOptions
.
map
(
v
=>
({
label
:
v
.
payVal
,
value
:
v
.
payType
,
disabled
:
v
?.
disabled
}))
}
// ?? 仅限线下支付下面只有一种方式
onChange=
{
e
=>
{
const
result
=
originOptions
.
find
(
v
=>
e
===
v
.
payType
)
setChildOptions
(
result
.
payList
.
map
(
v
=>
({
label
:
v
.
way
,
value
:
v
.
id
})))
form
.
setFieldsValue
({
channel
:
''
})
save
(
e
)
}
}
{
...
rest
}
id=
{
formId
}
/>
}
// 需联动的内容
if
(
dataIndex
===
'channel'
)
{
return
<
Select
ref=
{
formItemRef
}
onChange=
{
save
}
options=
{
childOptions
}
{
...
rest
}
id=
{
formId
}
/>
}
}
}
}
let
childNode
=
children
;
if
(
editable
)
{
childNode
=
(
forceEdit
)
?
(
<
Form
.
Item
style=
{
{
margin
:
0
}
}
name=
{
dataIndex
}
initialValue=
{
record
[
dataIndex
]
||
''
}
rules=
{
[
{
required
:
true
,
message
:
`${title}必须填写`
,
},
]
}
>
{
chooseFormItem
(
formItem
)
}
</
Form
.
Item
>
)
:
(
null
);
}
return
<
td
{
...
restProps
}
>
{
childNode
}
</
td
>;
}
PayInfoCell
.
defaultProps
=
{}
export
default
PayInfoCell
import
React
,
{
useState
,
useRef
,
useContext
,
useEffect
}
from
'react'
import
{
Form
,
Input
,
Select
}
from
'antd'
;
export
interface
PayInfoCellProps
{
title
:
React
.
ReactNode
;
editable
:
boolean
;
children
:
React
.
ReactNode
;
dataIndex
:
string
;
record
:
any
;
colIndex
:
number
,
handleChange
(
record
:
any
,
value
:
any
)
handleSave
:
(
record
:
any
)
=>
Promise
<
any
>
;
forceEdit
:
boolean
,
formItem
:
string
,
formItemProps
:
any
}
const
EditableContext
=
React
.
createContext
<
any
>
({});
export
const
EditableRow
:
React
.
FC
<
any
>
=
(
props
)
=>
{
const
[
form
]
=
Form
.
useForm
();
// form.setFieldsValue()
const
{
options
=
[]
}
=
props
?.
children
[
5
]?.
props
.
additionalProps
.
formItemProps
||
{}
const
[
childOptions
,
setChildOptions
]
=
useState
<
any
[]
>
(()
=>
{
const
{
payWay
}
=
props
?.
children
[
5
]?.
props
.
record
||
{}
if
(
payWay
)
{
return
options
.
find
(
v
=>
v
.
payType
===
payWay
)?.
payList
.
map
(
v
=>
({
label
:
v
.
way
,
value
:
v
.
id
}))
||
[]
}
else
{
return
[]
}
})
const
ctx
=
{
form
,
childOptions
,
setChildOptions
,
originOptions
:
options
}
return
(
<
Form
form=
{
form
}
component=
{
false
}
>
<
EditableContext
.
Provider
value=
{
ctx
}
>
<
tr
{
...
props
}
/>
</
EditableContext
.
Provider
>
</
Form
>
);
};
export
const
PayInfoCell
:
React
.
FC
<
PayInfoCellProps
>
=
({
title
,
editable
,
children
,
dataIndex
,
record
,
colIndex
,
handleChange
,
handleSave
,
forceEdit
,
formItem
,
formItemProps
=
{},
...
restProps
})
=>
{
const
formItemRef
=
useRef
<
any
>
();
const
{
form
,
childOptions
,
setChildOptions
,
originOptions
}
=
useContext
(
EditableContext
);
const
save
=
async
e
=>
{
try
{
const
values
=
await
form
.
validateFields
();
handleSave
({
...
record
,
...
values
});
}
catch
(
errInfo
)
{
console
.
log
(
'Save failed:'
,
errInfo
);
}
};
const
handleInputChange
=
(
e
)
=>
{
handleChange
(
record
,
e
.
target
.
value
)
}
const
chooseFormItem
=
(
type
)
=>
{
const
formId
=
dataIndex
+
colIndex
switch
(
type
)
{
case
'input'
:
{
return
<
Input
ref=
{
formItemRef
}
onPressEnter=
{
save
}
onBlur=
{
save
}
onChange=
{
handleInputChange
}
{
...
formItemProps
}
id=
{
formId
}
/>
}
case
'select'
:
{
const
{
options
,
...
rest
}
=
formItemProps
// 支付方式
if
(
dataIndex
===
'payWay'
)
{
return
<
Select
ref=
{
formItemRef
}
options=
{
originOptions
.
map
(
v
=>
({
label
:
v
.
payVal
,
value
:
v
.
payType
,
disabled
:
v
?.
disabled
}))
}
// ?? 仅限线下支付下面只有一种方式
onChange=
{
e
=>
{
const
result
=
originOptions
.
find
(
v
=>
e
===
v
.
payType
)
setChildOptions
(
result
.
payList
.
map
(
v
=>
({
label
:
v
.
way
,
value
:
v
.
id
})))
form
.
setFieldsValue
({
channel
:
''
})
save
(
e
)
}
}
{
...
rest
}
id=
{
formId
}
/>
}
// 需联动的内容
if
(
dataIndex
===
'channel'
)
{
return
<
Select
ref=
{
formItemRef
}
onChange=
{
save
}
options=
{
childOptions
}
{
...
rest
}
id=
{
formId
}
/>
}
}
}
}
let
childNode
=
children
;
if
(
editable
)
{
childNode
=
(
forceEdit
)
?
(
<
Form
.
Item
style=
{
{
margin
:
0
}
}
name=
{
dataIndex
}
initialValue=
{
record
[
dataIndex
]
||
''
}
rules=
{
[
{
required
:
true
,
message
:
`${title}必须填写`
,
},
]
}
>
{
chooseFormItem
(
formItem
)
}
</
Form
.
Item
>
)
:
(
null
);
}
return
<
td
{
...
restProps
}
>
{
childNode
}
</
td
>;
}
PayInfoCell
.
defaultProps
=
{}
export
default
PayInfoCell
src/pages/transaction/purchaseOrder/orderCollect/index.tsx
View file @
68c48c4e
...
...
@@ -79,6 +79,8 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
setFreePrice
(
res
.
data
)
}
})
}
else
{
setFreePrice
(
0
)
}
}
},
[
data
])
...
...
@@ -211,14 +213,14 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
// 校验是否选择支付渠道
let
judgementByPay
=
params
.
paymentInformationResponses
.
map
(
item
=>
{
if
(
item
.
channel
&&
item
.
payWay
){
if
(
item
.
channel
&&
item
.
payWay
&&
Number
(
item
.
payRatio
)
){
return
true
}
else
{
return
false
}
})
if
(
judgementByPay
.
includes
(
false
)){
throw
new
Error
(
'请
选择支付方式或者支付渠道
'
)
throw
new
Error
(
'请
正确填写支付信息
'
)
}
// 校验采购数量
let
judgementByCount
=
params
.
orderProductRequests
.
map
(
item
=>
{
...
...
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