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
cdf53e53
Commit
cdf53e53
authored
Mar 28, 2023
by
baxibaba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 更新外卖商品
parent
8d5d77d7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
134 deletions
+51
-134
FormTakeaway.jsx
src/pages/ServiceGoods/components/FormTakeaway.jsx
+11
-119
index.jsx
src/pages/ServiceGoods/index.jsx
+34
-14
utils.js
src/pages/ServiceGoods/utils.js
+6
-1
No files found.
src/pages/ServiceGoods/components/FormTakeaway.jsx
View file @
cdf53e53
...
@@ -36,7 +36,7 @@ import AddSellTimeModal from './AddSellTimeModal';
...
@@ -36,7 +36,7 @@ import AddSellTimeModal from './AddSellTimeModal';
import
styles
from
'
../common.less
'
;
import
styles
from
'
../common.less
'
;
import
AddRepertoryModal
from
'
./AddRepertoryModal
'
;
import
AddRepertoryModal
from
'
./AddRepertoryModal
'
;
import
AddMultiSpecModal
from
'
./AddMultiSpecModal
'
;
import
AddMultiSpecModal
from
'
./AddMultiSpecModal
'
;
import
{
apiTagList
,
apiUnits
,
apiGetShopDetail
}
from
'
../service
'
;
import
{
apiTagList
,
apiUnits
}
from
'
../service
'
;
import
{
localAutoSaveKey
}
from
'
../utils
'
;
import
{
localAutoSaveKey
}
from
'
../utils
'
;
import
localStorage
from
'
@/utils/localStorage
'
;
import
localStorage
from
'
@/utils/localStorage
'
;
...
@@ -51,7 +51,7 @@ const createInitValues = () => ({
...
@@ -51,7 +51,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
,
infoMation
}
=
props
;
const
{
editData
,
infoMation
,
takeAway
}
=
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
);
...
@@ -63,7 +63,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -63,7 +63,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const
[
saleDates
,
setSaleDates
]
=
useState
({
const
[
saleDates
,
setSaleDates
]
=
useState
({
saleDates
:
[],
saleDates
:
[],
saleTimes
:
[],
saleTimes
:
[],
// saleTimes: [[moment('22-02', 'HH:mm'), moment('23-02', 'HH:mm')]],
});
// 可售日期
});
// 可售日期
const
[
timeType
,
setTimeType
]
=
useState
(
0
);
const
[
timeType
,
setTimeType
]
=
useState
(
0
);
const
[
repertoryType
,
setRepertoryType
]
=
useState
(
'
1
'
);
const
[
repertoryType
,
setRepertoryType
]
=
useState
(
'
1
'
);
...
@@ -178,7 +177,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -178,7 +177,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
weight
.
forEach
((
item
,
weightIndex
)
=>
{
weight
.
forEach
((
item
,
weightIndex
)
=>
{
console
.
log
(
'
eee====
'
,
item
);
console
.
log
(
'
eee====
'
,
item
);
if
(
item
?.
unit
&&
item
?.
unit
.
length
)
{
if
(
item
?.
unit
&&
item
?.
unit
.
length
)
{
item
.
unit
=
(
item
?.
unit
?.
slice
(
item
.
unit
.
length
-
1
)
)?.
toString
();
item
.
unit
=
item
?.
unit
?.
slice
(
item
.
unit
.
length
-
1
)?.
toString
();
}
}
if
(
item
&&
!
item
.
specGroupName
)
{
if
(
item
&&
!
item
.
specGroupName
)
{
item
.
specGroupName
=
'
份量
'
;
item
.
specGroupName
=
'
份量
'
;
...
@@ -321,16 +320,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -321,16 +320,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
tempMultiSpu.push(...temp);
tempMultiSpu.push(...temp);
setTempMultiSpu(tempMultiSpu);
setTempMultiSpu(tempMultiSpu);
setMultiSpu(temp);
setMultiSpu(temp);
console.log('33333========>', multiSpu, tempMultiSpu);
// if (intactData?.items.length) {
// intactData.items[+idx].serviceItem.productStock = productStock;
// intactData.items[+idx].serviceItem.autoStock = autoStock;
// intactData.items[+idx].serviceItem.maxStock = maxStock;
// console.log('index===2222', +idx, intactData);
// const temp = { ...intactData };
// setIntactData(temp);
// }
}
}
if (type === 'all') {
if (type === 'all') {
if (intactData?.items.length) {
if (intactData?.items.length) {
...
@@ -344,18 +333,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -344,18 +333,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setIntactData(temp);
setIntactData(temp);
}
}
}
}
return false;
return false;
};
};
const querGetShopDetail = async () => {
let params = {
id: '638899799727110',
shopId: 15,
};
const result = await apiGetShopDetail(params);
console.log('result', result);
};
const fileterBrandOptions = (input, options) => options.children.includes(input);
const filterCategoryOptions = (inputValue, path) =>
const filterCategoryOptions = (inputValue, path) =>
path.some(option => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
path.some(option => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
...
@@ -377,13 +356,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -377,13 +356,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
detailImageList: imgList,
detailImageList: imgList,
});
});
};
};
const radioChangeEvent = key => {
const value = form.getFieldValue(key);
setInitValue({
...initValue,
[key]: value,
});
};
// 自定义菜单下拉
// 自定义菜单下拉
const dropdownRender = menus => (
const dropdownRender = menus => (
<div>
<div>
...
@@ -409,7 +381,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -409,7 +381,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
// 切换库存
// 切换库存
const onChangeRepertory = e => {
const onChangeRepertory = e => {
setRepertoryType(`
$
{
e
.
target
.
value
}
`);
setRepertoryType(`
$
{
e
.
target
.
value
}
`);
console.log(
"e,===",
e);
console.log(
'e,===',
e);
};
};
// 勾选库存设置
// 勾选库存设置
const onChangeSetRepertory = e => {
const onChangeSetRepertory = e => {
...
@@ -473,8 +445,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -473,8 +445,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const res = await apiUnits();
const res = await apiUnits();
setUnitsList(res.data || []);
setUnitsList(res.data || []);
}
}
querGetShopDetail();
setTempMultiSpu([])
setTempMultiSpu([])
;
return false;
return false;
};
};
useEffect(() => {
useEffect(() => {
...
@@ -556,32 +528,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -556,32 +528,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Form.Item>
</Form.Item>
<Form.Item label="售卖时段">
<Form.Item label="售卖时段">
<Form.List
<Form.List name="saleTimes" initialValue={[[]]}>
name="saleTimes"
initialValue={[[]]}
// rules={[
// {
// validator: async (_, times) => {
// if (!times || times.length < 2) {
// return Promise.reject(new Error('At least 2 passengers'));
// }
// },
// },
// ]}
>
{(fields, { add, remove }) => (
{(fields, { add, remove }) => (
<>
<>
{fields.map((field, index) => (
{fields.map((field, index) => (
<Form.Item
<Form.Item required={false} key={field.key} className={styles.deal}>
// {...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
required={false}
key={field.key}
className={styles.deal}
>
<Form.Item
<Form.Item
className={styles.deal}
className={styles.deal}
{...field}
{...field}
// validateTrigger={['onChange', 'onBlur']}
rules={[
rules={[
{
{
required: true,
required: true,
...
@@ -636,11 +590,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -636,11 +590,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Form.Item>
</Form.Item>
</>
</>
)}
)}
<Form.Item
<Form.Item name="label" label="商品标签">
name="label"
label="商品标签"
// rules={[{ type: 'array', required: true, message: '请输入售卖时间!' }]}
>
<Select
<Select
mode="multiple"
mode="multiple"
allowClear
allowClear
...
@@ -666,16 +616,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -666,16 +616,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</Radio.Group>
</Radio.Group>
</Form.Item>
</Form.Item>
<Title title="规格信息" />
<Title title="规格信息" />
{/* <Form.Item label="限购" name="limitPurchase" valuePropName="checked">
<Checkbox onChange={() => radioChangeEvent('limitPurchase')}>
<b style={{ marginLeft: 10 }}>启用限购</b>
<span style={{ marginLeft: 10 }} className="ant-form-text">
限制每人可购买数量
</span>
</Checkbox>
</Form.Item> */}
<Form.Item label="库存" name="stock">
<Form.Item label="库存" name="stock">
<Radio.Group
<Radio.Group
options={ENUM_REPERTORY}
options={ENUM_REPERTORY}
...
@@ -685,7 +625,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -685,7 +625,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
optionType="button"
optionType="button"
/>
/>
</Form.Item>
</Form.Item>
{/* 单规格 */}
{repertoryType === '1' && (
{repertoryType === '1' && (
<>
<>
<Form.Item label="份量" className={styles.required}>
<Form.Item label="份量" className={styles.required}>
...
@@ -791,41 +731,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -791,41 +731,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</div>
</div>
</>
</>
)}
)}
{/* 多规格 */}
{repertoryType === '2' && (
{repertoryType === '2' && (
<>
<>
<Form.Item>
<Form.Item>
<div>份量(如大小/小份、微辣/特辣等)</div>
<div>份量(如大小/小份、微辣/特辣等)</div>
{/* <Form.List name="deal">
{(dealFields, { add, remove }) => (
<>
{dealFields.map((field, index) => (
<Form.Item key={field.key} className={styles.conBg}>
<Form.Item
{...field}
validateTrigger={['onChange', 'onBlur']}
name={[field.name, 'specGroupName']}
rules={[
{
required: true,
whitespace: true,
message: '请输入名称例如(份量)',
},
]}
noStyle
>
<Input
placeholder="请输入名称"
style={{
width: '60%',
}}
/>
</Form.Item>
{dealFields.length > 1 ? (
<MinusCircleOutlined
className="dynamic-delete-button"
onClick={() => remove(field.name)}
/>
) : null} */}
<Form.List name="weight" initialValue={[{}]}>
<Form.List name="weight" initialValue={[{}]}>
{(weightFields, { add: weightAdd, remove: weightRemove }) => (
{(weightFields, { add: weightAdd, remove: weightRemove }) => (
<>
<>
...
@@ -923,24 +833,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
...
@@ -923,24 +833,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
</>
</>
)}
)}
</Form.List>
</Form.List>
{/* </Form.Item>
))} */}
{/* <Form.Item>
<Button
type="primary"
onClick={() => add()}
style={{
width: '400px',
}}
icon={<PlusOutlined />}
>
添加份量
</Button>
</Form.Item> */}
{/* </>
)}
</Form.List> */}
</Form.Item>
</Form.Item>
{takeawayData?.takeawayItem?.weight?.length > 0 && (
{takeawayData?.takeawayItem?.weight?.length > 0 && (
<>
<>
...
...
src/pages/ServiceGoods/index.jsx
View file @
cdf53e53
...
@@ -22,7 +22,7 @@ import {
...
@@ -22,7 +22,7 @@ import {
getByProductType
,
getByProductType
,
apiCreateDraft
,
apiCreateDraft
,
apiEditDraft
,
apiEditDraft
,
api
AddTakeawayProducts
,
api
GetShopDetail
,
}
from
'
./service
'
;
}
from
'
./service
'
;
import
{
isUrl
,
filterSendData
,
clearCurrent
,
onAutoSaveValue
,
localAutoSaveKey
}
from
'
./utils
'
;
import
{
isUrl
,
filterSendData
,
clearCurrent
,
onAutoSaveValue
,
localAutoSaveKey
}
from
'
./utils
'
;
import
{
ServiceContext
}
from
'
./context
'
;
import
{
ServiceContext
}
from
'
./context
'
;
...
@@ -35,12 +35,18 @@ import styles from './common.less';
...
@@ -35,12 +35,18 @@ import styles from './common.less';
* @returns ReactDOM
* @returns ReactDOM
*/
*/
const
ServiceGoods
=
options
=>
{
const
ServiceGoods
=
options
=>
{
const
{
SourceData
,
categoryList
,
virtualCategoryList
,
specListData
,
permissions
}
=
options
;
const
{
SourceData
,
categoryList
,
virtualCategoryList
,
specListData
,
permissions
,
takeAway
,
}
=
options
;
const
canAddService
=
permissions
[
GOOD_MANAGE
.
ADD_SERVICE_GOODS
];
const
canAddService
=
permissions
[
GOOD_MANAGE
.
ADD_SERVICE_GOODS
];
const
canAddNormal
=
permissions
[
GOOD_MANAGE
.
ADD_NORMAL_GOODS
];
const
canAddNormal
=
permissions
[
GOOD_MANAGE
.
ADD_NORMAL_GOODS
];
// const canTakeawayService = permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS];
// const canTakeawayService = permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS];
// const canTakeawayService = true
// const canTakeawayService = true
const
basicRef
=
useRef
(
null
);
const
basicRef
=
useRef
(
null
);
const
stockRef
=
useRef
(
null
);
const
stockRef
=
useRef
(
null
);
const
settingRef
=
useRef
(
null
);
const
settingRef
=
useRef
(
null
);
...
@@ -111,10 +117,21 @@ const ServiceGoods = options => {
...
@@ -111,10 +117,21 @@ const ServiceGoods = options => {
},
},
!
0
,
!
0
,
);
);
if
(
stockRef
.
current
)
{
stockRef
.
current
.
onFinish
();
stockRef
.
current
.
onFinish
();
}
},
1000
);
},
1000
);
};
};
// 查询外卖商品详情
const
querGetShopDetail
=
async
params
=>
{
const
{
spuId
,
shopId
}
=
params
;
const
temp
=
{
id
:
spuId
,
shopId
,
};
const
{
data
}
=
await
apiGetShopDetail
(
temp
);
console
.
log
(
data
,
'
=====外卖结果
'
);
};
const
onResetData
=
refresh
=>
{
const
onResetData
=
refresh
=>
{
setPageId
(
null
);
setPageId
(
null
);
setIsEdit
(
false
);
setIsEdit
(
false
);
...
@@ -195,7 +212,6 @@ const ServiceGoods = options => {
...
@@ -195,7 +212,6 @@ const ServiceGoods = options => {
});
});
}
}
};
};
// 保存商品
// 保存商品
const
submitEvent
=
async
()
=>
{
const
submitEvent
=
async
()
=>
{
const
checkPromiseList
=
clearCurrent
(
checkFormList
).
map
(({
current
})
=>
current
.
onCheck
());
const
checkPromiseList
=
clearCurrent
(
checkFormList
).
map
(({
current
})
=>
current
.
onCheck
());
...
@@ -209,12 +225,10 @@ const ServiceGoods = options => {
...
@@ -209,12 +225,10 @@ const ServiceGoods = options => {
return
origin
;
return
origin
;
},
{});
},
{});
// 外卖商品创建
// 外卖商品创建
if
(
+
productType
===
5
)
{
// if (+productType === 5) {
console
.
log
(
'
parmas
'
,
params
);
// console.log('parmas', params);
const
res
=
await
sendMerchantProductHttpRequest
(
params
?.
takeawayItem
?.
intactData
);
// const res = await sendMerchantProductHttpRequest(params?.takeawayItem?.intactData);
// }
return
false
;
}
const
sendData
=
filterSendData
(
productType
,
params
);
const
sendData
=
filterSendData
(
productType
,
params
);
if
(
isEdit
)
{
if
(
isEdit
)
{
sendData
.
id
=
pageId
;
sendData
.
id
=
pageId
;
...
@@ -302,6 +316,12 @@ const ServiceGoods = options => {
...
@@ -302,6 +316,12 @@ const ServiceGoods = options => {
// 默认生成一条规格数据
// 默认生成一条规格数据
stockRef
.
current
.
onFinish
();
stockRef
.
current
.
onFinish
();
}
}
console
.
log
(
'
takeAway
'
,
takeAway
);
if
(
takeAway
&&
takeAway
.
spuId
)
{
productChange
({
type
:
5
});
querGetShopDetail
(
takeAway
);
setIsEdit
(
true
);
}
setPageLoading
(
false
);
setPageLoading
(
false
);
})();
})();
},
[
SourceData
]);
},
[
SourceData
]);
...
@@ -411,7 +431,6 @@ const ServiceGoods = options => {
...
@@ -411,7 +431,6 @@ const ServiceGoods = options => {
},
},
});
});
};
};
console
.
log
(
'
productType
'
,
productType
);
const
providerValue
=
{
const
providerValue
=
{
pageId
,
pageId
,
isEdit
,
isEdit
,
...
@@ -538,7 +557,8 @@ const ServiceGoods = options => {
...
@@ -538,7 +557,8 @@ const ServiceGoods = options => {
<>
<>
<
FormTakeaway
<
FormTakeaway
ref=
{
takeawayRef
}
ref=
{
takeawayRef
}
editData=
{
editData
.
takeawayItem
}
takeAway=
{
takeAway
}
editData=
{
editData
.
takeaway
}
infoMation=
{
editData
.
infoMation
}
infoMation=
{
editData
.
infoMation
}
supplierIdList=
{
supplierIdList
}
supplierIdList=
{
supplierIdList
}
onValuesChange=
{
onValuesChange
}
onValuesChange=
{
onValuesChange
}
...
...
src/pages/ServiceGoods/utils.js
View file @
cdf53e53
...
@@ -109,7 +109,8 @@ const filterItems = (type, props) => {
...
@@ -109,7 +109,8 @@ const filterItems = (type, props) => {
};
};
export
const
filterSendData
=
(
type
,
params
)
=>
{
export
const
filterSendData
=
(
type
,
params
)
=>
{
const
{
infoMation
,
infoImageData
,
attributeApplyList
}
=
params
;
// takeawayItem 外卖商品
const
{
infoMation
,
infoImageData
,
attributeApplyList
,
takeawayItem
}
=
params
;
const
items
=
filterItems
(
type
,
params
);
const
items
=
filterItems
(
type
,
params
);
const
commonImageList
=
type
===
4
?
[]
:
infoImageData
.
commonImageList
;
const
commonImageList
=
type
===
4
?
[]
:
infoImageData
.
commonImageList
;
const
obj
=
{
const
obj
=
{
...
@@ -128,6 +129,10 @@ export const filterSendData = (type, params) => {
...
@@ -128,6 +129,10 @@ export const filterSendData = (type, params) => {
if
(
attributeApplyList
&&
attributeApplyList
.
attributeApplyList
)
{
if
(
attributeApplyList
&&
attributeApplyList
.
attributeApplyList
)
{
obj
.
attributeApplyList
=
attributeApplyList
.
attributeApplyList
;
obj
.
attributeApplyList
=
attributeApplyList
.
attributeApplyList
;
}
}
// 外卖商品
if
(
type
===
5
)
{
return
takeawayItem
?.
intactData
;
}
return
obj
;
return
obj
;
};
};
...
...
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