Commit 620ae826 authored by baxibaba's avatar baxibaba

feat:修改存草稿

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