Commit ede9b518 authored by 武广's avatar 武广

feat: 添加回显基本信息

parent 3ef322b9
...@@ -53,7 +53,7 @@ class goodsManage extends Component { ...@@ -53,7 +53,7 @@ class goodsManage extends Component {
stockSkuIds: [], stockSkuIds: [],
isType: '', isType: '',
serviceVisble: false, serviceVisble: true,
serviceData: {}, serviceData: {},
visibleAuditModal: false, visibleAuditModal: false,
auditRow: {}, // 查看审核信息使用 auditRow: {}, // 查看审核信息使用
......
...@@ -179,3 +179,10 @@ ...@@ -179,3 +179,10 @@
.btnMore { .btnMore {
text-align: center; text-align: center;
} }
.draftBox {
margin-bottom: 5px;
}
.conEdit {
color: #0e75fd;
cursor: pointer;
}
...@@ -97,7 +97,7 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -97,7 +97,7 @@ const EditFormTable = forwardRef((props, ref) => {
const getFormValues = debounce(() => { const getFormValues = debounce(() => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
props.onValuesChange(values); props.onValuesChange({ skuList: values.tableList });
}, 400); }, 400);
const rowOnClickEvent = row => { const rowOnClickEvent = row => {
......
...@@ -56,7 +56,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -56,7 +56,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
const getFormValues = debounce(() => { const getFormValues = debounce(() => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
props.onValuesChange(values); props.onValuesChange({ infoMation: values });
}, 400); }, 400);
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
...@@ -70,10 +70,8 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -70,10 +70,8 @@ const FormInformationBasic = forwardRef((props, ref) => {
}, [brandList]); }, [brandList]);
useEffect(() => { useEffect(() => {
if (customer.isEdit) {
if (!editData) return; if (!editData) return;
form.setFieldsValue(editData); form.setFieldsValue(editData);
}
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
return ( return (
......
...@@ -295,11 +295,6 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -295,11 +295,6 @@ const FormPriceOrStock = forwardRef((props, ref) => {
} }
}; };
const getFormValues = debounce(() => {
const values = form.getFieldsValue();
props.onValuesChange(values);
}, 400);
const CreateColumnsEvent = specData => { const CreateColumnsEvent = specData => {
const columsData = []; const columsData = [];
if (specData.firstSpec && specData.firstSpecValue.length) { if (specData.firstSpec && specData.firstSpecValue.length) {
...@@ -369,7 +364,7 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -369,7 +364,7 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
const { batchItem, bacthFirst, bacthSecon } = values; const { batchItem, bacthFirst, bacthSecon } = values;
const resetObject = batchTableSourceData({ batchItem, tableData, bacthSecon, bacthFirst }); const resetObject = batchTableSourceData({ batchItem, tableData, bacthSecon, bacthFirst });
props.onValuesChange({ tableList: resetObject }); props.onValuesChange({ skuList: resetObject });
setTableData(resetObject); setTableData(resetObject);
}; };
...@@ -395,6 +390,11 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -395,6 +390,11 @@ const FormPriceOrStock = forwardRef((props, ref) => {
return null; return null;
}; };
const getFormValues = debounce(async () => {
const cleanValues = await onSpecificationEvent();
props.onValuesChange({ infoSpecData: cleanValues });
}, 400);
const firstOnChangeEvent = async () => { const firstOnChangeEvent = async () => {
const cleanValues = await onSpecificationEvent(); const cleanValues = await onSpecificationEvent();
if (cleanValues) { if (cleanValues) {
...@@ -423,15 +423,16 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -423,15 +423,16 @@ const FormPriceOrStock = forwardRef((props, ref) => {
})); }));
useEffect(() => { useEffect(() => {
if (customer.isEdit) { // if (customer.isEdit) {
if (!editData) return; if (!editData) return;
form.setFieldsValue(editData); // 设置规格数据 form.setFieldsValue(editData); // 设置规格数据
firstOnChangeEvent(); // 触发成底部动态表格数据 firstOnChangeEvent(); // 触发成底部动态表格数据
setSpecInitValue(editData); // 缓存规格数据 setSpecInitValue(editData); // 缓存规格数据
CreateColumnsEvent(editData); CreateColumnsEvent(editData);
setMergeTable(Boolean(editData.secondSpecValue.length)); setMergeTable(Boolean(editData.secondSpecValue.length));
console.log('skuList :>> ', skuList);
setTableData(fliterSkuListSortData(skuList)); setTableData(fliterSkuListSortData(skuList));
} // }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
return ( return (
......
...@@ -64,7 +64,7 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -64,7 +64,7 @@ const FormRuleSetting = forwardRef((props, ref) => {
const getFormValues = debounce(() => { const getFormValues = debounce(() => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
props.onValuesChange(values); props.onValuesChange({ serviceItem: values });
}, 400); }, 400);
const nowDateTime = moment(moment().format('YYYY-MM-DD 00:00:00')); const nowDateTime = moment(moment().format('YYYY-MM-DD 00:00:00'));
......
...@@ -70,7 +70,7 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -70,7 +70,7 @@ const FormRuleVPictures = forwardRef((props, ref) => {
const getFormValues = debounce(() => { const getFormValues = debounce(() => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
props.onValuesChange(values); props.onValuesChange({ infoImageData: values });
}, 400); }, 400);
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
......
...@@ -38,7 +38,7 @@ const FormSettlementOthers = forwardRef((props, ref) => { ...@@ -38,7 +38,7 @@ const FormSettlementOthers = forwardRef((props, ref) => {
const getFormValues = debounce(() => { const getFormValues = debounce(() => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
props.onValuesChange(values); props.onValuesChange({ settlementItem: values });
}, 400); }, 400);
useEffect(() => { useEffect(() => {
......
...@@ -19,9 +19,10 @@ import { ...@@ -19,9 +19,10 @@ import {
merchantProductEdit, merchantProductEdit,
getByProductType, getByProductType,
} from './service'; } from './service';
import { isUrl, filterSendData, clearCurrent, onAutoSaveValue } from './utils'; import { isUrl, filterSendData, clearCurrent, onAutoSaveValue, localAutoSaveKey } from './utils';
import { ServiceContext } from './context'; import { ServiceContext } from './context';
import { GOOD_MANAGE } from '@/../config/permission.config'; import { GOOD_MANAGE } from '@/../config/permission.config';
import styles from './common.less';
/** /**
* 服务商品改造-商品模块 * 服务商品改造-商品模块
...@@ -52,6 +53,7 @@ const ServiceGoods = options => { ...@@ -52,6 +53,7 @@ const ServiceGoods = options => {
const [specList, setSpecList] = useState([]); // 规格列表 const [specList, setSpecList] = useState([]); // 规格列表
const [editData, setEditData] = useState({}); // 编辑保存数据 const [editData, setEditData] = useState({}); // 编辑保存数据
const [newCategoryList, setNewCategoryList] = useState({}); const [newCategoryList, setNewCategoryList] = useState({});
const [visibleCacheEdit, setVisibleCacheEdit] = useState(false); // 显示有缓存未保存提示
const [checkFormList] = useState([ const [checkFormList] = useState([
basicRef, basicRef,
attrRef, attrRef,
...@@ -67,6 +69,16 @@ const ServiceGoods = options => { ...@@ -67,6 +69,16 @@ const ServiceGoods = options => {
const onValuesChange = e => { const onValuesChange = e => {
if (!isEdit) { if (!isEdit) {
if (visibleCacheEdit) {
setVisibleCacheEdit(false);
localStorage.remove(localAutoSaveKey);
onAutoSaveValue(
{
type: productType,
},
!0,
);
}
onAutoSaveValue(e); onAutoSaveValue(e);
} }
}; };
...@@ -75,6 +87,7 @@ const ServiceGoods = options => { ...@@ -75,6 +87,7 @@ const ServiceGoods = options => {
setProductType(task.type); setProductType(task.type);
setPageLoading(true); setPageLoading(true);
setCategoryIds([]); setCategoryIds([]);
setVisibleCacheEdit(false);
const timer = setTimeout(() => { const timer = setTimeout(() => {
setPageLoading(false); setPageLoading(false);
resetForm(); resetForm();
...@@ -216,6 +229,17 @@ const ServiceGoods = options => { ...@@ -216,6 +229,17 @@ const ServiceGoods = options => {
} }
}, [productType, options.visible]); }, [productType, options.visible]);
useEffect(() => {
if (options.visible && !isEdit) {
const info = localStorage.get(localAutoSaveKey);
if (info) {
setVisibleCacheEdit(true);
return;
}
}
setVisibleCacheEdit(false);
}, [isEdit, options.visible]);
useEffect(() => { useEffect(() => {
setProductType(canAddNormal ? 1 : 4); setProductType(canAddNormal ? 1 : 4);
}, [canAddNormal]); }, [canAddNormal]);
...@@ -252,10 +276,22 @@ const ServiceGoods = options => { ...@@ -252,10 +276,22 @@ const ServiceGoods = options => {
}; };
// 保存草稿 // 保存草稿
const onSaveDraft = () => { const onSaveDraft = () => {
const localkey = 'good-info-auto-save'; const info = localStorage.get(localAutoSaveKey);
const info = localStorage.get(localkey); if (info) {
localStorage.remove(localAutoSaveKey);
}
};
// 继续编辑
const onContinueEdit = () => {
setVisibleCacheEdit(false);
const info = localStorage.get(localAutoSaveKey);
if (info) { if (info) {
localStorage.remove(localkey); console.log('info :>> ', info);
setProductType(info.type);
setEditData(info);
if (info.infoMation.categoryId && info.infoMation.categoryId.length) {
setCategoryIds(info.infoMation.categoryId);
}
} }
}; };
...@@ -297,6 +333,14 @@ const ServiceGoods = options => { ...@@ -297,6 +333,14 @@ const ServiceGoods = options => {
> >
<Spin tip="正在加载..." spinning={pageLoading} delay={100}> <Spin tip="正在加载..." spinning={pageLoading} delay={100}>
<WrapperContainer> <WrapperContainer>
{visibleCacheEdit && (
<div className={styles.draftBox}>
有未保存内容。是否
<span className={styles.conEdit} onClick={onContinueEdit}>
继续编辑
</span>
</div>
)}
<ServiceContext.Provider value={providerValue}> <ServiceContext.Provider value={providerValue}>
<Title title="商品类型" /> <Title title="商品类型" />
<TaskTypeSelect productType={productType} onChange={productChange} /> <TaskTypeSelect productType={productType} onChange={productChange} />
......
...@@ -255,13 +255,14 @@ export const createProductData = (props, isEdit, skuList) => { ...@@ -255,13 +255,14 @@ export const createProductData = (props, isEdit, skuList) => {
return list; return list;
}; };
export const localAutoSaveKey = 'good-info-auto-save';
export const onAutoSaveValue = (e, isClear) => { export const onAutoSaveValue = (e, isClear) => {
const localkey = 'good-info-auto-save';
if (isClear) { if (isClear) {
localStorage.set(localkey, Object.assign({}, e)); localStorage.set(localAutoSaveKey, Object.assign({}, e));
} else { } else {
const info = localStorage.get(localkey) || {}; const info = localStorage.get(localAutoSaveKey) || {};
localStorage.set(localkey, Object.assign({}, info, e)); localStorage.set(localAutoSaveKey, Object.assign({}, info, 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