Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
project
jinfa-admin
Commits
5d35a57e
Commit
5d35a57e
authored
Jul 30, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 添加校验是否元素真实有值
parent
c3690119
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
utils.tsx
src/pages/member/utils.tsx
+19
-1
No files found.
src/pages/member/utils.tsx
View file @
5d35a57e
...
...
@@ -144,6 +144,24 @@ export type GroupItem = {
export
type
FieldType
=
'string'
|
'long'
|
'upload'
|
'radio'
|
'select'
|
'checkbox'
|
'area'
|
string
&
{};
// 判断表单元素是否真的有值
const
fieldHasValue
=
(
fieldType
:
FieldType
,
value
:
any
):
boolean
=>
{
switch
(
fieldType
)
{
case
'string'
:
case
'long'
:
case
'radio'
:
case
'select'
:
return
!!
value
;
case
'upload'
:
case
'checkbox'
:
return
value
&&
value
.
length
>
0
;
case
'area'
:
return
value
&&
!!
value
.
provinceCode
;
default
:
return
true
;
}
};
// 字段校验规则枚举:0-无校验规则,1-邮箱规则,2-手机号码规则,3-身份证规则,4-电话号码规则
const
RULE_REG_MAP
=
{
1
:
PATTERN_MAPS
.
email
,
...
...
@@ -154,7 +172,7 @@ const RULE_REG_MAP = {
const
getFieldType
=
(
field
:
ElementType
,
editable
:
boolean
=
true
)
=>
{
const
isDisabled
=
(
!
editable
&&
field
.
fieldValue
)
||
!!
field
.
disabled
;
const
isDisabled
=
(
!
editable
&&
field
HasValue
(
field
.
fieldType
as
string
,
field
.
fieldValue
)
)
||
!!
field
.
disabled
;
// 默认是 输入框
let
description
:
{
[
key
:
string
]:
any
}
=
{
...
...
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