Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
8558d4a8
Commit
8558d4a8
authored
Jun 28, 2023
by
张子雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 模板第一版
parent
f4dc6983
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
482 additions
and
459 deletions
+482
-459
CustomerInfo.jsx
src/pages/businessCustomer/components/CustomerInfo.jsx
+1
-0
CustomerInfoCopy.jsx
src/pages/businessCustomer/components/CustomerInfoCopy.jsx
+479
-458
index.jsx
src/pages/businessCustomer/index.jsx
+2
-1
No files found.
src/pages/businessCustomer/components/CustomerInfo.jsx
View file @
8558d4a8
...
@@ -304,6 +304,7 @@ const CustomerInfo = props => {
...
@@ -304,6 +304,7 @@ const CustomerInfo = props => {
formData
.
mealLimit
=
mealLimitMap
;
formData
.
mealLimit
=
mealLimitMap
;
setSelectedMealTypes
(
formData
.
mealType
);
setSelectedMealTypes
(
formData
.
mealType
);
console
.
log
(
'
formData :>>
'
,
formData
);
form
.
setFieldsValue
(
formData
);
form
.
setFieldsValue
(
formData
);
}
}
};
};
...
...
src/pages/businessCustomer/components/CustomerInfoCopy.jsx
View file @
8558d4a8
//
import React, { useEffect, useState } from 'react';
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
//
import {
import
{
//
Button,
Button
,
//
Divider,
Divider
,
//
Form,
Form
,
//
Input,
Input
,
//
InputNumber,
InputNumber
,
//
Checkbox,
Checkbox
,
//
Radio,
Radio
,
//
Col,
Col
,
//
Row,
Row
,
//
Modal,
Modal
,
//
Select,
Select
,
//
message,
message
,
//
notification,
notification
,
//
} from 'antd';
}
from
'
antd
'
;
//
import { ExclamationCircleOutlined } from '@ant-design/icons';
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
//
import moment from 'moment';
import
moment
from
'
moment
'
;
//
import { jsonToArray } from '@/utils/utils';
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
//
import { layout, mealType, boolOptions, hideOptions, mealSections } from '../staticData/index';
import
{
layout
,
mealType
,
boolOptions
,
hideOptions
,
mealSections
}
from
'
../staticData/index
'
;
//
import {
import
{
//
apiEnterpriseInfo,
apiEnterpriseInfo
,
//
apiNewEnterprise,
apiNewEnterprise
,
//
apiEditEnterprise,
apiEditEnterprise
,
//
apiEnterprisePickSelf,
apiEnterprisePickSelf
,
//
} from '../service';
}
from
'
../service
'
;
//
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
RadioGroup
=
Radio
.
Group
;
//
const { confirm } = Modal;
const
{
confirm
}
=
Modal
;
//
const CustomerInfo = props => {
const
CustomerInfo
=
props
=>
{
//
const [form] = Form.useForm();
const
[
form
]
=
Form
.
useForm
();
//
const [meals, setMeals] = useState({});
const
[
meals
,
setMeals
]
=
useState
({});
//
const [selectedMealTypes, setSelectedMealTypes] = useState([]);
const
[
selectedMealTypes
,
setSelectedMealTypes
]
=
useState
([]);
//
const [pickSelfList, setPickSelfList] = useState([]);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// // 1. 表单展示
/*
// const formItem = [
* 7. 表单关闭
// {
*/
// type: 'Form.Item',
const
closeModal
=
index
=>
{
// label: '企业名称',
if
(
props
.
onClose
&&
typeof
props
.
onClose
===
'
function
'
)
{
// name: 'name',
props
.
onClose
(
!!
index
);
// wrapperCol: { span: 20 },
}
// rules: [{ required: true, message: '请输入企业名称' }],
};
// component: <Input placeholder="请输入企业名称" />,
// },
// {
// type: 'Form.Item',
// disabled: !props.id,
// label: '企业取餐点',
// wrapperCol: { span: 20 },
// name: 'pickselfIds',
// rules: [{ required: true, message: '请选择企业取餐点' }],
// component: (
// <Select
// mode="multiple"
// showSearch
// filterOption={(v, option) =>
// (option?.label ?? '').toLowerCase().includes(v.toLowerCase())
// }
// />
// ),
// },
// {
// type: 'Form.Item',
// label: '企业截止时间',
// wrapperCol: { span: 20 },
// name: 'endOrderTime',
// rules: [{ required: true, message: '请输入企业截止时间' }],
// component: <InputNumber min={0} max={600} addonAfter="分钟" />,
// extra: <span>企业员工下单的截至时间,仅支持正整数,单位为分钟。</span>,
// },
// {
// type: 'Form.Item',
// label: '餐品类型',
// name: 'mealType',
// rules: [{ required: true, message: '请选择餐品类型' }],
// component: <CheckboxGroup options={jsonToArray(mealType)} onChange={onChangeMealType} />,
// wrapperCol: { span: 20 },
// },
// {
// type: 'Form.Item',
// label: '餐段配置',
// name: 'mealTimePeriod',
// rules: [{ required: true, message: '请选择餐段配置' }],
// component: <MealSection meals={meals} onChange={onChangeMealSection} />,
// },
// {
// // 区分是什么标签 Divider Form.Item
// type: 'Divider',
// component: '企业单笔消费限额',
// },
// {
// type: 'Form.List',
// component: '',
// },
// {
// type: 'Form.Item',
// label: '商品隐藏信息',
// name: 'hideInfo',
// rules: [{ required: true, message: '请选择商品隐藏信息' }],
// component: <CheckboxGroup options={hideOptions} />,
// },
// {
// type: 'Form.Item',
// label: '是否周预览',
// name: 'weekPreview',
// rules: [{ required: true, message: '请选择是否周预览' }],
// component: <RadioGroup options={boolOptions} />,
// },
// ];
// // 2. 预加载数据, 数据模型转换,用于表单回显
/*
* 6. 表单提交
*/
const
submitForm
=
async
params
=>
{
let
api
=
apiNewEnterprise
;
if
(
props
.
id
)
{
params
.
id
=
props
.
id
;
api
=
apiEditEnterprise
;
}
const
resp
=
await
api
(
params
);
if
(
resp
&&
resp
.
data
)
{
// 保存成功后刷新列表
closeModal
(
1
);
notification
.
success
({
message
:
'
保存成功!
'
});
}
};
// // 3. 表单交互逻辑
/*
* 5. 表单校验
*/
// 校验时间
const
checkTime
=
(
arr
,
curren
,
curName
)
=>
{
let
valid
=
false
;
arr
.
forEach
(
item
=>
{
if
(
curren
<
item
.
endTime
)
{
valid
=
true
;
const
name
=
meals
[
item
.
mealPeriodType
];
notification
.
error
({
message
:
`
${
curName
}
起始时间不能早于
${
name
}
截止时间`
});
}
});
return
valid
;
};
const
validateForm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
if
(
res
.
mealTimePeriod
.
length
<
1
)
{
message
.
warn
(
'
请选择餐段
'
);
return
;
}
const
params
=
{
hideImage
:
0
,
hidePrice
:
0
,
...
res
,
};
const
arr
=
[];
let
validTime
=
false
;
res
.
mealTimePeriod
.
forEach
(
item
=>
{
if
(
item
&&
meals
[
item
.
mealPeriodType
])
{
const
obj
=
Object
.
assign
({},
item
);
obj
.
beginTime
=
moment
(
obj
.
time
[
0
]).
format
(
'
HH:mm
'
);
obj
.
endTime
=
moment
(
obj
.
time
[
1
]).
format
(
'
HH:mm
'
);
delete
obj
.
time
;
if
(
checkTime
(
arr
,
obj
.
beginTime
,
meals
[
item
.
mealPeriodType
]))
{
validTime
=
true
;
}
arr
.
push
(
obj
);
}
});
if
(
validTime
)
{
// notification.error({ message: '时间段不能交叉!' });
return
;
}
params
.
mealTimePeriod
=
arr
;
if
(
res
.
hideInfo
&&
res
.
hideInfo
.
length
)
{
params
.
hidePrice
=
res
.
hideInfo
.
includes
(
'
hidePrice
'
)
?
1
:
0
;
params
.
hideImage
=
res
.
hideInfo
.
includes
(
'
hideImage
'
)
?
1
:
0
;
delete
params
.
hideInfo
;
}
const
limits
=
[];
if
(
!
res
.
mealLimit
)
{
notification
.
error
({
message
:
'
请输入限额!
'
});
return
;
}
// 处理限额
Object
.
keys
(
res
.
mealLimit
).
forEach
(
item
=>
{
const
mealPeriodType
=
item
.
replace
(
'
limit
'
,
''
);
if
(
meals
[
mealPeriodType
])
{
const
json
=
{
mealPeriodType
,
limit
:
[],
};
Object
.
keys
(
res
.
mealLimit
[
item
]).
forEach
(
t
=>
{
if
(
selectedMealTypes
.
includes
(
t
))
{
json
.
limit
.
push
({
mealType
:
t
,
limit
:
res
.
mealLimit
[
item
][
t
],
});
}
});
limits
.
push
(
json
);
}
});
if
(
limits
.
length
<
1
)
{
notification
.
error
({
message
:
'
请选择餐段配置!
'
});
return
;
}
params
.
mealLimit
=
limits
;
submitForm
(
params
);
};
// // 4. 表单校验
/*
// const validateForm = async () => {
* 4. 表单交互逻辑
// const res = await form.validateFields();
*/
// console.log(11, res);
// 风险提示
// // TODO 其他校验
const
checkConfirm
=
()
=>
{
// };
const
mt
=
''
;
return
new
Promise
((
resolve
,
reject
)
=>
{
confirm
({
title
:
'
风险提示
'
,
icon
:
<
ExclamationCircleOutlined
/>,
content
:
`确定关闭
${
mt
}
餐品类型?此餐品类型下关联的商户及商品将一并删除,不可逆请谨慎操作!`
,
onOk
()
{
resolve
(
1
);
},
onCancel
()
{
reject
(
new
Error
());
},
});
});
};
// 改变餐品类型 (选自助餐必选外卖)
const
onChangeMealType
=
async
ms
=>
{
console
.
log
(
'
mealTypes
'
,
selectedMealTypes
,
ms
);
try
{
// 编辑时,取消餐段,提示确认
console
.
log
(
'
props.info :>>
'
,
props
.
id
);
if
(
props
.
id
&&
ms
.
length
<
selectedMealTypes
.
length
)
{
await
checkConfirm
();
}
// 取消外卖,必须取消自助餐
if
(
selectedMealTypes
.
includes
(
'
1
'
)
&&
!
ms
.
includes
(
'
1
'
))
{
ms
=
ms
.
filter
(
item
=>
item
!==
'
2
'
);
}
// // 5. 数据模型转换, 表单到接口的转换, 可以用 lodash
// 选择自助餐,必须选择外卖
// const tranformFormData = data => {};
if
(
!
selectedMealTypes
.
includes
(
'
1
'
)
&&
ms
.
includes
(
'
2
'
))
{
ms
.
push
(
'
1
'
);
}
// // 6. 表单关闭
form
.
setFieldsValue
({
// const closeModal = index => {
mealType
:
ms
,
// if (props.onClose && typeof props.onClose === 'function') {
});
// props.onClose(!!index);
setSelectedMealTypes
(
ms
);
// }
}
catch
{
// };
form
.
setFieldsValue
({
mealType
:
selectedMealTypes
,
});
}
};
// 改变餐段
const
onChangeMealSection
=
e
=>
{
const
{
id
,
checked
,
label
}
=
e
.
target
;
const
values
=
Object
.
assign
({},
meals
);
if
(
checked
)
{
values
[
id
]
=
label
;
}
else
{
delete
values
[
id
];
}
setMeals
(
values
);
};
// // 7. 表单提交
/*
* 3.表单数据处理,
*/
const
processMealTimePeriod
=
mealTimePeriod
=>
{
const
mealTimePeriodMap
=
{};
const
mealTimePeriodArr
=
Object
.
keys
(
mealSections
).
map
(()
=>
({}));
// const sumbitForm = async () => {
mealTimePeriod
.
forEach
(
item
=>
{
// const valid = await validateForm();
const
{
mealPeriodType
,
beginTime
,
endTime
}
=
item
;
// if (!valid) {
// 数据模型转换-餐段配置,转为 {餐段:餐段名称}
// return false;
// 把mealTimePeriod按mealPeriodType转为map
// }
const
mealPeriodName
=
mealSections
[
mealPeriodType
];
// return false;
mealTimePeriodMap
[
mealPeriodType
]
=
mealPeriodName
;
// // const params = tranformFormData(res);
// // const resp = await apiNewEnterprise(params);
// // if (resp && resp.data) {
// // // 保存成功后刷新列表
// // closeModal(1);
// // notification.success({ message: '保存成功!' });
// // }
// };
// // 校验时间
// 数据模型转换-餐段和时间配置, [{餐段, time}, {}, {}]
// const checkTime = (arr, curren, curName) => {
const
index
=
Object
.
keys
(
mealSections
).
indexOf
(
`
${
mealPeriodType
}
`
);
// let valid = false;
if
(
index
>
-
1
)
{
// arr.forEach(item => {
mealTimePeriodArr
[
index
]
=
{
// if (curren < item.endTime) {
mealPeriodType
:
`
${
mealPeriodType
}
`
,
// valid = true;
time
:
[
// const name = meals[item.mealPeriodType];
moment
(
`
${
moment
().
format
(
'
YYYY-MM-DD
'
)}
${
beginTime
}
`
),
// notification.error({ message: `${curName}起始时间不能早于${name}截止时间` });
moment
(
`
${
moment
().
format
(
'
YYYY-MM-DD
'
)}
${
endTime
}
`
),
// }
],
// });
};
// return valid;
}
// };
});
return
{
mealTimePeriodMap
,
mealTimePeriodArr
};
};
// 数据模型转换-消费限额, 转为{餐段: {餐品类型: 限额}}
const
processMealLimit
=
mealLimit
=>
{
const
mealLimitMap
=
{};
// // 提交
mealLimit
.
forEach
(
item
=>
{
// const handleConfirm = async () => {
const
{
mealPeriodType
,
limit
}
=
item
;
// const res = await form.validateFields();
// console.log('res :>> ', res);
// // const res = await form.getFieldsValue();
// if (res.mealTimePeriod.length < 1) {
// message.warn('请选择餐段');
// return;
// }
// const params = Object.assign(
// {
// hideImage: 0,
// hidePrice: 0,
// },
// res,
// );
// const arr = [];
// let validTime = false;
// res.mealTimePeriod.forEach(item => {
// if (item && meals[item.mealPeriodType]) {
// const obj = Object.assign({}, item);
// obj.beginTime = moment(obj.time[0]).format('HH:mm');
// obj.endTime = moment(obj.time[1]).format('HH:mm');
// delete obj.time;
// if (checkTime(arr, obj.beginTime, meals[item.mealPeriodType])) {
// validTime = true;
// }
// arr.push(obj);
// }
// });
// if (validTime) {
// // notification.error({ message: '时间段不能交叉!' });
// return;
// }
// params.mealTimePeriod = arr;
// if (res.hideInfo && res.hideInfo.length) {
// params.hidePrice = res.hideInfo.includes('hidePrice') ? 1 : 0;
// params.hideImage = res.hideInfo.includes('hideImage') ? 1 : 0;
// delete params.hideInfo;
// }
// const limits = [];
// if (!res.mealLimit) {
// notification.error({ message: '请输入限额!' });
// return;
// }
// // 处理限额
// Object.keys(res.mealLimit).forEach(item => {
// const mealPeriodType = item.replace('limit', '');
// if (meals[mealPeriodType]) {
// const json = {
// mealPeriodType,
// limit: [],
// };
// Object.keys(res.mealLimit[item]).forEach(t => {
// if (selectedMealTypes.includes(t)) {
// json.limit.push({
// mealType: t,
// limit: res.mealLimit[item][t],
// });
// }
// });
// limits.push(json);
// }
// });
// if (limits.length < 1) {
// notification.error({ message: '请选择餐段配置!' });
// return;
// }
// params.mealLimit = limits;
// console.log('params :>> ', params);
// let api = apiNewEnterprise;
// if (props.id) {
// params.id = props.id;
// api = apiEditEnterprise;
// }
// const resp = await api(params);
// if (resp && resp.data) {
// // 保存成功后刷新列表
// closeModal(1);
// notification.success({ message: '保存成功!' });
// }
// };
// // 风险提示
mealLimitMap
[
`limit
${
mealPeriodType
}
`
]
=
limit
.
reduce
(
// const checkConfirm = () => {
(
acc
,
t
)
=>
({
// const mt = '';
...
acc
,
// return new Promise((resolve, reject) => {
[
t
.
mealType
]:
t
.
limit
,
// confirm({
}),
// title: '风险提示',
{},
// icon: <ExclamationCircleOutlined />,
);
// content: `确定关闭${mt}餐品类型?此餐品类型下关联的商户及商品将一并删除,不可逆请谨慎操作!`,
});
// onOk() {
console
.
log
(
'
mealLimitMap :>>
'
,
mealLimitMap
);
// resolve(1);
return
mealLimitMap
;
// },
};
// onCancel() {
// reject(new Error());
// },
// });
// });
// };
// // 改变餐品类型 (选自助餐必选外卖)
const
processData
=
data
=>
{
// const onChangeMealType = async ms => {
const
{
// console.log('mealTypes', selectedMealTypes, ms);
hideImage
,
// try {
hidePrice
,
// // 编辑时,取消餐段,提示确认
id
,
// console.log('props.info :>> ', props.id);
name
,
// if (props.id && ms.length < selectedMealTypes.length) {
mealLimit
,
// await checkConfirm();
mealTimePeriod
=
[],
// }
mealType
:
type
,
// // 取消外卖,必须取消自助餐
weekPreview
,
// if (selectedMealTypes.includes('1') && !ms.includes('1')) {
endOrderTime
,
// ms = ms.filter(item => item !== '2');
}
=
data
;
// }
// // 选择自助餐,必须选择外卖
const
formData
=
{
// if (!selectedMealTypes.includes('1') && ms.includes('2')) {
id
,
// ms.push('1');
name
,
// }
weekPreview
,
mealType
:
type
?.
map
(
item
=>
`
${
item
}
`
)
??
[],
hideInfo
:
[],
endOrderTime
,
};
// form.setFieldsValue({
if
(
+
hidePrice
)
{
// mealType: ms,
formData
.
hideInfo
.
push
(
'
hidePrice
'
);
// });
}
// setSelectedMealTypes(ms);
if
(
+
hideImage
)
{
// } catch {
formData
.
hideInfo
.
push
(
'
hideImage
'
);
// form.setFieldsValue({
}
// mealType: selectedMealTypes,
// });
// }
// };
// // 改变餐段
// const onChangeMealSection = e => {
// const { id, checked, label } = e.target;
// const values = Object.assign({}, meals);
// if (checked) {
// values[id] = label;
// } else {
// delete values[id];
// }
// setMeals(values);
// };
// // 获取企业客户信息
const
{
mealTimePeriodMap
,
mealTimePeriodArr
}
=
processMealTimePeriod
(
mealTimePeriod
);
// const getInfo = async () => {
const
mealLimitMap
=
processMealLimit
(
mealLimit
);
// const res = await apiEnterpriseInfo(props.id);
// if (res && res.data) {
// const {
// hideImage,
// hidePrice,
// id,
// name,
// mealLimit,
// mealTimePeriod = [],
// mealType: type,
// weekPreview,
// } = res.data;
// const formData = {
// id,
// name,
// weekPreview,
// mealType: type?.map(item => `${item}`) ?? [],
// hideInfo: [],
// };
// // 数据模型转换-隐藏信息
formData
.
mealTimePeriod
=
mealTimePeriodArr
;
// if (+hidePrice) {
formData
.
mealLimit
=
mealLimitMap
;
// formData.hideInfo.push('hidePrice');
formData
.
mealTimePeriodMap
=
mealTimePeriodMap
;
// }
// if (+hideImage) {
// formData.hideInfo.push('hideImage');
// }
// // 数据模型转换-餐段配置,转为 {餐段:餐段名称}
return
formData
;
// // 把mealTimePeriod按mealPeriodType转为map
};
// const mealTimePeriodMap = {};
// mealTimePeriod.forEach(item => {
// mealTimePeriodMap[item.mealPeriodType] = mealSections[item.mealPeriodType];
// });
// setMeals(mealTimePeriodMap);
// // 数据模型转换-餐段和时间配置, [{餐段, time}, {}, {}]
/*
// const mealTimePeriodArr = Object.keys(mealSections).map(() => ({}));
* 2. 表单数据获取
// formData.mealTimePeriod = mealTimePeriodArr;
*/
// mealTimePeriod.forEach(item => {
// 获取自提点列表
// if (!item) return;
const
getPickSelf
=
async
()
=>
{
// const index = Object.keys(mealSections).indexOf(`${item.mealPeriodType}`);
const
res
=
await
apiEnterprisePickSelf
({});
// if (index > -1) {
if
(
res
&&
res
.
data
&&
res
.
data
.
records
)
{
// formData.mealTimePeriod[index] = {
const
data
=
res
.
data
.
records
;
// mealPeriodType: `${item.mealPeriodType}`,
setPickSelfList
(
// time: [
data
.
map
(
item
=>
({
// moment(`${moment().format('YYYY-MM-DD')} ${item.beginTime}`),
value
:
item
.
id
,
// moment(`${moment().format('YYYY-MM-DD')} ${item.endTime}`),
label
:
item
.
pickselfName
,
// ],
})),
// };
);
// }
}
// });
};
// 获取表单信息
const
getInfo
=
async
()
=>
{
const
res
=
await
apiEnterpriseInfo
(
props
.
id
);
if
(
res
&&
res
.
data
)
{
const
formData
=
processData
(
res
.
data
);
setSelectedMealTypes
(
formData
.
mealType
);
setMeals
(
formData
.
mealTimePeriodMap
);
form
.
setFieldsValue
(
formData
);
}
};
// // 数据模型转换-消费限额, 转为{餐段: {餐品类型: 限额}}
useEffect
(()
=>
{
// const mealLimitMap = {};
if
(
props
.
visible
)
{
// mealLimit.forEach(item => {
if
(
props
.
id
)
{
// mealLimitMap[`limit${item.mealPeriodType}`] = {};
getInfo
();
// item.limit.forEach(t => {
}
else
{
// mealLimitMap[`limit${item.mealPeriodType}`][t.mealType] = t.limit;
setSelectedMealTypes
([]);
// });
setMeals
({});
// });
form
.
resetFields
();
// formData.mealLimit = mealLimitMap;
getPickSelf
();
}
}
else
{
setSelectedMealTypes
([]);
setMeals
({});
form
.
setFieldsValue
({});
}
},
[
props
.
visible
]);
// setSelectedMealTypes(formData.mealType);
/*
// form.setFieldsValue(formData);
* 1. 表单结构
// }
*/
// };
const
formItem
=
[
{
type
:
'
Form.Item
'
,
label
:
'
企业名称
'
,
name
:
'
name
'
,
wrapperCol
:
{
span
:
20
},
rules
:
[{
required
:
true
,
message
:
'
请输入企业名称
'
}],
component
:
<
Input
placeholder=
"请输入企业名称"
/>,
},
{
type
:
'
Form.Item
'
,
disabled
:
props
.
id
,
label
:
'
企业取餐点
'
,
wrapperCol
:
{
span
:
20
},
// todo pickselfIds
name
:
'
pickSelfIds
'
,
rules
:
[{
required
:
true
,
message
:
'
请选择企业取餐点
'
}],
component
:
(
<
Select
options=
{
pickSelfList
}
mode=
"multiple"
showSearch
filterOption=
{
(
v
,
option
)
=>
(
option
?.
label
??
''
).
toLowerCase
().
includes
(
v
.
toLowerCase
())
}
/>
),
},
{
type
:
'
Form.Item
'
,
label
:
'
企业截止时间
'
,
wrapperCol
:
{
span
:
20
},
name
:
'
endOrderTime
'
,
rules
:
[{
required
:
true
,
message
:
'
请输入企业截止时间
'
}],
component
:
<
InputNumber
min=
{
0
}
max=
{
600
}
addonAfter=
"分钟"
/>,
extra
:
<
span
>
企业员工下单的截至时间,仅支持正整数,单位为分钟。
</
span
>,
},
{
type
:
'
Form.Item
'
,
label
:
'
餐品类型
'
,
wrapperCol
:
{
span
:
20
},
name
:
'
mealType
'
,
rules
:
[{
required
:
true
,
message
:
'
请选择餐品类型
'
}],
component
:
<
CheckboxGroup
options=
{
jsonToArray
(
mealType
)
}
onChange=
{
onChangeMealType
}
/>,
},
{
type
:
'
Form.Item
'
,
label
:
'
餐段配置
'
,
wrapperCol
:
{
span
:
12
},
name
:
'
mealTimePeriod
'
,
rules
:
[{
required
:
true
,
message
:
'
请选择餐段配置
'
}],
component
:
<
MealSection
meals=
{
meals
}
onChange=
{
onChangeMealSection
}
/>,
},
{
name
:
'
Divider
'
,
type
:
'
Divider
'
,
component
:
'
企业单笔消费限额
'
,
},
{
name
:
'
Form.List
'
,
type
:
'
Form.List
'
,
component
:
''
,
},
{
type
:
'
Form.Item
'
,
label
:
'
商品隐藏信息
'
,
wrapperCol
:
{
span
:
20
},
name
:
'
hideInfo
'
,
rules
:
[{
required
:
true
,
message
:
'
请选择商品隐藏信息
'
}],
component
:
<
CheckboxGroup
options=
{
hideOptions
}
/>,
},
{
type
:
'
Form.Item
'
,
label
:
'
是否周预览
'
,
wrapperCol
:
{
span
:
20
},
name
:
'
weekPreview
'
,
rules
:
[{
required
:
true
,
message
:
'
请选择是否周预览
'
}],
component
:
<
RadioGroup
options=
{
boolOptions
}
/>,
},
];
// // 获取自提点列表
return
(
// const getPickSelf = async () => {
<
Modal
// const res = await apiEnterprisePickSelf({});
title=
"企业客户信息"
// if (res && res.data && res.data.records) {
open=
{
props
.
visible
}
// const data = res.data.records;
destroyOnClose
// setPickSelfList(
maskClosable=
{
false
}
// data.map(item => ({
width=
"900px"
// value: item.id,
onOk=
{
submitForm
}
// label: item.pickselfName,
onCancel=
{
()
=>
closeModal
(
0
)
}
// })),
>
// );
<
Form
// }
name=
"basicInfo"
// };
initialValues=
{
{
mealTimePeriod
:
[{},
{},
{}]
}
}
{
...
layout
}
// useEffect(() => {
form=
{
form
}
// if (props.visible) {
>
// if (props.id) {
{
formItem
.
map
((
item
,
index
)
=>
{
// getInfo();
if
(
item
.
type
===
'
Divider
'
&&
!
item
.
disabled
)
{
// } else {
return
(
// setSelectedMealTypes([]);
<
Divider
key=
{
item
.
name
}
orientation=
"left"
plain
>
// setMeals({});
{
item
.
component
}
// form.resetFields();
</
Divider
>
// getPickSelf();
);
// }
}
// } else {
if
(
item
.
type
===
'
Form.Item
'
&&
!
item
.
disabled
)
{
// setSelectedMealTypes([]);
return
(
// setMeals({});
<
Form
.
Item
// form.setFieldsValue({});
key=
{
item
.
name
}
// }
label=
{
item
.
label
??
''
}
// }, [props.visible]);
name=
{
item
.
name
}
rules=
{
item
.
rules
??
[]
}
// return (
wrapperCol=
{
item
.
wrapperCol
}
// <Modal
extra=
{
item
.
extra
??
''
}
// title="企业客户信息"
>
// open={props.visible}
{
item
.
component
}
// destroyOnClose
</
Form
.
Item
>
// maskClosable={false}
);
// width="900px"
}
// onOk={sumbitForm}
if
(
item
.
type
===
'
Form.List
'
&&
!
item
.
disabled
)
{
// onCancel={() => closeModal(0)}
return
(
// >
<
Form
.
List
name=
"mealLimit"
key=
{
item
.
name
}
>
// <Form
{
fields
=>
(
// name="basicInfo"
<>
// initialValues={{ mealTimePeriod: [{}, {}, {}] }}
{
Object
.
keys
(
meals
).
map
(
meal
=>
(
// {...layout}
<
Form
.
Item
// form={form}
key=
{
`${mealSections[meal]}`
}
// >
label=
{
`${mealSections[meal]}订单`
}
// {formItem.map((item, index) => {
required
// if (item.type === 'divider') {
wrapperCol=
{
{
span
:
20
}
}
// return (
>
// <Divider key={item} orientation="left">
<
Form
.
List
// {item.component}
name=
{
`limit${meal}`
}
// </Divider>
key=
{
`${meal}limit`
}
// );
required
// }
wrapperCol=
{
{
span
:
20
}
}
// if (item.type === 'Form.Item') {
>
// return (
{
fs
=>
(
// <Form.Item key={item} label={item.label} name={item.name} rules={item.rules}>
<
Row
key=
{
`row${meal}`
}
>
// {item.component}
{
selectedMealTypes
.
map
((
t
,
i
)
=>
(
// </Form.Item>
<
Col
span=
{
7
}
offset=
{
i
?
1
:
0
}
key=
{
t
}
>
// );
<
MealLimit
value=
{
t
}
label=
{
mealType
[
t
]
}
name=
{
`${t}`
}
/>
// }
</
Col
>
// if (item.type === 'Form.List') {
))
}
// return (
</
Row
>
// <Form.List name="mealLimit">
)
}
// {fields => (
</
Form
.
List
>
// <>
</
Form
.
Item
>
// {Object.keys(meals).map(meal => (
))
}
// <Form.Item
</>
// label={`${mealSections[meal]}订单`}
)
}
// required
</
Form
.
List
>
// wrapperCol={{ span: 20 }}
);
// >
}
// <Form.List
return
null
;
// name={`limit${meal}`}
})
}
// key={`${meal}limit`}
</
Form
>
// required
</
Modal
>
// wrapperCol={{ span: 20 }}
);
// >
};
// {fs => (
export
default
CustomerInfo
;
// <Row key={`row${meal}`}>
// {selectedMealTypes.map((t, i) => (
// <Col span={7} offset={i ? 1 : 0} key={t}>
// <MealLimit value={t} label={mealType[t]} name={`${t}`} />
// </Col>
// ))}
// </Row>
// )}
// </Form.List>
// </Form.Item>
// ))}
// </>
// )}
// </Form.List>
// );
// }
// return null;
// })}
// </Form>
// </Modal>
// );
// };
// export default CustomerInfo;
src/pages/businessCustomer/index.jsx
View file @
8558d4a8
...
@@ -4,6 +4,7 @@ import { Button } from 'antd';
...
@@ -4,6 +4,7 @@ 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/CustomerInfoCopy
'
;
import
CustomerInfo
from
'
./components/CustomerInfoCopy
'
;
// import CustomerInfo from './components/CustomerInfo';
import
utilStyle
from
'
@/utils/utils.less
'
;
import
utilStyle
from
'
@/utils/utils.less
'
;
import
{
stringOrObjectTrim
}
from
'
@/utils/utils
'
;
import
{
stringOrObjectTrim
}
from
'
@/utils/utils
'
;
import
{
apiEnterpriseList
}
from
'
./service
'
;
import
{
apiEnterpriseList
}
from
'
./service
'
;
...
@@ -63,7 +64,7 @@ const BusinessCustomer = () => {
...
@@ -63,7 +64,7 @@ const BusinessCustomer = () => {
</
Button
>,
</
Button
>,
]
}
]
}
/>
/>
<
CustomerInfo
visible=
{
visible
}
id=
{
id
}
onClose=
{
onClose
}
/>
{
visible
&&
<
CustomerInfo
visible=
{
visible
}
id=
{
id
}
onClose=
{
onClose
}
/>
}
</
div
>
</
div
>
);
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment