Commit db23ce44 authored by 张子雨's avatar 张子雨

Merge branch 'feat/storeManagement' into feature/meal-3.0

* feat/storeManagement:
  feat: 接口联调
parents 12a621f0 ede5c396
...@@ -111,7 +111,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -111,7 +111,7 @@ const ViewDepartmentModal = ({ visible, onClose, enterpriseList }) => {
const pagination = { const pagination = {
...pageInfo, ...pageInfo,
total, total,
showTotal: t => `共 ${t} 项数据`, showTotal: t => `共 ${t} `,
onChange, onChange,
onShowSizeChange: onChange, onShowSizeChange: onChange,
}; };
......
...@@ -212,7 +212,7 @@ const StoreManagement = () => { ...@@ -212,7 +212,7 @@ const StoreManagement = () => {
const pagination = { const pagination = {
...page, ...page,
total, total,
showTotal: t => `共 ${t} 项数据`, showTotal: t => `共 ${t} `,
onChange, onChange,
onShowSizeChange: onChange, onShowSizeChange: onChange,
}; };
......
...@@ -4,11 +4,13 @@ import styles from '../index.less'; ...@@ -4,11 +4,13 @@ import styles from '../index.less';
import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js'; import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js';
const AddModal = props => { const AddModal = props => {
const [form] = Form.useForm();
const { addVisible, enterpriseId, name, onCancel } = props; const { addVisible, enterpriseId, name, onCancel } = props;
const [selectList, setSelectList] = useState([]); const [selectList, setSelectList] = useState([]);
const [options, setOptions] = useState([]); const [options, setOptions] = useState([]);
const handleCancel = () => { const handleCancel = status => {
onCancel(false); form.resetFields();
onCancel(status, 'add');
}; };
const handleChange = value => { const handleChange = value => {
setSelectList(value); setSelectList(value);
...@@ -25,7 +27,7 @@ const AddModal = props => { ...@@ -25,7 +27,7 @@ const AddModal = props => {
notification.success({ notification.success({
message: '添加成功', message: '添加成功',
}); });
props.onCancel(true); handleCancel(true);
} }
}; };
const getSelectedList = async () => { const getSelectedList = async () => {
...@@ -36,6 +38,7 @@ const AddModal = props => { ...@@ -36,6 +38,7 @@ const AddModal = props => {
data.forEach(item => { data.forEach(item => {
list.push(item.shopId); list.push(item.shopId);
}); });
form.setFieldsValue({ shopIds: list });
setSelectList(list); setSelectList(list);
} }
}; };
...@@ -59,22 +62,20 @@ const AddModal = props => { ...@@ -59,22 +62,20 @@ const AddModal = props => {
return ( return (
<> <>
<Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={handleCancel}> <Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={handleCancel}>
<Form> <Form form={form}>
<Form.Item label="企业名称"> <Form.Item label="企业名称">
<span>{name}</span> <span>{name}</span>
</Form.Item> </Form.Item>
{selectList && selectList.length > 0 && ( <Form.Item label="添加微店" name="shopIds" initialValue={selectList}>
<Form.Item label="添加微店" name="shopIds" initialValue={selectList}> <Select
<Select mode="multiple"
mode="multiple" allowClear
allowClear style={{ width: '100%' }}
style={{ width: '100%' }} placeholder="请选择微店"
placeholder="请选择微店" onChange={handleChange}
onChange={handleChange} options={options}
options={options} />
/> </Form.Item>
</Form.Item>
)}
<Form.Item label="餐饮类型"> <Form.Item label="餐饮类型">
<span>到店</span> <span>到店</span>
</Form.Item> </Form.Item>
......
...@@ -17,6 +17,17 @@ export const repastTypeList = [ ...@@ -17,6 +17,17 @@ export const repastTypeList = [
}, },
]; ];
const repastType = list => {
if (list.includes(4) && list.length > 1) {
return list
.filter(item => item !== 4)
.map(item => {
const name = repastTypeList.find(i => i.value === item)?.label;
return name ? `${name}/到店` : null;
});
}
return '到店';
};
export const columns = props => [ export const columns = props => [
{ {
title: '微店ID', title: '微店ID',
...@@ -36,14 +47,12 @@ export const columns = props => [ ...@@ -36,14 +47,12 @@ export const columns = props => [
dataIndex: 'mealType', dataIndex: 'mealType',
align: 'center', align: 'center',
render: (_, row) => { render: (_, row) => {
const status = !row?.pickselfName; const status = !row?.pickNameList?.length;
const isArray = Array.isArray(row?.mealType); const isArray = Array.isArray(row?.mealType);
if (isArray) { if (isArray) {
return ( return (
<Button type="text" disabled={status} onClick={() => props.editRepastType(row)}> <Button type="text" disabled={status} onClick={() => props.editRepastType(row)}>
{row.mealType?.map((item, index) => ( {repastType(row?.mealType)}
<span>{repastTypeList.find(itm => itm.value === item)?.label}&nbsp;</span>
))}
<FormOutlined /> <FormOutlined />
</Button> </Button>
); );
...@@ -53,15 +62,15 @@ export const columns = props => [ ...@@ -53,15 +62,15 @@ export const columns = props => [
}, },
{ {
title: '所属企业取餐点', title: '所属企业取餐点',
key: 'pickselfName', key: 'pickNameList',
dataIndex: 'pickselfName', dataIndex: 'pickNameList',
align: 'center', align: 'center',
render: (text, record) => { render: (text, record) => {
if (record.pickselfName?.length) { if (record.pickNameList?.length) {
return text.map((item, index) => ( return text.map((item, index) => (
<span> <span key={item}>
{item} {item}
{index < record.pickselfName.length - 1 && ','} {index < record.pickNameList.length - 1 && ','}
</span> </span>
)); ));
} }
......
import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react'; import React, { useState } from 'react';
import { Button, Modal, Radio, Form, Space, message, Checkbox, Col, Row } from 'antd'; import { Modal, Radio, Form, Space, message, Checkbox } from 'antd';
import styles from '../index.less'; import styles from '../index.less';
import { apiShopUpdate } from '../service.js'; import { apiShopUpdate, busineesTypeCheck } from '../service.js';
const EditRepastModal = props => { const EditRepastModal = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const { editVisible, repastType, id } = props; const { editVisible, repastType, id, enterpriseId, isStore } = props;
const handleCancel = () => { const handleCancel = status => {
props.onCancel(); form.resetFields();
props.onCancel(status, 'edit');
}; };
const onOk = () => { const onOk = () => {
form.validateFields().then(async values => { form.validateFields().then(async values => {
console.log(values);
const store = values?.store || '';
const mealTypeList = [...values.mealTypeList, ...store];
const params = { const params = {
id, id,
mealTypeList: values.mealTypeList, mealTypeList,
}; };
const res = await apiShopUpdate(params); const res = await apiShopUpdate(params);
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
...@@ -22,31 +27,42 @@ const EditRepastModal = props => { ...@@ -22,31 +27,42 @@ const EditRepastModal = props => {
} }
}); });
}; };
return ( return (
<> <>
<Modal title="餐饮类型" onOk={onOk} visible={editVisible} onCancel={() => handleCancel()}> <Modal
<Form layout="vertical" autoComplete="off" form={form}> title="餐饮类型"
onOk={onOk}
visible={editVisible}
onCancel={() => handleCancel(false)}
>
<Form layout="vertical" form={form}>
<Form.Item <Form.Item
label="取餐点下商户餐品类型" label="取餐点下商户餐品类型"
rules={[{ required: true, message: '请选择商户餐品类型' }]} rules={[{ required: true, message: '请选择商户餐品类型' }]}
name="mealTypeList"
> >
<Checkbox.Group>
<Space direction="mealTypeList">
{(repastType.length &&
repastType.map((index, value) => <Checkbox>{index}</Checkbox>)) ||
''}
</Space>
</Checkbox.Group>
<p className={styles.tip}>切换餐品类型后,请及时维护商品</p>
</Form.Item>
<Form.Item label="是否开启餐品类型">
<Checkbox.Group> <Checkbox.Group>
<Space direction="vertical"> <Space direction="vertical">
<Checkbox>到店</Checkbox> {repastType.map(item => (
<Checkbox value={item.value} key={item.value}>
{item.label}
</Checkbox>
))}
</Space> </Space>
<p className={styles.tip}>切换餐品类型后,请及时维护商品</p>
</Checkbox.Group> </Checkbox.Group>
<p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p>
</Form.Item> </Form.Item>
{isStore && (
<Form.Item label="是否开启餐品类型" name="store">
<Checkbox.Group>
<Space direction="vertical">
<Checkbox value={4}>到店</Checkbox>
</Space>
<p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p>
</Checkbox.Group>
</Form.Item>
)}
</Form> </Form>
</Modal> </Modal>
</> </>
......
...@@ -2,6 +2,7 @@ import React, { useState, useRef, forwardRef, useEffect } from 'react'; ...@@ -2,6 +2,7 @@ import React, { useState, useRef, forwardRef, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Modal, Form, Select, Table, Card, Row, Col, Input, Button, message } from 'antd'; import { Modal, Form, Select, Table, Card, Row, Col, Input, Button, message } from 'antd';
import { set } from 'lodash'; import { set } from 'lodash';
import { da } from 'date-fns/locale';
import { columns, repastTypeList } from './data'; import { columns, repastTypeList } from './data';
import EditRepastModal from './editRepastModal'; import EditRepastModal from './editRepastModal';
import AddModal from './addModal'; import AddModal from './addModal';
...@@ -32,7 +33,7 @@ const StoreManagement = () => { ...@@ -32,7 +33,7 @@ const StoreManagement = () => {
const [enterprise, setEnterprise] = useState({}); const [enterprise, setEnterprise] = useState({});
const [dataList, setDataList] = useState([]); const [dataList, setDataList] = useState([]);
const [name, setName] = useState(''); const [name, setName] = useState('');
const [isStore, setIsStore] = useState(false);
const shopList = async params => { const shopList = async params => {
const res = await setShopList(params); const res = await setShopList(params);
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
...@@ -63,25 +64,45 @@ const StoreManagement = () => { ...@@ -63,25 +64,45 @@ const StoreManagement = () => {
}, []); }, []);
// 关闭弹框 // 关闭弹框
const closeModal = value => { const closeModal = (status, val) => {
if (value) { if (status) {
shopList({ data: searchForm, ...page }); const pageInfo = {
page: 1,
size: 10,
};
setPage(pageInfo);
shopList({ data: searchForm, ...pageInfo });
}
if (val === 'edit') {
setIsStore(false);
setEditVisible(false);
setRepastType([]);
return;
} }
setEditVisible(false); setName(false);
setAddVisible(false); setAddVisible(false);
}; };
const setMealTypeList = async () => { const setMealTypeList = async id => {
setEditVisible(true); const res = await mealTypeList({ id });
const res = await mealTypeList({ id: repastId });
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
setRepastType(res.data); const resData = res.data;
const data = [];
repastTypeList.forEach(item => {
if (resData.includes(item.value) && item.value !== 4) {
data.push(item);
}
});
if (resData.includes(4)) {
setIsStore(true);
}
setRepastType(data);
setEditVisible(true); setEditVisible(true);
} }
}; };
// 修改餐饮类型 // 修改餐饮类型
const editRepastType = ({ id }) => { const editRepastType = ({ id }) => {
setRepastId(id); setRepastId(id);
setMealTypeList(); setMealTypeList(id);
}; };
// 删除 // 删除
const editShop = async id => { const editShop = async id => {
...@@ -137,15 +158,20 @@ const StoreManagement = () => { ...@@ -137,15 +158,20 @@ const StoreManagement = () => {
shopList({ data: { enterpriseId: firstEnterprise }, ...pageInfo }); shopList({ data: { enterpriseId: firstEnterprise }, ...pageInfo });
}; };
// 分页 // 分页
const handleTableChange = val => { const handleTableChange = (pageNo, size) => {
setPage(val); const pageInfo = {
page: pageNo,
size,
};
setPage(pageInfo);
shopList({ data: searchForm, ...pageInfo });
}; };
const pagination = { const pagination = {
...page, ...page,
total, total,
showTotal: t => `共 ${t} 项数据`, showTotal: t => `共 ${t} `,
handleTableChange, onChange: handleTableChange,
onShowSizeChange: handleTableChange, onShowSizeChange: handleTableChange,
}; };
...@@ -168,8 +194,6 @@ const StoreManagement = () => { ...@@ -168,8 +194,6 @@ const StoreManagement = () => {
initialValue={firstEnterprise} initialValue={firstEnterprise}
> >
<Select <Select
allowClear
showSearch
filterOption={(input, option) => filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()) (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
} }
...@@ -223,7 +247,6 @@ const StoreManagement = () => { ...@@ -223,7 +247,6 @@ const StoreManagement = () => {
dataSource={dataList} dataSource={dataList}
rowKey={r => r.id} rowKey={r => r.id}
bordered bordered
// onChange={handleTableChange}
pagination={pagination} pagination={pagination}
/> />
<EditRepastModal <EditRepastModal
...@@ -231,6 +254,8 @@ const StoreManagement = () => { ...@@ -231,6 +254,8 @@ const StoreManagement = () => {
repastType={repastType} repastType={repastType}
id={repastId} id={repastId}
onCancel={closeModal} onCancel={closeModal}
enterpriseId={searchForm.enterpriseId}
isStore={isStore}
/> />
<AddModal <AddModal
addVisible={addVisible} addVisible={addVisible}
......
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