Commit 04f973cc authored by 张子雨's avatar 张子雨

feat: 接口文档对接

parent 9b92283b
import React from 'react';
import { Modal, Table } from 'antd';
const RechargeDetailsModal = ({ visible, onClose, list }) => {
const columns = [
{
title: '员工ID',
dataIndex: 'id',
key: 'id',
},
{
title: '员工姓名',
dataIndex: 'staffName',
key: 'staffName',
},
{
title: '充值余额',
dataIndex: 'rechargeAmount',
key: 'rechargeAmount',
},
{
title: '充值时间',
dataIndex: 'generateDate',
key: 'generateDate',
},
];
return (
<Modal visible={visible} title="充值明细" onCancel={onClose} footer={null}>
<Table dataSource={list} columns={columns} pagination={false} border />
</Modal>
);
};
export default RechargeDetailsModal;
import React, { useState } from 'react';
import { Modal, Form, Radio, Input, Button, Upload, message, Select } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import { apiDepartmentSave, apiDepartmentExcel, apiStaffExcel } from '../service';
import styles from '../index.less';
const { Dragger } = Upload;
const { Item } = Form;
const layout = {
labelCol: { span: 6 },
wrapperCol: { span: 16 },
};
const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
const [form] = Form.useForm();
const handleCancel = val => {
form.resetFields();
onClose(val);
};
const handleImportChange = info => {
if (info.file.status === 'done') {
message.success('文件上传成功');
} else if (info.file.status === 'error') {
message.error('文件上传失败');
}
};
const handleSave = () => {
form.validateFields().then(async values => {
const params = {
enterpriseId: values.enterpriseId,
file: values.file,
};
const res = await apiStaffExcel(params);
if (res.businessCode === '0000') {
message.success('上传成功');
handleCancel(true);
}
});
};
return (
<Modal
title="创建部门"
visible={visible}
onCancel={() => handleCancel(false)}
footer={[
<Button key="cancel" onClick={onClose}>
取消
</Button>,
<Button key="save" type="primary" onClick={() => handleSave()}>
保存
</Button>,
]}
initialValue={{ configMode: 0 }}
>
<Form form={form} {...layout}>
<Item
label="选择企业"
name="enterpriseId"
rules={[{ required: true, message: '请选择企业' }]}
>
<Select
placeholder="请选择企业"
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={enterpriseList}
/>
</Item>
<Item
label="上传文件"
name="file"
rules={[
{ required: true, message: '请上传文件' },
{
// eslint-disable-next-line no-confusing-arrow
validator: (_, value) =>
value && value.fileList.length > 0
? Promise.resolve()
: // eslint-disable-next-line prefer-promise-reject-errors
Promise.reject('请上传文件'),
},
]}
>
<Dragger
beforeUpload={() => false}
onChange={handleImportChange}
maxCount={1}
accept=".xls,.xlsx"
>
<UploadOutlined />
<p>
将文件拖到此处,或<a href="#">点击上传</a>
</p>
</Dragger>
</Item>
</Form>
<div className={styles.employees}>
<a
data-v-7e627236=""
href="https://img.mumcooking.com//personnel/excel.xlsx?v1"
className="batchDialog-row-download-a"
>
员工导入模版.xlsx
</a>
</div>
</Modal>
);
};
export default DepartmentModal;
import React from 'react'; import React from 'react';
import { Modal, Form, Input, Checkbox } from 'antd'; import { Modal, Form, Input, Checkbox, message } from 'antd';
import styles from '../index.less'; import styles from '../index.less';
import { apiStaffBlack } from '../service';
const { Item } = Form; const { Item } = Form;
const BlacklistModal = ({ visible, onClose, onSave, list }) => { const BlacklistModal = ({ visible, onClose, list, employeeId }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const handleSave = () => { const handleSave = () => {
form.validateFields().then(values => { form.validateFields().then(values => {
onSave(values); const params = {
employeeId,
ids: list,
isBlack: 1,
balanceBackFlag: 1,
};
apiStaffBlack(params).then(res => {
if (res.businessCode === '0000') {
message.success('设置成功');
onClose(true);
}
});
}); });
}; };
return ( return (
<Modal visible={visible} title="设置员工黑名单" onCancel={onClose} onOk={handleSave}> <Modal visible={visible} title="设置员工黑名单" onCancel={onClose} onOk={handleSave}>
<Form form={form} layout="vertical"> <Form form={form} layout="vertical">
<Item name="employeeId" label="您确定要把员工ID:"> <Item name="ids" label="您确定要把员工ID:">
{list.length && list.map(item => <span>{item},</span>)} {list.length && list.map(item => <span>{item},</span>)}
</Item> </Item>
<Item name="reason" label="加入黑名单吗?"> <Item name="reason" label="加入黑名单吗?">
......
...@@ -3,6 +3,7 @@ import { Modal, Form, Radio, Input, Button, Upload, message, Select } from 'antd ...@@ -3,6 +3,7 @@ import { Modal, Form, Radio, Input, Button, Upload, message, Select } from 'antd
import { UploadOutlined } from '@ant-design/icons'; import { UploadOutlined } from '@ant-design/icons';
import { apiDepartmentSave, apiDepartmentExcel } from '../service'; import { apiDepartmentSave, apiDepartmentExcel } from '../service';
const { Dragger } = Upload;
const { Item } = Form; const { Item } = Form;
const layout = { const layout = {
labelCol: { span: 6 }, labelCol: { span: 6 },
...@@ -124,14 +125,17 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => { ...@@ -124,14 +125,17 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
}, },
]} ]}
> >
<Upload <Dragger
beforeUpload={() => false} beforeUpload={() => false}
onChange={handleImportChange}
maxCount={1} maxCount={1}
accept=".xls,.xlsx" accept=".xls,.xlsx"
onChange={handleImportChange}
> >
<Button icon={<UploadOutlined />}>点击上传</Button> <UploadOutlined />
</Upload> <p>
将文件拖到此处,或<a href="#">点击上传</a>
</p>
</Dragger>
</Item> </Item>
) : ( ) : (
<Item <Item
......
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Modal, Form, Input, Button, Select, message } from 'antd'; import { Modal, Form, Input, Button, Select, message, Upload, Radio } from 'antd';
import { apiStaffSave } from '../service'; import { UploadOutlined } from '@ant-design/icons';
import { apiStaffSave, apiStaffExcel } from '../service';
import styles from '../index.less';
const { Dragger } = Upload;
const { Option } = Select; const { Option } = Select;
const layout = { const layout = {
...@@ -12,21 +15,35 @@ const NewEmployeeModal = props => { ...@@ -12,21 +15,35 @@ const NewEmployeeModal = props => {
const { departmentList, visible, onClose, enterpriseList, getDepartmentList } = props; const { departmentList, visible, onClose, enterpriseList, getDepartmentList } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [importMode, setImportMode] = useState(false);
const handleCancel = val => {
form.resetFields();
setImportMode(false);
onClose(val);
};
const handleSave = () => { const handleSave = () => {
form.validateFields().then(async values => { form.validateFields().then(async values => {
setLoading(true); setLoading(true);
if (importMode) {
const res = await apiStaffExcel(values);
if (res.businessCode === '0000') {
message.success('上传成功');
handleCancel(true);
}
return;
}
const res = await apiStaffSave(values); const res = await apiStaffSave(values);
if (res.businessCode === '0000') { if (res.businessCode === '0000') {
setLoading(false); setLoading(false);
message.success('保存成功'); message.success('保存成功');
onClose(true); handleCancel(true);
} }
}); });
}; };
const validatePhone = (_, value) => { const validatePhone = (_, value) => {
const phoneRegex = /^[1-9]\d{9}$/; console.log(value);
const phoneRegex = /^1[3456789]\d{9}$/;
if (!value || phoneRegex.test(value)) { if (!value || phoneRegex.test(value)) {
return Promise.resolve(); return Promise.resolve();
} }
...@@ -73,6 +90,58 @@ const NewEmployeeModal = props => { ...@@ -73,6 +90,58 @@ const NewEmployeeModal = props => {
options={enterpriseList} options={enterpriseList}
/> />
</Form.Item> </Form.Item>
<Form.Item
label="配置方式"
name="configMode"
rules={[{ required: true, message: '请选择配置方式' }]}
initialValue={0}
>
<Radio.Group>
<Radio value={0} onChange={() => setImportMode(false)}>
单个添加
</Radio>
<Radio value={1} onChange={() => setImportMode(true)}>
批量导入
</Radio>
</Radio.Group>
</Form.Item>
{importMode ? (
<>
<Form.Item
label="上传文件"
name="file"
rules={[
{ required: true, message: '请上传文件' },
{
// eslint-disable-next-line no-confusing-arrow
validator: (_, value) =>
value && value.fileList.length > 0
? Promise.resolve()
: // eslint-disable-next-line prefer-promise-reject-errors
Promise.reject('请上传文件'),
},
]}
>
<Dragger beforeUpload={() => false} maxCount={1} accept=".xls,.xlsx">
<UploadOutlined />
<p>
将文件拖到此处,或<a href="#">点击上传</a>
</p>
</Dragger>
</Form.Item>
<div className={styles.employees}>
<a
data-v-7e627236=""
href="https://img.mumcooking.com//personnel/excel.xlsx?v1"
className="batchDialog-row-download-a"
>
员工导入模版.xlsx
</a>
</div>
</>
) : (
<>
{' '}
<Form.Item <Form.Item
name="departmentId" name="departmentId"
label="部门" label="部门"
...@@ -130,8 +199,10 @@ const NewEmployeeModal = props => { ...@@ -130,8 +199,10 @@ const NewEmployeeModal = props => {
}, },
]} ]}
> >
<Input /> <Input maxLength={11} />
</Form.Item> </Form.Item>
</>
)}
</Form> </Form>
</Modal> </Modal>
); );
......
...@@ -48,12 +48,17 @@ export const columns = props => [ ...@@ -48,12 +48,17 @@ export const columns = props => [
}, },
{ {
title: '是否消费限额', title: '是否消费限额',
key: 'balance', key: 'isLimit',
dataIndex: 'balance', dataIndex: 'isLimit',
align: 'center', align: 'center',
render: _ => ( render: (_, row) => (
<> <>
<Switch defaultChecked /> {_ ? '已开启' : '已关闭'} <Switch
checkedChildren="限额"
unCheckedChildren="不限额"
defaultChecked={row?.isLimit}
onChange={val => props.handleLimitChange(val, row)}
/>
</> </>
), ),
}, },
...@@ -76,7 +81,7 @@ export const columns = props => [ ...@@ -76,7 +81,7 @@ export const columns = props => [
align: 'center', align: 'center',
key: 'option', key: 'option',
render: (_, row) => [ render: (_, row) => [
<Button type="link" onClick={() => props.delEmployee(row)}> <Button type="link" onClick={() => props.goDetails(row)}>
余额充值明细 余额充值明细
</Button>, </Button>,
<Button type="link" disabled={!row?.isBlack} onClick={() => props.delEmployee(row)}> <Button type="link" disabled={!row?.isBlack} onClick={() => props.delEmployee(row)}>
......
...@@ -22,21 +22,25 @@ import { ...@@ -22,21 +22,25 @@ import {
apiDepartmentList, apiDepartmentList,
apiStaffExcel, apiStaffExcel,
apiStaffDelete, apiStaffDelete,
apiGenerateLogList,
apiStaffLimit,
} from './service.js'; } from './service.js';
import NewEmployeeModal from './components/newEmployeeModal'; import NewEmployeeModal from './components/newEmployeeModal';
import DepartmentModal from './components/departmentModal'; import DepartmentModal from './components/departmentModal';
import ViewDepartmentModal from './components/ViewDepartmentModal'; import ViewDepartmentModal from './components/ViewDepartmentModal';
import BlacklistModal from './components/BlacklistModal'; import BlacklistModal from './components/BlacklistModal';
import BatchFileModal from './components/batchFileModal'; import RechargeDetailsModal from './components/RechargeDetailsModal';
const fakeData = [ const fakeData = [
{ {
isBlack: 1, isBlack: 0,
id: 1, id: 1,
isLimit: 0,
}, },
{ {
isBlack: 1, isBlack: 1,
id: 2, id: 2,
isLimit: 1,
}, },
]; ];
...@@ -46,12 +50,13 @@ const StoreManagement = () => { ...@@ -46,12 +50,13 @@ const StoreManagement = () => {
const [departmentVisible, setDepartmentVisible] = useState(false); const [departmentVisible, setDepartmentVisible] = useState(false);
const [viewDepartmentVisible, setViewDepartmentVisible] = useState(false); const [viewDepartmentVisible, setViewDepartmentVisible] = useState(false);
const [blacklistVisible, setBlacklistVisible] = useState(false); const [blacklistVisible, setBlacklistVisible] = useState(false);
const [batchFileVisible, setBatchFileVisible] = useState(false); const [rechargeDetailsVisible, setRechargeDetailsVisible] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState([]); const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [staffList, setStaffList] = useState([]); const [staffList, setStaffList] = useState([]);
const [enterpriseList, setEnterpriseList] = useState([]); const [enterpriseList, setEnterpriseList] = useState([]);
const [firstEnterprise, setFirstEnterprise] = useState(); const [firstEnterprise, setFirstEnterprise] = useState();
const [departmentList, setDepartmentList] = useState([]); const [departmentList, setDepartmentList] = useState([]);
const [generateLog, setGenerateLog] = useState([]);
const [page, setPage] = useState({ const [page, setPage] = useState({
page: 1, page: 1,
size: 10, size: 10,
...@@ -96,10 +101,9 @@ const StoreManagement = () => { ...@@ -96,10 +101,9 @@ const StoreManagement = () => {
const rowSelection = { const rowSelection = {
selectedRowKeys, selectedRowKeys,
onChange: setSelectedRowKeys, onChange: setSelectedRowKeys,
}; getCheckboxProps: record => ({
// disabled: record.isBlack === 1,
const getBatchFile = () => { }),
setBatchFileVisible(true);
}; };
// 关闭弹框 // 关闭弹框
...@@ -108,7 +112,7 @@ const StoreManagement = () => { ...@@ -108,7 +112,7 @@ const StoreManagement = () => {
setDepartmentVisible(false); setDepartmentVisible(false);
setViewDepartmentVisible(false); setViewDepartmentVisible(false);
setBlacklistVisible(false); setBlacklistVisible(false);
setBatchFileVisible(false); setRechargeDetailsVisible(false);
if (val) { if (val) {
shopList(); shopList();
} }
...@@ -195,9 +199,28 @@ const StoreManagement = () => { ...@@ -195,9 +199,28 @@ const StoreManagement = () => {
const handleTableChange = val => { const handleTableChange = val => {
setPage(val); setPage(val);
}; };
const goDetails = async ({ staffNo }) => {
setRechargeDetailsVisible(true);
const res = await apiGenerateLogList({ staffNo, enterpriseId: searchForm.enterpriseId });
if (res.businessCode === '0000') {
const list = res.data;
setGenerateLog(list);
}
};
const handleLimitChange = async (checked, row) => {
const res = await apiStaffLimit({
id: row,
isLimit: checked ? 1 : 0,
enterpriseId: searchForm.enterpriseId,
});
if (res.businessCode === '0000') {
message.success('设置成功');
}
};
const res = { const res = {
delEmployee, delEmployee,
goDetails,
handleLimitChange,
}; };
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
...@@ -222,8 +245,9 @@ const StoreManagement = () => { ...@@ -222,8 +245,9 @@ const StoreManagement = () => {
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={8}> <Col span={8}>
<Form.Item label="部门查询" name="departmentId" wrapperCol={{ span: 16 }}> <Form.Item label="部门查询" name="departmentIds" wrapperCol={{ span: 16 }}>
<Select <Select
mode="multiple"
allowClear allowClear
showSearch showSearch
filterOption={(input, option) => filterOption={(input, option) =>
...@@ -283,9 +307,6 @@ const StoreManagement = () => { ...@@ -283,9 +307,6 @@ const StoreManagement = () => {
</Row> </Row>
</Form> </Form>
<div className={styles.addBtn}> <div className={styles.addBtn}>
<Button type="primary" onClick={getBatchFile}>
批量新增员工
</Button>
<Button type="primary" className={styles.left} onClick={getBlacklist}> <Button type="primary" className={styles.left} onClick={getBlacklist}>
设置员工黑名单 设置员工黑名单
</Button> </Button>
...@@ -348,10 +369,11 @@ const StoreManagement = () => { ...@@ -348,10 +369,11 @@ const StoreManagement = () => {
list={selectedRowKeys} list={selectedRowKeys}
visible={blacklistVisible} visible={blacklistVisible}
onClose={handleCloseModal} onClose={handleCloseModal}
employeeId={searchForm.enterpriseId}
/> />
<BatchFileModal <RechargeDetailsModal
list={selectedRowKeys} visible={rechargeDetailsVisible}
visible={batchFileVisible} list={generateLog}
onClose={handleCloseModal} onClose={handleCloseModal}
/> />
</PageHeaderWrapper> </PageHeaderWrapper>
......
...@@ -32,3 +32,19 @@ ...@@ -32,3 +32,19 @@
.employees { .employees {
text-align: center; text-align: center;
} }
.blackList {
display: flex;
align-items: center;
color: #8e8e8e;
span {
&:nth-child(1) {
font-size: 12px;
}
&:nth-child(3) {
font-size: 10px;
}
}
}
...@@ -103,3 +103,33 @@ export const apiDepartmentUpdate = async params => { ...@@ -103,3 +103,33 @@ export const apiDepartmentUpdate = async params => {
}); });
return data; return data;
}; };
// [企业员工]-充值明细查询
// http://yapi.quantgroups.com/project/389/interface/api/65489
export const apiGenerateLogList = async params => {
const data = await request.get('/api/consoles/enterprise/staff/generateLog/list', {
prefix: goodsApi,
params,
});
return data;
};
// [企业员工]-员工限额
// http://yapi.quantgroups.com/project/389/interface/api/65379
export const apiStaffLimit = async params => {
const data = await request.post('/api/consoles/enterprise/staff/limit', {
prefix: goodsApi,
data: params,
});
return data;
};
// [企业员工]-拉黑员工
// http://yapi.quantgroups.com/project/389/interface/api/65369
export const apiStaffBlack = async params => {
const data = await request.post('/api/consoles/enterprise/staff/black', {
prefix: goodsApi,
data: params,
});
return data;
};
import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react'; import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react';
import { Button, Modal, Select, Form, notification } from 'antd'; import { Button, Modal, Select, Form, notification } from 'antd';
import styles from '../index.less'; import styles from '../index.less';
import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js';
const AddModal = props => { const AddModal = props => {
const { addVisible } = props; const { addVisible, enterpriseId, name } = props;
const [shopIds, setShopIds] = useState([]); const [selectList, setSelectList] = useState([]);
const [options, setOptions] = useState([]);
const handleCancel = () => { const handleCancel = () => {
props.onCancel(false); props.onCancel(false);
}; };
const handleChange = value => { const handleChange = value => {
setShopIds(value); setSelectList(value);
}; };
const onOk = () => { const onOk = async () => {
if (!shopIds.length) { if (!selectList.length) {
notification.error({ notification.error({
message: '请添加微店', message: '请添加微店',
}); });
return;
}
const res = await apiShopAdd({ enterpriseId, shopIds: selectList });
if (res.businessCode === '0000') {
notification.success({
message: '添加成功',
});
props.onCancel(true);
}
};
const getSelectedList = async () => {
const res = await apiSelectedList({ enterpriseId });
if (res.businessCode === '0000') {
const { data } = res;
const list = [];
data.forEach(item => {
list.push(item.id);
});
setSelectList(list);
} }
}; };
const getSelectList = async () => {
const res = await apiSelectList({ id: enterpriseId });
if (res.businessCode === '0000') {
const optionData = res.data.map(item => ({
value: item.id,
label: item.name,
}));
setOptions(optionData);
}
};
useEffect(() => {
if (addVisible) {
getSelectedList();
}
}, [addVisible]);
return ( return (
<> <>
<Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={() => handleCancel()}> <Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={() => handleCancel}>
<Form> <Form>
<Form.Item label="企业名称"> <Form.Item label="企业名称">
<span>企业名称</span> <span>{name}</span>
</Form.Item> </Form.Item>
<Form.Item label="添加微店" name="shopIds"> <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>
</Form> </Form>
</Modal> </Modal>
......
...@@ -37,11 +37,17 @@ export const columns = props => [ ...@@ -37,11 +37,17 @@ export const columns = props => [
align: 'center', align: 'center',
render: (_, row) => { render: (_, row) => {
const status = !row?.pickselfName; const status = !row?.pickselfName;
if (row?.mealType?.length) {
return ( return (
<Button type="text" disabled={status} onClick={() => props.editRepastType(row)}> <Button type="text" disabled={status} onClick={() => props.editRepastType(row)}>
{row.mealType} <FormOutlined /> {row.mealType?.map((item, index) => (
<span>{repastTypeList.find(itm => itm.value === item)?.label}&nbsp;</span>
))}
<FormOutlined />
</Button> </Button>
); );
}
return '/';
}, },
}, },
{ {
...@@ -49,6 +55,17 @@ export const columns = props => [ ...@@ -49,6 +55,17 @@ export const columns = props => [
key: 'pickselfName', key: 'pickselfName',
dataIndex: 'pickselfName', dataIndex: 'pickselfName',
align: 'center', align: 'center',
render: (text, record) => {
if (record.pickselfName?.length) {
return text.map((item, index) => (
<span>
{item}
{index < record.pickselfName.length - 1 && ','}
</span>
));
}
return '/';
},
}, },
{ {
title: '修改人', title: '修改人',
...@@ -69,7 +86,7 @@ export const columns = props => [ ...@@ -69,7 +86,7 @@ export const columns = props => [
align: 'center', align: 'center',
key: 'option', key: 'option',
render: (_, row) => ( render: (_, row) => (
<Button type="link" disabled={row?.pickselfName} onClick={() => props.delShop(row)}> <Button type="link" disabled={row?.pickselfName?.length} onClick={() => props.delShop(row)}>
删除 删除
</Button> </Button>
), ),
......
import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react'; import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react';
import { Button, Modal, Radio, Form, Space, message, Checkbox, Col, Row } from 'antd'; import { Button, Modal, Radio, Form, Space, message, Checkbox, Col, Row } from 'antd';
import styles from '../index.less'; import styles from '../index.less';
import { shopUpdate } from '../service.js'; import { apiShopUpdate } from '../service.js';
const EditRepastModal = props => { const EditRepastModal = props => {
const [form] = Form.useForm();
const { editVisible, repastType, id } = props; const { editVisible, repastType, id } = props;
const handleCancel = () => { const handleCancel = () => {
props.onCancel(); props.onCancel();
}; };
const handleChange = e => {
console.log(e.target.value);
};
const onOk = () => { const onOk = () => {
// if (!shopIds.length) { form.validateFields().then(async values => {
// notification.error({ const params = {
// message: '请添加微店', id,
// }); mealTypeList: values.mealTypeList,
// } };
const res = await apiShopUpdate(params);
if (res.businessCode === '0000') {
message.success('修改成功');
handleCancel(true);
}
});
}; };
return ( return (
<> <>
<Modal title="餐饮类型" onOk={onOk} visible={editVisible} onCancel={() => handleCancel()}> <Modal title="餐饮类型" onOk={onOk} visible={editVisible} onCancel={() => handleCancel()}>
<Form layout="vertical" autoComplete="off"> <Form layout="vertical" autoComplete="off" form={form}>
<Form.Item label="取餐点下商户餐品类型"> <Form.Item
<Radio.Group onChange={handleChange}> label="取餐点下商户餐品类型"
<Space direction="vertical"> rules={[{ required: true, message: '请选择商户餐品类型' }]}
<Radio value={1}>外卖</Radio> >
<Radio value={2}>自助餐</Radio> <Checkbox.Group>
<Space direction="mealTypeList">
{(repastType.length &&
repastType.map((index, value) => <Checkbox>{index}</Checkbox>)) ||
''}
</Space> </Space>
</Radio.Group> </Checkbox.Group>
<p className={styles.tip}>切换餐品类型后,请及时维护商品</p> <p className={styles.tip}>切换餐品类型后,请及时维护商品</p>
</Form.Item> </Form.Item>
<Form.Item label="是否开启餐品类型"> <Form.Item label="是否开启餐品类型">
<Checkbox.Group> <Checkbox.Group>
<Space direction="vertical"> <Space direction="vertical">
{(repastType.length && <Checkbox>到店</Checkbox>
repastType.map((index, value) => <Checkbox value="A">到店</Checkbox>)) ||
''}
</Space> </Space>
</Checkbox.Group> </Checkbox.Group>
<p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p> <p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p>
......
...@@ -5,28 +5,53 @@ import { columns, repastTypeList } from './data'; ...@@ -5,28 +5,53 @@ import { columns, repastTypeList } from './data';
import EditRepastModal from './editRepastModal'; import EditRepastModal from './editRepastModal';
import AddModal from './addModal'; import AddModal from './addModal';
import styles from './index.less'; import styles from './index.less';
import { setShopList, setShopDelete, mealTypeList } from './service.js'; import {
setShopList,
setShopDelete,
mealTypeList,
apiEnterpriseList,
busineesTypeCheck,
} from './service.js';
const { confirm } = Modal; const { confirm } = Modal;
const StoreManagement = () => { const StoreManagement = () => {
const [page, setPage] = useState({ const [page, setPage] = useState({
current: 1, page: 1,
pageSize: 10, size: 10,
}); });
const optionData = [
{
value: 'jack',
label: '1',
},
{
value: 'lucy',
label: '2',
},
{
value: 'tom',
label: '3',
},
];
const [searchForm, setSearchForm] = useState({}); const [searchForm, setSearchForm] = useState({});
const formRef = useRef(null); const formRef = useRef(null);
const [editVisible, setEditVisible] = useState(false); const [editVisible, setEditVisible] = useState(false);
const [addVisible, setAddVisible] = useState(false); const [addVisible, setAddVisible] = useState(false);
const [repastType, setRepastType] = useState([]); const [repastType, setRepastType] = useState([]);
const [repastId, setRepastId] = useState(null); const [repastId, setRepastId] = useState(null);
const [enterpriseList, setEnterpriseList] = useState(optionData);
const [firstEnterprise, setFirstEnterprise] = useState('');
const [enterprise, setEnterprise] = useState({});
const [dataList, setDataList] = useState([]);
const [name, setName] = useState('');
const data = [ const data = [
{ {
enterpriseId: '企业id', enterpriseId: '企业id',
id: '1', id: '1',
shopId: 'shopId', shopId: 'shopId',
shopName: '店铺名称', shopName: '店铺名称',
mealType: '到店', mealType: [1, 2],
pickselfName: '', pickselfName: ['1', '1111'],
updatedBy: '修改人名称', updatedBy: '修改人名称',
amount: '2023/03/21 14:06:11', amount: '2023/03/21 14:06:11',
}, },
...@@ -35,19 +60,48 @@ const StoreManagement = () => { ...@@ -35,19 +60,48 @@ const StoreManagement = () => {
id: '2', id: '2',
shopId: 'shopId', shopId: 'shopId',
shopName: '店铺名称', shopName: '店铺名称',
mealType: '到店', mealType: [1, 2],
pickselfName: '取餐点',
updatedBy: '修改人名称', updatedBy: '修改人名称',
pickselfName: ['xxx', '1111'],
}, },
]; ];
const shopList = async () => { const shopList = async () => {
const res = await setShopList({ ...page, ...searchForm }); const params = {
console.log(res); ...page,
data: searchForm,
};
const res = await setShopList(params);
if (res.businessCode === '0000') {
setDataList(res.data?.records);
}
};
// 企业查询
const getEnterpriseList = async () => {
// const res = await apiEnterpriseList();
// if (res.businessCode === '0000' && res.data?.records?.length) {
// const list = res.data.records;
// const firstOption = list[0].id;
// const optionData = list.map(item => ({
// value: item.id,
// label: item.name,
// }));
// setFirstEnterprise(firstOption);
// setEnterpriseList(optionData);
// setSearchForm({ enterpriseId: firstOption });
// shopList();
// }
setSearchForm({ enterpriseId: 'jack' });
setFirstEnterprise('jack');
}; };
useEffect(() => {
getEnterpriseList();
}, []);
useEffect(() => { useEffect(() => {
shopList(); shopList();
}, []); }, [searchForm, page]);
// 关闭弹框 // 关闭弹框
const closeModal = value => { const closeModal = value => {
if (value) { if (value) {
...@@ -57,12 +111,12 @@ const StoreManagement = () => { ...@@ -57,12 +111,12 @@ const StoreManagement = () => {
setAddVisible(false); setAddVisible(false);
}; };
const setMealTypeList = async () => { const setMealTypeList = async () => {
// const res = await mealTypeList({ id: repastId });
// if (res.businessCode === '0000') {
// setRepastType(res.data);
// setEditVisible(true);
// }
setEditVisible(true); setEditVisible(true);
const res = await mealTypeList({ id: repastId });
if (res.businessCode === '0000') {
setRepastType(res.data);
setEditVisible(true);
}
}; };
// 修改餐饮类型 // 修改餐饮类型
const editRepastType = ({ id }) => { const editRepastType = ({ id }) => {
...@@ -90,21 +144,27 @@ const StoreManagement = () => { ...@@ -90,21 +144,27 @@ const StoreManagement = () => {
}, },
}); });
}; };
const onChange = (value, option) => {
setEnterprise(option);
};
// 添加商户 // 添加商户
const addShop = () => { const addShop = async () => {
const res = await busineesTypeCheck({ id: searchForm.id });
if (res.businessCode === '0000') {
const val = enterpriseList.find(item => item.value === searchForm.enterpriseId).label;
setName(val);
setAddVisible(true); setAddVisible(true);
}
}; };
// 搜索 // 搜索
const onFinish = values => { const onFinish = async values => {
setSearchForm(values); setSearchForm(values);
setPage({ current: 1, pageSize: 10 }); setPage({ current: 1, pageSize: 10 });
shopList();
}; };
// 重置 // 重置
const onReset = () => { const onReset = () => {
formRef.current.resetFields(); formRef.current.resetFields();
shopList(); setSearchForm({ enterpriseId: firstEnterprise });
}; };
// 分页 // 分页
const handleTableChange = val => { const handleTableChange = val => {
...@@ -118,6 +178,7 @@ const StoreManagement = () => { ...@@ -118,6 +178,7 @@ const StoreManagement = () => {
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<Card className={styles.card}> <Card className={styles.card}>
{firstEnterprise && (
<Form ref={formRef} onFinish={onFinish}> <Form ref={formRef} onFinish={onFinish}>
<Row gutter={24}> <Row gutter={24}>
<Col span={8}> <Col span={8}>
...@@ -126,6 +187,7 @@ const StoreManagement = () => { ...@@ -126,6 +187,7 @@ const StoreManagement = () => {
name="enterpriseId" name="enterpriseId"
wrapperCol={{ span: 16 }} wrapperCol={{ span: 16 }}
rules={[{ required: true }]} rules={[{ required: true }]}
initialValue={firstEnterprise}
> >
<Select <Select
allowClear allowClear
...@@ -133,20 +195,8 @@ const StoreManagement = () => { ...@@ -133,20 +195,8 @@ const StoreManagement = () => {
filterOption={(input, option) => filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()) (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
} }
options={[ onChange={onChange}
{ options={enterpriseList}
value: 'jack',
label: 'Jack',
},
{
value: 'lucy',
label: 'Lucy',
},
{
value: 'tom',
label: 'Tom',
},
]}
/> />
</Form.Item> </Form.Item>
</Col> </Col>
...@@ -188,6 +238,7 @@ const StoreManagement = () => { ...@@ -188,6 +238,7 @@ const StoreManagement = () => {
</Col> </Col>
</Row> </Row>
</Form> </Form>
)}
</Card> </Card>
<Table <Table
columns={columns(res)} columns={columns(res)}
...@@ -200,9 +251,9 @@ const StoreManagement = () => { ...@@ -200,9 +251,9 @@ const StoreManagement = () => {
editVisible={editVisible} editVisible={editVisible}
repastType={repastType} repastType={repastType}
id={repastId} id={repastId}
onCancel={() => closeModal()} onCancel={closeModal}
/> />
<AddModal addVisible={addVisible} name="name" onCancel={() => closeModal()} /> <AddModal addVisible={addVisible} name={name} onCancel={closeModal} />
</PageHeaderWrapper> </PageHeaderWrapper>
); );
}; };
......
...@@ -7,9 +7,10 @@ const { goodsApi } = config; ...@@ -7,9 +7,10 @@ const { goodsApi } = config;
const headers = { const headers = {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}; };
// // [企业店铺]-列表查询
// http://yapi.quantgroups.com/project/389/interface/api/65284
export const setShopList = async params => { export const setShopList = async params => {
const data = await request.post('/v1/channels/enterprise/shop/list', { const data = await request.post('/api/consoles/enterprise/shop/list', {
prefix: goodsApi, prefix: goodsApi,
data: params, data: params,
}); });
...@@ -19,7 +20,7 @@ export const setShopList = async params => { ...@@ -19,7 +20,7 @@ export const setShopList = async params => {
// [企业店铺]-删除企业下面的店铺 // [企业店铺]-删除企业下面的店铺
// http://yapi.quantgroups.com/project/389/interface/api/65319 // http://yapi.quantgroups.com/project/389/interface/api/65319
export const setShopDelete = async params => { export const setShopDelete = async params => {
const data = await request.post('/v1/channels/enterprise/shop/delete', { const data = await request.post('/api/consoles/enterprise/shop/delete', {
prefix: goodsApi, prefix: goodsApi,
data: params, data: params,
}); });
...@@ -29,7 +30,7 @@ export const setShopDelete = async params => { ...@@ -29,7 +30,7 @@ export const setShopDelete = async params => {
// [企业店铺]-查询餐品类型 // [企业店铺]-查询餐品类型
// http://yapi.quantgroups.com/project/389/interface/api/65314 // http://yapi.quantgroups.com/project/389/interface/api/65314
export const mealTypeList = async params => { export const mealTypeList = async params => {
const data = await request.post('/v1/channels/enterprise/shop/mealType/list', { const data = await request.post('/api/consoles/enterprise/shop/mealType/list', {
prefix: goodsApi, prefix: goodsApi,
data: params, data: params,
}); });
...@@ -39,7 +40,7 @@ export const mealTypeList = async params => { ...@@ -39,7 +40,7 @@ export const mealTypeList = async params => {
// [企业店铺]-添加企业店铺 // [企业店铺]-添加企业店铺
// http://yapi.quantgroups.com/project/389/interface/api/65304 // http://yapi.quantgroups.com/project/389/interface/api/65304
export const shopAdd = async params => { export const shopAdd = async params => {
const data = await request.post('/v1/channels/enterprise/shop/add', { const data = await request.post('/api/consoles/enterprise/shop/add', {
prefix: goodsApi, prefix: goodsApi,
data: params, data: params,
}); });
...@@ -48,10 +49,62 @@ export const shopAdd = async params => { ...@@ -48,10 +49,62 @@ export const shopAdd = async params => {
// 企业店铺]-修改餐品类型 // 企业店铺]-修改餐品类型
// http://yapi.quantgroups.com/project/389/interface/api/65309 // http://yapi.quantgroups.com/project/389/interface/api/65309
export const shopUpdate = async params => { export const apiShopUpdate = async params => {
const data = await request.post('/v1/channels/enterprise/shop/update', { const data = await request.post('/v1/channels/enterprise/shop/update', {
prefix: goodsApi, prefix: goodsApi,
data: params, data: params,
}); });
return data; return data;
}; };
// [企业客户]-列表查询
// http://yapi.quantgroups.com/project/389/interface/api/65324
export const apiEnterpriseList = async () => {
const data = await request.post('/api/consoles/enterprise/shop/update', {
prefix: goodsApi,
data: {
page: 1,
size: 10000,
},
});
return data;
};
// [企业店铺]-可选择店铺列表
// http://yapi.quantgroups.com/project/389/interface/api/65524
export const apiSelectList = async params => {
const data = await request.post('/api/console/enterprise/shop/select/list', {
prefix: goodsApi,
data: params,
});
return data;
};
// [企业店铺]-添加企业店铺校验是否是到店类型
// http://yapi.quantgroups.com/project/389/interface/api/65304
export const busineesTypeCheck = async params => {
const data = await request.post('/api/console/enterprise/shop/busineesType/check', {
prefix: goodsApi,
data: params,
});
return data;
};
// [企业店铺]-添加企业店铺
// http://yapi.quantgroups.com/project/389/interface/api/65304
export const apiShopAdd = async params => {
const data = await request.post('/api/consoles/enterprise/shop/add', {
prefix: goodsApi,
data: params,
});
return data;
};
// [企业店铺]-企业已选的店铺
// http://yapi.quantgroups.com/project/389/interface/api/65534
export const apiSelectedList = async params => {
const data = await request.post('/api/consoles/enterprise/shop/selected/list', {
prefix: goodsApi,
data: params,
});
return data;
};
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