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

feat: 修改库存

parent ab9dde94
......@@ -70,7 +70,6 @@ const GroupInfo = options => {
>
<Input />
</Form.Item>
<Form.Item label="下单必选分组" name="necessary" extra={extra}>
<Switch
checkedChildren="开启"
......
......@@ -6,13 +6,14 @@ import React, {
useImperativeHandle,
useRef,
} from 'react';
import { Cascader, Form, Input, Select, Popover, Button, Checkbox, Divider, Modal } from 'antd';
import { Cascader, Form, Input, Select, Popover, Button, Checkbox, Divider, Modal, notification } from 'antd';
import { formItemLayout } from '../config';
import { ServiceContext } from '../context';
import { debounce } from '@/utils/utils';
import AddMenusModal from './AddMenusModal';
import UploadImage from './UploadImage';
import { apiShopIds, apiQueryShopList, getByProductType } from '../service';
import GroupInfo from '../../GoodsManage/Takeaway/components/GroupInfo';
const CreateSelectOption = optionList =>
optionList.map(brandItem => (
......@@ -45,6 +46,8 @@ const FormInformationBasic = forwardRef((props, ref) => {
const [shopIds, setShopIds] = useState([]);
const [shopList, setShopList] = useState([]);
const [isEditTakeaway, setIsEditTakeaway] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [shopIdSource, setShopIdSource] = useState('');
const onCheck = async () => {
try {
......@@ -71,7 +74,11 @@ const FormInformationBasic = forwardRef((props, ref) => {
// 自定义加入菜单
const showModal = () => {
childAddMenusModalRef.current.setOpen(true);
if (shopIdSource) {
setIsModalOpen(true);
} else {
notification.error({ message: '请先选择名店在进行操作!' });
}
};
// 自定义菜单下拉
const dropdownRender = menus => (
......@@ -115,15 +122,19 @@ const FormInformationBasic = forwardRef((props, ref) => {
};
// 查询分组列表
const queryShopList = async params => {
if (!shopList.length) {
const result = await apiQueryShopList(params);
setShopList(result.data || []);
let result = [];
if (params) {
result = await apiQueryShopList(params);
} else {
result = await apiQueryShopList({ shopId: shopIdSource });
}
setShopList(result.data || []);
};
const onChangeShopId = async e => {
if (e) {
setShopList([]);
queryShopList({ shopId: e });
setShopIdSource(e)
form.setFieldsValue({
storageRackIds: '',
});
......@@ -147,6 +158,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
if (editData.productType === 5 && editData.name) {
shopGetByProductType(5);
queryShopList({ shopId: editData.productRefShopId });
setShopIdSource(editData.productRefShopId);
setIsEditTakeaway(true);
}
form.setFieldsValue(editData);
......@@ -155,17 +167,18 @@ const FormInformationBasic = forwardRef((props, ref) => {
useEffect(() => {
setShopList([]);
shopGetByProductType(5);
const { shopId = '', groupId = '' } = groupShopData
const { shopId = '', groupId = '' } = groupShopData;
if (shopId) {
setShopIdSource(shopId);
queryShopList({ shopId });
}
const temp = {
productRefShopId: shopId ? [`${shopId}`] : [],
storageRackIds: groupId ? [+groupId] : [],
}
};
setTimeout(() => {
form.setFieldsValue(temp);
}, [])
}, []);
}, [groupShopData]);
return (
<Form
......@@ -222,14 +235,13 @@ const FormInformationBasic = forwardRef((props, ref) => {
disabled={customer.isEdit && customer.isNormal}
showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'id', children: 'children' }}
// onChange={props.onCategoryChange}
options={shopList}
dropdownRender={dropdownRender}
/>
</Form.Item>
)}
{/* 新增菜单分组弹框 */}
<AddMenusModal ref={childAddMenusModalRef} queryShopList={queryShopList} />
{/* <AddMenusModal ref={childAddMenusModalRef} queryShopList={queryShopList} /> */}
<Form.Item
name="categoryId"
label="商品类目"
......@@ -341,6 +353,12 @@ const FormInformationBasic = forwardRef((props, ref) => {
<Input.TextArea showCount maxLength={100} placeholder="请输入描述, 100字以内" />
</Form.Item>
) : null}
<GroupInfo
isModalOpen={isModalOpen}
shopId={shopIdSource}
search={queryShopList}
handleClose={setIsModalOpen}
/>
</Form>
);
});
......
......@@ -32,7 +32,7 @@ import { formItemLayout, ENUM_REPERTORY, ENUM_SET_REPERTORY, ENUM_WEEK } from '.
import { ServiceContext } from '../context';
import { debounce } from '@/utils/utils';
import UploadImage from './UploadImage';
import AddSellTimeModal from './AddSellTimeModal';
// import AddSellTimeModal from './AddSellTimeModal';
import styles from '../common.less';
import AddRepertoryModal from './AddRepertoryModal';
import AddMultiSpecModal from './AddMultiSpecModal';
......@@ -79,12 +79,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const [tempSpecs, setTempSpecs] = useState([]);
const [weightUnits, setWeightUnits] = useState([]);
const initialDealValue = [
{
specGroupName: '',
},
];
// 自定义加入菜单
const showModal = () => {
addSellTimeRef.current.setOpen(true);
......@@ -105,7 +99,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const takeawayCalc = takeawayData => {
// 商品基本信息编辑商品名称
const { infoMation: name, infoMation, takeawayItem } = takeawayData;
console.log('i========', infoMation, takeawayItem, repertoryType);
// weight 份量 specs规格 生成sku规则 weight * specs
const {
specs = tempSpecs,
......@@ -386,7 +379,22 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
);
// 切换库存
const onChangeRepertory = e => {
setRepertoryType(`${e.target.value}`);
const value = e.target.value
setRepertoryType(`${value}`);
if(+value ===1 ){
form.setFieldsValue({weight:[]})
form.setFieldsValue({specs:[]})
} else {
const params = {
quantity:'',
unit:[],
salePrice:'',
productStock:'',
maxStock:'',
autoStock:false
}
form.setFieldsValue(params)
}
};
// 勾选库存设置
const onChangeSetRepertory = e => {
......@@ -471,7 +479,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
productStock,
shopId,
specs,
serviceItem: { maxStock, saleTimeType, saleDates, saleTimes, id },
serviceItem: { maxStock, saleTimeType, saleDates, saleTimes, id,autoStock },
} = editData?.skuList[0];
let { quantity, unit, salePrice } = specs[0];
editData.productStock = productStock;
......@@ -482,6 +490,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
editData.categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId];
editData.saleTimeType = saleTimeType;
editData.saleDates = saleDates;
editData.autoStock = +autoStock === 1 ? true :false
editData.saleTimes = saleTimes.length
? saleTimes.map(item => {
return [moment(item?.startTime, format), moment(item?.endTime, format)];
......@@ -542,7 +551,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
form.setFieldsValue({ productRefShopId: editData.shopId });
onCardSuccessImageList(editData?.detailImageList);
getFormValues();
// setInitValue({ ...editData });
}
}
}, [customer.isEdit, editData]);
......
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