Commit f96a9779 authored by 武广's avatar 武广

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

parents 40e72879 f8c96d7c
......@@ -213,10 +213,19 @@ const CustomerInfo = props => {
const obj = Object.assign({}, res.data);
if (res.data.mealTimePeriod && res.data.mealTimePeriod.length) {
const m = moment().format('YYYY-MM-DD');
obj.mealTimePeriod = res.data.mealTimePeriod.map(item => ({
mealPeriodType: `${item.mealPeriodType}`,
time: [moment(`${m} ${item.beginTime}`), moment(`${m} ${item.endTime}`)],
}));
const arr = Object.keys(mealSections);
obj.mealTimePeriod = Object.keys(mealSections).map(() => ({}));
res.data.mealTimePeriod.forEach((item, i) => {
if (item) {
const index = arr.indexOf(`${item.mealPeriodType}`);
if (index > -1) {
obj.mealTimePeriod[index] = {
mealPeriodType: `${item.mealPeriodType}`,
time: [moment(`${m} ${item.beginTime}`), moment(`${m} ${item.endTime}`)],
};
}
}
});
} else {
obj.mealTimePeriod = [];
}
......@@ -237,7 +246,6 @@ const CustomerInfo = props => {
obj.hideInfo.push('hideImage');
}
obj.mealType = res.data.mealType.map(item => `${item}`);
console.log('obj :>> ', obj);
setMealTypes(obj.mealType);
const json = {};
res.data.mealTimePeriod.forEach(item => {
......@@ -303,7 +311,11 @@ const CustomerInfo = props => {
<Input />
</Form.Item>
{!props.id && (
<Form.Item label="企业取餐点" name="pickselfIds">
<Form.Item
label="企业取餐点"
name="pickselfIds"
rules={[{ required: true, type: 'array', message: '请选择企业取餐点!' }]}
>
<Select
options={pickSelfList}
mode="multiple"
......
......@@ -4,6 +4,7 @@ import { Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { customerColumn } from './staticData/index';
import CustomerInfo from './components/CustomerInfo';
import utilStyle from '@/utils/utils.less';
import { apiEnterpriseList } from './service';
const BusinessCustomer = () => {
......@@ -28,7 +29,7 @@ const BusinessCustomer = () => {
};
return (
<div>
<div className={utilStyle.formPageBox}>
<ProTable
actionRef={refTable}
search={{
......
import React, { useState, useEffect } from 'react';
import { Form, Checkbox, Space, Modal, notification, message } from 'antd';
import { Checkbox, Space, Modal, notification, message } from 'antd';
import { mealColumn } from '../staticData/goods';
import { apiMealInfoUpdate } from '../service';
const SaleDateModal = props => {
const [form] = Form.useForm();
const [value, setValue] = useState([]);
// 关闭弹窗
......@@ -54,7 +53,9 @@ const SaleDateModal = props => {
<Checkbox.Group onChange={onChangeMeal} value={value}>
<Space direction="vertical">
{Object.keys(mealColumn).map(key => (
<Checkbox value={key}>{mealColumn[key]}</Checkbox>
<Checkbox key={key} value={key}>
{mealColumn[key]}
</Checkbox>
))}
</Space>
</Checkbox.Group>
......
......@@ -11,7 +11,6 @@ const { Option } = Select;
const SaleDateModal = props => {
const [searchType, setSearchType] = useState('1');
const [searchKeyword, setSearchKeyword] = useState('');
// const [goodsType, setGoodsType] = useState('1');
const [shopId, setShopId] = useState(props.shopID);
const [shopName, setShopName] = useState('');
const [searchName, setSearchName] = useState('');
......@@ -21,8 +20,8 @@ const SaleDateModal = props => {
const [total, setTotal] = useState(0);
const [dataSource, setDataSource] = useState([]);
const [shopList, setShopList] = useState([]);
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [selectedRows, setSelectedRows] = useState([]);
const [selectedRowKeys, setSelectedRowKeys] = useState(props.selectedRowKeys || []);
const [selectedRows, setSelectedRows] = useState(props.selectedRows || []);
const searchList = async params => {
console.log('params :>> ', params);
......@@ -58,6 +57,9 @@ const SaleDateModal = props => {
const res = await api(data);
console.log('res :>> ', res);
if (res && res.data && res.data.records) {
res.data.records.forEach(item => {
item.enterprisePrice = item.salePrice;
});
setDataSource(res.data.records);
setTotal(res.data.total);
}
......@@ -110,6 +112,9 @@ const SaleDateModal = props => {
if (!props.shopID) {
props.onChangeShop(shopId);
}
if (props.onSelectedRowKeys) {
props.onSelectedRowKeys(selectedRowKeys);
}
handleCancel();
};
......@@ -212,7 +217,7 @@ const SaleDateModal = props => {
<Pagination defaultCurrent={1} total={total} showQuickJumper onChange={onPageChange} />
<div className={style['footers-btn']}>
<div className={style['footers-desc']}>
已选商品(<span className={style['footers-num']}>{selectedRows.length}</span>)
已选商品(<span className={style['footers-num']}>{selectedRowKeys.length}</span>)
</div>
<Button key="back" onClick={handleCancel}>
取消
......
......@@ -82,7 +82,7 @@ export const takeawayGoodsColumn = options => {
{
title: 'SKU编码',
dataIndex: 'skuId',
width: 160,
width: 170,
align: 'center',
},
{
......@@ -101,7 +101,6 @@ export const takeawayGoodsColumn = options => {
{
title: '可售日期',
dataIndex: 'saleDateList',
width: 120,
align: 'center',
hideInSearch: true,
render: (_, record) => (
......@@ -125,7 +124,6 @@ export const takeawayGoodsColumn = options => {
{
title: '可售餐段',
dataIndex: 'tabCateList',
width: 120,
align: 'center',
hideInSearch: true,
render: (_, record) => (
......@@ -145,7 +143,7 @@ export const takeawayGoodsColumn = options => {
{
title: '企业价格',
dataIndex: 'activityPrice',
width: 100,
width: 120,
align: 'center',
hideInSearch: true,
render: (_, record) => (
......@@ -184,7 +182,7 @@ export const takeawayGoodsColumn = options => {
{
title: '排序',
dataIndex: 'sort',
width: 80,
width: 90,
align: 'center',
hideInSearch: true,
render: (_, record) => (
......@@ -204,8 +202,8 @@ export const takeawayGoodsColumn = options => {
{
title: '列出商品',
dataIndex: 'showFlag',
width: 80,
align: 'center',
width: 100,
hideInSearch: true,
render: (_, record) => (
<Space>
......@@ -217,15 +215,19 @@ export const takeawayGoodsColumn = options => {
},
{
title: '餐品类型',
dataIndex: 'mealType',
width: 80,
dataIndex: 'mealTypeList',
align: 'center',
hideInSearch: true,
render(arr) {
if (arr && arr.length) {
return arr.map(item => item.name).join('/');
}
return '-';
},
},
{
title: '添加时间',
dataIndex: 'createDate',
width: 120,
valueType: 'dateRange',
align: 'center',
render(v, record) {
......@@ -235,7 +237,6 @@ export const takeawayGoodsColumn = options => {
{
title: '当日餐段',
dataIndex: 'tabId',
width: 120,
align: 'center',
valueEnum: mealColumn,
hideInTable: true,
......@@ -303,6 +304,9 @@ export const GoodsInfoColumn = options => {
if (arr && arr.length) {
return arr[0].stock;
}
if (![null, undefined].includes(v)) {
return v;
}
return '-';
},
},
......
......@@ -35,19 +35,41 @@ const TakeawayGoodsInfo = props => {
message.error('请添加商品');
return;
}
const skuInfoList = dataSource.map(item => ({
skuId: item.skuId,
enterprisePrice: item.enterprisePrice,
mealTypeList: item.mealTypeList.map(m => m.code),
saleDateList: item.saleDate,
tabCateList: item.tabCate.map(t => ({ tabId: t })),
}));
const skuInfoList = [];
try {
dataSource.forEach(item => {
if (!item.mealTypeList || item.mealTypeList.length < 1) {
throw Error('请添加餐品类型!');
}
if (!item.enterprisePrice || `${item.enterprisePrice}`.length < 1) {
throw Error('请添加企业价格!');
}
if (!item.saleDate || item.saleDate.length < 1) {
throw Error('请添加可售日期!');
}
if (!item.tabCate || item.tabCate.length < 1) {
throw Error('请添加可售餐段!');
}
const json = {
skuId: item.skuId,
enterprisePrice: item.enterprisePrice,
mealTypeList: item.mealTypeList.map(m => m.code),
saleDateList: item.saleDate,
tabCateList: item.tabCate.map(t => ({ tabId: t })),
};
skuInfoList.push(json);
});
} catch (e) {
message.error(e.message);
return;
}
const params = {
shopId,
enterpriseId: id,
pickSelfIdList: slePickSelf,
skuInfoList,
};
console.log('params :>> ', params);
const res = await apiSaveGoodsList(params);
if (res && res.success) {
notification.success({ message: '添加成功' });
......
......@@ -8,7 +8,7 @@ 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';
import { apiSaveVirtualGoodsList, apiShopListByEnterpriseID, apiVirtualList } from './service';
import style from './style/index.less';
......@@ -24,6 +24,7 @@ const VirtualGoodsInfo = props => {
const [shopList, setShopList] = useState({}); // 店铺列表
const [sleShopID, setSelShopID] = useState(''); // 选中的店铺ID
const [sleShopName, setSelShopName] = useState(''); // 选中的店铺名称
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [editID, setEditID] = useState(''); // 编辑ID
// 取消
......@@ -46,13 +47,34 @@ const VirtualGoodsInfo = props => {
message.error('请添加商品');
return;
}
const skuInfoList = dataSource.map(item => ({
skuId: item.skuId,
enterprisePrice: item.enterprisePrice,
mealTypeList: item.mealTypeList.map(m => m.code),
saleDateList: item.saleDate,
tabCateList: item.tabCate.map(t => ({ tabId: t })),
}));
const skuInfoList = [];
try {
dataSource.forEach(item => {
if (!item.mealTypeList || item.mealTypeList.length < 1) {
throw Error('请添加餐品类型!');
}
if (!item.enterprisePrice || `${item.enterprisePrice}`.length < 1) {
throw Error('请添加企业价格!');
}
if (!item.saleDate || item.saleDate.length < 1) {
throw Error('请添加可售日期!');
}
if (!item.tabCate || item.tabCate.length < 1) {
throw Error('请添加可售餐段!');
}
const json = {
skuId: item.skuId,
enterprisePrice: item.enterprisePrice,
mealTypeList: item.mealTypeList.map(m => m.code),
saleDateList: item.saleDate,
tabCateList: item.tabCate.map(t => ({ tabId: t })),
};
skuInfoList.push(json);
});
} catch (e) {
message.error(e.message);
return;
}
const params = {
enterpriseId: id,
shopId: sleShopID,
......@@ -86,10 +108,38 @@ const VirtualGoodsInfo = props => {
}
};
// 查询已选商品列表
const getGoodsList = async shopId => {
const data = {
page: 1,
size: 1000,
data: {
enterpriseId: id,
shopId,
},
};
const res = await apiVirtualList(data);
if (res && res.data && res.data.records && res.data.records.length) {
const keys = [];
setDataSource(
res.data.records.map(item => {
item.saleDate = item.saleDateList.map(d => d.code);
item.tabCate = item.tabCateList.map(c => c.tabId);
item.enterprisePrice = item.activityPrice;
item.salePrice = item.price;
keys.push(item.skuId);
return item;
}),
);
setSelectedRowKeys(keys);
}
};
// 选中店铺
const onSelectShop = sid => {
setSelShopID(sid);
setSelShopName(shopList[sid]);
getGoodsList(sid);
};
// 刷新列表数据
......@@ -107,9 +157,6 @@ const VirtualGoodsInfo = props => {
setDataSource(arr);
};
// const initData = async () => {
// setLoading(true);
// };
useEffect(() => {
getShopList();
}, []);
......@@ -212,7 +259,10 @@ const VirtualGoodsInfo = props => {
productType={4}
shopID={sleShopID}
shopName={sleShopName}
selectedRowKeys={selectedRowKeys}
selectedRows={dataSource}
onSelectChange={setDataSource}
onSelectedRowKeys={setSelectedRowKeys}
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