Commit 620ae826 authored by baxibaba's avatar baxibaba

feat:修改存草稿

parent 297186b3
......@@ -86,7 +86,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
// 自定义加入菜单
const showModal = () => {
if (shopIdSource) {
if (shopIdSource || editData?.productRefShopId) {
setIsModalOpen(true);
} else {
notification.error({ message: '请先选择名店在进行操作!' });
......@@ -167,10 +167,12 @@ const FormInformationBasic = forwardRef((props, ref) => {
useEffect(() => {
if (!editData) return;
if (editData?.productType === 5 && editData?.name) {
if ((editData?.productType === 5 && editData?.name) || customer.productType === 5) {
shopGetByProductType(5);
queryShopList({ shopId: editData?.productRefShopId });
if (editData?.productRefShopId) {
setShopIdSource(editData?.productRefShopId);
queryShopList({ shopId: editData?.productRefShopId });
}
setIsEditTakeaway(true);
}
form.setFieldsValue(editData);
......@@ -192,6 +194,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
};
form.setFieldsValue(temp);
}, [groupShopData]);
// useEffect(() => {}, [shopList, shopIdSource]);
return (
<Form
{...formItemLayout}
......
......@@ -345,8 +345,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const onChange = () => {};
const getFormValues = debounce(() => {
const values = form.getFieldsValue();
console.log(values, 'values===');
props.onValuesChange({ takeawayItem: JSON.parse(JSON.stringify(values)) });
props.onValuesChange({
takeawayItem: JSON.parse(JSON.stringify(Object.assign(values, { multiSpu }))), // { multiSpu }草稿箱回显使用
});
const takeawayData = customer.isEdit
? { takeawayItem: Object.assign({}, editData, values) }
: localStorage.get(localAutoSaveKey) || {};
......@@ -504,24 +505,24 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const res = await apiTagList();
setTagList(res.data || []);
}
if (!unitsList.length) {
if (!unitsList?.length) {
const res = await apiUnits();
setUnitsList(res.data || []);
const tempWeight = res.data.filter(item => item.name === '准确重量单位');
const tempPeople = res.data.filter(item => item.name === '适用人数');
if (tempWeight.length && tempWeight[0]?.children) {
if (tempWeight?.length && tempWeight[0]?.children) {
const tempWeightName = tempWeight[0]?.children.map(item => item.name);
sessionStorage.setItem('weightUnits', JSON.stringify(tempWeightName || []));
setWeightUnits(tempWeightName);
}
if (tempPeople.length && tempPeople[0]?.children) {
if (tempPeople?.length && tempPeople[0]?.children) {
const tempPeopleName = tempPeople[0]?.children.map(item => item.name);
sessionStorage.setItem('peopleUnits', JSON.stringify(tempPeopleName || []));
setPeopleUnits(tempPeopleName);
}
}
setTempMultiSpu([]);
// setTempMultiSpu([]);// 回显时候库存无法展示
return false;
};
useEffect(() => {
......@@ -638,13 +639,15 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
? tempEdit?.saleTimes?.map(item => [moment(item[0]), moment(item[1])])
: [];
}
if (tempEdit?.stock === '1' && !tempEdit?.weight) {
if (tempEdit?.stock === '1') {
setRepertoryType('1');
}
if (tempEdit?.stock === '2' && !tempEdit?.weight) {
if (tempEdit?.stock === '2') {
setRepertoryType('2');
form.setFieldsValue({ weight: tempEdit?.weight });
form.setFieldsValue({ specs: tempEdit?.specs });
console.log('tempEdit?.multiSpu', tempEdit?.multiSpu);
setTempMultiSpu(JSON.parse(JSON.stringify(tempEdit?.multiSpu)));
}
if (tempEdit?.detailImageList) {
onCardSuccessImageList(tempEdit?.detailImageList);
......@@ -665,7 +668,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
getFormValues();
}, [repertoryType]);
useEffect(() => {
setTempMultiSpu(tempMultiSpu);
// setTempMultiSpu(tempMultiSpu);
console.log('tempEdit?.multiSpu1122222', tempMultiSpu);
}, [tempMultiSpu]);
return (
<>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment