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
f3fee090
Commit
f3fee090
authored
Aug 16, 2022
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改校验库存
parent
d2960ac7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
index.jsx
src/pages/GoodsManage/UpdateStock/index.jsx
+36
-13
index.jsx
src/pages/GoodsManage/index.jsx
+6
-2
No files found.
src/pages/GoodsManage/UpdateStock/index.jsx
View file @
f3fee090
import
{
Form
}
from
'
@ant-design/compatible
'
;
import
{
Form
}
from
'
@ant-design/compatible
'
;
import
'
@ant-design/compatible/assets/index.css
'
;
import
'
@ant-design/compatible/assets/index.css
'
;
import
{
Modal
,
InputNumber
,
notification
,
Input
,
Radio
}
from
'
antd
'
;
import
{
Modal
,
InputNumber
,
notification
,
Input
,
Radio
}
from
'
antd
'
;
import
React
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
'
;
const
UpdateStock
=
props
=>
{
const
UpdateStock
=
props
=>
{
const
{
getFieldDecorator
,
validateFields
,
resetFields
,
getFieldValue
}
=
props
.
form
;
const
{
getFieldDecorator
,
validateFields
,
resetFields
,
getFieldValue
}
=
props
.
form
;
const
valueInfo
=
props
.
info
;
const
valueInfo
=
props
.
info
;
getFieldDecorator
(
'
changeType
'
,
{
initialValue
:
1
});
getFieldDecorator
(
'
changeType
'
,
{
initialValue
:
28
});
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
submit
=
async
()
=>
{
const
submit
=
async
()
=>
{
validateFields
(
async
(
err
,
{
stock
,
changeReason
,
changeType
})
=>
{
validateFields
(
async
(
err
,
{
stock
,
changeReason
,
changeType
})
=>
{
if
(
err
)
return
;
if
(
err
)
return
;
const
error
=
await
apiCreateGoodsLog
({
setLoading
(
true
);
const
params
=
{
afterChange
:
stock
,
afterChange
:
stock
,
// id: valueInfo.id,
supplierId
:
valueInfo
.
supplierId
,
supplierId
:
valueInfo
.
supplierId
,
productIdType
:
2
,
productIdType
:
2
,
changeType
,
changeType
,
changeReason
,
changeReason
,
productIds
:
valueInfo
.
id
?
[
valueInfo
.
id
]
:
props
.
skuIds
,
productIds
:
props
.
skuIds
,
});
};
if
(
!
error
)
{
console
.
log
(
'
params :>>
'
,
params
);
notification
.
success
({
message
:
'
操作成功!
'
});
const
res
=
await
apiCreateGoodsLog
(
params
);
if
(
res
?.
businessCode
===
'
0000
'
)
{
notification
.
success
({
message
:
'
库存更改申请已提交!
'
});
props
.
onCancel
(
'
success
'
);
props
.
onCancel
(
'
success
'
);
resetFields
();
resetFields
();
}
}
setLoading
(
false
);
});
});
};
};
const
onCancel
=
()
=>
{
const
onCancel
=
()
=>
{
...
@@ -34,23 +40,40 @@ const UpdateStock = props => {
...
@@ -34,23 +40,40 @@ const UpdateStock = props => {
};
};
const
formItemLayout
=
{
const
formItemLayout
=
{
labelCol
:
{
labelCol
:
{
span
:
6
,
span
:
7
,
},
},
wrapperCol
:
{
wrapperCol
:
{
span
:
1
6
,
span
:
1
5
,
},
},
};
};
const
validatorCallback
=
(
rule
,
value
,
callback
)
=>
{
const
validatorCallback
=
(
rule
,
value
,
callback
)
=>
{
// 减库存存时,校验可售库存-输入值>=0,即可售库存不可为负;
// 减库存存时,校验可售库存-输入值>=0,即可售库存不可为负;
const
changeType
=
getFieldValue
(
'
changeType
'
);
const
changeType
=
getFieldValue
(
'
changeType
'
);
const
increment
=
valueInfo
.
marketableStock
-
value
;
const
increment
=
valueInfo
.
stock
-
value
;
console
.
log
(
'
valueInfo :>>
'
,
valueInfo
,
increment
);
return
+
changeType
===
29
&&
increment
<
0
?
callback
(
new
Error
(
rule
.
message
))
:
callback
();
return
+
changeType
===
29
&&
increment
<
0
?
callback
(
new
Error
(
rule
.
message
))
:
callback
();
};
};
return
(
return
(
<
Modal
title=
"修改库存"
visible=
{
props
.
visible
}
onCancel=
{
onCancel
}
onOk=
{
submit
}
width=
{
500
}
>
<
Modal
title=
"修改库存"
visible=
{
props
.
visible
}
okButtonProps=
{
{
loading
}
}
onCancel=
{
onCancel
}
onOk=
{
submit
}
width=
{
500
}
>
<
Form
{
...
formItemLayout
}
>
<
Form
{
...
formItemLayout
}
>
{
props
.
skuIds
.
length
>
1
?
(
<
Form
.
Item
label=
"可修改库存商品数:"
>
<
span
>
{
props
.
skuIds
.
length
}
</
span
>
</
Form
.
Item
>
)
:
(
<
Form
.
Item
label=
"当前库存:"
>
<
span
>
{
valueInfo
.
stock
}
</
span
>
</
Form
.
Item
>
)
}
<
Form
.
Item
label=
"变更类型:"
>
<
Form
.
Item
label=
"变更类型:"
>
{
getFieldDecorator
(
'
changeType
'
,
{
{
getFieldDecorator
(
'
changeType
'
,
{
rules
:
[{
required
:
true
,
message
:
'
请选择类型!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请选择类型!
'
}],
...
@@ -69,7 +92,7 @@ const UpdateStock = props => {
...
@@ -69,7 +92,7 @@ const UpdateStock = props => {
{
required
:
true
,
message
:
'
请输入库存!
'
},
{
required
:
true
,
message
:
'
请输入库存!
'
},
{
validator
:
validatorCallback
,
message
:
'
减库存,输入库存数不可大于可售库存!
'
},
{
validator
:
validatorCallback
,
message
:
'
减库存,输入库存数不可大于可售库存!
'
},
],
],
validateTrigger
:
[
'
onSubmit
'
],
validateTrigger
:
[
'
onSubmit
'
,
'
onChange
'
],
})(<
InputNumber
min=
{
0
}
precision=
{
0
}
placeholder=
"请输入库存"
style=
{
{
width
:
200
}
}
/>)
}
})(<
InputNumber
min=
{
0
}
precision=
{
0
}
placeholder=
"请输入库存"
style=
{
{
width
:
200
}
}
/>)
}
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
label=
"变更原因:"
>
<
Form
.
Item
label=
"变更原因:"
>
...
...
src/pages/GoodsManage/index.jsx
View file @
f3fee090
...
@@ -48,6 +48,7 @@ class goodsManage extends Component {
...
@@ -48,6 +48,7 @@ class goodsManage extends Component {
selectedRowKeys
:
[],
selectedRowKeys
:
[],
isAll
:
0
,
isAll
:
0
,
templateList
:
[],
templateList
:
[],
stockSkuIds
:
[],
isType
:
''
,
isType
:
''
,
};
};
...
@@ -230,7 +231,10 @@ class goodsManage extends Component {
...
@@ -230,7 +231,10 @@ class goodsManage extends Component {
if
(
ids
)
{
if
(
ids
)
{
const
res
=
await
apiEnableUpdataStock
(
ids
);
const
res
=
await
apiEnableUpdataStock
(
ids
);
if
(
res
.
data
)
{
if
(
res
.
data
)
{
if
(
res
.
data
.
allResult
||
res
.
data
.
successSkuIds
?.
length
)
{
if
(
res
.
data
.
successSkuIds
?.
length
)
{
this
.
setState
({
stockSkuIds
:
res
.
data
.
successSkuIds
,
});
this
.
openModal
(
row
,
1
);
this
.
openModal
(
row
,
1
);
}
else
{
}
else
{
const
message
=
res
.
data
.
failedInfoList
[
0
]?.
message
||
'
未存在可修改库存的商品
'
;
const
message
=
res
.
data
.
failedInfoList
[
0
]?.
message
||
'
未存在可修改库存的商品
'
;
...
@@ -418,7 +422,7 @@ class goodsManage extends Component {
...
@@ -418,7 +422,7 @@ class goodsManage extends Component {
<
UpdateStock
<
UpdateStock
visible=
{
this
.
state
.
updateStockVisible
}
visible=
{
this
.
state
.
updateStockVisible
}
skuIds=
{
this
.
state
.
s
electedRowKey
s
}
skuIds=
{
this
.
state
.
s
tockSkuId
s
}
info=
{
this
.
state
.
priceInfo
}
info=
{
this
.
state
.
priceInfo
}
onCancel=
{
this
.
cancel
}
onCancel=
{
this
.
cancel
}
/>
/>
...
...
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