Commit 81e54fd6 authored by 武广's avatar 武广

fix: 修改外卖商品列表

parent f1e3c41b
...@@ -5,7 +5,7 @@ const environment = 'sc'; ...@@ -5,7 +5,7 @@ const environment = 'sc';
// 从tob进入的判断接口前缀 // 从tob进入的判断接口前缀
const getUrlParams = name => { const getUrlParams = name => {
const regArg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`); const regArg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
const r = window.location.search.substr(1).match(regArg); const r = window.location.search.substring(1).match(regArg);
if (r != null) return decodeURIComponent(r[2]); if (r != null) return decodeURIComponent(r[2]);
return null; return null;
}; };
......
...@@ -104,6 +104,7 @@ const SaleDateModal = props => { ...@@ -104,6 +104,7 @@ const SaleDateModal = props => {
shopName, shopName,
})); }));
props.onSelectChange(arr); props.onSelectChange(arr);
props.onChangeShop(shopId);
handleCancel(); handleCancel();
}; };
......
...@@ -46,7 +46,6 @@ export const weekOptions = { ...@@ -46,7 +46,6 @@ export const weekOptions = {
export const takeawayGoodsColumn = options => { export const takeawayGoodsColumn = options => {
const { const {
onDel, onDel,
companyEnum,
shopEnum, shopEnum,
onChangeFlag, onChangeFlag,
setVisibleSaleDate, setVisibleSaleDate,
...@@ -73,28 +72,27 @@ export const takeawayGoodsColumn = options => { ...@@ -73,28 +72,27 @@ export const takeawayGoodsColumn = options => {
title: '微店名称', title: '微店名称',
dataIndex: 'shopId', dataIndex: 'shopId',
hideInTable: true, hideInTable: true,
fieldProps: { // fieldProps: {
showSearch: true, // showSearch: true,
}, // },
// request: getShopList, // request: getShopList,
// valueEnum: {}, // shopEnum, // valueEnum: {}, // shopEnum,
}, },
{ {
title: 'SKU编码', title: 'SKU编码',
dataIndex: 'skuId', dataIndex: 'skuId',
width: 120, width: 160,
align: 'center', align: 'center',
}, },
{ {
title: '商品名称', title: '商品名称',
dataIndex: 'skuName', dataIndex: 'skuName',
width: 120,
align: 'center', align: 'center',
}, },
{ {
title: '商品图片', title: '商品图片',
dataIndex: 'primaryImage', dataIndex: 'primaryImage',
width: 120, width: 80,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
valueType: 'image', valueType: 'image',
...@@ -121,13 +119,13 @@ export const takeawayGoodsColumn = options => { ...@@ -121,13 +119,13 @@ export const takeawayGoodsColumn = options => {
}, },
{ {
title: '可售餐段', title: '可售餐段',
dataIndex: 'saleDate', dataIndex: 'tabCateList',
width: 120, width: 120,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render: (_, record) => ( render: (_, record) => (
<Space> <Space>
<span>{_}</span> {_ && _.length && <span>{_.map(item => item.tabName).join('/')}</span>}
<span <span
onClick={() => { onClick={() => {
setRecordID(record.id); setRecordID(record.id);
...@@ -142,7 +140,7 @@ export const takeawayGoodsColumn = options => { ...@@ -142,7 +140,7 @@ export const takeawayGoodsColumn = options => {
{ {
title: '企业价格', title: '企业价格',
dataIndex: 'activityPrice', dataIndex: 'activityPrice',
width: 120, width: 100,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render: (_, record) => ( render: (_, record) => (
...@@ -162,14 +160,14 @@ export const takeawayGoodsColumn = options => { ...@@ -162,14 +160,14 @@ export const takeawayGoodsColumn = options => {
{ {
title: '商品销售价', title: '商品销售价',
dataIndex: 'price', dataIndex: 'price',
width: 120, width: 100,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'status', dataIndex: 'status',
width: 120, width: 80,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
valueEnum: { valueEnum: {
...@@ -181,7 +179,7 @@ export const takeawayGoodsColumn = options => { ...@@ -181,7 +179,7 @@ export const takeawayGoodsColumn = options => {
{ {
title: '排序', title: '排序',
dataIndex: 'sort', dataIndex: 'sort',
width: 120, width: 80,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render: (_, record) => ( render: (_, record) => (
...@@ -201,7 +199,7 @@ export const takeawayGoodsColumn = options => { ...@@ -201,7 +199,7 @@ export const takeawayGoodsColumn = options => {
{ {
title: '列出商品', title: '列出商品',
dataIndex: 'showFlag', dataIndex: 'showFlag',
width: 120, width: 80,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render: (_, record) => ( render: (_, record) => (
...@@ -215,7 +213,7 @@ export const takeawayGoodsColumn = options => { ...@@ -215,7 +213,7 @@ export const takeawayGoodsColumn = options => {
{ {
title: '餐品类型', title: '餐品类型',
dataIndex: 'mealType', dataIndex: 'mealType',
width: 120, width: 80,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
}, },
...@@ -225,6 +223,9 @@ export const takeawayGoodsColumn = options => { ...@@ -225,6 +223,9 @@ export const takeawayGoodsColumn = options => {
width: 120, width: 120,
valueType: 'dateRange', valueType: 'dateRange',
align: 'center', align: 'center',
render(v, record) {
return record.createDate;
},
}, },
{ {
title: '当日餐段', title: '当日餐段',
...@@ -347,7 +348,7 @@ export const GoodsInfoColumn = options => { ...@@ -347,7 +348,7 @@ export const GoodsInfoColumn = options => {
hideInSearch: true, hideInSearch: true,
render(arr) { render(arr) {
if (arr && arr.length) { if (arr && arr.length) {
return arr.map(item => mealType[item]).join('/'); return arr.map(item => item.name).join('/');
} }
return '-'; return '-';
}, },
......
...@@ -17,47 +17,59 @@ import { getToUrlQuery } from '@/utils/utils'; ...@@ -17,47 +17,59 @@ import { getToUrlQuery } from '@/utils/utils';
const TakeawayGoods = () => { const TakeawayGoods = () => {
const history = useHistory(); const history = useHistory();
const refTable = useRef(); const refTable = useRef();
const [pageLoading, setPageLoading] = useState(true); // 可售日期弹窗 const [pageLoaded, setPageLoaded] = useState(false); // 可售日期弹窗
const [visibleSaleDate, setVisibleSaleDate] = useState(false); // 可售日期弹窗 const [visibleSaleDate, setVisibleSaleDate] = useState(false); // 可售日期弹窗
const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗 const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗
const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗 const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗
const [visibleSort, setVisibleSort] = useState(false); // 商品排序弹窗 const [visibleSort, setVisibleSort] = useState(false); // 商品排序弹窗
const [enterprises, setEnterprises] = useState({ 1: { text: '领红包' } }); // 企业列表 const [enterprises, setEnterprises] = useState({}); // 企业列表
const [shopEnum, setShopEnum] = useState({}); // 店铺列表 const [shopEnum, setShopEnum] = useState({}); // 店铺列表
const [activeKey, setActiveKey] = useState(''); const [activeKey, setActiveKey] = useState('');
const [enterpriseId, setEnterpriseId] = useState('1'); const [enterpriseId, setEnterpriseId] = useState();
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表 const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
const [recordID, setRecordID] = useState(''); // 编辑的记录ID const [recordID, setRecordID] = useState(''); // 编辑的记录ID
// 刷新列表
const onRefresh = () => {
if (pageLoaded) {
refTable.current.reloadAndRest();
// refTable.current.reload();
}
};
// 搜索商品列表 // 搜索商品列表
const searchList = async params => { const searchList = async params => {
if (params.enterpriseId && params.enterpriseId !== enterpriseId) {
setEnterpriseId(params.enterpriseId);
}
const data = { const data = {
page: params.current, page: params.current || 1,
size: params.pageSize, size: params.pageSize || 10,
data: Object.assign( data: Object.assign({}, params, {
{ enterpriseId,
enterpriseId, pickSelfId: activeKey,
}, }),
params,
),
}; };
const res = await apiTakeawayList(data); const res = await apiTakeawayList(data);
if (res && res.records) {
return {
data: res.records || [],
total: res.total || 0,
};
}
return { return {
data: res.records, data: [],
total: res.total, total: 0,
}; };
}; };
// 删除商品
const onDel = async id => { const onDel = async id => {
await apiMealInfoDel({ await apiMealInfoDel({
id, id,
}); });
refTable.current.reload();
notification.success({ notification.success({
message: '删除成功', message: '删除成功',
}); });
}; };
// 跳转添加商品
const onAdd = async () => { const onAdd = async () => {
const params = getToUrlQuery(); const params = getToUrlQuery();
const query = Object.assign( const query = Object.assign(
...@@ -72,7 +84,7 @@ const TakeawayGoods = () => { ...@@ -72,7 +84,7 @@ const TakeawayGoods = () => {
query, query,
}); });
}; };
// 修改商品是否列出
const onChangeFlag = async (id, checked) => { const onChangeFlag = async (id, checked) => {
const params = { const params = {
id, id,
...@@ -80,28 +92,33 @@ const TakeawayGoods = () => { ...@@ -80,28 +92,33 @@ const TakeawayGoods = () => {
}; };
await apiMealInfoUpdate(params); await apiMealInfoUpdate(params);
notification.success({ message: '保存成功' }); notification.success({ message: '保存成功' });
onRefresh();
}; };
// 根据企业ID获取取餐点 // 根据企业ID获取取餐点
const getPickSelf = async id => { const getPickSelf = async id => {
const res = await apiSelPickSelfList({ enterpriseId: id }); const res = await apiSelPickSelfList({ enterpriseId: id });
if (res && res.data) { if (res && res.data && res.data.length) {
setPickSelfList( setPickSelfList(
res.data.map(item => ({ res.data.map(item => ({
key: item.pickSelfId, key: `${item.pickSelfId}`,
label: <span>{item.pickSelfName}</span>, label: <span>{item.pickSelfName}</span>,
})), })),
); );
setActiveKey(res.data[0].pickSelfId); const pid = res.data[0].pickSelfId;
setActiveKey(`${pid}`);
if (pageLoaded) {
onRefresh();
}
} else {
setPickSelfList([]);
setActiveKey('');
if (pageLoaded) {
onRefresh();
}
} }
}; };
// 根据企业ID获取取餐点
// const getShops = async () => {
// const res = await getShopList({});
// setShopEnum(res.list);
// };
// 改变企业 // 改变企业
const onChangeEnterprise = v => { const onChangeEnterprise = v => {
setEnterpriseId(v); setEnterpriseId(v);
...@@ -113,18 +130,14 @@ const TakeawayGoods = () => { ...@@ -113,18 +130,14 @@ const TakeawayGoods = () => {
const obj = await getEnterpriseList(); const obj = await getEnterpriseList();
if (obj.list && Object.keys(obj.list).length) { if (obj.list && Object.keys(obj.list).length) {
setEnterprises(obj.list); setEnterprises(obj.list);
setEnterpriseId(obj.id); setEnterpriseId(`${obj.id}`);
getPickSelf(obj.id); await getPickSelf(obj.id);
setPageLoading(true); setPageLoaded(true);
} }
}; };
useEffect(() => { useEffect(() => {
getList(); getList();
// getShops();
// setTimeout(() => {
// // refTable.current.reload();
// }, 1000);
}, []); }, []);
const options = { const options = {
...@@ -137,12 +150,13 @@ const TakeawayGoods = () => { ...@@ -137,12 +150,13 @@ const TakeawayGoods = () => {
enterprises, enterprises,
onChangeEnterprise, onChangeEnterprise,
onChangeFlag, onChangeFlag,
onRefresh,
shopEnum, shopEnum,
}; };
return ( return (
<div> <div className={utilStyle.formPageBox}>
{pageLoading && ( {pageLoaded && (
<ProTable <ProTable
search={{ search={{
span: 6, span: 6,
...@@ -165,7 +179,8 @@ const TakeawayGoods = () => { ...@@ -165,7 +179,8 @@ const TakeawayGoods = () => {
activeKey, activeKey,
items: pickSelfList, items: pickSelfList,
onChange: key => { onChange: key => {
setActiveKey(key); setActiveKey(`${key}`);
onRefresh();
}, },
}, },
actions: [ actions: [
...@@ -182,7 +197,7 @@ const TakeawayGoods = () => { ...@@ -182,7 +197,7 @@ const TakeawayGoods = () => {
<SaleDateModal <SaleDateModal
visible={visibleSaleDate} visible={visibleSaleDate}
id={recordID} id={recordID}
handleRefresh={() => searchList({})} handleRefresh={() => onRefresh()}
handleClose={() => setVisibleSaleDate(false)} handleClose={() => setVisibleSaleDate(false)}
/> />
)} )}
...@@ -191,7 +206,7 @@ const TakeawayGoods = () => { ...@@ -191,7 +206,7 @@ const TakeawayGoods = () => {
<SaleSectionModal <SaleSectionModal
visible={visibleSaleSection} visible={visibleSaleSection}
id={recordID} id={recordID}
handleRefresh={() => searchList({})} handleRefresh={() => onRefresh()}
handleClose={() => setVisibleSaleSection(false)} handleClose={() => setVisibleSaleSection(false)}
/> />
)} )}
...@@ -200,7 +215,7 @@ const TakeawayGoods = () => { ...@@ -200,7 +215,7 @@ const TakeawayGoods = () => {
<GoodPriceModal <GoodPriceModal
visible={visiblePrice} visible={visiblePrice}
id={recordID} id={recordID}
handleRefresh={() => searchList({})} handleRefresh={() => onRefresh()}
handleClose={() => setVisiblePrice(false)} handleClose={() => setVisiblePrice(false)}
/> />
)} )}
...@@ -209,7 +224,7 @@ const TakeawayGoods = () => { ...@@ -209,7 +224,7 @@ const TakeawayGoods = () => {
<GoodSortModal <GoodSortModal
visible={visibleSort} visible={visibleSort}
id={recordID} id={recordID}
handleRefresh={() => searchList({})} handleRefresh={() => onRefresh()}
handleClose={() => setVisibleSort(false)} handleClose={() => setVisibleSort(false)}
/> />
)} )}
......
...@@ -23,6 +23,7 @@ const TakeawayGoodsInfo = props => { ...@@ -23,6 +23,7 @@ const TakeawayGoodsInfo = props => {
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表 const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
const [slePickSelf, setSelPickSelf] = useState([]); // 选中的取餐点列表 const [slePickSelf, setSelPickSelf] = useState([]); // 选中的取餐点列表
const [editID, setEditID] = useState(''); // 编辑ID const [editID, setEditID] = useState(''); // 编辑ID
const [shopId, setShopId] = useState(''); // 店铺ID
// 取消 // 取消
const onCancel = () => { const onCancel = () => {
...@@ -37,12 +38,12 @@ const TakeawayGoodsInfo = props => { ...@@ -37,12 +38,12 @@ const TakeawayGoodsInfo = props => {
const skuInfoList = dataSource.map(item => ({ const skuInfoList = dataSource.map(item => ({
skuId: item.skuId, skuId: item.skuId,
enterprisePrice: item.enterprisePrice, enterprisePrice: item.enterprisePrice,
mealTypeList: item.mealType, mealTypeList: item.mealTypeList.map(m => m.code),
saleDateList: item.saleDate, saleDateList: item.saleDate,
tabCateList: { tabId: item.tabCate }, tabCateList: item.tabCate.map(t => ({ tabId: t })),
})); }));
const params = { const params = {
shopId: id, shopId,
enterpriseId: id, enterpriseId: id,
pickSelfIdList: slePickSelf, pickSelfIdList: slePickSelf,
skuInfoList, skuInfoList,
...@@ -234,6 +235,7 @@ const TakeawayGoodsInfo = props => { ...@@ -234,6 +235,7 @@ const TakeawayGoodsInfo = props => {
enterpriseId={id} enterpriseId={id}
productType={5} productType={5}
pickSelfIdList={slePickSelf} pickSelfIdList={slePickSelf}
onChangeShop={setShopId}
onSelectChange={setDataSource} onSelectChange={setDataSource}
handleClose={() => setVisibleSelectGoods(false)} handleClose={() => setVisibleSelectGoods(false)}
/> />
......
...@@ -107,7 +107,7 @@ const VirtualGoods = () => { ...@@ -107,7 +107,7 @@ const VirtualGoods = () => {
}, []); }, []);
return ( return (
<div> <div className={utilStyle.formPageBox}>
{pageLoading && ( {pageLoading && (
<ProTable <ProTable
search={{ search={{
......
...@@ -183,7 +183,7 @@ export const getErrorMessage = err => { ...@@ -183,7 +183,7 @@ export const getErrorMessage = err => {
// 获取地址栏参数,name:参数名称 // 获取地址栏参数,name:参数名称
export const getUrlParams = name => { export const getUrlParams = name => {
const regArg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`); const regArg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
const r = window.location.search.substr(1).match(regArg); const r = window.location.search.substring(1).match(regArg);
if (r != null) return decodeURIComponent(r[2]); if (r != null) return decodeURIComponent(r[2]);
return null; return null;
}; };
......
...@@ -59,3 +59,7 @@ ...@@ -59,3 +59,7 @@
.formTable { .formTable {
padding: 0; padding: 0;
} }
.formPageBox {
box-sizing: border-box;
padding: 20px;
}
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