Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
merchant-manage-ui
Commits
02e5e774
Commit
02e5e774
authored
Aug 29, 2022
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改库存校验
parent
90733548
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
7 deletions
+28
-7
index.jsx
src/pages/GoodsManage/UpdateStock/index.jsx
+8
-6
index.jsx
src/pages/GoodsManage/index.jsx
+1
-0
style.less
src/pages/GoodsManage/style.less
+1
-1
validator.js
src/utils/validator.js
+18
-0
No files found.
src/pages/GoodsManage/UpdateStock/index.jsx
View file @
02e5e774
...
@@ -4,6 +4,7 @@ import { Modal, InputNumber, notification, Input, Radio } from 'antd';
...
@@ -4,6 +4,7 @@ import { Modal, InputNumber, notification, Input, Radio } from 'antd';
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
{
apiCreateGoodsLog
}
from
'
../service
'
;
import
{
apiCreateGoodsLog
}
from
'
../service
'
;
import
styles
from
'
../style.less
'
;
import
styles
from
'
../style.less
'
;
import
{
isNumberSection
}
from
'
@/utils/validator
'
;
const
UpdateStock
=
props
=>
{
const
UpdateStock
=
props
=>
{
const
{
getFieldDecorator
,
validateFields
,
resetFields
,
getFieldValue
}
=
props
.
form
;
const
{
getFieldDecorator
,
validateFields
,
resetFields
,
getFieldValue
}
=
props
.
form
;
...
@@ -65,14 +66,14 @@ const UpdateStock = props => {
...
@@ -65,14 +66,14 @@ const UpdateStock = props => {
width=
{
500
}
width=
{
500
}
>
>
<
Form
{
...
formItemLayout
}
>
<
Form
{
...
formItemLayout
}
>
{
props
.
skuIds
.
length
>
1
?
(
{
valueInfo
.
curStock
?
(
<
Form
.
Item
label=
"可修改库存商品数:"
>
<
span
>
{
props
.
skuIds
.
length
}
</
span
>
</
Form
.
Item
>
)
:
(
<
Form
.
Item
label=
"当前库存:"
>
<
Form
.
Item
label=
"当前库存:"
>
<
span
>
{
valueInfo
.
curStock
}
</
span
>
<
span
>
{
valueInfo
.
curStock
}
</
span
>
</
Form
.
Item
>
</
Form
.
Item
>
)
:
(
<
Form
.
Item
label=
"可修改库存商品数:"
>
<
span
>
{
props
.
skuIds
.
length
}
</
span
>
</
Form
.
Item
>
)
}
)
}
<
Form
.
Item
label=
"变更类型:"
>
<
Form
.
Item
label=
"变更类型:"
>
{
getFieldDecorator
(
'
changeType
'
,
{
{
getFieldDecorator
(
'
changeType
'
,
{
...
@@ -92,6 +93,7 @@ const UpdateStock = props => {
...
@@ -92,6 +93,7 @@ const UpdateStock = props => {
rules
:
[
rules
:
[
{
required
:
true
,
message
:
'
请输入库存!
'
},
{
required
:
true
,
message
:
'
请输入库存!
'
},
{
validator
:
validatorCallback
,
message
:
'
减库存,输入库存数不可大于可售库存!
'
},
{
validator
:
validatorCallback
,
message
:
'
减库存,输入库存数不可大于可售库存!
'
},
{
validator
:
isNumberSection
,
min
:
1
,
max
:
500
,
message
:
'
请输入1-500的整数
'
},
],
],
validateTrigger
:
[
'
onSubmit
'
,
'
onChange
'
],
validateTrigger
:
[
'
onSubmit
'
,
'
onChange
'
],
initialValue
:
valueInfo
.
stock
,
initialValue
:
valueInfo
.
stock
,
...
@@ -109,7 +111,7 @@ const UpdateStock = props => {
...
@@ -109,7 +111,7 @@ const UpdateStock = props => {
{
getFieldDecorator
(
'
changeReason
'
,
{
{
getFieldDecorator
(
'
changeReason
'
,
{
rules
:
[{
required
:
true
,
message
:
'
请输入变更原因!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请输入变更原因!
'
}],
initialValue
:
valueInfo
.
changeReason
,
initialValue
:
valueInfo
.
changeReason
,
})(<
Input
.
TextArea
disabled=
{
valueInfo
.
status
===
1
}
/>)
}
})(<
Input
.
TextArea
disabled=
{
valueInfo
.
status
===
1
}
maxLength=
{
50
}
/>)
}
</
Form
.
Item
>
</
Form
.
Item
>
{
valueInfo
.
stateDesc
&&
<
div
className=
{
styles
.
stockErrMsg
}
>
{
valueInfo
.
stateDesc
}
</
div
>
}
{
valueInfo
.
stateDesc
&&
<
div
className=
{
styles
.
stockErrMsg
}
>
{
valueInfo
.
stateDesc
}
</
div
>
}
</
Form
>
</
Form
>
...
...
src/pages/GoodsManage/index.jsx
View file @
02e5e774
...
@@ -234,6 +234,7 @@ class goodsManage extends Component {
...
@@ -234,6 +234,7 @@ class goodsManage extends Component {
if
(
res
.
data
)
{
if
(
res
.
data
)
{
if
(
res
.
data
.
successSkuIds
?.
length
)
{
if
(
res
.
data
.
successSkuIds
?.
length
)
{
this
.
setState
({
this
.
setState
({
priceInfo
:
{},
stockSkuIds
:
res
.
data
.
successSkuIds
,
stockSkuIds
:
res
.
data
.
successSkuIds
,
});
});
this
.
openModal
({},
1
);
this
.
openModal
({},
1
);
...
...
src/pages/GoodsManage/style.less
View file @
02e5e774
...
@@ -101,7 +101,7 @@
...
@@ -101,7 +101,7 @@
}
}
.stockTip {
.stockTip {
color: #
999
;
color: #
d9363e
;
line-height: 1;
line-height: 1;
}
}
.stockErrMsg {
.stockErrMsg {
...
...
src/utils/validator.js
View file @
02e5e774
...
@@ -172,6 +172,24 @@ export const isIntegerNotZero = (rule, value, callback) => {
...
@@ -172,6 +172,24 @@ export const isIntegerNotZero = (rule, value, callback) => {
}
}
};
};
/**
* 验证 数字区间
* rule.min: 0
* rule.max: 100
*/
export
const
isNumberSection
=
(
rule
,
value
,
callback
)
=>
{
if
([
''
,
undefined
,
null
].
includes
(
value
))
{
callback
();
}
if
(
!
Number
(
value
))
{
callback
(
new
Error
(
'
请输入数字
'
));
}
else
if
(
rule
.
min
>
+
value
||
rule
.
max
<
+
value
)
{
callback
(
new
Error
(
rule
.
message
||
`请输入
${
rule
.
min
}
-
${
rule
.
max
}
区间的数字`
));
}
else
{
callback
();
}
};
// 验证是否整数,非必填
// 验证是否整数,非必填
export
function
isIntegerNotMust
(
rule
,
value
,
callback
)
{
export
function
isIntegerNotMust
(
rule
,
value
,
callback
)
{
if
(
!
value
)
{
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