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

feat: 修改库存

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