Commit ede9b518 authored by 武广's avatar 武广

feat: 添加回显基本信息

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