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
8cdb816f
Commit
8cdb816f
authored
Jun 20, 2024
by
guang.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 恢复master代码
parent
ed2a2896
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
665 deletions
+89
-665
CustomerInfo.jsx
src/pages/businessCustomer/components/CustomerInfo.jsx
+67
-127
CustomerInfoCopy.jsx
src/pages/businessCustomer/components/CustomerInfoCopy.jsx
+0
-498
MealLimit.jsx
src/pages/businessCustomer/components/MealLimit.jsx
+0
-3
MealSection.jsx
src/pages/businessCustomer/components/MealSection.jsx
+14
-27
index.jsx
src/pages/businessCustomer/index.jsx
+8
-10
No files found.
src/pages/businessCustomer/components/CustomerInfo.jsx
View file @
8cdb816f
...
@@ -15,8 +15,8 @@ import {
...
@@ -15,8 +15,8 @@ import {
notification
,
notification
,
}
from
'
antd
'
;
}
from
'
antd
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
{
ExclamationCircleOutlined
}
from
'
@ant-design/icons
'
;
import
moment
from
'
moment
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
{
jsonToArray
}
from
'
@/utils/utils
'
;
import
moment
from
'
moment
'
;
import
{
layout
,
mealType
,
boolOptions
,
hideOptions
,
mealSections
}
from
'
../staticData/index
'
;
import
{
layout
,
mealType
,
boolOptions
,
hideOptions
,
mealSections
}
from
'
../staticData/index
'
;
import
{
import
{
apiEnterpriseInfo
,
apiEnterpriseInfo
,
...
@@ -33,54 +33,13 @@ const { confirm } = Modal;
...
@@ -33,54 +33,13 @@ 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
,
setSelected
MealTypes
]
=
useState
([]);
const
[
mealTypes
,
set
MealTypes
]
=
useState
([]);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
const
[
pickSelfList
,
setPickSelfList
]
=
useState
([]);
// 1. 表单展示
// 关闭分组信息弹窗
// const formItem = [
const
handleCancel
=
()
=>
{
// {
props
.
reFresh
();
// label: '企业名称',
props
.
handleClose
(
false
);
// name: 'enterpriseName',
// rules: [{ required: true, message: '请输入企业名称' }],
// component: <Input placeholder="请输入企业名称" />,
// },
// 2. 预加载数据, 数据模型转换,用于表单回显
// 3. 表单交互逻辑
// 4. 表单校验
const
validateForm
=
async
()
=>
{
const
res
=
await
form
.
validateFields
();
console
.
log
(
11
,
res
);
// TODO 其他校验
};
// 5. 数据模型转换, 表单到接口的转换, 可以用 lodash
const
tranformFormData
=
data
=>
{};
// 6. 表单关闭
const
closeModal
=
index
=>
{
if
(
props
.
onClose
&&
typeof
props
.
onClose
===
'
function
'
)
{
props
.
onClose
(
!!
index
);
}
};
// 7. 表单提交
const
sumbitForm
=
async
()
=>
{
const
valid
=
await
validateForm
();
if
(
!
valid
)
{
return
false
;
}
return
false
;
// const params = tranformFormData(res);
// const resp = await apiNewEnterprise(params);
// if (resp && resp.data) {
// // 保存成功后刷新列表
// closeModal(1);
// notification.success({ message: '保存成功!' });
// }
};
};
// 校验时间
// 校验时间
...
@@ -150,7 +109,7 @@ const CustomerInfo = props => {
...
@@ -150,7 +109,7 @@ const CustomerInfo = props => {
limit
:
[],
limit
:
[],
};
};
Object
.
keys
(
res
.
mealLimit
[
item
]).
forEach
(
t
=>
{
Object
.
keys
(
res
.
mealLimit
[
item
]).
forEach
(
t
=>
{
if
(
selectedM
ealTypes
.
includes
(
t
))
{
if
(
m
ealTypes
.
includes
(
t
))
{
json
.
limit
.
push
({
json
.
limit
.
push
({
mealType
:
t
,
mealType
:
t
,
limit
:
res
.
mealLimit
[
item
][
t
],
limit
:
res
.
mealLimit
[
item
][
t
],
...
@@ -173,8 +132,8 @@ const CustomerInfo = props => {
...
@@ -173,8 +132,8 @@ const CustomerInfo = props => {
}
}
const
resp
=
await
api
(
params
);
const
resp
=
await
api
(
params
);
if
(
resp
&&
resp
.
data
)
{
if
(
resp
&&
resp
.
data
)
{
// 保存成功后刷新列表
handleCancel
();
closeModal
(
1
);
props
.
reFresh
(
);
notification
.
success
({
message
:
'
保存成功!
'
});
notification
.
success
({
message
:
'
保存成功!
'
});
}
}
};
};
...
@@ -199,30 +158,26 @@ const CustomerInfo = props => {
...
@@ -199,30 +158,26 @@ const CustomerInfo = props => {
// 改变餐品类型 (选自助餐必选外卖)
// 改变餐品类型 (选自助餐必选外卖)
const
onChangeMealType
=
async
ms
=>
{
const
onChangeMealType
=
async
ms
=>
{
console
.
log
(
'
mealTypes
'
,
selectedMealTypes
,
ms
);
try
{
try
{
// 编辑时,取消餐段,提示确认
if
(
props
.
id
&&
ms
.
length
<
mealTypes
.
length
)
{
console
.
log
(
'
props.info :>>
'
,
props
.
id
);
if
(
props
.
id
&&
ms
.
length
<
selectedMealTypes
.
length
)
{
await
checkConfirm
();
await
checkConfirm
();
}
}
// 取消外卖,必须取消自助餐
// 取消外卖,必须取消自助餐
if
(
selectedM
ealTypes
.
includes
(
'
1
'
)
&&
!
ms
.
includes
(
'
1
'
))
{
if
(
m
ealTypes
.
includes
(
'
1
'
)
&&
!
ms
.
includes
(
'
1
'
))
{
ms
=
ms
.
filter
(
item
=>
item
!==
'
2
'
);
ms
=
ms
.
filter
(
item
=>
item
!==
'
2
'
);
}
}
// 选择自助餐,必须选择外卖
// 选择自助餐,必须选择外卖
if
(
!
selectedM
ealTypes
.
includes
(
'
1
'
)
&&
ms
.
includes
(
'
2
'
))
{
if
(
!
m
ealTypes
.
includes
(
'
1
'
)
&&
ms
.
includes
(
'
2
'
))
{
ms
.
push
(
'
1
'
);
ms
.
push
(
'
1
'
);
}
}
form
.
setFieldsValue
({
form
.
setFieldsValue
({
mealType
:
ms
,
mealType
:
ms
,
});
});
set
Selected
MealTypes
(
ms
);
setMealTypes
(
ms
);
}
catch
{
}
catch
{
form
.
setFieldsValue
({
form
.
setFieldsValue
({
mealType
:
selectedM
ealTypes
,
mealType
:
m
ealTypes
,
});
});
}
}
};
};
...
@@ -242,70 +197,55 @@ const CustomerInfo = props => {
...
@@ -242,70 +197,55 @@ const CustomerInfo = props => {
const
getInfo
=
async
()
=>
{
const
getInfo
=
async
()
=>
{
const
res
=
await
apiEnterpriseInfo
(
props
.
id
);
const
res
=
await
apiEnterpriseInfo
(
props
.
id
);
if
(
res
&&
res
.
data
)
{
if
(
res
&&
res
.
data
)
{
const
{
const
obj
=
Object
.
assign
({},
res
.
data
);
hideImage
,
if
(
res
.
data
.
mealTimePeriod
&&
res
.
data
.
mealTimePeriod
.
length
)
{
hidePrice
,
const
m
=
moment
().
format
(
'
YYYY-MM-DD
'
);
id
,
const
arr
=
Object
.
keys
(
mealSections
);
name
,
obj
.
mealTimePeriod
=
Object
.
keys
(
mealSections
).
map
(()
=>
({}));
mealLimit
,
res
.
data
.
mealTimePeriod
.
forEach
((
item
,
i
)
=>
{
mealTimePeriod
=
[],
if
(
item
)
{
mealType
:
type
,
const
index
=
arr
.
indexOf
(
`
${
item
.
mealPeriodType
}
`
);
weekPreview
,
if
(
index
>
-
1
)
{
}
=
res
.
data
;
obj
.
mealTimePeriod
[
index
]
=
{
const
formData
=
{
mealPeriodType
:
`
${
item
.
mealPeriodType
}
`
,
id
,
time
:
[
moment
(
`
${
m
}
${
item
.
beginTime
}
`
),
moment
(
`
${
m
}
${
item
.
endTime
}
`
)],
name
,
weekPreview
,
mealType
:
type
?.
map
(
item
=>
`
${
item
}
`
)
??
[],
hideInfo
:
[],
};
};
// 数据模型转换-隐藏信息
if
(
+
hidePrice
)
{
formData
.
hideInfo
.
push
(
'
hidePrice
'
);
}
}
if
(
+
hideImage
)
{
formData
.
hideInfo
.
push
(
'
hideImage
'
);
}
}
// 数据模型转换-餐段配置,转为 {餐段:餐段名称}
// 把mealTimePeriod按mealPeriodType转为map
const
mealTimePeriodMap
=
{};
mealTimePeriod
.
forEach
(
item
=>
{
mealTimePeriodMap
[
item
.
mealPeriodType
]
=
mealSections
[
item
.
mealPeriodType
];
});
});
setMeals
(
mealTimePeriodMap
);
}
else
{
obj
.
mealTimePeriod
=
[];
// 数据模型转换-餐段和时间配置, [{餐段, time}, {}, {}]
const
mealTimePeriodArr
=
Object
.
keys
(
mealSections
).
map
(()
=>
({}));
formData
.
mealTimePeriod
=
mealTimePeriodArr
;
mealTimePeriod
.
forEach
(
item
=>
{
if
(
!
item
)
return
;
const
index
=
Object
.
keys
(
mealSections
).
indexOf
(
`
${
item
.
mealPeriodType
}
`
);
if
(
index
>
-
1
)
{
formData
.
mealTimePeriod
[
index
]
=
{
mealPeriodType
:
`
${
item
.
mealPeriodType
}
`
,
time
:
[
moment
(
`
${
moment
().
format
(
'
YYYY-MM-DD
'
)}
${
item
.
beginTime
}
`
),
moment
(
`
${
moment
().
format
(
'
YYYY-MM-DD
'
)}
${
item
.
endTime
}
`
),
],
};
}
}
obj
.
mealLimit
=
{};
if
(
res
.
data
.
mealLimit
&&
res
.
data
.
mealLimit
.
length
)
{
res
.
data
.
mealLimit
.
forEach
(
item
=>
{
obj
.
mealLimit
[
`limit
${
item
.
mealPeriodType
}
`
]
=
{};
item
.
limit
.
forEach
(
limit
=>
{
obj
.
mealLimit
[
`limit
${
item
.
mealPeriodType
}
`
][
limit
.
mealType
]
=
limit
.
limit
;
});
});
// 数据模型转换-消费限额, 转为{餐段: {餐品类型: 限额}}
const
mealLimitMap
=
{};
mealLimit
.
forEach
(
item
=>
{
mealLimitMap
[
`limit
${
item
.
mealPeriodType
}
`
]
=
{};
item
.
limit
.
forEach
(
t
=>
{
mealLimitMap
[
`limit
${
item
.
mealPeriodType
}
`
][
t
.
mealType
]
=
t
.
limit
;
});
});
}
obj
.
hideInfo
=
[];
if
(
+
res
.
data
.
hidePrice
)
{
obj
.
hideInfo
.
push
(
'
hidePrice
'
);
}
if
(
+
res
.
data
.
hideImage
)
{
obj
.
hideInfo
.
push
(
'
hideImage
'
);
}
if
(
res
.
data
.
mealType
)
{
obj
.
mealType
=
res
.
data
.
mealType
.
map
(
item
=>
`
${
item
}
`
);
}
else
{
obj
.
mealType
=
[];
}
setMealTypes
(
obj
.
mealType
);
const
json
=
{};
if
(
res
.
data
.
mealTimePeriod
)
{
res
.
data
.
mealTimePeriod
.
forEach
(
item
=>
{
json
[
item
.
mealPeriodType
]
=
mealSections
[
item
.
mealPeriodType
];
});
});
formData
.
mealLimit
=
mealLimitMap
;
}
setMeals
(
json
);
setSelectedMealTypes
(
formData
.
mealType
);
form
.
setFieldsValue
(
obj
);
console
.
log
(
'
formData :>>
'
,
formData
);
form
.
setFieldsValue
(
formData
);
}
}
};
};
...
@@ -328,13 +268,13 @@ const CustomerInfo = props => {
...
@@ -328,13 +268,13 @@ const CustomerInfo = props => {
if
(
props
.
id
)
{
if
(
props
.
id
)
{
getInfo
();
getInfo
();
}
else
{
}
else
{
set
Selected
MealTypes
([]);
setMealTypes
([]);
setMeals
({});
setMeals
({});
form
.
resetFields
();
form
.
resetFields
();
getPickSelf
();
getPickSelf
();
}
}
}
else
{
}
else
{
set
Selected
MealTypes
([]);
setMealTypes
([]);
setMeals
({});
setMeals
({});
form
.
setFieldsValue
({});
form
.
setFieldsValue
({});
}
}
...
@@ -347,8 +287,8 @@ const CustomerInfo = props => {
...
@@ -347,8 +287,8 @@ const CustomerInfo = props => {
destroyOnClose
destroyOnClose
maskClosable=
{
false
}
maskClosable=
{
false
}
width=
"900px"
width=
"900px"
onOk=
{
sumbitFo
rm
}
onOk=
{
handleConfi
rm
}
onCancel=
{
()
=>
closeModal
(
0
)
}
onCancel=
{
handleCancel
}
>
>
<
Form
<
Form
name=
"basicInfo"
name=
"basicInfo"
...
@@ -380,10 +320,10 @@ const CustomerInfo = props => {
...
@@ -380,10 +320,10 @@ const CustomerInfo = props => {
</
Form
.
Item
>
</
Form
.
Item
>
)
}
)
}
<
Form
.
Item
<
Form
.
Item
label=
"企业截
止
时间"
label=
"企业截
单
时间"
name=
"endOrderTime"
name=
"endOrderTime"
wrapperCol=
{
{
span
:
20
}
}
wrapperCol=
{
{
span
:
20
}
}
rules=
{
[{
required
:
true
,
message
:
'
请输入企业截
止
时间!
'
}]
}
rules=
{
[{
required
:
true
,
message
:
'
请输入企业截
单
时间!
'
}]
}
extra=
{
<
span
>
企业员工下单的截至时间,仅支持正整数,单位为分钟。
</
span
>
}
extra=
{
<
span
>
企业员工下单的截至时间,仅支持正整数,单位为分钟。
</
span
>
}
>
>
<
InputNumber
min=
{
0
}
max=
{
600
}
addonAfter=
"分钟"
/>
<
InputNumber
min=
{
0
}
max=
{
600
}
addonAfter=
"分钟"
/>
...
@@ -414,7 +354,7 @@ const CustomerInfo = props => {
...
@@ -414,7 +354,7 @@ const CustomerInfo = props => {
>
>
{
fs
=>
(
{
fs
=>
(
<
Row
key=
{
`row${meal}`
}
>
<
Row
key=
{
`row${meal}`
}
>
{
selectedM
ealTypes
.
map
((
t
,
i
)
=>
(
{
m
ealTypes
.
map
((
t
,
i
)
=>
(
<
Col
span=
{
7
}
offset=
{
i
?
1
:
0
}
key=
{
t
}
>
<
Col
span=
{
7
}
offset=
{
i
?
1
:
0
}
key=
{
t
}
>
<
MealLimit
value=
{
t
}
label=
{
mealType
[
t
]
}
name=
{
`${t}`
}
/>
<
MealLimit
value=
{
t
}
label=
{
mealType
[
t
]
}
name=
{
`${t}`
}
/>
</
Col
>
</
Col
>
...
...
src/pages/businessCustomer/components/CustomerInfoCopy.jsx
deleted
100644 → 0
View file @
ed2a2896
This diff is collapsed.
Click to expand it.
src/pages/businessCustomer/components/MealLimit.jsx
View file @
8cdb816f
...
@@ -7,9 +7,6 @@ const MealLimit = props => (
...
@@ -7,9 +7,6 @@ const MealLimit = props => (
<
Form
.
Item
<
Form
.
Item
label=
{
`${props.label}限额`
}
label=
{
`${props.label}限额`
}
name=
{
props
.
name
}
name=
{
props
.
name
}
value=
{
props
.
value
}
labelCol=
{
{
span
:
10
}
}
wrapperCol=
{
{
span
:
14
}
}
rules=
{
[
rules=
{
[
{
validator
:
validateRequired
,
message
:
`请输入${props.label}限额`
},
{
validator
:
validateRequired
,
message
:
`请输入${props.label}限额`
},
{
validator
:
isCheckPriceTwoDecimal
,
message
:
'
请输入正确的价格
'
},
{
validator
:
isCheckPriceTwoDecimal
,
message
:
'
请输入正确的价格
'
},
...
...
src/pages/businessCustomer/components/MealSection.jsx
View file @
8cdb816f
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Form
,
Row
,
Col
,
TimePicker
,
Space
}
from
'
antd
'
;
import
{
Form
,
Space
,
TimePicker
}
from
'
antd
'
;
import
{
mealSections
}
from
'
../staticData/index
'
;
import
{
mealSections
}
from
'
../staticData/index
'
;
import
MealCheckbox
from
'
./MealCheckbox
'
;
import
MealCheckbox
from
'
./MealCheckbox
'
;
...
@@ -8,32 +8,19 @@ const MealSection = props => (
...
@@ -8,32 +8,19 @@ const MealSection = props => (
{
fields
=>
(
{
fields
=>
(
<>
<>
{
Object
.
keys
(
mealSections
).
map
((
field
,
i
)
=>
(
{
Object
.
keys
(
mealSections
).
map
((
field
,
i
)
=>
(
<
Row
key=
{
field
}
align=
"baseline"
>
<
Space
key=
{
field
}
align=
"baseline"
>
<
Col
span=
{
4
}
>
<
Form
.
Item
label=
""
name=
{
[
i
,
'
mealPeriodType
'
]
}
>
<
Form
.
Item
label=
""
name=
{
[
i
,
'
mealPeriodType
'
]
}
>
<
MealCheckbox
<
MealCheckbox
changeType=
{
props
.
onChange
}
meals=
{
props
.
meals
}
field=
{
field
}
/>
changeType=
{
e
=>
props
.
onChangeSection
(
e
,
props
)
}
meals=
{
props
.
meals
}
field=
{
field
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
</
Col
>
<
Col
span=
{
18
}
>
<
Form
.
Item
<
Form
.
Item
name=
{
[
i
,
'
time
'
]
}
name=
{
[
i
,
'
time
'
]
}
rules=
{
rules=
{
props
.
meals
[
field
]
props
.
meals
[
field
]
?
[{
type
:
'
array
'
,
required
:
true
,
message
:
'
请选择!
'
}]
:
[]
?
[
{
type
:
'
array
'
,
required
:
true
,
message
:
'
请选择!
'
},
{
validator
:
props
.
validateMeals
,
message
:
'
时间段不能交叉!
'
},
]
:
[]
}
}
>
>
<
TimePicker
.
RangePicker
format=
"HH:mm"
minuteStep=
{
30
}
/>
<
TimePicker
.
RangePicker
format=
"HH:mm"
minuteStep=
{
30
}
/>
</
Form
.
Item
>
</
Form
.
Item
>
</
Col
>
</
Space
>
</
Row
>
))
}
))
}
</>
</>
)
}
)
}
...
...
src/pages/businessCustomer/index.jsx
View file @
8cdb816f
...
@@ -3,9 +3,7 @@ import ProTable from '@ant-design/pro-table';
...
@@ -3,9 +3,7 @@ import ProTable from '@ant-design/pro-table';
import
{
Button
}
from
'
antd
'
;
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/CustomerInfo
'
;
// import CustomerInfo from './components/CustomerInfo';
import
CustomerInfo
from
'
@/example/proForm/ModalForm/index
'
;
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
'
;
...
@@ -31,12 +29,6 @@ const BusinessCustomer = () => {
...
@@ -31,12 +29,6 @@ const BusinessCustomer = () => {
setVisible
(
true
);
setVisible
(
true
);
};
};
const
onClose
=
refresh
=>
{
console
.
log
(
3
);
setVisible
(
false
);
refresh
&&
refTable
.
current
.
reload
();
};
return
(
return
(
<
div
className=
{
utilStyle
.
formPageBox
}
>
<
div
className=
{
utilStyle
.
formPageBox
}
>
<
ProTable
<
ProTable
...
@@ -48,6 +40,7 @@ const BusinessCustomer = () => {
...
@@ -48,6 +40,7 @@ const BusinessCustomer = () => {
columns=
{
customerColumn
({
onEdit
})
}
columns=
{
customerColumn
({
onEdit
})
}
request=
{
params
=>
query
({
...
params
})
}
request=
{
params
=>
query
({
...
params
})
}
rowKey=
{
r
=>
r
.
id
}
rowKey=
{
r
=>
r
.
id
}
expandIconColumnIndex=
{
10
}
bordered
bordered
options=
{
false
}
options=
{
false
}
toolBarRender=
{
()
=>
[
toolBarRender=
{
()
=>
[
...
@@ -64,7 +57,12 @@ const BusinessCustomer = () => {
...
@@ -64,7 +57,12 @@ const BusinessCustomer = () => {
</
Button
>,
</
Button
>,
]
}
]
}
/>
/>
{
visible
&&
<
CustomerInfo
visible=
{
visible
}
id=
{
id
}
onClose=
{
onClose
}
/>
}
<
CustomerInfo
visible=
{
visible
}
id=
{
id
}
reFresh=
{
()
=>
refTable
.
current
.
reload
()
}
handleClose=
{
setVisible
}
/>
</
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