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

feat: 更新数据

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