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
28cf37c8
Commit
28cf37c8
authored
Apr 01, 2023
by
baxibaba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改商品逻辑
parent
12a59224
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
181 deletions
+150
-181
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+133
-172
index.jsx
src/pages/ServiceGoods/index.jsx
+17
-9
No files found.
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
28cf37c8
...
@@ -37,7 +37,7 @@ import styles from '../common.less';
...
@@ -37,7 +37,7 @@ import styles from '../common.less';
import
AddRepertoryModal
from
'
./AddRepertoryModal
'
;
import
AddRepertoryModal
from
'
./AddRepertoryModal
'
;
import
AddMultiSpecModal
from
'
./AddMultiSpecModal
'
;
import
AddMultiSpecModal
from
'
./AddMultiSpecModal
'
;
import
{
apiTagList
,
apiUnits
}
from
'
../service
'
;
import
{
apiTagList
,
apiUnits
}
from
'
../service
'
;
import
{
localAutoSaveKey
,
calcDescartes
}
from
'
../utils
'
;
import
{
localAutoSaveKey
,
calcDescartes
}
from
'
../utils
'
;
import
localStorage
from
'
@/utils/localStorage
'
;
import
localStorage
from
'
@/utils/localStorage
'
;
const
createInitValues
=
()
=>
({
const
createInitValues
=
()
=>
({
...
@@ -52,7 +52,7 @@ const createInitValues = () => ({
...
@@ -52,7 +52,7 @@ const createInitValues = () => ({
const
format
=
'
HH:mm
'
;
const
format
=
'
HH:mm
'
;
const
{
RangePicker
}
=
DatePicker
;
const
{
RangePicker
}
=
DatePicker
;
const
TakeawayGoodsInfo
=
forwardRef
((
props
,
ref
)
=>
{
const
TakeawayGoodsInfo
=
forwardRef
((
props
,
ref
)
=>
{
const
{
editData
}
=
props
;
const
{
editData
,
infoMation
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
[
initValue
,
setInitValue
]
=
useState
(
createInitValues
());
const
[
initValue
,
setInitValue
]
=
useState
(
createInitValues
());
const
customer
=
useContext
(
ServiceContext
);
const
customer
=
useContext
(
ServiceContext
);
...
@@ -99,6 +99,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -99,6 +99,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
takeawayCalc
=
takeawayData
=>
{
const
takeawayCalc
=
takeawayData
=>
{
// 商品基本信息编辑商品名称
// 商品基本信息编辑商品名称
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
}
=
takeawayData
;
const
{
infoMation
:
name
,
infoMation
,
takeawayItem
}
=
takeawayData
;
console
.
log
(
'
infoMation====
'
,
name
,
infoMation
);
// weight 份量 specs规格 生成sku规则 weight * specs
// weight 份量 specs规格 生成sku规则 weight * specs
const
{
const
{
specs
=
[],
specs
=
[],
...
@@ -123,23 +124,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -123,23 +124,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
categoryId
,
categoryId
,
}
=
takeawayItem
;
}
=
takeawayItem
;
console
.
log
(
"
weight
"
,
weight
);
console
.
log
(
"
sepcx
"
,
specs
)
// const sepcx = specs.map(item => item.specs)
// let sku = [[...weight],...sepcx].reduce((x,y) =>{
// let arr = [];
// x.forEach(x => y.forEach(y => arr.push(x.concat([y]))))
// return arr;
// },[[]])
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 单规格
const
singularSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 单规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 多规格
const
multiSpecList
=
[{
specGroupName
:
'
份量
'
,
generateSku
:
1
,
specs
:
[]
}];
// 多规格
// const multiSpu = customer.isEdit ? skuList:[]; // 多库存spu、
// const multiSpu = customer.isEdit ? skuList:[]; // 多库存spu、
const
multiSpu
=
[];
// 多库存spu、
let
multiSpuData
=
[];
// 多库存spu、
let
singularSpu
=
[];
// 单库存spu
let
singularSpu
=
[];
// 单库存spu
const
saleTimesTemp
=
[];
const
saleTimesTemp
=
[];
...
@@ -170,6 +158,19 @@ console.log("sepcx",specs)
...
@@ -170,6 +158,19 @@ console.log("sepcx",specs)
autoStock
,
// 弹框设置---自动补足
autoStock
,
// 弹框设置---自动补足
},
},
};
};
let
serviceItem
=
{
description
,
// 商品描述
maxStock
,
// 最大库存
productStock
,
minPurchaseNum
,
// 最少购买
saleTimeType
,
// 售卖时间
singleDelivery
,
// 单点不送
list
,
// 是否列出 1 是 0 否(外卖商品必填)
label
,
// 商品标签id
saleDates
,
// 可售日期 1-8
saleTimes
:
saleTimesTemp
,
// 可售日期 时间段
autoStock
,
// 弹框设置---自动补足
};
// 单规格
// 单规格
if
(
+
repertoryType
===
1
)
{
if
(
+
repertoryType
===
1
)
{
...
@@ -186,128 +187,77 @@ console.log("sepcx",specs)
...
@@ -186,128 +187,77 @@ console.log("sepcx",specs)
singularSpu
=
[{
...
temp
,
specs
:
[
specs
]
}];
singularSpu
=
[{
...
temp
,
specs
:
[
specs
]
}];
setSingularSpu
(
singularSpu
);
setSingularSpu
(
singularSpu
);
}
}
console
.
log
(
"
weight
"
,
weight
,
repertoryType
,
weight
.
length
);
console
.
log
(
'
weight
'
,
weight
,
repertoryType
,
weight
.
length
);
// 多规格
// 多规格
if
(
+
repertoryType
===
2
)
{
if
(
+
repertoryType
===
2
)
{
//
if (name || editData.name) {
if
(
name
||
editData
.
name
)
{
if
(
weight
.
length
)
{
if
(
weight
.
length
)
{
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
multiSpecList
[
0
].
specs
=
weight
;
// 处理specList
if
(
specs
.
length
)
{
if
(
specs
.
length
)
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
specs
.
forEach
((
specsItem
,
specsIndex
)
=>
{
if
(
specsItem
&&
!
specsItem
.
generateSku
)
{
if
(
specsItem
&&
!
specsItem
.
generateSku
)
{
specsItem
.
generateSku
=
1
;
specsItem
.
generateSku
=
1
;
}
}
multiSpecList
.
push
(
specsItem
)
multiSpecList
.
push
(
specsItem
);
})
});
}
}
console
.
log
(
"
multiSpecList
"
,
multiSpecList
);
const
sepcx
=
specs
.
map
(
item
=>
item
.
specs
);
// 生成 specs 规格sku
let
tempSku
=
[[...
weight
],
...
sepcx
].
reduce
(
// const sepcx = specs.map(item => item.specs)
(
x
,
y
)
=>
{
// let sku = [[...weight],...sepcx].reduce((x,y) =>{
let
arr
=
[];
// let arr = [];
x
.
forEach
(
x
=>
y
.
forEach
(
y
=>
arr
.
push
(
x
.
concat
([
y
]))));
// x.forEach(x => y.forEach(y => arr.push(x.concat([y]))))
return
arr
;
// return arr;
},
// },[[]])
[[]],
let
result
=
[]
);
weight
.
forEach
(
item
=>
{
console
.
log
(
"
item
"
,
item
);
specs
.
forEach
((
itm
,
idx
)
=>
{
console
.
log
(
"
itm
"
,
itm
);
itm
.
specs
.
forEach
((
it
,
idx
)
=>
{
result
.
push
({...
temp
,
specs
:[
item
,
specs
[
idx
],
it
]})
})
})
})
console
.
log
(
result
,
"
result
"
)
multiSpuData
=
tempSku
.
map
((
item
,
index
)
=>
{
// weight.forEach((item, weightIndex) => {
let
obj
=
{};
// if (item?.unit && item?.unit.length) {
obj
.
salePrice
=
salePrice
;
// item.unit =
obj
.
productStock
=
productStock
;
// item?.unit &&
obj
.
list
=
list
;
// (Array.isArray(item?.unit) ? item.unit.slice(item.unit.length - 1)[0] : item.unit);
obj
.
serviceItem
=
{
...
serviceItem
};
// }
obj
.
unique
=
''
;
// if (item && !item.specGroupName) {
multiSpecList
.
forEach
((
itm
,
idx
)
=>
{
// item.specGroupName = '份量';
if
(
item
[
idx
]
&&
!
item
[
idx
]?.
specGroupName
)
{
// }
item
[
idx
].
specGroupName
=
''
;
// if (item && !item.generateSku) {
item
[
idx
].
specGroupName
=
multiSpecList
[
idx
].
specGroupName
;
// item.generateSku = 1;
}
// }
});
// multiSpecList[0].specs = weight; // 处理specList
obj
.
specs
=
[...
item
];
// // 循环一次 插入规则列表
return
obj
;
// let isFirstLoops = true;
});
}
console
.
log
(
multiSpuData
,
'
multiSpuData
'
);
// if (specs.length) {
multiSpuData
.
map
(
item
=>
{
// specs.forEach((specsItem, specsIndex) => {
console
.
log
(
'
item
'
,
item
);
// if (specsItem && !specsItem.generateSku) {
item
.
salePrice
=
0
;
// specsItem.generateSku = 1;
item
.
unique
=
item
?.
specs
// }
.
map
(
itm
=>
{
// if (isFirstLoops && multiSpecList.length < specs.length + 1) {
itm
.
unit
=
// multiSpecList.push(specsItem); // 处理specList
itm
.
unit
&&
// }
(
Array
.
isArray
(
itm
?.
unit
)
?
itm
.
unit
.
slice
(
itm
.
unit
.
length
-
1
)[
0
]
:
itm
.
unit
);
// if (specsItem.specs.length > 1) {
// specsItem.specs.forEach((itm, idx) => {
// const params = {
// initIndex,
// unique: `${item.specName}-${specsItem.specGroupName}-${specsItem.specs[idx].specName}`,
// ...JSON.parse(JSON.stringify(temp)),
// // ...intactData?.items[initIndex],
// specs: [
// { ...item },
// { ...specsItem.specs[idx], specGroupName: specsItem.specGroupName },
// ],
// };
// multiSpu.push(params); // 处理spu
if
(
itm
?.
specName
)
{
// initIndex++;
return
itm
.
specName
;
// });
// } else {
// const params = {
// initIndex,
// unique: `${item.specName}-${specsItem.specGroupName}-${specsItem.specs[0].specName}`,
// ...JSON.parse(JSON.stringify(temp)),
// // ...intactData?.items[initIndex],
// specs: [
// { ...item },
// { ...specsItem.specs[0], specGroupName: specsItem.specGroupName },
// ],
// };
// multiSpu.push(params); // 处理spu
// initIndex++;
// }
// });
// isFirstLoops = false;
// } else {
// const params = {
// initIndex,
// unique: `${item?.specName}`,
// ...JSON.parse(JSON.stringify(temp)),
// // ...intactData?.items[initIndex],
// specs: [{ ...item }],
// };
// multiSpu.push(params); // 处理spu
// initIndex++;
// }
// });
}
}
// }
})
.
toString
();
console
.
log
(
"
multiSpu
"
,
multiSpu
);
});
}
console
.
log
(
'
sku
'
,
multiSpuData
);
if
(
tempMultiSpu
.
length
)
{
if
(
tempMultiSpu
.
length
)
{
multiSpu
.
forEach
((
item
,
index
)
=>
{
multiSpu
Data
.
forEach
((
item
,
index
)
=>
{
tempMultiSpu
.
forEach
((
itm
,
idx
)
=>
{
tempMultiSpu
.
forEach
((
itm
,
idx
)
=>
{
if
(
item
.
unique
===
itm
.
unique
)
{
if
(
item
.
unique
===
itm
.
unique
)
{
item
.
serviceItem
=
objectComparison
(
item
.
serviceItem
,
itm
);
item
.
serviceItem
=
objectComparison
(
item
.
serviceItem
,
itm
);
item
.
id
=
itm
.
id
;
}
}
});
});
});
});
}
}
// let weight= form.getFieldValue('weight')
setMultiSpu
(
JSON
.
parse
(
JSON
.
stringify
(
multiSpuData
)));
console
.
log
(
"
weight
"
,
weight
);
console
.
log
(
multiSpu
,
tempMultiSpu
,
'
multiSpumultiSpu
'
);
setMultiSpu
(
multiSpu
);
}
}
// +repertoryType === 1 单规格 2多规格
// +repertoryType === 1 单规格 2多规格
const
intactDataTemp
=
{
const
intactDataTemp
=
{
...
@@ -321,7 +271,7 @@ console.log(result,"result")
...
@@ -321,7 +271,7 @@ console.log(result,"result")
detailImageList
,
detailImageList
,
singleDelivery
,
singleDelivery
,
specList
:
+
repertoryType
===
1
?
singularSpecList
:
multiSpecList
,
// 单库存和多库存specList
specList
:
+
repertoryType
===
1
?
singularSpecList
:
multiSpecList
,
// 单库存和多库存specList
items
:
+
repertoryType
===
1
?
singularSpu
:
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
)),
items
:
+
repertoryType
===
1
?
singularSpu
:
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
Data
)),
// categoryId:
// categoryId:
// (
// (
// infoMation?.categoryId &&
// infoMation?.categoryId &&
...
@@ -330,6 +280,7 @@ console.log(result,"result")
...
@@ -330,6 +280,7 @@ console.log(result,"result")
// (Array.isArray(categoryId) && categoryId?.slice(categoryId?.length - 1)?.toString()),
// (Array.isArray(categoryId) && categoryId?.slice(categoryId?.length - 1)?.toString()),
};
};
console
.
log
(
'
intactDataTemp
'
,
intactDataTemp
);
setIntactData
(
intactDataTemp
);
setIntactData
(
intactDataTemp
);
return
intactData
;
return
intactData
;
};
};
...
@@ -344,6 +295,7 @@ console.log(result,"result")
...
@@ -344,6 +295,7 @@ console.log(result,"result")
};
};
const
onChange
=
()
=>
{};
const
onChange
=
()
=>
{};
const
getFormValues
=
debounce
(()
=>
{
const
getFormValues
=
debounce
(()
=>
{
console
.
log
(
'
eeeee
'
,
editData
);
const
values
=
form
.
getFieldsValue
();
const
values
=
form
.
getFieldsValue
();
props
.
onValuesChange
({
takeawayItem
:
JSON
.
parse
(
JSON
.
stringify
(
values
))
});
props
.
onValuesChange
({
takeawayItem
:
JSON
.
parse
(
JSON
.
stringify
(
values
))
});
const
takeawayData
=
customer
.
isEdit
const
takeawayData
=
customer
.
isEdit
...
@@ -364,10 +316,10 @@ console.log(result,"result")
...
@@ -364,10 +316,10 @@ console.log(result,"result")
}
}
return
item
;
return
item
;
});
});
let
temp
=
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
));
//
let temp = JSON.parse(JSON.stringify(multiSpu));
tempMultiSpu
.
push
(...
temp
);
//
tempMultiSpu.push(...temp);
setTempMultiSpu
(
tempMultiSpu
);
//
setTempMultiSpu(tempMultiSpu);
setMultiSpu
(
temp
);
//
setMultiSpu(temp);
}
}
if
(
type
===
'
all
'
)
{
if
(
type
===
'
all
'
)
{
multiSpu
.
map
(
item
=>
{
multiSpu
.
map
(
item
=>
{
...
@@ -376,11 +328,17 @@ console.log(result,"result")
...
@@ -376,11 +328,17 @@ console.log(result,"result")
item
.
serviceItem
.
maxStock
=
maxStock
;
item
.
serviceItem
.
maxStock
=
maxStock
;
return
item
;
return
item
;
});
});
// let temp = JSON.parse(JSON.stringify(multiSpu));
// tempMultiSpu.push(...temp);
// setTempMultiSpu(tempMultiSpu);
// setMultiSpu(multiSpu);
}
let
temp
=
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
));
let
temp
=
JSON
.
parse
(
JSON
.
stringify
(
multiSpu
));
tempMultiSpu
.
push
(...
temp
);
tempMultiSpu
.
push
(...
temp
);
console
.
log
(
'
tempMultiSpu2
'
,
tempMultiSpu
);
setTempMultiSpu
(
tempMultiSpu
);
setTempMultiSpu
(
tempMultiSpu
);
setMultiSpu
(
multiSpu
);
setMultiSpu
(
temp
);
}
console
.
log
(
'
multiSpu===333
'
,
multiSpu
);
getFormValues
();
getFormValues
();
return
false
;
return
false
;
};
};
...
@@ -485,19 +443,22 @@ console.log(result,"result")
...
@@ -485,19 +443,22 @@ console.log(result,"result")
AddRepertoryRef
.
current
.
setOpenRepertory
(
true
);
AddRepertoryRef
.
current
.
setOpenRepertory
(
true
);
setRepertoryModel
({
type
,
idx
,
item
});
setRepertoryModel
({
type
,
idx
,
item
});
};
};
const
onFinish
=
values
=>
{
console
.
log
(
'
Received values of form:
'
,
values
);
};
// 拼接sku 名称
// 拼接sku 名称
const
calcLabelName
=
(
intactData
,
item
)
=>
{
const
calcLabelName
=
(
intactData
,
item
)
=>
{
// const tempName = `${intactData?.name || ''}`;
let
firstName
=
''
;
const
tempSpecName
=
`
${
item
?.
specs
[
0
]?.
specName
||
''
}
`;
let
lastName
=
''
;
const tempQuantity = `
(
$
{
item
.
specs
[
0
]?.
quantity
||
''
}
`;
const
tempName
=
`
${
editData
?.
name
||
''
}
`;
const tempUnit = `
$
{
item
.
specs
[
0
]?.
unit
||
''
})
`;
// const tempSpecName = `
$
{
item
?.
specs
[
0
]?.
specName
||
''
}
`;
const tempSecondSpecName = `
$
{
item
.
specs
[
1
]?.
specName
||
''
}
`;
const tempQuantity = `
$
{
item
.
specs
[
0
]?.
quantity
?
'
(
'
:
''
}
$
{
item
.
specs
[
0
]?.
quantity
||
''
}
`;
const tempUnit = `
$
{
item
.
specs
[
0
]?.
unit
||
''
}
$
{
item
.
specs
[
0
]?.
unit
?
'
)
'
:
''
}
`;
// const tempSecondSpecName = `
$
{
item
.
specs
[
1
]?.
specName
||
''
}
`;
// const isShow = tempQuantity && tempUnit && '+';
// const isShow = tempQuantity && tempUnit && '+';
//
${
tempName
}
const uniqueName = item?.unique?.split(',') || [];
return `
$
{
tempSpecName
}
$
{
tempQuantity
}
$
{
tempUnit
}
$
{
tempSecondSpecName
}
`;
if (uniqueName && uniqueName.length) {
firstName = uniqueName[0] || '';
lastName = uniqueName?.slice(1).join(' ') || '';
}
return `
$
{
tempName
}
$
{
firstName
}
$
{
tempQuantity
}
$
{
tempUnit
}
$
{
lastName
}
`;
};
};
const init = async () => {
const init = async () => {
if (!tagList.length) {
if (!tagList.length) {
...
@@ -523,6 +484,7 @@ console.log(result,"result")
...
@@ -523,6 +484,7 @@ console.log(result,"result")
editData.label = label.split(',').map(item => +item);
editData.label = label.split(',').map(item => +item);
let specList = editData?.specList;
let specList = editData?.specList;
let weight = specList.filter(item => item.specGroupName === '份量');
let weight = specList.filter(item => item.specGroupName === '份量');
let specs = specList.filter(item => item.specGroupName !== '份量');
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
weight.forEach(item => {
weight.forEach(item => {
if (item?.specs?.length) {
if (item?.specs?.length) {
...
@@ -537,7 +499,7 @@ console.log(result,"result")
...
@@ -537,7 +499,7 @@ console.log(result,"result")
if (editData?.skuList.length) {
if (editData?.skuList.length) {
editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum;
editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum;
// 单规格
// 单规格
if (
editData?.skuList.length === 1
) {
if (
specs.length === 0 && !editData?.specList[0]?.specs[0]?.activityPrice
) {
let {
let {
productStock,
productStock,
shopId,
shopId,
...
@@ -546,7 +508,7 @@ console.log(result,"result")
...
@@ -546,7 +508,7 @@ console.log(result,"result")
} = editData?.skuList[0];
} = editData?.skuList[0];
let { quantity, unit, salePrice } = specs[0];
let { quantity, unit, salePrice } = specs[0];
editData.productStock = productStock;
editData.productStock = productStock;
editData.quantity =
`
$
{
quantity
}
`.indexOf('约') > -1 ? quantity.slice(1) :quantity || '';
;
editData.quantity =
`
$
{
quantity
}
`.indexOf('约') > -1 ? quantity.slice(1) : quantity || ''
;
editData.unit = unit;
editData.unit = unit;
editData.salePrice = salePrice;
editData.salePrice = salePrice;
editData.maxStock = maxStock;
editData.maxStock = maxStock;
...
@@ -583,7 +545,7 @@ console.log(result,"result")
...
@@ -583,7 +545,7 @@ console.log(result,"result")
});
});
}
}
});
});
let specs = specList.filter(item => item.specGroupName !== '份量
');
console.log(specs, 'specs
');
editData.categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId];
editData.categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId];
editData.saleTimeType = saleTimeType;
editData.saleTimeType = saleTimeType;
editData.saleDates = saleDates;
editData.saleDates = saleDates;
...
@@ -602,13 +564,19 @@ console.log(result,"result")
...
@@ -602,13 +564,19 @@ console.log(result,"result")
form.setFieldsValue({ specs });
form.setFieldsValue({ specs });
const tempMultiSpu = editData?.skuList.map(item => {
const tempMultiSpu = editData?.skuList.map(item => {
if (item) {
if (item) {
let weightIdx = item.specs.findIndex(itm => itm.specGroupName === '份量');
item.serviceItem.productStock = item.productStock;
let specsIdx = item.specs.findIndex(itm => itm.specGroupName !== '份量');
let weightIndex = item.specs.findIndex(itm => itm.specGroupName === '份量');
item.unique = `
$
{
item
.
specs
[
weightIdx
]?.
specName
}
-
$
{
item
.
specs
[
specsIdx
]?.
specGroupName
}
-
$
{
item
.
specs
[
specsIdx
]?.
specName
}
`;
let tempQuantity = item.specs[weightIndex].quantity;
let tempUnit = item.specs[weightIndex].unit;
let specsNameList = item.specs.map(itm => itm.specGroupName);
let lastName = specsNameList.slice(1)?.join(' ');
item.unique = `
$
{
specsNameList
[
0
]}
(
$
{
tempQuantity
}
$
{
tempUnit
})
$
{
lastName
}
`;
}
}
return item;
return item;
});
});
console.log('tempMultiSpu111', tempMultiSpu);
setTempMultiSpu(tempMultiSpu || []);
setTempMultiSpu(tempMultiSpu || []);
setMultiSpu(tempMultiSpu);
}
}
form.setFieldsValue({ productRefShopId: editData.shopId });
form.setFieldsValue({ productRefShopId: editData.shopId });
onCardSuccessImageList(editData?.detailImageList);
onCardSuccessImageList(editData?.detailImageList);
...
@@ -661,12 +629,7 @@ console.log(result,"result")
...
@@ -661,12 +629,7 @@ console.log(result,"result")
label="最少购买"
label="最少购买"
// rules={[{ required: true, message: '每日最低接待量' }]}
// rules={[{ required: true, message: '每日最低接待量' }]}
>
>
<InputNumber
<InputNumber min={1} max={999999999} style={{ width: 200 }} placeholder="请输入购买量" />
min={1}
max={999999999}
style={{ width: 200 }}
placeholder="请输入购买量"
/>
</Form.Item>
</Form.Item>
<Form.Item
<Form.Item
name="saleTimeType"
name="saleTimeType"
...
@@ -1013,7 +976,9 @@ console.log(result,"result")
...
@@ -1013,7 +976,9 @@ console.log(result,"result")
placeholder="活动价(元)"
placeholder="活动价(元)"
/>
/>
</Form.Item>
</Form.Item>
{weightFields.length > 1 ? (
<MinusCircleOutlined onClick={() => weightRemove(weightField.name)} />
<MinusCircleOutlined onClick={() => weightRemove(weightField.name)} />
) : null}
</Space>
</Space>
))}
))}
...
@@ -1067,21 +1032,16 @@ console.log(result,"result")
...
@@ -1067,21 +1032,16 @@ console.log(result,"result")
>
>
<Input placeholder="规格名称" className={styles.nameWidth} />
<Input placeholder="规格名称" className={styles.nameWidth} />
</Form.Item>
</Form.Item>
{
/* {specsFields.length > 1 ? ( */}
{
specsFields.length > 1 ? (
<MinusCircleOutlined
<MinusCircleOutlined
className="dynamic-delete-button"
className="dynamic-delete-button"
onClick={() => remove(specsField.name)}
onClick={() => remove(specsField.name)}
/>
/>
{/* ) : null} */
}
) : null
}
<Form.List
<Form.List
{...specsField}
{...specsField}
name={[specsField.name, 'specs']}
name={[specsField.name, 'specs']}
initialValue={[
initialValue={[{}]}
{
specName: '',
salePrice: '',
},
]}
>
>
{(specsInfoFields, { add: specsAdd, remove: specsRemove }) => (
{(specsInfoFields, { add: specsAdd, remove: specsRemove }) => (
<>
<>
...
@@ -1117,10 +1077,11 @@ console.log(result,"result")
...
@@ -1117,10 +1077,11 @@ console.log(result,"result")
placeholder="加价名称金额(元)"
placeholder="加价名称金额(元)"
/>
/>
</Form.Item>
</Form.Item>
{specsInfoFields.length > 1 ? (
<MinusCircleOutlined
<MinusCircleOutlined
onClick={() => specsRemove(specsInfofield.name)}
onClick={() => specsRemove(specsInfofield.name)}
/>
/>
) : null}
</Space>
</Space>
))}
))}
<Form.Item>
<Form.Item>
...
...
src/pages/ServiceGoods/index.jsx
View file @
28cf37c8
...
@@ -69,7 +69,7 @@ const ServiceGoods = options => {
...
@@ -69,7 +69,7 @@ const ServiceGoods = options => {
const
[
editData
,
setEditData
]
=
useState
({});
// 编辑保存数据
const
[
editData
,
setEditData
]
=
useState
({});
// 编辑保存数据
const
[
newCategoryList
,
setNewCategoryList
]
=
useState
({});
const
[
newCategoryList
,
setNewCategoryList
]
=
useState
({});
const
[
takeawayEditData
,
setTakeawayEditData
]
=
useState
({});
// 外卖编辑保存数据
const
[
takeawayEditData
,
setTakeawayEditData
]
=
useState
({});
// 外卖编辑保存数据
const
[
groupShopData
,
setGroupShopData
]
=
useState
(
''
)
// 从分组进入创建
const
[
groupShopData
,
setGroupShopData
]
=
useState
(
''
)
;
// 从分组进入创建
const
[
visibleCacheEdit
,
setVisibleCacheEdit
]
=
useState
(
false
);
// 显示有缓存未保存提示
const
[
visibleCacheEdit
,
setVisibleCacheEdit
]
=
useState
(
false
);
// 显示有缓存未保存提示
const
[
checkFormList
]
=
useState
([
const
[
checkFormList
]
=
useState
([
basicRef
,
basicRef
,
...
@@ -247,6 +247,7 @@ const ServiceGoods = options => {
...
@@ -247,6 +247,7 @@ const ServiceGoods = options => {
},
{});
},
{});
const
sendData
=
filterSendData
(
productType
,
params
);
const
sendData
=
filterSendData
(
productType
,
params
);
if
(
productType
===
5
)
{
if
(
productType
===
5
)
{
console
.
log
(
sendData
,
'
sendData
'
);
sendMerchantProductHttpRequest
(
sendData
);
sendMerchantProductHttpRequest
(
sendData
);
return
false
;
return
false
;
}
}
...
@@ -371,12 +372,12 @@ const ServiceGoods = options => {
...
@@ -371,12 +372,12 @@ const ServiceGoods = options => {
console
.
log
(
'
takeAway
'
,
takeAway
);
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
);
}
}
if
(
groupId
)
{
if
(
groupId
)
{
setGroupShopData
(
takeAway
)
setGroupShopData
(
takeAway
)
;
}
}
setProductType
(
5
);
setProductType
(
5
);
}
}
...
@@ -487,9 +488,13 @@ const ServiceGoods = options => {
...
@@ -487,9 +488,13 @@ const ServiceGoods = options => {
maskClosable=
{
false
}
maskClosable=
{
false
}
keyboard=
{
false
}
keyboard=
{
false
}
footer=
{
[
footer=
{
[
productType
===
5
?
''
:
<
Button
key=
"draft"
type=
"primary"
ghost
loading=
{
pageLoading
}
onClick=
{
onSaveDraft
}
>
productType
===
5
?
(
''
)
:
(
<
Button
key=
"draft"
type=
"primary"
ghost
loading=
{
pageLoading
}
onClick=
{
onSaveDraft
}
>
保存草稿
保存草稿
</
Button
>,
</
Button
>
),
<
Button
key=
"submit"
type=
"primary"
loading=
{
pageLoading
}
onClick=
{
submitEvent
}
>
<
Button
key=
"submit"
type=
"primary"
loading=
{
pageLoading
}
onClick=
{
submitEvent
}
>
提交
提交
</
Button
>,
</
Button
>,
...
@@ -510,7 +515,11 @@ const ServiceGoods = options => {
...
@@ -510,7 +515,11 @@ const ServiceGoods = options => {
)
}
)
}
<
ServiceContext
.
Provider
value=
{
providerValue
}
>
<
ServiceContext
.
Provider
value=
{
providerValue
}
>
<
Title
title=
"商品类型"
/>
<
Title
title=
"商品类型"
/>
<
TaskTypeSelect
productType=
{
productType
}
takeAway=
{
takeAway
}
onChange=
{
productChange
}
/>
<
TaskTypeSelect
productType=
{
productType
}
takeAway=
{
takeAway
}
onChange=
{
productChange
}
/>
<
Title
title=
"商品基本信息编辑"
/>
<
Title
title=
"商品基本信息编辑"
/>
<
FormInformationBasic
<
FormInformationBasic
...
@@ -589,7 +598,6 @@ const ServiceGoods = options => {
...
@@ -589,7 +598,6 @@ const ServiceGoods = options => {
ref=
{
takeawayRef
}
ref=
{
takeawayRef
}
takeAway=
{
takeAway
}
takeAway=
{
takeAway
}
editData=
{
takeawayEditData
}
editData=
{
takeawayEditData
}
infoMation=
{
editData
.
infoMation
}
supplierIdList=
{
supplierIdList
}
supplierIdList=
{
supplierIdList
}
onValuesChange=
{
onValuesChange
}
onValuesChange=
{
onValuesChange
}
/>
/>
...
...
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