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
c692257b
Commit
c692257b
authored
Apr 07, 2023
by
张子雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加校验规则
parent
8d2dd0b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
30 deletions
+48
-30
storeModal.jsx
src/pages/chainStoreManage/components/storeModal.jsx
+17
-12
index.jsx
src/pages/chainStoreManage/index.jsx
+16
-3
utils.js
src/utils/utils.js
+15
-15
No files found.
src/pages/chainStoreManage/components/storeModal.jsx
View file @
c692257b
...
...
@@ -232,6 +232,18 @@ const StoreModal = props => {
const
normFile
=
fileList
=>
fileList
;
const
timerWrapper
=
async
(
time
,
timeString
,
callback
)
=>
{
if
(
timeString
&&
timeString
.
length
)
{
const
begin
=
moment
(
timeString
[
0
]).
format
(
'
HH:mm
'
);
const
end
=
moment
(
timeString
[
1
]).
format
(
'
HH:mm
'
);
if
(
begin
===
end
)
{
callback
(
new
Error
(
'
选择开始时间结束时间不能一样
'
));
}
}
else
{
callback
();
}
};
useEffect
(()
=>
{
if
(
visible
)
{
resetFields
();
...
...
@@ -254,7 +266,6 @@ const StoreModal = props => {
if
(
info
.
townId
)
{
info
.
addr
.
push
(
info
.
townId
);
}
console
.
log
(
info
);
setTimes
(
harr
);
setFormData
(
info
);
getLazyAddr
(
info
);
...
...
@@ -331,18 +342,12 @@ const StoreModal = props => {
<
div
>
<
FormItem
name=
{
item
.
name
}
>
{
getFieldDecorator
(
item
.
name
,
{
rules
:
[{
required
:
true
,
message
:
'
请选择营业时间!
'
}],
rules
:
[
{
required
:
true
,
message
:
'
请选择营业时间!
'
},
{
validator
:
timerWrapper
,
message
:
'
选择开始时间结束时间不能一样
'
},
],
initialValue
:
formData
[
item
.
name
],
})(
<
TimePicker
.
RangePicker
format=
"HH:mm"
showTime=
{
{
hideDisabledOptions
:
true
,
defaultValue
:
[
moment
(
'
00:00
'
,
'
HH:mm
'
),
moment
(
'
23:59
'
,
'
HH:mm
'
)],
}
}
disabled=
{
disabled
}
/>,
)
}
})(<
TimePicker
.
RangePicker
format=
"HH:mm"
disabled=
{
disabled
}
/>)
}
</
FormItem
>
</
div
>
{
!
disabled
&&
...
...
src/pages/chainStoreManage/index.jsx
View file @
c692257b
...
...
@@ -37,7 +37,6 @@ export default () => {
// 获取业务模式
const
getBusiness
=
async
()
=>
{
const
res
=
await
apiproductBusiness
();
console
.
log
(
res
);
if
(
res
)
{
setProductBusiness
(
res
.
productBusiness
||
[]);
setExistTakewayShop
(
res
.
existTakewayShop
);
...
...
@@ -127,6 +126,9 @@ export default () => {
if
(
val
.
businessStatus
)
{
params
.
businessStatus
=
val
.
businessStatus
;
}
if
(
val
.
productBusiness
)
{
params
.
productBusiness
=
val
.
productBusiness
;
}
getList
(
params
);
};
...
...
@@ -220,8 +222,8 @@ export default () => {
dataIndex
:
'
productBusiness
'
,
width
:
120
,
align
:
'
center
'
,
render
:
v
=>
v
&&
(
render
:
(
v
,
value
)
=>
v
alue
?.
productBusiness
?.
length
&&
(
<
div
>
{
v
.
map
(
it
=>
(
<
span
>
{
businessList
.
find
(
item
=>
+
it
===
+
item
.
value
).
label
}
</
span
>
...
...
@@ -314,6 +316,17 @@ export default () => {
</
Select
>
</
Form
.
Item
>
</
Col
>
<
Col
span=
{
8
}
>
<
Form
.
Item
label=
"业务模式"
name=
"productBusiness"
>
<
Select
>
{
businessList
.
map
(
item
=>
(
<
Option
label=
{
item
.
label
}
value=
{
item
.
value
}
key=
{
item
.
value
}
>
{
item
.
label
}
</
Option
>
))
}
</
Select
>
</
Form
.
Item
>
</
Col
>
</
Row
>
<
div
className=
{
style
.
search
}
>
<
Button
type=
"primary"
htmlType=
"submit"
size=
"middle"
>
...
...
src/utils/utils.js
View file @
c692257b
...
...
@@ -133,20 +133,20 @@ export const getObjectType = v => Object.prototype.toString.call(v).replace(/\[o
export
const
getErrorMessage
=
err
=>
{
const
message
=
'
请检查表单数据!
'
;
// eslint-disable-next-line wrap-iife
//
(function getMsg(v) {
//
if (Array.isArray(v)) {
//
getMsg(v[0]);
//
} else {
//
const keys = Object.keys(v);
//
if (Array.isArray(v[keys[0]])) {
//
getMsg(v[keys[0]][0]);
//
} else if (v[keys[0]].errors && v[keys[0]].errors.length) {
//
// eslint-disable-next-line no-const-assign
//
message = v[keys[0]].errors[0].message;
//
} else {
//
getMsg(v);
//
}
//
}
//
})(err);
(
function
getMsg
(
v
)
{
if
(
Array
.
isArray
(
v
))
{
getMsg
(
v
[
0
]);
}
else
{
const
keys
=
Object
.
keys
(
v
);
if
(
Array
.
isArray
(
v
[
keys
[
0
]]))
{
getMsg
(
v
[
keys
[
0
]][
0
]);
}
else
if
(
v
[
keys
[
0
]].
errors
&&
v
[
keys
[
0
]].
errors
.
length
)
{
// eslint-disable-next-line no-const-assign
message
=
v
[
keys
[
0
]].
errors
[
0
].
message
;
}
else
{
getMsg
(
v
);
}
}
})(
err
);
return
message
;
};
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