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
5d4359f5
Commit
5d4359f5
authored
Apr 06, 2023
by
陈万宝
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改新增商品无法同步sku
parent
ad22d13b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
56 deletions
+61
-56
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+61
-56
No files found.
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
5d4359f5
...
...
@@ -49,6 +49,7 @@ const createInitValues = () => ({
singleDelivery
:
0
,
// 单点不送
list
:
1
,
// 列出商品
label
:
[],
minPurchaseNum
:
1
,
});
const
format
=
'
HH:mm
'
;
const
{
RangePicker
}
=
DatePicker
;
...
...
@@ -99,6 +100,15 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
return
null
;
}
};
// 过滤对象
const
objectComparison
=
(
item
,
itm
)
=>
{
const
{
serviceItem
:
{
maxStock
,
autoStock
,
productStock
},
}
=
itm
;
const
params
=
{
maxStock
,
autoStock
,
productStock
:
productStock
||
itm
.
productStock
};
const
temp
=
{
...
item
,
...
params
};
return
temp
;
};
const
takeawayCalc
=
takeawayData
=>
{
// 商品基本信息编辑商品名称
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
}
=
takeawayData
;
...
...
@@ -109,7 +119,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
description
,
detailImageList
,
list
,
minPurchaseNum
=
1
,
minPurchaseNum
,
saleDates
,
maxStock
=
0
,
saleTimes
=
[],
...
...
@@ -124,7 +134,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
id
,
categoryId
,
}
=
takeawayItem
;
let
unit
=
takeawayItem
.
unit
;
let
{
unit
}
=
takeawayItem
;
unit
=
(
unit
&&
(
Array
.
isArray
(
unit
)
&&
unit
?.
length
&&
unit
?.
slice
(
1
).
toString
()))
||
unit
;
console
.
log
(
takeawayItem
,
'
takeawayItem
'
);
...
...
@@ -180,9 +190,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setSingularSpu
(
singularSpu
);
console
.
log
(
'
singularSpu
'
,
singularSpu
);
}
console
.
log
(
'
name || editData.name
'
,
name
,
editData
.
name
,
weight
);
// 多规格
if
(
+
repertoryType
===
2
)
{
if
(
name
||
editData
.
name
)
{
//
if (name || editData.name) {
if
(
weight
.
length
)
{
let
tempSku
=
[];
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
...
...
@@ -202,11 +214,12 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
sepcx
=
specs
.
map
(
item
=>
item
.
specs
);
sepcx
.
map
(
item
=>
{
item
.
unit
=
''
;
return
item
});
// 生成 specs 规格sku
tempSku
=
[[...
weight
],
...
sepcx
].
reduce
(
(
x
,
y
)
=>
{
le
t
arr
=
[];
cons
t
arr
=
[];
x
.
forEach
(
x
=>
y
.
forEach
(
y
=>
arr
.
push
(
x
.
concat
([
y
]))));
return
arr
;
},
...
...
@@ -214,10 +227,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
);
console
.
log
(
'
multiSpu1111
'
,
multiSpu
);
multiSpu
=
tempSku
.
map
((
item
,
index
)
=>
{
le
t
obj
=
{};
cons
t
obj
=
{};
obj
.
salePrice
=
salePrice
;
obj
.
productStock
=
productStock
;
obj
.
list
=
list
;
obj
.
id
=
multiSpu
?.[
index
]?.
id
||
''
obj
.
serviceItem
=
{
...
temp
.
serviceItem
,
productStock
:
multiSpu
?.[
index
]?.
serviceItem
?.
productStock
||
productStock
,
...
...
@@ -269,7 +283,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
console
.
log
(
multiSpu
,
'
multiSpumultiSpu
'
);
setMultiSpu
(
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
)));
}
//
}
}
// +repertoryType === 1 单规格 2多规格
const
intactDataTemp
=
{
...
...
@@ -296,15 +310,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setIntactData
(
intactDataTemp
);
return
intactData
;
};
// 过滤对象
const
objectComparison
=
(
item
,
itm
)
=>
{
let
{
serviceItem
:
{
maxStock
,
autoStock
,
productStock
},
}
=
itm
;
let
params
=
{
maxStock
,
autoStock
,
productStock
:
productStock
||
itm
.
productStock
};
let
temp
=
{
...
item
,
...
params
};
return
temp
;
};
const
onChange
=
()
=>
{};
const
getFormValues
=
debounce
(()
=>
{
const
values
=
form
.
getFieldsValue
();
...
...
@@ -340,7 +346,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
return
item
;
});
}
le
t
temp
=
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
));
cons
t
temp
=
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
));
tempMultiSpu
.
push
(...
temp
);
setTempMultiSpu
(
tempMultiSpu
);
setMultiSpu
(
multiSpu
);
...
...
@@ -392,7 +398,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
);
// 切换库存
const
onChangeRepertory
=
e
=>
{
const
value
=
e
.
target
.
value
;
const
{
value
}
=
e
.
target
;
setRepertoryType
(
`
${
value
}
`
);
if
(
+
value
===
1
)
{
form
.
setFieldsValue
({
weight
:
[]
});
...
...
@@ -475,8 +481,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if (!unitsList.length) {
const res = await apiUnits();
setUnitsList(res.data || []);
le
t tempWeight = res.data.filter(item => item.name === '准确重量单位');
le
t tempPeople = res.data.filter(item => item.name === '适用人数');
cons
t tempWeight = res.data.filter(item => item.name === '准确重量单位');
cons
t tempPeople = res.data.filter(item => item.name === '适用人数');
if (tempWeight.length && tempWeight[0]?.children) {
const tempWeightName = tempWeight[0]?.children.map(item => item.name);
...
...
@@ -495,7 +501,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
useEffect(() => {
if (customer.isEdit || customer.isUseCache) {
if (!editData) return;
le
t {
cons
t {
label,
firstCategoryId,
secondCategoryId,
...
...
@@ -505,9 +511,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
saleTimeType,
} = editData;
editData.label = label && label.split(',')?.map(item => +item);
le
t specList = editData?.specList;
le
t weight = specList?.filter(item => item.specGroupName === '份量');
le
t specs = specList?.filter(item => item.specGroupName !== '份量');
cons
t specList = editData?.specList;
cons
t weight = specList?.filter(item => item.specGroupName === '份量');
cons
t specs = specList?.filter(item => item.specGroupName !== '份量');
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
weight?.forEach(item => {
if (item?.specs?.length) {
...
...
@@ -520,40 +526,38 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}
});
editData.saleTimes = saleTimes?.length
? saleTimes.map(item => {
return [moment(item?.startTime, format), moment(item?.endTime, format)];
})
? saleTimes.map(item => [moment(item?.startTime, format), moment(item?.endTime, format)])
: [];
if (editData?.skuList?.length) {
// editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum;
// 单规格
if (editData?.skuList?.length === 1) {
le
t {
cons
t {
productStock,
shopId,
specs,
serviceItem: { maxStock, id, autoStock },
} = editData?.skuList[0];
le
t { quantity, unit, salePrice } = specs[0];
cons
t { quantity, unit, salePrice } = specs[0];
editData.productStock = productStock;
editData.quantity = `
$
{
quantity
}
`.indexOf('约') > -1 ? quantity.slice(1) : quantity || '';
editData.unit = unit;
editData.salePrice = salePrice;
editData.maxStock = maxStock;
editData.categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId];
editData.autoStock = +autoStock === 1
? true : false
;
editData.autoStock = +autoStock === 1;
editData.productRefShopId = editData.shopId;
editData.skuId = id;
// setSingularSpu(JSON.parse(JSON.stringify(tempMultiSpu)) || []);
form.setFieldsValue(editData);
} else {
// 多规格
setRepertoryType(
`
2
`
);
le
t {
setRepertoryType(
'2'
);
cons
t {
serviceItem: { saleTimeType, saleDates, saleTimes },
} = editData?.skuList[0];
le
t specList = editData?.specList;
le
t weight = specList.filter(item => item.specGroupName === '份量');
cons
t specList = editData?.specList;
cons
t weight = specList.filter(item => item.specGroupName === '份量');
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
weight?.forEach(item => {
if (item?.specs?.length) {
...
...
@@ -579,11 +583,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if (item) {
console.log('item===', item);
item.serviceItem.productStock = item.productStock;
le
t weightIndex = item.specs.findIndex(itm => itm.specGroupName === '份量');
le
t tempQuantity = item.specs[weightIndex].quantity;
le
t tempUnit = item.specs[weightIndex].unit;
le
t specsNameList = item.specs.map(itm => itm.specName);
le
t lastName = specsNameList.slice(1)?.join(' ');
cons
t weightIndex = item.specs.findIndex(itm => itm.specGroupName === '份量');
cons
t tempQuantity = item.specs[weightIndex].quantity;
cons
t tempUnit = item.specs[weightIndex].unit;
cons
t specsNameList = item.specs.map(itm => itm.specName);
cons
t lastName = specsNameList.slice(1)?.join(' ');
item.unique = item?.specs.map(itm => itm.specName).toString();
}
return item;
...
...
@@ -644,12 +648,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<Form.Item
name="minPurchaseNum"
label="最少购买"
rules={[{ required: true, message: '请输入最少购买数' },
{
validator: isIntegerNotZero,
type: 'number',
message: '请输入大于0的整数',
},]}
rules={[
{ required: true, message: '请输入最少购买数' },
{
validator: isIntegerNotZero,
type: 'number',
message: '请输入大于0的整数',
},
]}
>
<InputNumber min={1} max={999999999} style={{ width: 200 }} placeholder="请输入购买量" />
</Form.Item>
...
...
@@ -833,7 +839,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'name', children: 'children' }}
onChange={() => {
le
t unit = form.getFieldValue('unit') || [];
cons
t unit = form.getFieldValue('unit') || [];
if (unit && peopleUnits.includes(unit[1])) {
form.setFieldsValue({ quantity: '' });
}
...
...
@@ -889,13 +895,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<Form.Item
name="maxStock"
label="最大库存"
rules={[{ required: isRequired, message: '请填写最大库存' },
{
validator: isIntegerNotZero,
type: 'number',
message: '请输入大于0的整数',
},
]}
rules={[
{ required: isRequired, message: '请填写最大库存' },
{
validator: isIntegerNotZero,
type: 'number',
message: '请输入大于0的整数',
},
]}
>
<InputNumber
max={999999999}
...
...
@@ -988,11 +995,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
name={[weightField.name, 'quantity']}
rules={[
{
required: peopleUnits.includes(
required:
!
peopleUnits.includes(
form.getFieldValue(['weight'])?.[index]?.unit,
)
? false
: true,
),
message: '份量',
},
{
...
...
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