Commit ac79722f authored by 武广's avatar 武广

Merge branch 'feature/group-meal' of git.quantgroup.cn:ui/merchant-manage-ui into feature/meal-3.0

parents a6bf4d34 e3206489
......@@ -25,8 +25,8 @@ export default [
},
{
title: '商户管理后台-企业团餐-虚拟商品-添加商品',
path: '/takeawayGoodsInfo',
name: 'TakeawayGoodsInfo',
path: '/virtualGoodsInfo',
name: 'VirtualGoodsInfo',
component: './businessGoods/virtualGoodsInfo',
},
];
......@@ -51,11 +51,13 @@ const CustomerInfo = props => {
};
// 校验时间
const checkTime = (arr, curren) => {
const checkTime = (arr, curren, curName) => {
let valid = false;
arr.forEach(item => {
if (curren > item.beginTime && curren < item.endTime) {
if (curren < item.endTime) {
valid = true;
const name = meals[item.mealPeriodType];
notification.error({ message: `${curName}起始时间不能早于${name}截止时间` });
}
});
return valid;
......@@ -79,19 +81,19 @@ const CustomerInfo = props => {
const arr = [];
let validTime = false;
res.mealTimePeriod.forEach(item => {
if (item.mealPeriodType) {
if (item && meals[item.mealPeriodType]) {
const obj = Object.assign({}, item);
obj.beginTime = moment(obj.time[0]).format('HH:mm');
obj.endTime = moment(obj.time[1]).format('HH:mm');
delete obj.time;
if (checkTime(arr, obj.beginTime) || checkTime(arr, obj.endTime)) {
if (checkTime(arr, obj.beginTime, meals[item.mealPeriodType])) {
validTime = true;
}
arr.push(obj);
}
});
if (validTime) {
notification.error({ message: '时间段不能交叉!' });
// notification.error({ message: '时间段不能交叉!' });
return;
}
params.mealTimePeriod = arr;
......@@ -107,18 +109,27 @@ const CustomerInfo = props => {
}
// 处理限额
Object.keys(res.mealLimit).forEach(item => {
const json = {
mealPeriodType: item.replace('limit', ''),
limit: [],
};
Object.keys(res.mealLimit[item]).forEach(t => {
json.limit.push({
mealType: t,
limit: res.mealLimit[item][t],
const mealPeriodType = item.replace('limit', '');
if (meals[mealPeriodType]) {
const json = {
mealPeriodType,
limit: [],
};
Object.keys(res.mealLimit[item]).forEach(t => {
if (mealTypes.includes(t)) {
json.limit.push({
mealType: t,
limit: res.mealLimit[item][t],
});
}
});
});
limits.push(json);
limits.push(json);
}
});
if (limits.length < 1) {
notification.error({ message: '请选择餐段配置!' });
return;
}
params.mealLimit = limits;
console.log('params :>> ', params);
let api = apiNewEnterprise;
......@@ -127,7 +138,7 @@ const CustomerInfo = props => {
api = apiEditEnterprise;
}
const resp = await api(params);
if (resp) {
if (resp && resp.data) {
handleCancel();
props.reFresh();
notification.success({ message: '保存成功!' });
......@@ -158,7 +169,6 @@ const CustomerInfo = props => {
if (props.info && props.info.id && ms.length < mealTypes.length) {
await checkConfirm();
}
console.log('ms :>> ', ms);
if (mealTypes.length > ms.length) {
if (ms.includes('1') && ms.includes('2')) {
ms = ['1', '2'];
......
......@@ -12,7 +12,8 @@ const SaleDateModal = props => {
const [searchType, setSearchType] = useState('1');
const [searchKeyword, setSearchKeyword] = useState('');
// const [goodsType, setGoodsType] = useState('1');
const [shopId, setShopId] = useState();
const [shopId, setShopId] = useState(props.shopID);
const [shopName, setShopName] = useState('');
const [searchName, setSearchName] = useState('');
const [loading, setLoading] = useState(false);
const [page, setPage] = useState(1);
......@@ -90,21 +91,25 @@ const SaleDateModal = props => {
notification.error({ message: '请选择要添加的商品' });
return;
}
let shopName = '';
if (shopList) {
let sName = '';
if (shopList && shopList.length) {
shopList.forEach(item => {
if (+item.value === +shopId) {
shopName = item.label;
sName = item.label;
}
});
} else {
sName = shopName;
}
const arr = deepClone(selectedRows).map(item => ({
...item,
shopId,
shopName,
shopName: sName,
}));
props.onSelectChange(arr);
props.onChangeShop(shopId);
if (!props.shopID) {
props.onChangeShop(shopId);
}
handleCancel();
};
......@@ -220,7 +225,13 @@ const SaleDateModal = props => {
];
useEffect(() => {
getShopList();
if (+props.productType === 5) {
getShopList();
} else {
setShopId(props.shopID);
setShopName(props.shopName);
searchList({});
}
// setGoodsType(props.productType);
}, []);
......@@ -236,13 +247,17 @@ const SaleDateModal = props => {
footer={footers()}
>
<div className={style['select-goods-box']}>
<Select
placeholder="请选择店铺"
options={shopList}
value={shopId}
onChange={onChangeShop}
className={style['select-goods-box--select']}
/>
{props.productType === 5 ? (
<Select
placeholder="请选择店铺"
options={shopList}
value={shopId}
onChange={onChangeShop}
className={style['select-goods-box--select']}
/>
) : (
<Input disabled value={shopName} className={style['select-goods-box--txt']} />
)}
<Select
placeholder="请选择商品类型"
disabled
......
......@@ -24,23 +24,19 @@ export const getEnterpriseList = async () => {
};
};
// 获取店铺列表
export const getShopList = debounce(async e => {
const res = await apiShopList({ name: e });
if (res && res.data && res.data.records) {
const data = res.data.records;
// const json = {};
// data.forEach(item => {
// json[item.id] = { text: item.name };
// });
// return json;
return data.map(item => ({
value: item.id,
text: item.name,
}));
export const getShopList = async e => {
if (e.keyWords) {
const res = await apiShopList({ name: e.keyWords });
if (res && res.data) {
const { data } = res;
return data.map(item => ({
value: item.id,
label: item.name,
}));
}
}
// return {};
return [];
}, 300);
};
// 获取店铺列表通过自提点ID
export const getShopListByPickSelf = async e => {
const { name } = e;
......
......@@ -64,15 +64,25 @@ export async function apiMealInfoUpdate(param) {
});
}
/**
* 企业团餐->删除
* 企业团餐->删除外卖商品
* http://yapi.quantgroups.com/project/389/interface/api/65109
*/
export async function apiMealInfoDel(param) {
export async function apiTakeawayGoodsDel(param) {
return request.post(`${apiPrefix}/product/enterprise/main/deleteById`, {
data: param,
prefix: roleApi,
});
}
/**
* 企业团餐->删除虚拟商品
* http://yapi.quantgroups.com/project/389/interface/api/65109
*/
export async function apiVirtualGoodsDel(param) {
return request.post(`${apiPrefix}/product/enterprise/virtual/deleteById`, {
data: param,
prefix: roleApi,
});
}
/**
* 企业团餐->查询自提点列表
* http://yapi.quantgroups.com/project/389/interface/api/65494
......@@ -127,7 +137,7 @@ export async function apiSaveGoodsList(param) {
* http://yapi.quantgroups.com/project/389/interface/api/65484
*/
export async function apiSaveVirtualGoodsList(param) {
return request.post(`${apiPrefix}/products/enterprise/virtual/add`, {
return request.post(`${apiPrefix}/product/enterprise/virtual/add`, {
data: param,
prefix: roleApi,
});
......
......@@ -46,7 +46,6 @@ export const weekOptions = {
export const takeawayGoodsColumn = options => {
const {
onDel,
shopEnum,
onChangeFlag,
setVisibleSaleDate,
enterprises,
......@@ -66,7 +65,7 @@ export const takeawayGoodsColumn = options => {
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise,
},
valueEnum: enterprises, // companyEnum,
valueEnum: enterprises,
},
{
title: '微店名称',
......@@ -75,10 +74,10 @@ export const takeawayGoodsColumn = options => {
fieldProps: {
showSearch: true,
filterOption: false,
onSearch: getShopList,
// onSearch: getShopList,
},
// request: getShopList,
valueEnum: {}, // shopEnum,
request: getShopList,
valueEnum: {},
},
{
title: 'SKU编码',
......@@ -177,7 +176,7 @@ export const takeawayGoodsColumn = options => {
align: 'center',
hideInSearch: true,
valueEnum: {
1: '生效中',
1: '已上架',
2: '已下架',
3: '已售罄',
},
......@@ -442,9 +441,9 @@ export const virtualGoodsColumn = options => {
fieldProps: {
showSearch: true,
filterOption: false,
onSearch: getShopList,
// onSearch: getShopList,
},
// request: getShopList,
request: getShopList,
valueEnum: {}, // shopEnum,
},
{
......@@ -518,17 +517,23 @@ export const virtualGoodsColumn = options => {
align: 'center',
hideInSearch: true,
valueEnum: {
1: '生效中',
1: '已上架',
2: '已下架',
3: '已售罄',
},
},
{
title: '餐品类型',
dataIndex: 'mealType',
width: 80,
dataIndex: 'mealTypeList',
width: 120,
align: 'center',
hideInSearch: true,
render(arr) {
if (arr && arr.length) {
return arr.map(item => item.name).join('/');
}
return '-';
},
},
{
title: '添加时间',
......
......@@ -5,8 +5,13 @@ import { Button, notification } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { takeawayGoodsColumn } from './staticData/goods';
import utilStyle from '@/utils/utils.less';
import { apiTakeawayList, apiSelPickSelfList, apiMealInfoDel, apiMealInfoUpdate } from './service';
import { getEnterpriseList, getShopList } from './service/bll';
import {
apiTakeawayList,
apiSelPickSelfList,
apiTakeawayGoodsDel,
apiMealInfoUpdate,
} from './service';
import { getEnterpriseList } from './service/bll';
import SaleDateModal from './components/SaleDateModal';
import SaleSectionModal from './components/SaleSectionModal';
import GoodPriceModal from './components/GoodPriceModal';
......@@ -23,7 +28,6 @@ const TakeawayGoods = () => {
const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗
const [visibleSort, setVisibleSort] = useState(false); // 商品排序弹窗
const [enterprises, setEnterprises] = useState({}); // 企业列表
const [shopEnum, setShopEnum] = useState({}); // 店铺列表
const [activeKey, setActiveKey] = useState('');
const [enterpriseId, setEnterpriseId] = useState();
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
......@@ -39,6 +43,11 @@ const TakeawayGoods = () => {
// 搜索商品列表
const searchList = async params => {
if (params.createDate && params.createDate.length) {
const [startDateTime, endDateTime] = params.createDate;
params.startDateTime = startDateTime;
params.endDateTime = endDateTime;
}
const data = {
page: params.current || 1,
size: params.pageSize || 10,
......@@ -61,7 +70,7 @@ const TakeawayGoods = () => {
};
// 删除商品
const onDel = async id => {
await apiMealInfoDel({
await apiTakeawayGoodsDel({
id,
});
refTable.current.reload();
......@@ -151,7 +160,6 @@ const TakeawayGoods = () => {
onChangeEnterprise,
onChangeFlag,
onRefresh,
shopEnum,
};
return (
......
......@@ -5,8 +5,8 @@ import { Button, notification } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { virtualGoodsColumn } from './staticData/goods';
import utilStyle from '@/utils/utils.less';
import { apiVirtualList, apiSelPickSelfList, apiMealInfoDel } from './service';
import { getEnterpriseList, getShopList } from './service/bll';
import { apiVirtualList, apiVirtualGoodsDel } from './service';
import { getEnterpriseList } from './service/bll';
import { getToUrlQuery } from '@/utils/utils';
// 企业虚拟商品
......@@ -15,7 +15,6 @@ const VirtualGoods = () => {
const refTable = useRef();
const [pageLoaded, setPageLoaded] = useState(false);
const [enterprises, setEnterprises] = useState({}); // 企业列表
const [activeKey, setActiveKey] = useState('');
const [enterpriseId, setEnterpriseId] = useState();
// 刷新列表
......@@ -28,19 +27,23 @@ const VirtualGoods = () => {
// 搜索商品列表
const searchList = async params => {
if (params.createDate && params.createDate.length) {
const [startDateTime, endDateTime] = params.createDate;
params.startDateTime = startDateTime;
params.endDateTime = endDateTime;
}
const data = {
page: params.current || 1,
size: params.pageSize || 10,
data: Object.assign({}, params, {
enterpriseId,
pickSelfId: activeKey,
}),
};
const res = await apiVirtualList(data);
if (res && res.records) {
if (res && res.data && res.data.records && res.data.records.length) {
return {
data: res.records || [],
total: res.total || 0,
data: res.data.records || [],
total: res.data.total || 0,
};
}
return {
......@@ -50,7 +53,7 @@ const VirtualGoods = () => {
};
// 删除商品
const onDel = async id => {
await apiMealInfoDel({
await apiVirtualGoodsDel({
id,
});
refTable.current.reload();
......@@ -69,7 +72,7 @@ const VirtualGoods = () => {
params,
);
history.push({
pathname: '/takeawayGoodsInfo',
pathname: '/virtualGoodsInfo',
query,
});
};
......
......@@ -3,7 +3,9 @@ import { Button, notification, Spin, Select, Row, Col, Table, message } from 'an
import { useHistory } from 'react-router-dom';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { GoodsInfoColumn } from './staticData/goods';
import { jsonToArray } from '@/utils/utils';
import SaleDateModal from './components/SaleDateModal';
import GoodPriceModal from './components/GoodPriceModal';
import SaleSectionModal from './components/SaleSectionModal';
import SelectGoodsModal from './components/SelectGoodsModal';
import { apiSaveVirtualGoodsList, apiShopListByEnterpriseID } from './service';
......@@ -17,15 +19,27 @@ const VirtualGoodsInfo = props => {
const [visibleSaleDate, setVisibleSaleDate] = useState(false); // 可售日期弹窗
const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗
const [visibleSelectGoods, setVisibleSelectGoods] = useState(false); // 选择商品弹窗
const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗
const [dataSource, setDataSource] = useState([]);
const [shopList, setShopList] = useState([]); // 店铺列表
const [sleShopID, setSelShopID] = useState(''); // 选中的店铺
const [shopList, setShopList] = useState({}); // 店铺列表
const [sleShopID, setSelShopID] = useState(''); // 选中的店铺ID
const [sleShopName, setSelShopName] = useState(''); // 选中的店铺名称
const [editID, setEditID] = useState(''); // 编辑ID
// 取消
const onCancel = () => {
history.goBack();
};
// 打开选择商品弹窗
const openSelectModal = () => {
if (!sleShopID) {
message.error('请选择店铺');
return;
}
setVisibleSelectGoods(true);
};
// 提交
const onSubmit = async () => {
if (!dataSource || dataSource.length < 1) {
......@@ -41,6 +55,7 @@ const VirtualGoodsInfo = props => {
}));
const params = {
enterpriseId: id,
shopId: sleShopID,
skuInfoList,
};
const res = await apiSaveVirtualGoodsList(params);
......@@ -63,15 +78,20 @@ const VirtualGoodsInfo = props => {
enterpriseId: id,
});
if (res && res.data) {
setShopList(
res.data.map(item => ({
value: item.id,
label: item.name,
})),
);
const json = {};
res.data.forEach(item => {
json[item.id] = item.name;
});
setShopList(json);
}
};
// 选中店铺
const onSelectShop = sid => {
setSelShopID(sid);
setSelShopName(shopList[sid]);
};
// 刷新列表数据
const refreshList = (type, v) => {
const arr = dataSource.map(item => {
......@@ -98,6 +118,7 @@ const VirtualGoodsInfo = props => {
setVisibleSaleDate,
setVisibleSaleSection,
setEditID,
setVisiblePrice,
onDel,
};
......@@ -118,11 +139,11 @@ const VirtualGoodsInfo = props => {
<Col span={20}>
<Select
showSearch
options={shopList}
options={jsonToArray(shopList)}
className={style['info-box--select']}
placeholder="清选择"
value={sleShopID}
onChange={setSelShopID}
onChange={e => onSelectShop(e)}
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
......@@ -134,7 +155,7 @@ const VirtualGoodsInfo = props => {
添加商品:
</Col>
<Col span={20}>
<Button type="primary" onClick={() => setVisibleSelectGoods(true)}>
<Button type="primary" onClick={openSelectModal}>
选择商品
</Button>
</Col>
......@@ -170,18 +191,27 @@ const VirtualGoodsInfo = props => {
{visibleSaleSection && (
<SaleSectionModal
visible={visibleSaleSection}
handleRefresh={v => refreshList('mealType', v)}
handleRefresh={v => refreshList('tabCate', v)}
handleClose={() => setVisibleSaleSection(false)}
/>
)}
{/* 修改企业商品价格弹窗 */}
{visiblePrice && (
<GoodPriceModal
visible={visiblePrice}
handleRefresh={v => refreshList('enterprisePrice', v)}
handleClose={() => setVisiblePrice(false)}
/>
)}
{/* 选择商品弹窗 */}
{visibleSelectGoods && (
<SelectGoodsModal
visible={visibleSelectGoods}
type="virtual"
enterpriseId={id}
productType={2}
productType={4}
shopID={sleShopID}
shopName={sleShopName}
onSelectChange={setDataSource}
handleClose={() => setVisibleSelectGoods(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