Commit f1e3c41b authored by 武广's avatar 武广

fix: 修改餐品类型

parent ee7dfdf8
...@@ -152,24 +152,26 @@ const CustomerInfo = props => { ...@@ -152,24 +152,26 @@ const CustomerInfo = props => {
}); });
}; };
// 改变餐品类型 // 改变餐品类型 (1和2要选都选 要不都不选)
const onChangeMealType = async ms => { const onChangeMealType = async ms => {
try { try {
if (props.info && props.info.id && ms.length < mealTypes.length) { if (props.info && props.info.id && ms.length < mealTypes.length) {
await checkConfirm(); await checkConfirm();
} }
if (mealTypes.includes('1') && mealTypes.includes('2')) { console.log('ms :>> ', ms);
if (!(ms.includes('1') && ms.includes('2'))) { if (mealTypes.length > ms.length) {
if (ms.includes('4')) { if (ms.includes('1') && ms.includes('2')) {
ms = ['1', '2'];
} else if (ms.includes('4')) {
ms = ['4']; ms = ['4'];
} else { } else {
ms = []; ms = [];
} }
} } else if (ms.includes('1') || ms.includes('2')) {
} else if (ms.length < 3 && ms.length) {
ms = ['1', '2'];
if (ms.includes('4')) { if (ms.includes('4')) {
ms.push('4'); ms = ['1', '2', '4'];
} else {
ms = ['1', '2'];
} }
} }
form.setFieldsValue({ form.setFieldsValue({
......
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { Form, InputNumber, Modal, notification } from 'antd'; import { Form, InputNumber, Modal, notification } from 'antd';
import { layout } from '../staticData/goods';
import { isCheckPriceTwoDecimal } from '@/utils/validator'; import { isCheckPriceTwoDecimal } from '@/utils/validator';
import { apiMealInfoUpdate } from '../service'; import { apiMealInfoUpdate } from '../service';
const SaleDateModal = props => { const SaleDateModal = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 14 },
};
// 关闭弹窗 // 关闭弹窗
const handleCancel = () => { const handleCancel = () => {
props.handleClose(false); props.handleClose(false);
...@@ -16,14 +20,16 @@ const SaleDateModal = props => { ...@@ -16,14 +20,16 @@ const SaleDateModal = props => {
const handleConfirm = async () => { const handleConfirm = async () => {
const res = await form.validateFields(); const res = await form.validateFields();
console.log('res :>> ', res); console.log('res :>> ', res);
if (props.id) {
const params = { const params = {
id: props.id, id: props.id,
enterprisePrice: res.price, enterprisePrice: res.price,
}; };
await apiMealInfoUpdate(params); await apiMealInfoUpdate(params);
notification.success({ message: '保存成功' }); notification.success({ message: '保存成功' });
}
handleCancel(); handleCancel();
props.handleRefresh(); props.handleRefresh(res.price);
}; };
useEffect(() => { useEffect(() => {
...@@ -38,7 +44,7 @@ const SaleDateModal = props => { ...@@ -38,7 +44,7 @@ const SaleDateModal = props => {
open={props.visible} open={props.visible}
destroyOnClose destroyOnClose
maskClosable={false} maskClosable={false}
width="300px" width="400px"
okText="保存" okText="保存"
onOk={handleConfirm} onOk={handleConfirm}
onCancel={handleCancel} onCancel={handleCancel}
......
...@@ -11,7 +11,7 @@ const { Option } = Select; ...@@ -11,7 +11,7 @@ const { Option } = Select;
const SaleDateModal = props => { const SaleDateModal = props => {
const [searchType, setSearchType] = useState('1'); const [searchType, setSearchType] = useState('1');
const [searchKeyword, setSearchKeyword] = useState(''); const [searchKeyword, setSearchKeyword] = useState('');
const [goodsType, setGoodsType] = useState('1'); // const [goodsType, setGoodsType] = useState('1');
const [shopId, setShopId] = useState(); const [shopId, setShopId] = useState();
const [searchName, setSearchName] = useState(''); const [searchName, setSearchName] = useState('');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
...@@ -19,7 +19,7 @@ const SaleDateModal = props => { ...@@ -19,7 +19,7 @@ const SaleDateModal = props => {
const [pageSize, setPageSize] = useState(10); const [pageSize, setPageSize] = useState(10);
const [total, setTotal] = useState(0); const [total, setTotal] = useState(0);
const [dataSource, setDataSource] = useState([]); const [dataSource, setDataSource] = useState([]);
const [shopList, setShopList] = useState(jsonToArray(productType)); const [shopList, setShopList] = useState([]);
const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [selectedRows, setSelectedRows] = useState([]); const [selectedRows, setSelectedRows] = useState([]);
...@@ -90,9 +90,18 @@ const SaleDateModal = props => { ...@@ -90,9 +90,18 @@ const SaleDateModal = props => {
notification.error({ message: '请选择要添加的商品' }); notification.error({ message: '请选择要添加的商品' });
return; return;
} }
let shopName = '';
if (shopList) {
shopList.forEach(item => {
if (+item.value === +shopId) {
shopName = item.label;
}
});
}
const arr = deepClone(selectedRows).map(item => ({ const arr = deepClone(selectedRows).map(item => ({
...item, ...item,
shopId, shopId,
shopName,
})); }));
props.onSelectChange(arr); props.onSelectChange(arr);
handleCancel(); handleCancel();
...@@ -123,9 +132,11 @@ const SaleDateModal = props => { ...@@ -123,9 +132,11 @@ const SaleDateModal = props => {
const onSelectAllChange = (selected, rows) => { const onSelectAllChange = (selected, rows) => {
const keys = [...selectedRowKeys]; const keys = [...selectedRowKeys];
const arr = [...selectedRows]; const arr = [...selectedRows];
console.log('selected :>> ', selected);
console.log('rows :>> ', rows);
if (selected) { if (selected) {
rows.forEach(item => { rows.forEach(item => {
if (!keys.includes(item.skuId)) { if (item && !keys.includes(item.skuId)) {
keys.push(item.skuId); keys.push(item.skuId);
arr.push(item); arr.push(item);
} }
...@@ -181,13 +192,17 @@ const SaleDateModal = props => { ...@@ -181,13 +192,17 @@ const SaleDateModal = props => {
}; };
const selectBefore = ( const selectBefore = (
<Select defaultValue="1" onChange={setSearchType}> <Select defaultValue="1" onChange={setSearchType}>
<Option value="1">名称</Option> <Option value="1" key={1}>
<Option value="2">SKU</Option> 名称
</Option>
<Option value="2" key={2}>
SKU
</Option>
</Select> </Select>
); );
const selectAfter = <SearchOutlined onClick={onSearch} />; const selectAfter = <SearchOutlined onClick={onSearch} />;
const footers = () => [ const footers = () => [
<div className={style.footers}> <div className={style.footers} key="footer">
<Pagination defaultCurrent={1} total={total} showQuickJumper onChange={onPageChange} /> <Pagination defaultCurrent={1} total={total} showQuickJumper onChange={onPageChange} />
<div className={style['footers-btn']}> <div className={style['footers-btn']}>
<div className={style['footers-desc']}> <div className={style['footers-desc']}>
...@@ -205,7 +220,7 @@ const SaleDateModal = props => { ...@@ -205,7 +220,7 @@ const SaleDateModal = props => {
useEffect(() => { useEffect(() => {
getShopList(); getShopList();
setGoodsType(props.productType); // setGoodsType(props.productType);
}, []); }, []);
return ( return (
......
...@@ -26,6 +26,13 @@ export const productType = { ...@@ -26,6 +26,13 @@ export const productType = {
5: '外卖商品', 5: '外卖商品',
}; };
// 餐品类型:(1外卖 2 自助餐 4到店)
export const mealType = {
1: '外卖',
2: '自助餐',
4: '到店',
};
export const weekOptions = { export const weekOptions = {
1: '周一', 1: '周一',
2: '周二', 2: '周二',
...@@ -244,11 +251,11 @@ export const takeawayGoodsColumn = options => { ...@@ -244,11 +251,11 @@ export const takeawayGoodsColumn = options => {
}; };
export const GoodsInfoColumn = options => { export const GoodsInfoColumn = options => {
const { onDel, setVisibleSaleDate, setVisibleSaleSection, setEditID } = options; const { onDel, setVisibleSaleDate, setVisibleSaleSection, setEditID, setVisiblePrice } = options;
return [ return [
{ {
title: '微店名称', title: '微店名称',
dataIndex: 'shopId', dataIndex: 'shopName',
}, },
{ {
title: '商品名称', title: '商品名称',
...@@ -263,9 +270,22 @@ export const GoodsInfoColumn = options => { ...@@ -263,9 +270,22 @@ export const GoodsInfoColumn = options => {
}, },
{ {
title: '企业价格', title: '企业价格',
dataIndex: 'activityPrice', dataIndex: 'enterprisePrice',
width: 120, width: 120,
align: 'center', align: 'center',
render: (_, record) => (
<Space>
<span>{_}</span>
<span
onClick={() => {
setEditID(record.skuId);
setVisiblePrice(true);
}}
>
<FormOutlined />
</span>
</Space>
),
}, },
{ {
title: '库存', title: '库存',
...@@ -302,7 +322,7 @@ export const GoodsInfoColumn = options => { ...@@ -302,7 +322,7 @@ export const GoodsInfoColumn = options => {
}, },
{ {
title: '可售餐段', title: '可售餐段',
dataIndex: 'mealType', dataIndex: 'tabCate',
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render: (_, record) => ( render: (_, record) => (
...@@ -321,10 +341,16 @@ export const GoodsInfoColumn = options => { ...@@ -321,10 +341,16 @@ export const GoodsInfoColumn = options => {
}, },
{ {
title: '餐品类型', title: '餐品类型',
dataIndex: 'mealType', dataIndex: 'mealTypeList',
width: 120, width: 120,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render(arr) {
if (arr && arr.length) {
return arr.map(item => mealType[item]).join('/');
}
return '-';
},
}, },
{ {
title: '操作', title: '操作',
......
...@@ -85,14 +85,14 @@ const TakeawayGoods = () => { ...@@ -85,14 +85,14 @@ const TakeawayGoods = () => {
// 根据企业ID获取取餐点 // 根据企业ID获取取餐点
const getPickSelf = async id => { const getPickSelf = async id => {
const res = await apiSelPickSelfList({ enterpriseId: id }); const res = await apiSelPickSelfList({ enterpriseId: id });
if (res) { if (res && res.data) {
setPickSelfList( setPickSelfList(
res.map(item => ({ res.data.map(item => ({
key: item.pickSelfId, key: item.pickSelfId,
label: <span>{item.pickSelfName}</span>, label: <span>{item.pickSelfName}</span>,
})), })),
); );
setActiveKey(res[0].pickSelfId); setActiveKey(res.data[0].pickSelfId);
} }
}; };
......
...@@ -4,6 +4,7 @@ import { useHistory } from 'react-router-dom'; ...@@ -4,6 +4,7 @@ import { useHistory } from 'react-router-dom';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { GoodsInfoColumn } from './staticData/goods'; import { GoodsInfoColumn } from './staticData/goods';
import SaleDateModal from './components/SaleDateModal'; import SaleDateModal from './components/SaleDateModal';
import GoodPriceModal from './components/GoodPriceModal';
import SaleSectionModal from './components/SaleSectionModal'; import SaleSectionModal from './components/SaleSectionModal';
import SelectGoodsModal from './components/SelectGoodsModal'; import SelectGoodsModal from './components/SelectGoodsModal';
import { apiSelPickSelfList, apiPickSelfList, apiSaveGoodsList } from './service'; import { apiSelPickSelfList, apiPickSelfList, apiSaveGoodsList } from './service';
...@@ -17,6 +18,7 @@ const TakeawayGoodsInfo = props => { ...@@ -17,6 +18,7 @@ const TakeawayGoodsInfo = props => {
const [visibleSaleDate, setVisibleSaleDate] = useState(false); // 可售日期弹窗 const [visibleSaleDate, setVisibleSaleDate] = useState(false); // 可售日期弹窗
const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗 const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗
const [visibleSelectGoods, setVisibleSelectGoods] = useState(false); // 选择商品弹窗 const [visibleSelectGoods, setVisibleSelectGoods] = useState(false); // 选择商品弹窗
const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗
const [dataSource, setDataSource] = useState([]); const [dataSource, setDataSource] = useState([]);
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表 const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
const [slePickSelf, setSelPickSelf] = useState([]); // 选中的取餐点列表 const [slePickSelf, setSelPickSelf] = useState([]); // 选中的取餐点列表
...@@ -37,6 +39,7 @@ const TakeawayGoodsInfo = props => { ...@@ -37,6 +39,7 @@ const TakeawayGoodsInfo = props => {
enterprisePrice: item.enterprisePrice, enterprisePrice: item.enterprisePrice,
mealTypeList: item.mealType, mealTypeList: item.mealType,
saleDateList: item.saleDate, saleDateList: item.saleDate,
tabCateList: { tabId: item.tabCate },
})); }));
const params = { const params = {
shopId: id, shopId: id,
...@@ -44,9 +47,11 @@ const TakeawayGoodsInfo = props => { ...@@ -44,9 +47,11 @@ const TakeawayGoodsInfo = props => {
pickSelfIdList: slePickSelf, pickSelfIdList: slePickSelf,
skuInfoList, skuInfoList,
}; };
await apiSaveGoodsList(params); const res = await apiSaveGoodsList(params);
if (res && res.success) {
notification.success({ message: '添加成功' }); notification.success({ message: '添加成功' });
onCancel(); onCancel();
}
}; };
// 删除 // 删除
...@@ -74,7 +79,7 @@ const TakeawayGoodsInfo = props => { ...@@ -74,7 +79,7 @@ const TakeawayGoodsInfo = props => {
enterpriseId: id, enterpriseId: id,
}); });
if (res && res.data) { if (res && res.data) {
setSelPickSelf(res.map(item => item.pickSelfId)); setSelPickSelf(res.data.map(item => item.pickSelfId));
} }
}; };
...@@ -115,6 +120,7 @@ const TakeawayGoodsInfo = props => { ...@@ -115,6 +120,7 @@ const TakeawayGoodsInfo = props => {
setVisibleSaleSection, setVisibleSaleSection,
setEditID, setEditID,
onDel, onDel,
setVisiblePrice,
}; };
return ( return (
...@@ -176,7 +182,11 @@ const TakeawayGoodsInfo = props => { ...@@ -176,7 +182,11 @@ const TakeawayGoodsInfo = props => {
批量配置餐段 批量配置餐段
</Button> </Button>
</div> </div>
<Table columns={GoodsInfoColumn(options)} dataSource={dataSource} /> <Table
columns={GoodsInfoColumn(options)}
pagination={false}
dataSource={dataSource}
/>
</Col> </Col>
</Row> </Row>
<Row className={style['info-box--btns']}> <Row className={style['info-box--btns']}>
...@@ -205,10 +215,18 @@ const TakeawayGoodsInfo = props => { ...@@ -205,10 +215,18 @@ const TakeawayGoodsInfo = props => {
{visibleSaleSection && ( {visibleSaleSection && (
<SaleSectionModal <SaleSectionModal
visible={visibleSaleSection} visible={visibleSaleSection}
handleRefresh={v => refreshList('mealType', v)} handleRefresh={v => refreshList('tabCate', v)}
handleClose={() => setVisibleSaleSection(false)} handleClose={() => setVisibleSaleSection(false)}
/> />
)} )}
{/* 修改企业商品价格弹窗 */}
{visiblePrice && (
<GoodPriceModal
visible={visiblePrice}
handleRefresh={v => refreshList('enterprisePrice', v)}
handleClose={() => setVisiblePrice(false)}
/>
)}
{/* 选择商品弹窗 */} {/* 选择商品弹窗 */}
{visibleSelectGoods && ( {visibleSelectGoods && (
<SelectGoodsModal <SelectGoodsModal
......
...@@ -79,13 +79,15 @@ const VirtualGoods = () => { ...@@ -79,13 +79,15 @@ const VirtualGoods = () => {
// 根据企业ID获取取餐点 // 根据企业ID获取取餐点
const getPickSelf = async () => { const getPickSelf = async () => {
const res = await apiSelPickSelfList({}); const res = await apiSelPickSelfList({});
if (res && res.data) {
setPickSelfList( setPickSelfList(
res.map(item => ({ res.data.map(item => ({
key: item.pickSelfId, key: item.pickSelfId,
label: <span>{item.pickSelfName}</span>, label: <span>{item.pickSelfName}</span>,
})), })),
); );
setActiveKey(res[0].pickSelfId); setActiveKey(res.data[0].pickSelfId);
}
}; };
// 获取企业列表 // 获取企业列表
......
...@@ -59,12 +59,14 @@ const VirtualGoodsInfo = props => { ...@@ -59,12 +59,14 @@ const VirtualGoodsInfo = props => {
const res = await apiShopListByEnterpriseID({ const res = await apiShopListByEnterpriseID({
enterpriseId: id, enterpriseId: id,
}); });
if (res && res.data) {
setShopList( setShopList(
res.map(item => ({ res.data.map(item => ({
key: item.id, key: item.id,
label: <span>{item.name}</span>, label: item.name,
})), })),
); );
}
}; };
// 刷新列表数据 // 刷新列表数据
......
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