Commit 910a4dce authored by 陈万宝's avatar 陈万宝

feat:更新暂存信息

parent 59619ce4
...@@ -62,7 +62,7 @@ class goodsManage extends Component { ...@@ -62,7 +62,7 @@ class goodsManage extends Component {
auditRow: {}, // 查看审核信息使用 auditRow: {}, // 查看审核信息使用
isVisibleDraft: false, // 显示隐藏草稿箱 isVisibleDraft: false, // 显示隐藏草稿箱
isEditDraft: false, // 是否编辑草稿 isEditDraft: false, // 是否编辑草稿
productType: 1, // 商品类型 productType: 5, // 商品类型
takeAway: {}, // 弹窗外卖商品参数 takeAway: {}, // 弹窗外卖商品参数
searchValue: {}, // 搜索条件 searchValue: {}, // 搜索条件
refresh: '', // 外卖刷新 refresh: '', // 外卖刷新
......
...@@ -319,8 +319,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -319,8 +319,8 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
props.onValuesChange({ takeawayItem: JSON.parse(JSON.stringify(values)) }); props.onValuesChange({ takeawayItem: JSON.parse(JSON.stringify(values)) });
const takeawayData = customer.isEdit const takeawayData = customer.isEdit
? { takeawayItem: Object.assign({}, editData, values) } ? { takeawayItem: Object.assign({}, editData, values) }
: { takeawayItem: values }; : localStorage.get(localAutoSaveKey) || {};
// : localStorage.get(localAutoSaveKey) || {}; // : { takeawayItem: values };
setTakeawayData(takeawayData); setTakeawayData(takeawayData);
takeawayCalc(takeawayData); takeawayCalc(takeawayData);
}, 400); }, 400);
...@@ -499,7 +499,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -499,7 +499,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
return false; return false;
}; };
useEffect(() => { useEffect(() => {
if (customer.isEdit || customer.isUseCache) { if (customer.isEdit && !customer.isUseCache) {
if (!editData) return; if (!editData) return;
const { const {
label, label,
...@@ -601,6 +601,29 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -601,6 +601,29 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
getFormValues(); getFormValues();
} }
} }
if (customer.isUseCache) {
onValuesChange(editData, !0);
let tempEdit = JSON.parse(JSON.stringify(editData));
tempEdit = Object.assign({}, editData, { ...tempEdit.takeawayItem });
console.log('tempEdit', tempEdit);
tempEdit.saleTimes = tempEdit?.saleTimes?.length
? tempEdit?.saleTimes?.map(item => [moment(item[0]), moment(item[1])])
: [];
if (tempEdit?.saleTimes && !(tempEdit?.weight)) {
setRepertoryType('1');
} else {
setRepertoryType('2');
form.setFieldsValue({ weight: tempEdit?.weight });
form.setFieldsValue(tempEdit);
form.setFieldsValue({ specs: tempEdit?.specs });
}
onCardSuccessImageList(tempEdit?.detailImageList);
if (tempEdit && tempEdit?.saleTimeType) {
setTimeType(tempEdit?.saleTimeType);
}
form.setFieldsValue(tempEdit);
// getFormValues();
}
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => { useEffect(() => {
setIntactData(intactData); setIntactData(intactData);
......
...@@ -326,13 +326,18 @@ const ServiceGoods = options => { ...@@ -326,13 +326,18 @@ const ServiceGoods = options => {
await getAfterSalesAddrsPage(); await getAfterSalesAddrsPage();
await getMerchantSpecList(); await getMerchantSpecList();
if (Object.keys(SourceData).length) { if (Object.keys(SourceData).length) {
console.log('SourceData :>> ', SourceData); console.log('SourceData :>> ', SourceData, options.isDraft);
// 从编辑草稿进入 执行以下代码 // 从编辑草稿进入 执行以下代码
if (options.isDraft) { if (options.isDraft) {
setIsUseCache(true); setIsUseCache(true);
setVisibleCacheEdit(false); setVisibleCacheEdit(false);
onSetData(SourceData); onSetData(SourceData);
onValuesChange(SourceData, !0); onValuesChange(SourceData, !0);
// 外卖类型---
if (SourceData && SourceData?.type === 5) {
setTakeawayEditData(SourceData);
setIsUseCache(true);
}
} else { } else {
setEditData(SourceData); setEditData(SourceData);
setPageId(SourceData.id); setPageId(SourceData.id);
...@@ -418,12 +423,13 @@ const ServiceGoods = options => { ...@@ -418,12 +423,13 @@ const ServiceGoods = options => {
console.log('newCategoryList :>> ', newCategoryList); console.log('newCategoryList :>> ', newCategoryList);
const info = localStorage.get(localAutoSaveKey); const info = localStorage.get(localAutoSaveKey);
console.log('info', info);
if ( if (
!info || !info ||
!info.infoMation || !info.infoMation ||
!info.infoMation.name || !info.infoMation.name ||
!info.infoMation.categoryId || !info.infoMation.categoryId ||
info.infoMation.categoryId.length !== 3 (info.infoMation.categoryId.length !== 3 && info.type !== 5)
) { ) {
message.warning('请添加商品类目和名称'); message.warning('请添加商品类目和名称');
return; return;
...@@ -448,7 +454,7 @@ const ServiceGoods = options => { ...@@ -448,7 +454,7 @@ const ServiceGoods = options => {
secondCategoryId: info.infoMation.categoryId[1], secondCategoryId: info.infoMation.categoryId[1],
secondCategoryName: second.name, secondCategoryName: second.name,
thirdCategoryId: info.infoMation.categoryId[2], thirdCategoryId: info.infoMation.categoryId[2],
thirdCategoryName: third.name, thirdCategoryName: third?.name,
content: JSON.stringify(info), content: JSON.stringify(info),
}; };
console.log('params :>> ', params); console.log('params :>> ', params);
...@@ -494,13 +500,9 @@ const ServiceGoods = options => { ...@@ -494,13 +500,9 @@ 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}>
'' 保存草稿
) : ( </Button>,
<Button key="draft" type="primary" ghost loading={pageLoading} onClick={onSaveDraft}>
保存草稿
</Button>
),
<Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}> <Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}>
提交 提交
</Button>, </Button>,
......
...@@ -303,10 +303,10 @@ export const localAutoSaveKey = 'good-info-auto-save'; ...@@ -303,10 +303,10 @@ export const localAutoSaveKey = 'good-info-auto-save';
export const onAutoSaveValue = (e, isClear) => { export const onAutoSaveValue = (e, isClear) => {
// 暂时去掉外卖类型 // 暂时去掉外卖类型
if (e && e.type === 5) { // if (e && e.type === 5) {
localStorage.remove(localAutoSaveKey); // localStorage.remove(localAutoSaveKey);
return; // return;
} // }
const keys = Object.keys(e); const keys = Object.keys(e);
if ( if (
e && e &&
......
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