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 { Modal, Form, Input, Checkbox } from 'antd';
import { Modal, Form, Input, Checkbox, message } from 'antd';
import styles from '../index.less';
import { apiStaffBlack } from '../service';
const { Item } = Form;
const BlacklistModal = ({ visible, onClose, onSave, list }) => {
const BlacklistModal = ({ visible, onClose, list, employeeId }) => {
const [form] = Form.useForm();
const handleSave = () => {
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 (
<Modal visible={visible} title="设置员工黑名单" onCancel={onClose} onOk={handleSave}>
<Form form={form} layout="vertical">
<Item name="employeeId" label="您确定要把员工ID:">
<Item name="ids" label="您确定要把员工ID:">
{list.length && list.map(item => <span>{item},</span>)}
</Item>
<Item name="reason" label="加入黑名单吗?">
......
......@@ -3,6 +3,7 @@ import { Modal, Form, Radio, Input, Button, Upload, message, Select } from 'antd
import { UploadOutlined } from '@ant-design/icons';
import { apiDepartmentSave, apiDepartmentExcel } from '../service';
const { Dragger } = Upload;
const { Item } = Form;
const layout = {
labelCol: { span: 6 },
......@@ -124,14 +125,17 @@ const DepartmentModal = ({ visible, onClose, enterpriseList }) => {
},
]}
>
<Upload
<Dragger
beforeUpload={() => false}
onChange={handleImportChange}
maxCount={1}
accept=".xls,.xlsx"
onChange={handleImportChange}
>
<Button icon={<UploadOutlined />}>点击上传</Button>
</Upload>
<UploadOutlined />
<p>
将文件拖到此处,或<a href="#">点击上传</a>
</p>
</Dragger>
</Item>
) : (
<Item
......
import React, { useState } from 'react';
import { Modal, Form, Input, Button, Select, message } from 'antd';
import { apiStaffSave } from '../service';
import { Modal, Form, Input, Button, Select, message, Upload, Radio } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import { apiStaffSave, apiStaffExcel } from '../service';
import styles from '../index.less';
const { Dragger } = Upload;
const { Option } = Select;
const layout = {
......@@ -12,21 +15,35 @@ const NewEmployeeModal = props => {
const { departmentList, visible, onClose, enterpriseList, getDepartmentList } = props;
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const [importMode, setImportMode] = useState(false);
const handleCancel = val => {
form.resetFields();
setImportMode(false);
onClose(val);
};
const handleSave = () => {
form.validateFields().then(async values => {
setLoading(true);
if (importMode) {
const res = await apiStaffExcel(values);
if (res.businessCode === '0000') {
message.success('上传成功');
handleCancel(true);
}
return;
}
const res = await apiStaffSave(values);
if (res.businessCode === '0000') {
setLoading(false);
message.success('保存成功');
onClose(true);
handleCancel(true);
}
});
};
const validatePhone = (_, value) => {
const phoneRegex = /^[1-9]\d{9}$/;
console.log(value);
const phoneRegex = /^1[3456789]\d{9}$/;
if (!value || phoneRegex.test(value)) {
return Promise.resolve();
}
......@@ -74,64 +91,118 @@ const NewEmployeeModal = props => {
/>
</Form.Item>
<Form.Item
name="departmentId"
label="部门"
rules={[
{
required: true,
message: '请选择部门',
},
]}
>
<Select
placeholder="请选择部门"
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={departmentList}
/>
</Form.Item>
<Form.Item
name="staffNo"
label="员工ID"
rules={[
{
required: true,
message: '请输入员工ID',
},
]}
>
<Input />
</Form.Item>
<Form.Item
name="staffName"
label="员工姓名"
rules={[
{
required: true,
message: '请输入员工姓名',
},
]}
>
<Input />
</Form.Item>
<Form.Item
name="mobile"
label="员工手机号"
rules={[
{
required: true,
message: '请输入员工手机号',
},
{
validator: validatePhone,
},
]}
label="配置方式"
name="configMode"
rules={[{ required: true, message: '请选择配置方式' }]}
initialValue={0}
>
<Input />
<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
name="departmentId"
label="部门"
rules={[
{
required: true,
message: '请选择部门',
},
]}
>
<Select
placeholder="请选择部门"
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={departmentList}
/>
</Form.Item>
<Form.Item
name="staffNo"
label="员工ID"
rules={[
{
required: true,
message: '请输入员工ID',
},
]}
>
<Input />
</Form.Item>
<Form.Item
name="staffName"
label="员工姓名"
rules={[
{
required: true,
message: '请输入员工姓名',
},
]}
>
<Input />
</Form.Item>
<Form.Item
name="mobile"
label="员工手机号"
rules={[
{
required: true,
message: '请输入员工手机号',
},
{
validator: validatePhone,
},
]}
>
<Input maxLength={11} />
</Form.Item>
</>
)}
</Form>
</Modal>
);
......
......@@ -48,12 +48,17 @@ export const columns = props => [
},
{
title: '是否消费限额',
key: 'balance',
dataIndex: 'balance',
key: 'isLimit',
dataIndex: 'isLimit',
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 => [
align: 'center',
key: 'option',
render: (_, row) => [
<Button type="link" onClick={() => props.delEmployee(row)}>
<Button type="link" onClick={() => props.goDetails(row)}>
余额充值明细
</Button>,
<Button type="link" disabled={!row?.isBlack} onClick={() => props.delEmployee(row)}>
......
......@@ -22,21 +22,25 @@ import {
apiDepartmentList,
apiStaffExcel,
apiStaffDelete,
apiGenerateLogList,
apiStaffLimit,
} from './service.js';
import NewEmployeeModal from './components/newEmployeeModal';
import DepartmentModal from './components/departmentModal';
import ViewDepartmentModal from './components/ViewDepartmentModal';
import BlacklistModal from './components/BlacklistModal';
import BatchFileModal from './components/batchFileModal';
import RechargeDetailsModal from './components/RechargeDetailsModal';
const fakeData = [
{
isBlack: 1,
isBlack: 0,
id: 1,
isLimit: 0,
},
{
isBlack: 1,
id: 2,
isLimit: 1,
},
];
......@@ -46,12 +50,13 @@ const StoreManagement = () => {
const [departmentVisible, setDepartmentVisible] = useState(false);
const [viewDepartmentVisible, setViewDepartmentVisible] = useState(false);
const [blacklistVisible, setBlacklistVisible] = useState(false);
const [batchFileVisible, setBatchFileVisible] = useState(false);
const [rechargeDetailsVisible, setRechargeDetailsVisible] = useState(false);
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [staffList, setStaffList] = useState([]);
const [enterpriseList, setEnterpriseList] = useState([]);
const [firstEnterprise, setFirstEnterprise] = useState();
const [departmentList, setDepartmentList] = useState([]);
const [generateLog, setGenerateLog] = useState([]);
const [page, setPage] = useState({
page: 1,
size: 10,
......@@ -96,10 +101,9 @@ const StoreManagement = () => {
const rowSelection = {
selectedRowKeys,
onChange: setSelectedRowKeys,
};
//
const getBatchFile = () => {
setBatchFileVisible(true);
getCheckboxProps: record => ({
disabled: record.isBlack === 1,
}),
};
// 关闭弹框
......@@ -108,7 +112,7 @@ const StoreManagement = () => {
setDepartmentVisible(false);
setViewDepartmentVisible(false);
setBlacklistVisible(false);
setBatchFileVisible(false);
setRechargeDetailsVisible(false);
if (val) {
shopList();
}
......@@ -195,9 +199,28 @@ const StoreManagement = () => {
const handleTableChange = 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 = {
delEmployee,
goDetails,
handleLimitChange,
};
return (
<PageHeaderWrapper>
......@@ -222,8 +245,9 @@ const StoreManagement = () => {
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="部门查询" name="departmentId" wrapperCol={{ span: 16 }}>
<Form.Item label="部门查询" name="departmentIds" wrapperCol={{ span: 16 }}>
<Select
mode="multiple"
allowClear
showSearch
filterOption={(input, option) =>
......@@ -283,9 +307,6 @@ const StoreManagement = () => {
</Row>
</Form>
<div className={styles.addBtn}>
<Button type="primary" onClick={getBatchFile}>
批量新增员工
</Button>
<Button type="primary" className={styles.left} onClick={getBlacklist}>
设置员工黑名单
</Button>
......@@ -348,10 +369,11 @@ const StoreManagement = () => {
list={selectedRowKeys}
visible={blacklistVisible}
onClose={handleCloseModal}
employeeId={searchForm.enterpriseId}
/>
<BatchFileModal
list={selectedRowKeys}
visible={batchFileVisible}
<RechargeDetailsModal
visible={rechargeDetailsVisible}
list={generateLog}
onClose={handleCloseModal}
/>
</PageHeaderWrapper>
......
......@@ -32,3 +32,19 @@
.employees {
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 => {
});
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 { Button, Modal, Select, Form, notification } from 'antd';
import styles from '../index.less';
import { apiSelectedList, apiSelectList, apiShopAdd } from '../service.js';
const AddModal = props => {
const { addVisible } = props;
const [shopIds, setShopIds] = useState([]);
const { addVisible, enterpriseId, name } = props;
const [selectList, setSelectList] = useState([]);
const [options, setOptions] = useState([]);
const handleCancel = () => {
props.onCancel(false);
};
const handleChange = value => {
setShopIds(value);
setSelectList(value);
};
const onOk = () => {
if (!shopIds.length) {
const onOk = async () => {
if (!selectList.length) {
notification.error({
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 (
<>
<Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={() => handleCancel()}>
<Modal title="添加企业店铺" onOk={onOk} visible={addVisible} onCancel={() => handleCancel}>
<Form>
<Form.Item label="企业名称">
<span>企业名称</span>
<span>{name}</span>
</Form.Item>
<Form.Item label="添加微店" name="shopIds">
<Form.Item label="添加微店" name="shopIds" initialValue={selectList}>
<Select
mode="multiple"
allowClear
style={{ width: '100%' }}
placeholder="请选择微店"
onChange={handleChange}
// options={options}
options={options}
/>
</Form.Item>
<Form.Item label="餐饮类型">
<span>餐饮类型</span>
<span>到店</span>
</Form.Item>
</Form>
</Modal>
......
......@@ -37,11 +37,17 @@ export const columns = props => [
align: 'center',
render: (_, row) => {
const status = !row?.pickselfName;
return (
<Button type="text" disabled={status} onClick={() => props.editRepastType(row)}>
{row.mealType} <FormOutlined />
</Button>
);
if (row?.mealType?.length) {
return (
<Button type="text" disabled={status} onClick={() => props.editRepastType(row)}>
{row.mealType?.map((item, index) => (
<span>{repastTypeList.find(itm => itm.value === item)?.label}&nbsp;</span>
))}
<FormOutlined />
</Button>
);
}
return '/';
},
},
{
......@@ -49,6 +55,17 @@ export const columns = props => [
key: 'pickselfName',
dataIndex: 'pickselfName',
align: 'center',
render: (text, record) => {
if (record.pickselfName?.length) {
return text.map((item, index) => (
<span>
{item}
{index < record.pickselfName.length - 1 && ','}
</span>
));
}
return '/';
},
},
{
title: '修改人',
......@@ -69,7 +86,7 @@ export const columns = props => [
align: 'center',
key: 'option',
render: (_, row) => (
<Button type="link" disabled={row?.pickselfName} onClick={() => props.delShop(row)}>
<Button type="link" disabled={row?.pickselfName?.length} onClick={() => props.delShop(row)}>
删除
</Button>
),
......
import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle } from 'react';
import { Button, Modal, Radio, Form, Space, message, Checkbox, Col, Row } from 'antd';
import styles from '../index.less';
import { shopUpdate } from '../service.js';
import { apiShopUpdate } from '../service.js';
const EditRepastModal = props => {
const [form] = Form.useForm();
const { editVisible, repastType, id } = props;
const handleCancel = () => {
props.onCancel();
};
const handleChange = e => {
console.log(e.target.value);
};
const onOk = () => {
// if (!shopIds.length) {
// notification.error({
// message: '请添加微店',
// });
// }
form.validateFields().then(async values => {
const params = {
id,
mealTypeList: values.mealTypeList,
};
const res = await apiShopUpdate(params);
if (res.businessCode === '0000') {
message.success('修改成功');
handleCancel(true);
}
});
};
return (
<>
<Modal title="餐饮类型" onOk={onOk} visible={editVisible} onCancel={() => handleCancel()}>
<Form layout="vertical" autoComplete="off">
<Form.Item label="取餐点下商户餐品类型">
<Radio.Group onChange={handleChange}>
<Space direction="vertical">
<Radio value={1}>外卖</Radio>
<Radio value={2}>自助餐</Radio>
<Form layout="vertical" autoComplete="off" form={form}>
<Form.Item
label="取餐点下商户餐品类型"
rules={[{ required: true, message: '请选择商户餐品类型' }]}
>
<Checkbox.Group>
<Space direction="mealTypeList">
{(repastType.length &&
repastType.map((index, value) => <Checkbox>{index}</Checkbox>)) ||
''}
</Space>
</Radio.Group>
</Checkbox.Group>
<p className={styles.tip}>切换餐品类型后,请及时维护商品</p>
</Form.Item>
<Form.Item label="是否开启餐品类型">
<Checkbox.Group>
<Space direction="vertical">
{(repastType.length &&
repastType.map((index, value) => <Checkbox value="A">到店</Checkbox>)) ||
''}
<Checkbox>到店</Checkbox>
</Space>
</Checkbox.Group>
<p className={styles.tip}>关闭【到店】餐类时,关联到店企业商品将一并删除</p>
......
......@@ -5,28 +5,53 @@ import { columns, repastTypeList } from './data';
import EditRepastModal from './editRepastModal';
import AddModal from './addModal';
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 StoreManagement = () => {
const [page, setPage] = useState({
current: 1,
pageSize: 10,
page: 1,
size: 10,
});
const optionData = [
{
value: 'jack',
label: '1',
},
{
value: 'lucy',
label: '2',
},
{
value: 'tom',
label: '3',
},
];
const [searchForm, setSearchForm] = useState({});
const formRef = useRef(null);
const [editVisible, setEditVisible] = useState(false);
const [addVisible, setAddVisible] = useState(false);
const [repastType, setRepastType] = useState([]);
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 = [
{
enterpriseId: '企业id',
id: '1',
shopId: 'shopId',
shopName: '店铺名称',
mealType: '到店',
pickselfName: '',
mealType: [1, 2],
pickselfName: ['1', '1111'],
updatedBy: '修改人名称',
amount: '2023/03/21 14:06:11',
},
......@@ -35,19 +60,48 @@ const StoreManagement = () => {
id: '2',
shopId: 'shopId',
shopName: '店铺名称',
mealType: '到店',
pickselfName: '取餐点',
mealType: [1, 2],
updatedBy: '修改人名称',
pickselfName: ['xxx', '1111'],
},
];
const shopList = async () => {
const res = await setShopList({ ...page, ...searchForm });
console.log(res);
const params = {
...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(() => {
shopList();
getEnterpriseList();
}, []);
useEffect(() => {
shopList();
}, [searchForm, page]);
// 关闭弹框
const closeModal = value => {
if (value) {
......@@ -57,12 +111,12 @@ const StoreManagement = () => {
setAddVisible(false);
};
const setMealTypeList = async () => {
// const res = await mealTypeList({ id: repastId });
// if (res.businessCode === '0000') {
// setRepastType(res.data);
// setEditVisible(true);
// }
setEditVisible(true);
const res = await mealTypeList({ id: repastId });
if (res.businessCode === '0000') {
setRepastType(res.data);
setEditVisible(true);
}
};
// 修改餐饮类型
const editRepastType = ({ id }) => {
......@@ -90,21 +144,27 @@ const StoreManagement = () => {
},
});
};
const onChange = (value, option) => {
setEnterprise(option);
};
// 添加商户
const addShop = () => {
setAddVisible(true);
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);
}
};
// 搜索
const onFinish = values => {
const onFinish = async values => {
setSearchForm(values);
setPage({ current: 1, pageSize: 10 });
shopList();
};
// 重置
const onReset = () => {
formRef.current.resetFields();
shopList();
setSearchForm({ enterpriseId: firstEnterprise });
};
// 分页
const handleTableChange = val => {
......@@ -118,76 +178,67 @@ const StoreManagement = () => {
return (
<PageHeaderWrapper>
<Card className={styles.card}>
<Form ref={formRef} onFinish={onFinish}>
<Row gutter={24}>
<Col span={8}>
<Form.Item
label="企业名称"
name="enterpriseId"
wrapperCol={{ span: 16 }}
rules={[{ required: true }]}
>
<Select
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={[
{
value: 'jack',
label: 'Jack',
},
{
value: 'lucy',
label: 'Lucy',
},
{
value: 'tom',
label: 'Tom',
},
]}
/>
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="微店名称" name="shopName" wrapperCol={{ span: 16 }}>
<Input maxLength="20" allowClear />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="微店ID" name="shopId" wrapperCol={{ span: 16 }}>
<Input maxLength="20" allowClear />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="餐品类型" name="mealType" wrapperCol={{ span: 16 }}>
<Select
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={repastTypeList}
placeholder="全部"
/>
</Form.Item>
</Col>
<Col className={styles.btn}>
<Form.Item>
<Button type="primary" htmlType="submit">
搜索
</Button>
<Button htmlType="button" onClick={onReset} className={styles.left}>
重置
</Button>
<Button type="primary" onClick={addShop} className={styles.left}>
添加商户
</Button>
</Form.Item>
</Col>
</Row>
</Form>
{firstEnterprise && (
<Form ref={formRef} onFinish={onFinish}>
<Row gutter={24}>
<Col span={8}>
<Form.Item
label="企业名称"
name="enterpriseId"
wrapperCol={{ span: 16 }}
rules={[{ required: true }]}
initialValue={firstEnterprise}
>
<Select
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
onChange={onChange}
options={enterpriseList}
/>
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="微店名称" name="shopName" wrapperCol={{ span: 16 }}>
<Input maxLength="20" allowClear />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="微店ID" name="shopId" wrapperCol={{ span: 16 }}>
<Input maxLength="20" allowClear />
</Form.Item>
</Col>
<Col span={8}>
<Form.Item label="餐品类型" name="mealType" wrapperCol={{ span: 16 }}>
<Select
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={repastTypeList}
placeholder="全部"
/>
</Form.Item>
</Col>
<Col className={styles.btn}>
<Form.Item>
<Button type="primary" htmlType="submit">
搜索
</Button>
<Button htmlType="button" onClick={onReset} className={styles.left}>
重置
</Button>
<Button type="primary" onClick={addShop} className={styles.left}>
添加商户
</Button>
</Form.Item>
</Col>
</Row>
</Form>
)}
</Card>
<Table
columns={columns(res)}
......@@ -200,9 +251,9 @@ const StoreManagement = () => {
editVisible={editVisible}
repastType={repastType}
id={repastId}
onCancel={() => closeModal()}
onCancel={closeModal}
/>
<AddModal addVisible={addVisible} name="name" onCancel={() => closeModal()} />
<AddModal addVisible={addVisible} name={name} onCancel={closeModal} />
</PageHeaderWrapper>
);
};
......
......@@ -7,9 +7,10 @@ const { goodsApi } = config;
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
};
//
// [企业店铺]-列表查询
// http://yapi.quantgroups.com/project/389/interface/api/65284
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,
data: params,
});
......@@ -19,7 +20,7 @@ export const setShopList = async params => {
// [企业店铺]-删除企业下面的店铺
// http://yapi.quantgroups.com/project/389/interface/api/65319
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,
data: params,
});
......@@ -29,7 +30,7 @@ export const setShopDelete = async params => {
// [企业店铺]-查询餐品类型
// http://yapi.quantgroups.com/project/389/interface/api/65314
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,
data: params,
});
......@@ -39,7 +40,7 @@ export const mealTypeList = async params => {
// [企业店铺]-添加企业店铺
// http://yapi.quantgroups.com/project/389/interface/api/65304
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,
data: params,
});
......@@ -48,10 +49,62 @@ export const shopAdd = async params => {
// 企业店铺]-修改餐品类型
// 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', {
prefix: goodsApi,
data: params,
});
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