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
82e82977
Commit
82e82977
authored
Apr 11, 2023
by
baxibaba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改库存
parent
b6e89ae0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
39 deletions
+56
-39
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+42
-27
utils.js
src/pages/ServiceGoods/utils.js
+14
-12
No files found.
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
82e82977
/* eslint-disable prefer-const */
/* eslint-disable react/no-array-index-key */
/* eslint-disable react/no-array-index-key */
/* eslint-disable no-shadow */
/* eslint-disable no-shadow */
import
React
,
{
import
React
,
{
...
@@ -24,6 +25,7 @@ import {
...
@@ -24,6 +25,7 @@ import {
Cascader
,
Cascader
,
Divider
,
Divider
,
DatePicker
,
DatePicker
,
message
,
}
from
'
antd
'
;
}
from
'
antd
'
;
import
moment
from
'
moment
'
;
import
moment
from
'
moment
'
;
import
{
MinusCircleOutlined
,
PlusOutlined
}
from
'
@ant-design/icons
'
;
import
{
MinusCircleOutlined
,
PlusOutlined
}
from
'
@ant-design/icons
'
;
...
@@ -261,7 +263,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -261,7 +263,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
itm
?.
unit
&&
itm
?.
unit
&&
(
Array
.
isArray
(
itm
?.
unit
)
?
itm
?.
unit
.
slice
(
itm
?.
unit
.
length
-
1
)[
0
]
:
itm
?.
unit
);
(
Array
.
isArray
(
itm
?.
unit
)
?
itm
?.
unit
.
slice
(
itm
?.
unit
.
length
-
1
)[
0
]
:
itm
?.
unit
);
}
}
console
.
log
(
'
itm.unit
'
,
itm
.
unit
);
if
(
itm
?.
unit
&&
peopleUnits
.
includes
(
itm
.
unit
))
{
if
(
itm
?.
unit
&&
peopleUnits
.
includes
(
itm
.
unit
))
{
delete
itm
.
quantity
;
delete
itm
.
quantity
;
}
}
...
@@ -271,10 +272,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -271,10 +272,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
})
})
.
toString
();
.
toString
();
});
});
// 编辑数据
// 编辑数据
if
(
customer
.
isEdit
)
{
if
(
customer
.
isEdit
)
{
const
uniqueArr
=
tempMultiSpu
.
map
(
item
=>
item
.
unique
);
const
uniqueArr
=
tempMultiSpu
.
map
(
item
=>
item
.
unique
);
const
multiSpuUnique
=
multiSpu
.
map
(
item
=>
item
.
unique
);
const
multiSpuUnique
=
multiSpu
.
map
(
item
=>
item
.
unique
);
console
.
log
(
'
uniqueArr
'
,
uniqueArr
);
console
.
log
(
'
multiSpuUnique
'
,
multiSpuUnique
);
const
newArrLen
=
Array
.
from
(
new
Set
(
multiSpuUnique
)).
length
;
if
(
newArrLen
<
multiSpuUnique
.
length
)
{
message
.
error
(
'
份量名称不能重复!
'
);
return
;
}
// 新增对比数据
// 新增对比数据
multiSpu
.
forEach
((
item
,
index
)
=>
{
multiSpu
.
forEach
((
item
,
index
)
=>
{
if
(
!
uniqueArr
.
includes
(
item
.
unique
))
{
if
(
!
uniqueArr
.
includes
(
item
.
unique
))
{
...
@@ -285,6 +294,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -285,6 +294,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
});
});
}
}
});
});
// // 删除对比数据
// // 删除对比数据
// tempMultiSpu.forEach((item, index) => {
// tempMultiSpu.forEach((item, index) => {
// console.log('33333', index);
// console.log('33333', index);
...
@@ -294,7 +304,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -294,7 +304,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// }
// }
// }
// }
// });
// });
while
(
multiSpu
.
length
!==
tempMultiSpu
.
length
)
{
while
(
multiSpu
.
length
!==
tempMultiSpu
.
length
)
{
tempMultiSpu
.
forEach
((
item
,
index
)
=>
{
tempMultiSpu
.
forEach
((
item
,
index
)
=>
{
if
(
!
multiSpuUnique
.
includes
(
item
.
unique
))
{
if
(
!
multiSpuUnique
.
includes
(
item
.
unique
))
{
...
@@ -302,11 +311,12 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -302,11 +311,12 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
}
});
});
}
}
// 库存设置
//
同步
库存设置
multiSpu
.
map
(
item
=>
{
multiSpu
.
map
(
item
=>
{
tempMultiSpu
.
forEach
(
itm
=>
{
tempMultiSpu
.
forEach
(
itm
=>
{
if
(
item
.
unique
===
itm
.
unique
)
{
if
(
item
.
unique
===
itm
.
unique
)
{
item
.
serviceItem
=
{
...
item
.
serviceItem
,
...
itm
.
serviceItem
};
item
.
serviceItem
=
{
...
item
.
serviceItem
,
...
itm
.
serviceItem
};
itm
.
specs
=
[...
item
.
specs
];
}
}
});
});
return
item
;
return
item
;
...
@@ -315,8 +325,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -315,8 +325,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setTempMultiSpu
(
tempMultiSpu
);
setTempMultiSpu
(
tempMultiSpu
);
setMultiSpu
(
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
)));
setMultiSpu
(
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
)));
console
.
log
(
'
tempMultiSpu
'
,
tempMultiSpu
);
//
console.log('tempMultiSpu', tempMultiSpu);
console
.
log
(
'
multiSpu
'
,
multiSpu
);
//
console.log('multiSpu', multiSpu);
}
}
// 新增
// 新增
if
(
!
customer
.
isEdit
)
{
if
(
!
customer
.
isEdit
)
{
...
@@ -330,11 +340,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -330,11 +340,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setMultiSpu
(
multiSpu
);
setMultiSpu
(
multiSpu
);
}
}
// console.log('multiSpu', multiSpu);
console
.
log
(
'
multiSpu
'
,
multiSpu
);
// console.log('tempMultiSpu', tempMultiSpu);
console
.
log
(
'
tempMultiSpu222
'
,
tempMultiSpu
);
// console.log('multiSpuData', multiSpuData);
// setTempMultiSpu(JSON.parse(JSON.stringify(tempMultiSpu)))
// setTempMultiSpu(JSON.parse(JSON.stringify(tempMultiSpu)))
;
// setMultiSpu(JSON.parse(JSON.stringify(tempMultiSpu)));
// setMultiSpu(JSON.parse(JSON.stringify(tempMultiSpu)));
// }
// }
}
}
...
@@ -376,7 +385,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -376,7 +385,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// : localStorage.get(localAutoSaveKey) || {};
// : localStorage.get(localAutoSaveKey) || {};
setTakeawayData
(
takeawayData
);
setTakeawayData
(
takeawayData
);
takeawayCalc
(
takeawayData
);
takeawayCalc
(
takeawayData
);
const
multiSpuUnique
=
multiSpu
.
map
(
item
=>
item
.
unique
);
//
const multiSpuUnique = multiSpu.map(item => item.unique);
// 删除对比数据
// 删除对比数据
// if (multiSpu.length !== tempMultiSpu.length) {
// if (multiSpu.length !== tempMultiSpu.length) {
...
@@ -386,18 +395,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -386,18 +395,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// }
// }
// });
// });
// }
// }
while
(
multiSpu
.
length
!==
tempMultiSpu
.
length
)
{
//
while (multiSpu.length !== tempMultiSpu.length) {
tempMultiSpu
.
forEach
((
item
,
index
)
=>
{
//
tempMultiSpu.forEach((item, index) => {
if
(
!
multiSpuUnique
.
includes
(
item
.
unique
))
{
//
if (!multiSpuUnique.includes(item.unique)) {
tempMultiSpu
.
splice
(
index
,
1
);
//
tempMultiSpu.splice(index, 1);
}
//
}
});
//
});
}
//
}
console
.
log
(
multiSpuUnique
,
'
multiSpuUnique
'
);
//
console.log(multiSpuUnique, 'multiSpuUnique');
console
.
log
(
tempMultiSpu
,
'
tempMultiSpu
'
);
//
console.log(tempMultiSpu, 'tempMultiSpu');
console
.
log
(
multiSpu
,
'
multiSpu
'
);
//
console.log(multiSpu, 'multiSpu');
setTempMultiSpu
(
JSON
.
parse
(
JSON
.
stringify
(
tempMultiSpu
)));
//
setTempMultiSpu(JSON.parse(JSON.stringify(tempMultiSpu)));
},
400
);
},
400
);
// 设置库存
// 设置库存
const
modifiedInventory
=
(
type
,
idx
,
values
)
=>
{
const
modifiedInventory
=
(
type
,
idx
,
values
)
=>
{
...
@@ -534,7 +543,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -534,7 +543,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setRepertoryModel
({
type
,
idx
,
item
});
setRepertoryModel
({
type
,
idx
,
item
});
};
};
// 拼接sku 名称
// 拼接sku 名称
const
calcLabelName
=
(
intactData
,
item
)
=>
{
const
calcLabelName
=
item
=>
{
let
firstName
=
''
;
let
firstName
=
''
;
let
lastName
=
''
;
let
lastName
=
''
;
const
tempName
=
`
${
editData
?.
name
||
''
}
`;
const
tempName
=
`
${
editData
?.
name
||
''
}
`;
...
@@ -596,7 +605,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -596,7 +605,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
weight.forEach(item => {
weight.forEach(item => {
if (item?.specs?.length) {
if (item?.specs?.length) {
item.specs.forEach(itm => {
item.specs.forEach(itm => {
if (tempWeightName.includes(itm.unit)) {
console.log('itm?.unit11111', itm?.unit);
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm.quantity =
itm?.quantity.indexOf('约') > -1 ? itm?.quantity.slice(1) : itm?.quantity || '';
itm?.quantity.indexOf('约') > -1 ? itm?.quantity.slice(1) : itm?.quantity || '';
}
}
...
@@ -637,7 +647,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -637,7 +647,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
weight.forEach(item => {
weight.forEach(item => {
if (item?.specs?.length) {
if (item?.specs?.length) {
item.specs.forEach(itm => {
item.specs.forEach(itm => {
if (tempWeightName.includes(itm.unit)) {
console.log('itm?.unit112222', itm?.unit);
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm.quantity =
itm?.quantity?.indexOf('约') > -1
itm?.quantity?.indexOf('约') > -1
? itm?.quantity.slice(1)
? itm?.quantity.slice(1)
...
@@ -686,6 +698,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -686,6 +698,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
useEffect(() => {
useEffect(() => {
getFormValues();
getFormValues();
}, [repertoryType]);
}, [repertoryType]);
useEffect(() => {
setTempMultiSpu(tempMultiSpu);
}, [tempMultiSpu]);
return (
return (
<>
<>
<Form
<Form
...
@@ -1012,7 +1027,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -1012,7 +1027,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
singularSpu[0]?.specs[0]?.unit &&
singularSpu[0]?.specs[0]?.unit &&
singularSpu.map((item, index) => (
singularSpu.map((item, index) => (
<div className={styles.specsSingularBetween}>
<div className={styles.specsSingularBetween}>
<Form.Item label={calcLabelName(i
ntactData, i
tem, 'singular')}>
<Form.Item label={calcLabelName(item, 'singular')}>
<div className={styles.specsSingularBetween}>
<div className={styles.specsSingularBetween}>
<span className={styles.repertoryLimit}>
<span className={styles.repertoryLimit}>
{item?.specs[0]?.productStock}/{item?.specs[0]?.maxStock}
{item?.specs[0]?.productStock}/{item?.specs[0]?.maxStock}
...
@@ -1320,7 +1335,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -1320,7 +1335,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<div key={idx} className={styles.specsBetween}>
<div key={idx} className={styles.specsBetween}>
<Form.Item>
<Form.Item>
<div className={styles.specsBetween}>
<div className={styles.specsBetween}>
<div>{calcLabelName(i
ntactData, i
tem)} :</div>
<div>{calcLabelName(item)} :</div>
<span className={styles.repertoryLimit}>
<span className={styles.repertoryLimit}>
{item?.serviceItem?.productStock}/
{item?.serviceItem?.productStock}/
{item?.serviceItem?.maxStock}
{item?.serviceItem?.maxStock}
...
@@ -1331,7 +1346,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -1331,7 +1346,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
showAddRepertoryModal('multi', `
$
{
item
.
unique
}
`, item); // 多个库存
showAddRepertoryModal('multi', `
$
{
item
.
unique
}
`, item); // 多个库存
}}
}}
>
>
去设置
{item.id}
去设置
</div>
</div>
</div>
</div>
</Form.Item>
</Form.Item>
...
...
src/pages/ServiceGoods/utils.js
View file @
82e82977
...
@@ -114,7 +114,7 @@ export const filterSendData = (type, params) => {
...
@@ -114,7 +114,7 @@ export const filterSendData = (type, params) => {
// 外卖商品
// 外卖商品
if
(
type
===
5
)
{
if
(
type
===
5
)
{
const
temp
=
Object
.
assign
({},
takeawayItem
?.
intactData
,
infoMation
);
const
temp
=
Object
.
assign
({},
takeawayItem
?.
intactData
,
infoMation
);
const
deepTemp
=
JSON
.
parse
(
JSON
.
stringify
(
temp
))
const
deepTemp
=
JSON
.
parse
(
JSON
.
stringify
(
temp
))
;
deepTemp
.
categoryId
=
deepTemp
.
categoryId
=
Array
.
isArray
(
deepTemp
.
categoryId
)
&&
Array
.
isArray
(
deepTemp
.
categoryId
)
&&
...
@@ -127,8 +127,8 @@ export const filterSendData = (type, params) => {
...
@@ -127,8 +127,8 @@ export const filterSendData = (type, params) => {
item
.
productStock
=
item
?.
serviceItem
?.
productStock
;
item
.
productStock
=
item
?.
serviceItem
?.
productStock
;
item
.
list
=
deepTemp
.
list
;
item
.
list
=
deepTemp
.
list
;
if
(
item
?.
specs
?.
length
)
{
if
(
item
?.
specs
?.
length
)
{
item
?
.
specs
.
forEach
(
itm
=>
{
item
.
specs
.
forEach
(
itm
=>
{
if
(
tempWeightName
.
includes
(
itm
.
unit
))
{
if
(
itm
?.
unit
&&
tempWeightName
.
includes
(
itm
?
.
unit
))
{
itm
.
quantity
=
itm
.
quantity
=
`
${
itm
?.
quantity
}
`.indexOf('约') > -1 ? itm?.quantity : `
约
$
{
itm
?.
quantity
}
`;
`
${
itm
?.
quantity
}
`.indexOf('约') > -1 ? itm?.quantity : `
约
$
{
itm
?.
quantity
}
`;
}
}
...
@@ -138,13 +138,15 @@ export const filterSendData = (type, params) => {
...
@@ -138,13 +138,15 @@ export const filterSendData = (type, params) => {
deepTemp.specList &&
deepTemp.specList &&
deepTemp.specList.forEach(item => {
deepTemp.specList.forEach(item => {
if (item?.specs?.length) {
if (item?.specs?.length) {
item?.specs.forEach(itm => {
item.specs.forEach(itm => {
if (itm?.unit) {
itm.unit =
itm.unit =
(Array.isArray(itm.unit) &&
(Array.isArray(itm?.unit) &&
itm.unit?.length >= 2 &&
itm?.unit?.length >= 2 &&
itm.unit?.splice(itm.unit?.length - 1)[0]) ||
itm?.unit?.splice(itm?.unit?.length - 1)[0]) ||
itm.unit;
itm?.unit;
if (tempWeightName.includes(itm.unit)) {
}
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm.quantity =
`
$
{
itm
?.
quantity
}
`.indexOf('约') > -1 ? itm?.quantity : `
约
$
{
itm
?.
quantity
}
`;
`
$
{
itm
?.
quantity
}
`.indexOf('约') > -1 ? itm?.quantity : `
约
$
{
itm
?.
quantity
}
`;
}
}
...
...
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