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

feat: 更新默认值

parent d55b139b
......@@ -78,26 +78,13 @@ const AddRepertoryModal = (props, ref) => {
};
useEffect(() => {
if (item?.serviceItem) {
const { productStock = 1, autoStock = 0, maxStock = 2 } = item?.serviceItem;
const { productStock = 0, autoStock = 0, maxStock = 0 } = item?.serviceItem;
const params = {
productStock,
autoStock: +autoStock === 1,
maxStock,
};
switch (type) {
case 'all': // 统一设置
form.setFieldsValue(params);
break;
case 'multi': // 多规格设置
form.setFieldsValue(params);
break;
case 'singular': // 单规格设置
// setInitialValues(params);
form.setFieldsValue(params);
break;
default:
break;
}
form.setFieldsValue(params);
}
}, [openRepertory, item]);
return (
......
......@@ -38,7 +38,7 @@ import UploadCropImage from './UploadCropImage';
// import AddSellTimeModal from './AddSellTimeModal';
import styles from '../common.less';
import AddRepertoryModal from './AddRepertoryModal';
import AddMultiSpecModal from './AddMultiSpecModal';
// import AddMultiSpecModal from './AddMultiSpecModal';
import { apiTagList, apiUnits } from '../service';
import { localAutoSaveKey, calcDescartes } from '../utils';
import localStorage from '@/utils/localStorage';
......@@ -103,16 +103,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
return null;
}
};
// // 过滤存在的sku对象
// const objectComparison = (item, itm) => {
// console.log(item, itm, '==========');
// const {
// serviceItem: { maxStock, autoStock, productStock },
// } = itm;
// const params = { maxStock, autoStock, productStock: productStock || itm.productStock };
// const temp = { ...item, ...params };
// return temp;
// };
const takeawayCalc = takeawayData => {
// 商品基本信息编辑商品名称
......@@ -551,16 +541,18 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const weight = specList?.filter(item => item.specGroupName === '份量');
const specs = specList?.filter(item => item.specGroupName !== '份量');
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
weight.forEach(item => {
if (item?.specs?.length) {
item.specs.forEach(itm => {
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm?.quantity.indexOf('约') > -1 ? itm?.quantity.slice(1) : itm?.quantity || '';
}
});
}
});
if (weight?.length) {
weight.forEach(item => {
if (item?.specs?.length) {
item.specs.forEach(itm => {
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm?.quantity.indexOf('约') > -1 ? itm?.quantity.slice(1) : itm?.quantity || '';
}
});
}
});
}
editData.saleTimes = saleTimes?.length
? saleTimes.map(item => [moment(item?.startTime, format), moment(item?.endTime, format)])
: [];
......@@ -592,18 +584,20 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const specList = editData?.specList;
const weight = specList.filter(item => item.specGroupName === '份量');
const tempWeightName = JSON.parse(sessionStorage.getItem('weightUnits'));
weight.forEach(item => {
if (item?.specs?.length) {
item.specs.forEach(itm => {
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm?.quantity?.indexOf('约') > -1
? itm?.quantity.slice(1)
: itm?.quantity || '';
}
});
}
});
if (weight?.length) {
weight.forEach(item => {
if (item?.specs?.length) {
item.specs.forEach(itm => {
if (itm?.unit && tempWeightName.includes(itm?.unit)) {
itm.quantity =
itm?.quantity?.indexOf('约') > -1
? itm?.quantity.slice(1)
: itm?.quantity || '';
}
});
}
});
}
editData.categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId];
editData.productRefShopId = editData.shopId;
// setTempWeight(weight)
......@@ -1313,8 +1307,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
intactData={intactData}
repertoryModel={repertoryModel}
/>
{/* 加入多规格 */}
<AddMultiSpecModal ref={AddMultiSpecRef} />
</>
);
});
......
......@@ -60,7 +60,7 @@ const ServiceGoods = options => {
const [categoryIds, setCategoryIds] = useState([]); // 商品品类ID
const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态
const [isUseCache, setIsUseCache] = useState(false); // 是否使用缓存
let ptype = canTakeawayService ? 5 : 4;
let ptype = canAddService ? 4 : 5;
ptype = canAddNormal ? 1 : ptype;
const [productType, setProductType] = useState(ptype); // 商品状态
const [pageLoading, setPageLoading] = useState(false); // 页面加载状态
......
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