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

Merge branch 'feature/20230315_take_out_goods' into feature/20230327_public_takeaway

parents 6fec3ca3 5470e60a
...@@ -78,7 +78,7 @@ class goodsManage extends Component { ...@@ -78,7 +78,7 @@ class goodsManage extends Component {
componentDidMount() { componentDidMount() {
this.props.goodsManage.tableData = {}; this.props.goodsManage.tableData = {};
this.categoryList(); this.categoryList(this.state.productType);
this.categoryListByType(this.state.productType); this.categoryListByType(this.state.productType);
this.getVirtualCategory(); this.getVirtualCategory();
this.specList(); this.specList();
......
...@@ -245,6 +245,15 @@ ...@@ -245,6 +245,15 @@
.specsBetween { .specsBetween {
display: flex; display: flex;
flex-flow: row nowrap; flex-flow: row nowrap;
:global {
.ant-form-item-label{
overflow:inherit;
}
.ant-col-sm-3{
max-width: fit-content;
}
}
} }
.specRepertory { .specRepertory {
background-color: #319bfe; background-color: #319bfe;
......
...@@ -12,7 +12,7 @@ import { ServiceContext } from '../context'; ...@@ -12,7 +12,7 @@ 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 } from '../service'; import { apiShopIds, apiQueryShopList, getByProductType } from '../service';
const CreateSelectOption = optionList => const CreateSelectOption = optionList =>
optionList.map(brandItem => ( optionList.map(brandItem => (
...@@ -22,7 +22,6 @@ const CreateSelectOption = optionList => ...@@ -22,7 +22,6 @@ const CreateSelectOption = optionList =>
)); ));
const fileterBrandOptions = (input, options) => options.children.includes(input); const fileterBrandOptions = (input, options) => options.children.includes(input);
const filterCategoryOptions = (inputValue, path) => const filterCategoryOptions = (inputValue, path) =>
path.some(option => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1); path.some(option => option.name.toLowerCase().indexOf(inputValue.toLowerCase()) > -1);
...@@ -35,6 +34,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -35,6 +34,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
brandList, brandList,
afterAddressList, afterAddressList,
specListData, specListData,
shopGetByProductType,
} = props; } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [noreBrandList, setNoreBrandList] = useState([]); const [noreBrandList, setNoreBrandList] = useState([]);
...@@ -43,6 +43,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -43,6 +43,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
const [takeawayImageList, setTakeawayImageList] = useState([]); const [takeawayImageList, setTakeawayImageList] = useState([]);
const [shopIds, setShopIds] = useState([]); const [shopIds, setShopIds] = useState([]);
const [shopList, setShopList] = useState([]); const [shopList, setShopList] = useState([]);
const [isEditTakeaway, setIsEditTakeaway] = useState(false);
const onCheck = async () => { const onCheck = async () => {
try { try {
...@@ -66,6 +67,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -66,6 +67,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
return null; return null;
} }
}; };
// 自定义加入菜单 // 自定义加入菜单
const showModal = () => { const showModal = () => {
childAddMenusModalRef.current.setOpen(true); childAddMenusModalRef.current.setOpen(true);
...@@ -100,6 +102,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -100,6 +102,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
}; };
const getFormValues = debounce(() => { const getFormValues = debounce(() => {
const values = form.getFieldsValue(); const values = form.getFieldsValue();
console.log('infoMation', values);
props.onValuesChange({ infoMation: values }); props.onValuesChange({ infoMation: values });
}, 400); }, 400);
// 查询shopIds // 查询shopIds
...@@ -118,13 +121,17 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -118,13 +121,17 @@ const FormInformationBasic = forwardRef((props, ref) => {
}; };
const onChangeShopId = async e => { const onChangeShopId = async e => {
if (e) { if (e) {
queryShopList({ shopId: e }); // 分组列表 setShopList([]);
queryShopList({ shopId: e });
} }
}; };
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
onCheck, onCheck,
reset: form.resetFields, reset: form.resetFields,
})); }));
useEffect(() => {
queryShopIds();
}, [customer.productType]);
useEffect(() => { useEffect(() => {
const noreList = (brandList || []).filter(item => item.name === '虚拟商品'); const noreList = (brandList || []).filter(item => item.name === '虚拟商品');
...@@ -133,15 +140,15 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -133,15 +140,15 @@ const FormInformationBasic = forwardRef((props, ref) => {
useEffect(() => { useEffect(() => {
if (!editData) return; if (!editData) return;
if (editData.productType === 5 && editData.name) {
shopGetByProductType(5);
queryShopList({ shopId: editData.productRefShopId });
setIsEditTakeaway(true);
}
form.setFieldsValue(editData); form.setFieldsValue(editData);
onTakeawayImageList(editData.commonImageList);
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => {
console.log('!customer.isTakeawayService', customer);
console.log('newCategoryList[customer.productType]', newCategoryList[customer.productType]);
console.log('newCategoryList[customer.productType]', shopList);
queryShopIds()
}, [customer.productType]);
return ( return (
<Form <Form
{...formItemLayout} {...formItemLayout}
...@@ -152,6 +159,8 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -152,6 +159,8 @@ const FormInformationBasic = forwardRef((props, ref) => {
name: '', name: '',
categoryId: [], categoryId: [],
description: '', description: '',
productRefShopId: [],
storageRackIds: [],
}} }}
scrollToFirstError scrollToFirstError
onValuesChange={getFormValues} onValuesChange={getFormValues}
...@@ -171,12 +180,12 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -171,12 +180,12 @@ const FormInformationBasic = forwardRef((props, ref) => {
{customer.isTakeawayService && ( {customer.isTakeawayService && (
<Form.Item <Form.Item
name="productRefShopId" name="productRefShopId"
key="productRefShopId"
label="所属门店" label="所属门店"
rules={[{ required: true, message: '请选择所属门店' }]} rules={[{ required: true, message: '请选择所属门店' }]}
> >
<Select <Select
fieldNames={{ label: 'name', value: 'id' }} fieldNames={{ label: 'name', value: 'id' }}
filterOption={fileterBrandOptions}
placeholder="请选择所属门店" placeholder="请选择所属门店"
options={shopIds} options={shopIds}
onChange={onChangeShopId} onChange={onChangeShopId}
...@@ -195,7 +204,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -195,7 +204,7 @@ 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} // onChange={props.onCategoryChange}
options={shopList} options={shopList}
dropdownRender={dropdownRender} dropdownRender={dropdownRender}
/> />
...@@ -205,7 +214,6 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -205,7 +214,6 @@ const FormInformationBasic = forwardRef((props, ref) => {
<AddMenusModal ref={childAddMenusModalRef} queryShopList={queryShopList} /> <AddMenusModal ref={childAddMenusModalRef} queryShopList={queryShopList} />
<Form.Item <Form.Item
name="categoryId" name="categoryId"
key="categoryId"
label="商品类目" label="商品类目"
rules={[{ type: 'array', required: true, message: '请输入商品类目' }]} rules={[{ type: 'array', required: true, message: '请输入商品类目' }]}
> >
......
...@@ -22,7 +22,7 @@ import { ...@@ -22,7 +22,7 @@ import {
getByProductType, getByProductType,
apiCreateDraft, apiCreateDraft,
apiEditDraft, apiEditDraft,
apiAddTakeawayProducts, apiGetShopDetail,
} from './service'; } from './service';
import { isUrl, filterSendData, clearCurrent, onAutoSaveValue, localAutoSaveKey } from './utils'; import { isUrl, filterSendData, clearCurrent, onAutoSaveValue, localAutoSaveKey } from './utils';
import { ServiceContext } from './context'; import { ServiceContext } from './context';
...@@ -35,12 +35,18 @@ import styles from './common.less'; ...@@ -35,12 +35,18 @@ import styles from './common.less';
* @returns ReactDOM * @returns ReactDOM
*/ */
const ServiceGoods = options => { const ServiceGoods = options => {
const { SourceData, categoryList, virtualCategoryList, specListData, permissions } = options; const {
SourceData,
categoryList,
virtualCategoryList,
specListData,
permissions,
takeAway,
} = options;
const canAddService = permissions[GOOD_MANAGE.ADD_SERVICE_GOODS]; const canAddService = permissions[GOOD_MANAGE.ADD_SERVICE_GOODS];
const canAddNormal = permissions[GOOD_MANAGE.ADD_NORMAL_GOODS]; const canAddNormal = permissions[GOOD_MANAGE.ADD_NORMAL_GOODS];
// const canTakeawayService = permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS]; // const canTakeawayService = permissions[GOOD_MANAGE.ADD_TAKEAWAY_GOODS];
// const canTakeawayService = true // const canTakeawayService = true
const basicRef = useRef(null); const basicRef = useRef(null);
const stockRef = useRef(null); const stockRef = useRef(null);
const settingRef = useRef(null); const settingRef = useRef(null);
...@@ -62,6 +68,7 @@ const ServiceGoods = options => { ...@@ -62,6 +68,7 @@ const ServiceGoods = options => {
const [specList, setSpecList] = useState([]); // 规格列表 const [specList, setSpecList] = useState([]); // 规格列表
const [editData, setEditData] = useState({}); // 编辑保存数据 const [editData, setEditData] = useState({}); // 编辑保存数据
const [newCategoryList, setNewCategoryList] = useState({}); const [newCategoryList, setNewCategoryList] = useState({});
const [takeawayEditData, setTakeawayEditData] = useState({}); // 外卖编辑保存数据
const [visibleCacheEdit, setVisibleCacheEdit] = useState(false); // 显示有缓存未保存提示 const [visibleCacheEdit, setVisibleCacheEdit] = useState(false); // 显示有缓存未保存提示
const [checkFormList] = useState([ const [checkFormList] = useState([
...@@ -111,10 +118,44 @@ const ServiceGoods = options => { ...@@ -111,10 +118,44 @@ const ServiceGoods = options => {
}, },
!0, !0,
); );
stockRef.current.onFinish(); if (stockRef.current) {
stockRef.current.onFinish();
}
}, 1000); }, 1000);
}; };
// 查询外卖商品详情
const querGetShopDetail = async params => {
const { spuId, shopId } = params;
const temp = {
id: spuId,
shopId,
};
const { data } = await apiGetShopDetail(temp);
const {
name,
storageRackIds,
firstCategoryId,
secondCategoryId,
thirdCategoryId,
commonImageList,
id,
} = data;
const categoryId = [firstCategoryId, secondCategoryId, thirdCategoryId];
const editInfoMation = {
infoMation: {
name,
productRefShopId: `${shopId}`,
commonImageList,
categoryId,
storageRackIds,
productType: 5,
},
};
setEditData(editInfoMation);
setTakeawayEditData(data);
setIsEdit(true);
setPageLoading(false);
};
const onResetData = refresh => { const onResetData = refresh => {
setPageId(null); setPageId(null);
setIsEdit(false); setIsEdit(false);
...@@ -195,7 +236,6 @@ const ServiceGoods = options => { ...@@ -195,7 +236,6 @@ const ServiceGoods = options => {
}); });
} }
}; };
// 保存商品 // 保存商品
const submitEvent = async () => { const submitEvent = async () => {
const checkPromiseList = clearCurrent(checkFormList).map(({ current }) => current.onCheck()); const checkPromiseList = clearCurrent(checkFormList).map(({ current }) => current.onCheck());
...@@ -208,14 +248,11 @@ const ServiceGoods = options => { ...@@ -208,14 +248,11 @@ const ServiceGoods = options => {
origin[temp] = other; origin[temp] = other;
return origin; return origin;
}, {}); }, {});
// 外卖商品创建 const sendData = filterSendData(productType, params);
if (+productType === 5) { if (productType === 5) {
console.log('parmas', params); sendMerchantProductHttpRequest(sendData);
const res = await sendMerchantProductHttpRequest(params?.takeawayItem?.intactData);
return false; return false;
} }
const sendData = filterSendData(productType, params);
if (isEdit) { if (isEdit) {
sendData.id = pageId; sendData.id = pageId;
} }
...@@ -333,6 +370,13 @@ const ServiceGoods = options => { ...@@ -333,6 +370,13 @@ const ServiceGoods = options => {
}, },
[specKeyList], [specKeyList],
); );
useEffect(() => {
// 外卖类型
if (takeAway && takeAway.spuId) {
setProductType(5);
querGetShopDetail(takeAway);
}
}, []);
const onEventBus = (event, params) => { const onEventBus = (event, params) => {
if (event === 'cloneImg') { if (event === 'cloneImg') {
...@@ -411,7 +455,6 @@ const ServiceGoods = options => { ...@@ -411,7 +455,6 @@ const ServiceGoods = options => {
}, },
}); });
}; };
console.log('productType', productType);
const providerValue = { const providerValue = {
pageId, pageId,
isEdit, isEdit,
...@@ -470,6 +513,7 @@ const ServiceGoods = options => { ...@@ -470,6 +513,7 @@ const ServiceGoods = options => {
ref={basicRef} ref={basicRef}
editData={editData.infoMation} editData={editData.infoMation}
newCategoryList={newCategoryList} newCategoryList={newCategoryList}
shopGetByProductType={shopGetByProductType}
categoryList={categoryList} categoryList={categoryList}
virtualCategoryList={virtualCategoryList} virtualCategoryList={virtualCategoryList}
brandList={brandList} brandList={brandList}
...@@ -538,7 +582,8 @@ const ServiceGoods = options => { ...@@ -538,7 +582,8 @@ const ServiceGoods = options => {
<> <>
<FormTakeaway <FormTakeaway
ref={takeawayRef} ref={takeawayRef}
editData={editData.takeawayItem} takeAway={takeAway}
editData={takeawayEditData}
infoMation={editData.infoMation} infoMation={editData.infoMation}
supplierIdList={supplierIdList} supplierIdList={supplierIdList}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
......
...@@ -109,7 +109,15 @@ const filterItems = (type, props) => { ...@@ -109,7 +109,15 @@ const filterItems = (type, props) => {
}; };
export const filterSendData = (type, params) => { export const filterSendData = (type, params) => {
const { infoMation, infoImageData, attributeApplyList } = params; // takeawayItem 外卖商品
const { infoMation, infoImageData, attributeApplyList, takeawayItem } = params;
console.log('infoMation', infoMation, takeawayItem);
const temp = Object.assign({}, takeawayItem?.intactData, infoMation)
temp.categoryId = (Array.isArray(temp.categoryId) && temp.categoryId?.slice(temp.categoryId?.length - 1)?.toString())
// 外卖商品
if (type === 5) {
return temp;
}
const items = filterItems(type, params); const items = filterItems(type, params);
const commonImageList = type === 4 ? [] : infoImageData.commonImageList; const commonImageList = type === 4 ? [] : infoImageData.commonImageList;
const obj = { const obj = {
...@@ -128,6 +136,7 @@ export const filterSendData = (type, params) => { ...@@ -128,6 +136,7 @@ export const filterSendData = (type, params) => {
if (attributeApplyList && attributeApplyList.attributeApplyList) { if (attributeApplyList && attributeApplyList.attributeApplyList) {
obj.attributeApplyList = attributeApplyList.attributeApplyList; obj.attributeApplyList = attributeApplyList.attributeApplyList;
} }
return obj; return obj;
}; };
......
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