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
aadf31b8
Commit
aadf31b8
authored
Apr 04, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改库存问题
parent
8f1a428f
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
77 deletions
+142
-77
AddRepertoryModal.jsx
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
+44
-29
FormInformationBasic.jsx
src/pages/ServiceGoods/components/FormInformationBasic.jsx
+6
-6
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+62
-35
index.jsx
src/pages/ServiceGoods/index.jsx
+8
-6
utils.js
src/pages/ServiceGoods/utils.js
+6
-1
validator.js
src/utils/validator.js
+16
-0
No files found.
src/pages/ServiceGoods/components/AddRepertoryModal.jsx
View file @
aadf31b8
...
@@ -3,6 +3,7 @@ import { Button, Modal, Radio, Form, InputNumber, Switch, Space, message } from
...
@@ -3,6 +3,7 @@ import { Button, Modal, Radio, Form, InputNumber, Switch, Space, message } from
import
styles
from
'
../common.less
'
;
import
styles
from
'
../common.less
'
;
import
{
ENUM_SET_REPERTORY
}
from
'
../config
'
;
import
{
ENUM_SET_REPERTORY
}
from
'
../config
'
;
import
{
debounce
}
from
'
@/utils/utils
'
;
import
{
debounce
}
from
'
@/utils/utils
'
;
import
{
isCheckPriceTwoDecimal
,
isIntegerNotZero
}
from
'
@/utils/validator
'
;
const
AddRepertoryModal
=
(
props
,
ref
)
=>
{
const
AddRepertoryModal
=
(
props
,
ref
)
=>
{
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
...
@@ -28,7 +29,7 @@ const AddRepertoryModal = (props, ref) => {
...
@@ -28,7 +29,7 @@ const AddRepertoryModal = (props, ref) => {
form
.
setFieldsValue
({
form
.
setFieldsValue
({
autoStock
:
e
?
1
:
0
,
autoStock
:
e
?
1
:
0
,
});
});
setIsRequired
(
!
e
)
setIsRequired
(
!
e
)
;
};
};
// 勾选库存设置
// 勾选库存设置
const
onChangeSetRepertory
=
e
=>
{
const
onChangeSetRepertory
=
e
=>
{
...
@@ -60,8 +61,8 @@ const AddRepertoryModal = (props, ref) => {
...
@@ -60,8 +61,8 @@ const AddRepertoryModal = (props, ref) => {
const
values
=
await
form
.
validateFields
();
const
values
=
await
form
.
validateFields
();
values
.
autoStock
=
values
.
autoStock
?
1
:
0
;
values
.
autoStock
=
values
.
autoStock
?
1
:
0
;
if
(
+
values
.
autoStock
===
1
&&
+
values
.
maxStock
===
0
)
{
if
(
+
values
.
autoStock
===
1
&&
+
values
.
maxStock
===
0
)
{
message
.
error
(
'
最大库存不能为0
'
)
message
.
error
(
'
最大库存不能为0
'
)
;
return
return
;
}
}
// 回调库存
// 回调库存
modifiedInventory
(
type
,
idx
,
values
);
modifiedInventory
(
type
,
idx
,
values
);
...
@@ -119,7 +120,14 @@ const AddRepertoryModal = (props, ref) => {
...
@@ -119,7 +120,14 @@ const AddRepertoryModal = (props, ref) => {
display
:
'
flex
'
,
display
:
'
flex
'
,
marginRight
:
'
8px
'
,
marginRight
:
'
8px
'
,
}
}
}
}
rules=
{
[{
required
:
true
,
message
:
'
请填写剩余库存
'
}]
}
rules=
{
[
{
required
:
true
,
message
:
'
请填写剩余库存
'
},
{
validator
:
isIntegerNotZero
,
type
:
'
number
'
,
message
:
'
请输入大于0的整数
'
,
},
]
}
>
>
<
InputNumber
<
InputNumber
min=
{
0
}
min=
{
0
}
...
@@ -140,7 +148,14 @@ const AddRepertoryModal = (props, ref) => {
...
@@ -140,7 +148,14 @@ const AddRepertoryModal = (props, ref) => {
<
Form
.
Item
<
Form
.
Item
name=
"maxStock"
name=
"maxStock"
label=
"最大库存"
label=
"最大库存"
rules=
{
[{
required
:
isRequired
,
message
:
'
请填写最大库存
'
}]
}
rules=
{
[
{
required
:
isRequired
,
message
:
'
请填写最大库存
'
},
{
validator
:
isIntegerNotZero
,
type
:
'
number
'
,
message
:
'
请输入大于0的整数
'
,
},
]
}
>
>
<
InputNumber
<
InputNumber
min=
{
0
}
min=
{
0
}
...
...
src/pages/ServiceGoods/components/FormInformationBasic.jsx
View file @
aadf31b8
...
@@ -167,14 +167,16 @@ const FormInformationBasic = forwardRef((props, ref) => {
...
@@ -167,14 +167,16 @@ const FormInformationBasic = forwardRef((props, ref) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
editData
)
return
;
if
(
!
editData
)
return
;
if
(
editData
.
productType
===
5
&&
editData
.
name
)
{
if
(
editData
.
productType
===
5
&&
editData
?
.
name
)
{
shopGetByProductType
(
5
);
shopGetByProductType
(
5
);
queryShopList
({
shopId
:
editData
.
productRefShopId
});
queryShopList
({
shopId
:
editData
?
.
productRefShopId
});
setShopIdSource
(
editData
.
productRefShopId
);
setShopIdSource
(
editData
?
.
productRefShopId
);
setIsEditTakeaway
(
true
);
setIsEditTakeaway
(
true
);
}
}
form
.
setFieldsValue
(
editData
);
form
.
setFieldsValue
(
editData
);
onTakeawayImageList
(
editData
.
commonImageList
);
if
(
editData
?.
commonImageList
?.
length
)
{
onTakeawayImageList
(
editData
?.
commonImageList
);
}
},
[
customer
.
isEdit
,
editData
]);
},
[
customer
.
isEdit
,
editData
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
setShopList
([]);
setShopList
([]);
...
@@ -188,9 +190,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
...
@@ -188,9 +190,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
productRefShopId
:
shopId
?
[
`
${
shopId
}
`
]
:
[],
productRefShopId
:
shopId
?
[
`
${
shopId
}
`
]
:
[],
storageRackIds
:
groupId
?
[
+
groupId
]
:
[],
storageRackIds
:
groupId
?
[
+
groupId
]
:
[],
};
};
setTimeout
(()
=>
{
form
.
setFieldsValue
(
temp
);
form
.
setFieldsValue
(
temp
);
},
[]);
},
[
groupShopData
]);
},
[
groupShopData
]);
return
(
return
(
<
Form
<
Form
...
...
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
aadf31b8
This diff is collapsed.
Click to expand it.
src/pages/ServiceGoods/index.jsx
View file @
aadf31b8
...
@@ -87,7 +87,7 @@ const ServiceGoods = options => {
...
@@ -87,7 +87,7 @@ const ServiceGoods = options => {
const
resetForm
=
()
=>
clearCurrent
(
checkFormList
).
forEach
(({
current
})
=>
current
.
reset
());
const
resetForm
=
()
=>
clearCurrent
(
checkFormList
).
forEach
(({
current
})
=>
current
.
reset
());
const
onValuesChange
=
e
=>
{
const
onValuesChange
=
e
=>
{
if
(
!
isEdit
)
{
if
(
!
isEdit
&&
productType
!==
5
)
{
if
(
visibleCacheEdit
)
{
if
(
visibleCacheEdit
)
{
setVisibleCacheEdit
(
false
);
setVisibleCacheEdit
(
false
);
localStorage
.
remove
(
localAutoSaveKey
);
localStorage
.
remove
(
localAutoSaveKey
);
...
@@ -102,7 +102,6 @@ const ServiceGoods = options => {
...
@@ -102,7 +102,6 @@ const ServiceGoods = options => {
}
}
if
(
productType
===
5
)
{
if
(
productType
===
5
)
{
setTakeawayInfoMation
(
e
);
setTakeawayInfoMation
(
e
);
// console.log('takeawayInfoMation', takeawayInfoMation);
}
}
};
};
...
@@ -253,8 +252,12 @@ const ServiceGoods = options => {
...
@@ -253,8 +252,12 @@ const ServiceGoods = options => {
const
sendData
=
filterSendData
(
productType
,
params
);
const
sendData
=
filterSendData
(
productType
,
params
);
if
(
productType
===
5
)
{
if
(
productType
===
5
)
{
console
.
log
(
sendData
,
'
sendData
'
);
console
.
log
(
sendData
,
'
sendData
'
);
if
(
+
sendData
?.
repertoryType
===
2
&&
sendData
?.
items
?.
length
<
2
)
{
message
.
error
(
'
最少生成2个sku
'
)
return
}
sendMerchantProductHttpRequest
(
sendData
);
sendMerchantProductHttpRequest
(
sendData
);
return
false
;
return
;
}
}
if
(
isEdit
)
{
if
(
isEdit
)
{
sendData
.
id
=
pageId
;
sendData
.
id
=
pageId
;
...
@@ -374,9 +377,8 @@ const ServiceGoods = options => {
...
@@ -374,9 +377,8 @@ const ServiceGoods = options => {
[
specKeyList
],
[
specKeyList
],
);
);
useEffect
(()
=>
{
useEffect
(()
=>
{
console
.
log
(
'
takeAway
'
,
takeAway
);
// 外卖类型
// 外卖类型
if
(
Object
.
keys
(
takeAway
).
length
)
{
if
(
Object
.
keys
(
takeAway
)
?
.
length
)
{
const
{
spuId
=
''
,
groupId
=
''
}
=
takeAway
;
const
{
spuId
=
''
,
groupId
=
''
}
=
takeAway
;
if
(
spuId
)
{
if
(
spuId
)
{
querGetShopDetail
(
takeAway
);
querGetShopDetail
(
takeAway
);
...
@@ -510,7 +512,7 @@ const ServiceGoods = options => {
...
@@ -510,7 +512,7 @@ const ServiceGoods = options => {
>
>
<
Spin
tip=
"正在加载..."
spinning=
{
pageLoading
}
delay=
{
100
}
>
<
Spin
tip=
"正在加载..."
spinning=
{
pageLoading
}
delay=
{
100
}
>
<
WrapperContainer
>
<
WrapperContainer
>
{
visibleCacheEdit
&&
productType
!==
5
&&
(
{
visibleCacheEdit
&&
(
<
div
className=
{
styles
.
draftBox
}
>
<
div
className=
{
styles
.
draftBox
}
>
有未保存内容。是否
有未保存内容。是否
<
span
className=
{
styles
.
conEdit
}
onClick=
{
onContinueEdit
}
>
<
span
className=
{
styles
.
conEdit
}
onClick=
{
onContinueEdit
}
>
...
...
src/pages/ServiceGoods/utils.js
View file @
aadf31b8
...
@@ -300,6 +300,11 @@ export const createProductData = (props, isEdit, skuList) => {
...
@@ -300,6 +300,11 @@ export const createProductData = (props, isEdit, skuList) => {
export const localAutoSaveKey = 'good-info-auto-save';
export const localAutoSaveKey = 'good-info-auto-save';
export const onAutoSaveValue = (e, isClear) => {
export const onAutoSaveValue = (e, isClear) => {
// 暂时去掉外卖类型
if (e && e.type === 5) {
localStorage.remove(localAutoSaveKey);
return;
}
const keys = Object.keys(e);
const keys = Object.keys(e);
if (
if (
e &&
e &&
...
@@ -314,7 +319,7 @@ export const onAutoSaveValue = (e, isClear) => {
...
@@ -314,7 +319,7 @@ export const onAutoSaveValue = (e, isClear) => {
localStorage.set(localAutoSaveKey, Object.assign({}, e));
localStorage.set(localAutoSaveKey, Object.assign({}, e));
} else {
} else {
const info = localStorage.get(localAutoSaveKey) || {};
const info = localStorage.get(localAutoSaveKey) || {};
localStorage.set(localAutoSaveKey, Object.assign({ type:
1
}, info, e));
localStorage.set(localAutoSaveKey, Object.assign({ type:
e.type
}, info, e));
}
}
};
};
...
...
src/utils/validator.js
View file @
aadf31b8
...
@@ -419,3 +419,19 @@ export function isCheckPriceOneDecimal(rule, value, callback) {
...
@@ -419,3 +419,19 @@ export function isCheckPriceOneDecimal(rule, value, callback) {
callback
();
callback
();
}
}
}
}
// 验证价格保留小数点2位
export
function
isCheckPriceTwoDecimal
(
rule
,
value
,
callback
)
{
const
num
=
+
value
;
const
arr
=
`
${
value
}
`
.
split
(
'
.
'
);
if
(
!
value
)
{
callback
();
}
else
if
(
Number
.
isNaN
(
num
))
{
callback
(
new
Error
(
'
请输入数字
'
));
}
else
if
(
num
<
0
)
{
callback
(
new
Error
(
'
请输入大于0的数字
'
));
}
else
if
(
arr
.
length
===
2
&&
arr
[
1
].
length
>
2
)
{
callback
(
new
Error
(
'
小数点保留2位
'
));
}
else
{
callback
();
}
}
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