Commit e90b5e5c authored by 陈万宝's avatar 陈万宝

feat: 更新数据

parent 5470e60a
...@@ -370,6 +370,7 @@ class goodsManage extends Component { ...@@ -370,6 +370,7 @@ class goodsManage extends Component {
serviceVisble: flag, serviceVisble: flag,
isEditDraft: false, isEditDraft: false,
serviceData: {}, serviceData: {},
takeAway: {},
}); });
if (refresh) { if (refresh) {
this.handleSearch(); this.handleSearch();
......
...@@ -35,6 +35,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -35,6 +35,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
afterAddressList, afterAddressList,
specListData, specListData,
shopGetByProductType, shopGetByProductType,
groupShopData,
} = props; } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [noreBrandList, setNoreBrandList] = useState([]); const [noreBrandList, setNoreBrandList] = useState([]);
...@@ -148,7 +149,17 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -148,7 +149,17 @@ const FormInformationBasic = forwardRef((props, ref) => {
form.setFieldsValue(editData); form.setFieldsValue(editData);
onTakeawayImageList(editData.commonImageList); onTakeawayImageList(editData.commonImageList);
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => {
const { shopId = '', groupId = '' } = groupShopData
if (shopId) {
queryShopList({ shopId });
}
const temp = {
productRefShopId: [`${shopId}`],
storageRackIds: [`${groupId}`],
}
form.setFieldsValue(temp);
}, [groupShopData]);
return ( return (
<Form <Form
{...formItemLayout} {...formItemLayout}
......
...@@ -128,7 +128,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -128,7 +128,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
id, id,
categoryId, categoryId,
} = takeawayItem; } = takeawayItem;
console.log('skuList====', infoMation, takeawayItem, skuList);
const singularSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 单规格 const singularSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 单规格
const multiSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 多规格 const multiSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 多规格
// const multiSpu = customer.isEdit ? skuList:[]; // 多库存spu、 // const multiSpu = customer.isEdit ? skuList:[]; // 多库存spu、
...@@ -288,7 +287,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -288,7 +287,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}; };
setIntactData(intactDataTemp); setIntactData(intactDataTemp);
console.log('intactData======>', form.getFieldsValue(), intactDataTemp);
return intactData; return intactData;
}; };
// 过滤对象 // 过滤对象
...@@ -303,7 +301,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -303,7 +301,6 @@ 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({ 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) }
...@@ -340,7 +337,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -340,7 +337,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
setTempMultiSpu(tempMultiSpu); setTempMultiSpu(tempMultiSpu);
setMultiSpu(multiSpu); setMultiSpu(multiSpu);
} }
console.log('=========', multiSpu, tempMultiSpu);
getFormValues(); getFormValues();
return false; return false;
}; };
...@@ -435,13 +431,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -435,13 +431,14 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
}; };
// 拼接sku 名称 // 拼接sku 名称
const calcLabelName = (intactData, item) => { const calcLabelName = (intactData, item) => {
const tempName = `${intactData?.name || ''}`; // const tempName = `${intactData?.name || ''}`;
const tempSpecName = `${item?.specs[0]?.specName || ''}`; const tempSpecName = `${item?.specs[0]?.specName || ''}`;
const tempQuantity = `(${item.specs[0]?.quantity || ''}`; const tempQuantity = `(${item.specs[0]?.quantity || ''}`;
const tempUnit = `${item.specs[0]?.unit || ''})`; const tempUnit = `${item.specs[0]?.unit || ''})`;
const tempSecondSpecName = `${item.specs[1]?.specName || ''}`; const tempSecondSpecName = `${item.specs[1]?.specName || ''}`;
const isShow = tempQuantity && tempUnit && '+'; // const isShow = tempQuantity && tempUnit && '+';
return `${tempName} ${tempSpecName} ${tempQuantity} ${isShow} ${tempUnit} ${tempSecondSpecName}`; // ${tempName}
return `${tempSpecName} ${tempQuantity} ${tempUnit} ${tempSecondSpecName}`;
}; };
const init = async () => { const init = async () => {
if (!tagList.length) { if (!tagList.length) {
...@@ -460,7 +457,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -460,7 +457,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
if (customer.isEdit || customer.isUseCache) { if (customer.isEdit || customer.isUseCache) {
if (!editData) return; if (!editData) return;
let { label, firstCategoryId, secondCategoryId, thirdCategoryId, id } = editData; let { label, firstCategoryId, secondCategoryId, thirdCategoryId, id } = editData;
editData.label = label.split(','); editData.label = label.split(',').map(item => +item);
if (editData?.skuList.length) { if (editData?.skuList.length) {
editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum; editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum;
// 单规格 // 单规格
...@@ -515,14 +512,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -515,14 +512,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
form.setFieldsValue({ weight: weight[0].specs }); form.setFieldsValue({ weight: weight[0].specs });
form.setFieldsValue(editData); form.setFieldsValue(editData);
form.setFieldsValue({ specs }); form.setFieldsValue({ specs });
console.log('editData?.skuList', editData?.skuList);
const tempMultiSpu = editData?.skuList.map(item => { const tempMultiSpu = editData?.skuList.map(item => {
if (item) { if (item) {
let weightIdx = item.specs.findIndex(itm => itm.specGroupName === '份量'); let weightIdx = item.specs.findIndex(itm => itm.specGroupName === '份量');
console.log('weightIdx', weightIdx);
let specsIdx = item.specs.findIndex(itm => itm.specGroupName !== '份量'); let specsIdx = item.specs.findIndex(itm => itm.specGroupName !== '份量');
console.log('specsIdx', specsIdx);
item.unique = `${item.specs[weightIdx]?.specName}-${item.specs[specsIdx]?.specGroupName}-${item.specs[specsIdx]?.specName}`; item.unique = `${item.specs[weightIdx]?.specName}-${item.specs[specsIdx]?.specGroupName}-${item.specs[specsIdx]?.specName}`;
} }
return item; return item;
...@@ -1073,7 +1066,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -1073,7 +1066,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
showAddRepertoryModal('multi', `${item.unique}`, item); // 多个库存 showAddRepertoryModal('multi', `${item.unique}`, item); // 多个库存
}} }}
> >
设置库存{item.unique} 设置库存
</div> </div>
</div> </div>
</Form.Item> </Form.Item>
......
...@@ -29,7 +29,6 @@ export const TaskTypeSelect = props => { ...@@ -29,7 +29,6 @@ export const TaskTypeSelect = props => {
> >
<dd className="prodcut-name">{task.name}</dd> <dd className="prodcut-name">{task.name}</dd>
<dd className="prodcut-desc">({task.desc})</dd> <dd className="prodcut-desc">({task.desc})</dd>
<dd className="prodcut-desc">({task.type})</dd>
</dl> </dl>
); );
})} })}
......
...@@ -329,12 +329,12 @@ export const ENUM_SET_REPERTORY = [ ...@@ -329,12 +329,12 @@ export const ENUM_SET_REPERTORY = [
{ label: '最大', value: '1' }, { label: '最大', value: '1' },
]; ];
export const ENUM_WEEK = [ export const ENUM_WEEK = [
{ value: 1, label: '周一' }, { value: '1', label: '周一' },
{ value: 2, label: '周二' }, { value: '2', label: '周二' },
{ value: 3, label: '周三' }, { value: '3', label: '周三' },
{ value: 4, label: '周四' }, { value: '4', label: '周四' },
{ value: 5, label: '周五' }, { value: '5', label: '周五' },
{ value: 6, label: '周六' }, { value: '6', label: '周六' },
{ value: 7, label: '周日' }, { value: '7', label: '周日' },
{ value: 8, label: '法定假日' }, // { value: 8, label: '法定假日' },
]; ];
...@@ -69,7 +69,7 @@ const ServiceGoods = options => { ...@@ -69,7 +69,7 @@ const ServiceGoods = options => {
const [editData, setEditData] = useState({}); // 编辑保存数据 const [editData, setEditData] = useState({}); // 编辑保存数据
const [newCategoryList, setNewCategoryList] = useState({}); const [newCategoryList, setNewCategoryList] = useState({});
const [takeawayEditData, setTakeawayEditData] = useState({}); // 外卖编辑保存数据 const [takeawayEditData, setTakeawayEditData] = useState({}); // 外卖编辑保存数据
const [groupShopData, setGroupShopData] = useState('') // 从分组进入创建
const [visibleCacheEdit, setVisibleCacheEdit] = useState(false); // 显示有缓存未保存提示 const [visibleCacheEdit, setVisibleCacheEdit] = useState(false); // 显示有缓存未保存提示
const [checkFormList] = useState([ const [checkFormList] = useState([
basicRef, basicRef,
...@@ -118,9 +118,7 @@ const ServiceGoods = options => { ...@@ -118,9 +118,7 @@ const ServiceGoods = options => {
}, },
!0, !0,
); );
if (stockRef.current) { stockRef.current && stockRef.current.onFinish();
stockRef.current.onFinish();
}
}, 1000); }, 1000);
}; };
// 查询外卖商品详情 // 查询外卖商品详情
...@@ -138,9 +136,8 @@ const ServiceGoods = options => { ...@@ -138,9 +136,8 @@ const ServiceGoods = options => {
secondCategoryId, secondCategoryId,
thirdCategoryId, thirdCategoryId,
commonImageList, commonImageList,
id,
} = data; } = data;
const categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId]; const categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId].filter(item => !!item);
const editInfoMation = { const editInfoMation = {
infoMation: { infoMation: {
name, name,
...@@ -337,7 +334,7 @@ const ServiceGoods = options => { ...@@ -337,7 +334,7 @@ const ServiceGoods = options => {
} }
} else { } else {
// 默认生成一条规格数据 // 默认生成一条规格数据
stockRef.current.onFinish(); stockRef.current && stockRef.current.onFinish();
} }
setPageLoading(false); setPageLoading(false);
})(); })();
...@@ -371,12 +368,19 @@ const ServiceGoods = options => { ...@@ -371,12 +368,19 @@ const ServiceGoods = options => {
[specKeyList], [specKeyList],
); );
useEffect(() => { useEffect(() => {
console.log('takeAway', takeAway);
// 外卖类型 // 外卖类型
if (takeAway && takeAway.spuId) { if (takeAway) {
setProductType(5); const { spuId = '', groupId = '' } = takeAway
if (spuId) {
querGetShopDetail(takeAway); querGetShopDetail(takeAway);
} }
}, []); if (groupId) {
setGroupShopData(takeAway)
}
setProductType(5);
}
}, [takeAway]);
const onEventBus = (event, params) => { const onEventBus = (event, params) => {
if (event === 'cloneImg') { if (event === 'cloneImg') {
...@@ -512,6 +516,7 @@ const ServiceGoods = options => { ...@@ -512,6 +516,7 @@ const ServiceGoods = options => {
<FormInformationBasic <FormInformationBasic
ref={basicRef} ref={basicRef}
editData={editData.infoMation} editData={editData.infoMation}
groupShopData={groupShopData}
newCategoryList={newCategoryList} newCategoryList={newCategoryList}
shopGetByProductType={shopGetByProductType} shopGetByProductType={shopGetByProductType}
categoryList={categoryList} categoryList={categoryList}
......
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