Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
陈智峰
jinfa-platform
Commits
ee8681db
Commit
ee8681db
authored
Jul 03, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加 是否可编辑有值元素 参数
parent
68434b27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
createRole.ts
src/pages/member/memberQuery/schema/createRole.ts
+2
-2
utils.tsx
src/pages/member/utils.tsx
+18
-10
No files found.
src/pages/member/memberQuery/schema/createRole.ts
View file @
ee8681db
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Author: XieZhiXiong
* @Date: 2021-06-04 15:51:19
* @Date: 2021-06-04 15:51:19
* @LastEditors: XieZhiXiong
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-0
6-04 15:51:20
* @LastEditTime: 2021-0
7-03 17:19:58
* @Description:
* @Description:
*/
*/
import
{
ISchema
}
from
'@formily/antd'
;
import
{
ISchema
}
from
'@formily/antd'
;
...
@@ -41,7 +41,7 @@ export const schema = (groups: GroupItem[]): ISchema => {
...
@@ -41,7 +41,7 @@ export const schema = (groups: GroupItem[]): ISchema => {
wrapperCol
:
8
,
wrapperCol
:
8
,
labelAlign
:
'left'
,
labelAlign
:
'left'
,
},
},
properties
:
createMemberSchema
(
item
.
elements
),
properties
:
createMemberSchema
(
item
.
elements
,
false
),
},
},
},
},
};
};
...
...
src/pages/member/utils.tsx
View file @
ee8681db
...
@@ -104,12 +104,15 @@ const RULE_REG_MAP = {
...
@@ -104,12 +104,15 @@ const RULE_REG_MAP = {
4
:
PATTERN_MAPS
.
tel
,
4
:
PATTERN_MAPS
.
tel
,
};
};
const
getFieldType
=
(
field
:
ElementType
)
=>
{
const
getFieldType
=
(
field
:
ElementType
,
editable
:
boolean
=
true
)
=>
{
const
isDisabled
=
(
!
editable
&&
field
.
fieldValue
)
||
!!
field
.
disabled
;
// 默认是 输入框
// 默认是 输入框
let
description
:
{
[
key
:
string
]:
any
}
=
{
let
description
:
{
[
key
:
string
]:
any
}
=
{
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
field
.
fieldRemark
,
placeholder
:
field
.
fieldRemark
,
disabled
:
!!
field
.
d
isabled
,
disabled
:
isD
isabled
,
},
},
};
};
// 公共的属性
// 公共的属性
...
@@ -144,7 +147,7 @@ const getFieldType = (field: ElementType) => {
...
@@ -144,7 +147,7 @@ const getFieldType = (field: ElementType) => {
'x-component'
:
'CustomUpload'
,
'x-component'
:
'CustomUpload'
,
'x-component-props'
:
{
'x-component-props'
:
{
showDesc
:
false
,
showDesc
:
false
,
disabled
:
!!
field
.
d
isabled
,
disabled
:
isD
isabled
,
},
},
};
};
break
;
break
;
...
@@ -154,7 +157,7 @@ const getFieldType = (field: ElementType) => {
...
@@ -154,7 +157,7 @@ const getFieldType = (field: ElementType) => {
'x-component'
:
'RadioGroup'
,
'x-component'
:
'RadioGroup'
,
enum
:
field
.
fieldEnum
,
enum
:
field
.
fieldEnum
,
'x-component-props'
:
{
'x-component-props'
:
{
disabled
:
!!
field
.
disabled
,
disabled
:
isDisabled
},
},
};
};
break
;
break
;
...
@@ -163,7 +166,7 @@ const getFieldType = (field: ElementType) => {
...
@@ -163,7 +166,7 @@ const getFieldType = (field: ElementType) => {
description
=
{
description
=
{
enum
:
field
.
fieldEnum
,
enum
:
field
.
fieldEnum
,
'x-component-props'
:
{
'x-component-props'
:
{
disabled
:
!!
field
.
d
isabled
,
disabled
:
isD
isabled
,
},
},
};
};
break
;
break
;
...
@@ -173,7 +176,7 @@ const getFieldType = (field: ElementType) => {
...
@@ -173,7 +176,7 @@ const getFieldType = (field: ElementType) => {
'x-component'
:
'CheckboxGroup'
,
'x-component'
:
'CheckboxGroup'
,
enum
:
field
.
fieldEnum
,
enum
:
field
.
fieldEnum
,
'x-component-props'
:
{
'x-component-props'
:
{
disabled
:
!!
field
.
d
isabled
,
disabled
:
isD
isabled
,
},
},
};
};
break
;
break
;
...
@@ -182,7 +185,7 @@ const getFieldType = (field: ElementType) => {
...
@@ -182,7 +185,7 @@ const getFieldType = (field: ElementType) => {
description
=
{
description
=
{
'x-component'
:
'AreaSelect'
,
'x-component'
:
'AreaSelect'
,
'x-component-props'
:
{
'x-component-props'
:
{
disabled
:
!!
field
.
d
isabled
,
disabled
:
isD
isabled
,
},
},
};
};
break
;
break
;
...
@@ -193,15 +196,20 @@ const getFieldType = (field: ElementType) => {
...
@@ -193,15 +196,20 @@ const getFieldType = (field: ElementType) => {
return
Object
.
assign
({},
description
,
common
);
return
Object
.
assign
({},
description
,
common
);
};
};
// 根据后台生成注册资料 schema
/**
export
function
createMemberSchema
(
elements
:
ElementType
[])
{
* 根据后台生成注册资料 schema
* @param elements
* @param editable 有值的元素是否可编辑
* @returns
*/
export
function
createMemberSchema
(
elements
:
ElementType
[],
editable
:
boolean
=
true
)
{
const
components
=
{};
const
components
=
{};
if
(
!
Array
.
isArray
(
elements
))
{
if
(
!
Array
.
isArray
(
elements
))
{
return
components
;
return
components
;
}
}
for
(
let
item
of
elements
)
{
for
(
let
item
of
elements
)
{
components
[
item
.
fieldName
as
string
]
=
getFieldType
(
item
);
components
[
item
.
fieldName
as
string
]
=
getFieldType
(
item
,
editable
);
}
}
return
components
;
return
components
;
};
};
...
...
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