Commit 45a70a0a authored by 武广's avatar 武广

feat: 添加企业客户逻辑

parent ca70ccf0
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
const isPre = process.env.PRE_ENV === 'pre'; const isPre = process.env.PRE_ENV === 'pre';
const environment = 'yxm2'; const environment = 'xyqb';
const envAPi = { const envAPi = {
api: `https://security-${environment}.liangkebang.net`, //'https://security-xyqb.liangkebang.net', api: `https://security-${environment}.liangkebang.net`, //'https://security-xyqb.liangkebang.net',
kdspOpApi: `https://sc-merchant-api-${environment}.liangkebang.net`, kdspOpApi: `https://sc-merchant-api-${environment}.liangkebang.net`,
......
import React, { useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Divider, Form, Input, Checkbox, Col, Row, Modal, Select } from 'antd'; import {
Button,
Divider,
Form,
Input,
InputNumber,
Checkbox,
Radio,
Col,
Row,
Modal,
Select,
message,
} from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons'; import { ExclamationCircleOutlined } from '@ant-design/icons';
import { jsonToArray } from '@/utils/utils'; import { jsonToArray } from '@/utils/utils';
import { layout, typeOptions, boolOptions, infoOptions } from '../staticData/index'; import {
layout,
mealType,
boolOptions,
hideOptions,
infoOptions,
mealSections,
} from '../staticData/index';
import { apiEnterpriseInfo, apiNewEnterprise, apiEditEnterprise } from '../service';
import style from '../style/info.less'; import style from '../style/info.less';
import MealSection from './MealSection'; import MealSection from './MealSection';
import MealLimit from './MealLimit'; import MealLimit from './MealLimit';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const RadioGroup = Radio.Group;
const { confirm } = Modal; const { confirm } = Modal;
const CustomerInfo = props => { const CustomerInfo = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
...@@ -22,6 +44,19 @@ const CustomerInfo = props => { ...@@ -22,6 +44,19 @@ const CustomerInfo = props => {
// 添加/保存分组 // 添加/保存分组
const handleConfirm = async () => { const handleConfirm = async () => {
const res = await form.validateFields(); const res = await form.validateFields();
// const res = await form.getFieldsValue();
if (res.mealTimePeriod.length < 1) {
message.warn('请选择餐段');
return;
}
const params = Object.assign({}, res);
const arr = [];
res.mealTimePeriod.forEach(item => {
if (item.mealPeriodType) {
arr.push(item);
}
});
params.mealTimePeriod = arr;
console.log('res :>> ', res); console.log('res :>> ', res);
}; };
...@@ -76,94 +111,109 @@ const CustomerInfo = props => { ...@@ -76,94 +111,109 @@ const CustomerInfo = props => {
// 改变餐段 // 改变餐段
const onChangeMealSection = e => { const onChangeMealSection = e => {
console.log('e.target :>> ', e.target); console.log('e.target :>> ', e.target);
const { value, checked, label } = e.target; const { id, checked, label } = e.target;
const values = Object.assign({}, meals); const values = Object.assign({}, meals);
if (checked) { if (checked) {
values[value] = label; values[id] = label;
// values.push(value); // values.push(value);
// } else if (values.includes(value)) { // } else if (values.includes(value)) {
// const index = values.findIndex(v => v === value); // const index = values.findIndex(v => v === value);
// values.splice(index, 1); // values.splice(index, 1);
} else { } else {
delete values[value]; delete values[id];
} }
console.log('values :>> ', values);
setMeals(values); setMeals(values);
}; };
// 获取企业客户新
const getInfo = async () => {
const res = await apiEnterpriseInfo(1);
};
useEffect(() => {
if (props.visible) {
getInfo();
}
}, [props.visible]);
return ( return (
<Modal <Modal
title="企业客户信息" title="企业客户信息"
open={props.visible} open={props.visible}
destroyOnClose destroyOnClose
maskClosable={false} maskClosable={false}
width="850px" width="880px"
onOk={handleConfirm} onOk={handleConfirm}
onCancel={handleCancel} onCancel={handleCancel}
> >
<Form name="basicInfo" {...layout} form={form}> <Form
name="basicInfo"
initialValues={{ mealTimePeriod: [{}, {}, {}] }}
{...layout}
form={form}
>
<Form.Item <Form.Item
label="公司名称" label="公司名称"
name="businessName" name="name"
rules={[{ required: true, message: '请输入公司名称!' }]} rules={[{ required: true, message: '请输入公司名称!' }]}
> >
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item label="企业取餐点" name="qucan"> <Form.Item label="企业取餐点" name="pickselfIds">
<Select /> <Select />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="企业截止时间" label="企业截止时间"
name="times" name="endOrderTime"
wrapperCol={{ span: 20 }} wrapperCol={{ span: 20 }}
rules={[{ required: true, message: '请输入企业截止时间!' }]} rules={[{ required: true, message: '请输入企业截止时间!' }]}
extra={<span>企业员工下单的截至时间,仅支持正整数,单位为分钟。</span>} extra={<span>企业员工下单的截至时间,仅支持正整数,单位为分钟。</span>}
> >
<Row> <Row>
<Col span={22}> <InputNumber min={0} max={600} addonAfter="分钟" />
<Input />
</Col>
<Col span={2}>
<div className={style.tip}>分钟</div>
</Col>
</Row> </Row>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="餐品类型" label="餐品类型"
name="types" name="mealType"
rules={[{ required: true, message: '请选择餐品类型!' }]} rules={[{ required: true, message: '请选择餐品类型!' }]}
> >
<CheckboxGroup options={jsonToArray(typeOptions)} onChange={onChangeMealType} /> <CheckboxGroup options={jsonToArray(mealType)} onChange={onChangeMealType} />
</Form.Item> </Form.Item>
<Form.Item label="餐段配置" required> <Form.Item label="餐段配置" required wrapperCol={{ span: 12 }}>
<MealSection meals={meals} onChange={onChangeMealSection} /> <MealSection meals={meals} onChange={onChangeMealSection} />
</Form.Item> </Form.Item>
<Form.Item {/* <Form.Item
label="商品展示信息" label="商品展示信息"
name="xinxin" name="xinxin"
rules={[{ required: true, message: '请选择商品展示信息!' }]} rules={[{ required: true, message: '请选择商品展示信息!' }]}
> >
<CheckboxGroup options={infoOptions} /> <CheckboxGroup options={infoOptions} />
</Form.Item> </Form.Item> */}
<Divider orientation="left" plain> <Divider orientation="left" plain>
企业单笔消费限额 企业单笔消费限额
</Divider> </Divider>
{Object.keys(meals).map(meal => ( {Object.keys(meals).map(meal => (
<Form.Item label={meals[meal]} required wrapperCol={{ span: 20 }}> <Form.Item label={meals[meal]} key={meal} required wrapperCol={{ span: 20 }}>
<Row> <Row>
{mealTypes.map((t, i) => ( {mealTypes.map((t, i) => (
<Col span={7} offset={i ? 1 : 0}> <Col span={7} offset={i ? 1 : 0} key={t}>
<MealLimit value={t} label={typeOptions[t]} name={`${meal}-${t.value}`} /> <MealLimit value={t} label={mealType[t]} name={`${meal}-${t.value}`} />
</Col> </Col>
))} ))}
</Row> </Row>
</Form.Item> </Form.Item>
))} ))}
<Form.Item label="商品隐藏信息" name="hideInfo">
<CheckboxGroup options={hideOptions} />
</Form.Item>
<Form.Item <Form.Item
label="是否周预览" label="是否周预览"
name="yulan" name="weekPreview"
rules={[{ required: true, message: '请选择是否周预览!' }]} rules={[{ required: true, message: '请选择是否周预览!' }]}
> >
<CheckboxGroup options={boolOptions} /> <RadioGroup options={boolOptions} />
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>
......
import React from 'react';
import { Checkbox } from 'antd';
import { mealSections } from '../staticData/index';
const MealCheckbox = props => {
const onChange = e => {
props.onChange(props.field);
props.changeType(e);
};
return (
<Checkbox
onChange={onChange}
checked={props.meals[props.field]}
id={props.field}
label={mealSections[props.field]}
>
{mealSections[props.field]}
</Checkbox>
);
};
export default MealCheckbox;
...@@ -12,15 +12,7 @@ const MealLimit = props => ( ...@@ -12,15 +12,7 @@ const MealLimit = props => (
{ validator: isCheckPriceTwoDecimal, message: '请输入正确的价格' }, { validator: isCheckPriceTwoDecimal, message: '请输入正确的价格' },
]} ]}
> >
<InputNumber addonAfter="元" max={999.99} defaultValue={100} /> <InputNumber addonAfter="元" max={999.99} />
{/* <Row>
<Col span={18}>
<Input maxLength={6} />
</Col>
<Col span={6}>
<div className={style.tip}>元</div>
</Col>
</Row> */}
</Form.Item> </Form.Item>
); );
......
import React from 'react'; import React from 'react';
import { Form, Space, Checkbox, TimePicker } from 'antd'; import { Form, Space, TimePicker } from 'antd';
import { mealSections } from '../staticData/index'; import { mealSections } from '../staticData/index';
import MealCheckbox from './MealCheckbox';
const MealSection = props => const MealSection = props => (
mealSections.map(field => ( <Form.List name="mealTimePeriod">
<Space key={field.key} align="baseline"> {fields => (
<Form.Item label=""> <>
<Checkbox onChange={props.onChange} value={field.value} label={field.label}> {Object.keys(mealSections).map((field, i) => (
{field.label} <Space key={field} align="baseline">
</Checkbox> <Form.Item label="" name={[fields[i].name, 'mealPeriodType']}>
</Form.Item> <MealCheckbox changeType={props.onChange} meals={props.meals} field={field} />
<Form.Item name={[field.time, field.key]}> </Form.Item>
<TimePicker.RangePicker format="HH:mm" /> <Form.Item
</Form.Item> name={[fields[i].name, 'time']}
</Space> rules={[
)); props.meals[field] ? { type: 'array', required: true, message: '请选择!' } : {},
]}
>
<TimePicker.RangePicker format="HH:mm" />
</Form.Item>
</Space>
))}
</>
)}
</Form.List>
);
export default MealSection; export default MealSection;
...@@ -4,10 +4,18 @@ import { Button } from 'antd'; ...@@ -4,10 +4,18 @@ import { Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { customerColumn } from './staticData/index'; import { customerColumn } from './staticData/index';
import CustomerInfo from './components/CustomerInfo'; import CustomerInfo from './components/CustomerInfo';
import { apiEnterpriseList } from './service';
const BusinessCustomer = () => { const BusinessCustomer = () => {
const [visible, setVisible] = useState(true); const [visible, setVisible] = useState(false);
const query = async () => {}; const query = async params => {
const data = {
page: params.current,
size: params.pageSize,
data: params,
};
return apiEnterpriseList(data);
};
const onEdit = async () => {}; const onEdit = async () => {};
return ( return (
...@@ -24,13 +32,13 @@ const BusinessCustomer = () => { ...@@ -24,13 +32,13 @@ const BusinessCustomer = () => {
bordered bordered
options={false} options={false}
toolBarRender={() => [ toolBarRender={() => [
<Button key="3" icon={<PlusOutlined />} type="primary" onClick={onEdit}> <Button key="3" icon={<PlusOutlined />} type="primary" onClick={() => setVisible(!0)}>
添加企业客户 添加企业客户
</Button>, </Button>,
]} ]}
scroll={{ x: '100%', y: 400 }} scroll={{ x: '100%', y: 400 }}
/> />
<CustomerInfo visible={visible} /> <CustomerInfo visible={visible} handleClose={setVisible} />
</div> </div>
); );
}; };
......
import request from '@/utils/request';
import config from '@/../config/env.config';
// import qs from 'qs';
const { kdspApi, goodsApi } = config;
/**
* 获取企业客户列表
* http://yapi.quantgroups.com/project/389/interface/api/65324
*/
export async function apiEnterpriseList(data) {
return request.post('/api/consoles/enterprise/pageList', {
data,
prefix: goodsApi,
});
}
/**
* 获取企业客户详细
* http://yapi.quantgroups.com/project/389/interface/api/65339
*/
export async function apiEnterpriseInfo(id) {
return request.get(`/api/consoles/enterprise/info?id=${id}`, {
prefix: goodsApi,
});
}
/**
* 添加企业客户
* http://yapi.quantgroups.com/project/389/interface/api/65329
*/
export async function apiNewEnterprise(data) {
return request.post('/api/consoles/enterprise/save', {
data,
prefix: goodsApi,
});
}
/**
* 编辑企业客户
* http://yapi.quantgroups.com/project/389/interface/api/65334
*/
export async function apiEditEnterprise(data) {
return request.post('/api/consoles/enterprise/update', {
data,
prefix: goodsApi,
});
}
...@@ -6,14 +6,64 @@ export const layout = { ...@@ -6,14 +6,64 @@ export const layout = {
wrapperCol: { span: 18 }, wrapperCol: { span: 18 },
}; };
// 餐品类型:(1外卖 2 自助餐 4到店)
export const mealType = {
1: '外卖',
2: '自助餐',
4: '到店',
};
export const infoOptions = [
{ label: '商品价格及图片', value: 1 },
{ label: '仅商品价格', value: 2 },
{ label: '仅商品图片', value: 3 },
{ label: '均不展示', value: 4 },
];
export const boolOptions = [{ label: '', value: 1 }, { label: '', value: 0 }];
export const hideOptions = [
{ label: '隐藏商品价格', value: 'hidePrice' },
{ label: '隐藏商品图片', value: 'hideImage' },
];
// export const mealSections = [
// {
// label: '早餐',
// value: '1',
// key: 'time1',
// },
// {
// label: '中餐',
// value: '2',
// key: 'time2',
// },
// {
// label: '晚餐',
// value: '4',
// key: 'time4',
// },
// ];
export const mealSections = {
1: '早餐',
2: '中餐',
4: '晚餐',
};
// 企业列表字段
export const customerColumn = options => { export const customerColumn = options => {
const { onEdit } = options; const { onEdit } = options;
return [ return [
{
title: 'ID',
dataIndex: 'enterpriseId',
hideInTable: true,
},
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
width: 120, width: 120,
align: 'center', align: 'center',
hideInSearch: true,
}, },
{ {
title: '公司名称', title: '公司名称',
...@@ -23,21 +73,25 @@ export const customerColumn = options => { ...@@ -23,21 +73,25 @@ export const customerColumn = options => {
}, },
{ {
title: '截单时间(分钟)', title: '截单时间(分钟)',
dataIndex: 'times', dataIndex: 'endOrderTime',
width: 120, width: 120,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
}, },
{ {
title: '餐品类型', title: '餐品类型',
dataIndex: 'types', dataIndex: 'mealType',
width: 120, width: 120,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
render(types) {
const arr = types.map(meal => mealType[meal]);
return arr.join('/');
},
}, },
{ {
title: '创建人', title: '创建人',
dataIndex: 'cr', dataIndex: 'createdBy',
width: 120, width: 120,
align: 'center', align: 'center',
hideInSearch: true, hideInSearch: true,
...@@ -64,41 +118,3 @@ export const customerColumn = options => { ...@@ -64,41 +118,3 @@ export const customerColumn = options => {
}, },
]; ];
}; };
// export const typeOptions = [
// { label: '外卖', value: 1 },
// { label: '自助餐', value: 2 },
// { label: '到店', value: 3 },
// ];
export const typeOptions = {
1: '外卖',
2: '自助餐',
4: '到店',
};
export const infoOptions = [
{ label: '商品价格及图片', value: 1 },
{ label: '仅商品价格', value: 2 },
{ label: '仅商品图片', value: 3 },
{ label: '均不展示', value: 4 },
];
export const boolOptions = [{ label: '', value: 1 }, { label: '', value: 0 }];
export const mealSections = [
{
label: '早餐',
value: '1',
key: 'time1',
},
{
label: '中餐',
value: '2',
key: 'time2',
},
{
label: '晚餐',
value: '3',
key: 'time3',
},
];
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
margin-right: 15px; margin-right: 15px;
} }
} }
&--batch-btn {
text-align: right;
}
} }
.select-goods-box { .select-goods-box {
display: flex; display: flex;
......
...@@ -86,6 +86,10 @@ const TakeawayGoodsInfo = props => { ...@@ -86,6 +86,10 @@ const TakeawayGoodsInfo = props => {
</Row> </Row>
<Row className={style['info-box--line']}> <Row className={style['info-box--line']}>
<Col span={24}> <Col span={24}>
<div className={style['info-box--batch-btn']}>
<Button>批量配置日期</Button>
<Button>批量配置餐段</Button>
</div>
<Table columns={GoodsInfoColumn(options)} dataSource={dataSource} /> <Table columns={GoodsInfoColumn(options)} dataSource={dataSource} />
</Col> </Col>
</Row> </Row>
......
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