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
shenshaokai
jinfa-platform
Commits
312cac1d
Commit
312cac1d
authored
Aug 20, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
bb787a4a
eb1b0669
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
341 additions
and
10 deletions
+341
-10
CheckBoxSingle.tsx
src/components/NiceForm/components/CheckBoxSingle.tsx
+0
-0
CustomRadio.tsx
src/components/NiceForm/components/CustomRadio.tsx
+16
-0
CustomUpload.tsx
src/components/NiceForm/components/CustomUpload.tsx
+2
-0
Phone.tsx
src/components/NiceForm/components/Phone.tsx
+37
-0
index.tsx
src/components/NiceForm/index.tsx
+7
-2
index.tsx
src/components/UploadImage/index.tsx
+10
-5
index.ts
src/constants/index.ts
+2
-1
reset.less
src/global/styles/reset.less
+5
-0
LoginWrap.tsx
src/pages/user/components/LoginWrap.tsx
+1
-1
register.tsx
src/pages/user/register.tsx
+0
-0
index.ts
src/pages/user/schema/index.ts
+169
-0
index.ts~2a51756929cf7da4655efbc6177a581462b486b2
...ervices/index.ts~2a51756929cf7da4655efbc6177a581462b486b2
+0
-0
index.tsx
src/utils/index.tsx
+92
-1
No files found.
src/components/NiceForm/components/CheckBoxSingle.tsx
0 → 100644
View file @
312cac1d
src/components/NiceForm/components/CustomRadio.tsx
0 → 100644
View file @
312cac1d
import
React
from
'react'
;
import
{
Radio
,
Tooltip
}
from
'antd'
;
const
CustomCheckbox
=
props
=>
{
const
{
layout
}
=
props
return
(
<
Radio
.
Group
value=
{
props
.
value
}
onChange=
{
props
.
onChange
}
className=
{
layout
===
'column'
?
'identityRadio'
:
'businessRadio'
}
name=
{
props
.
name
}
>
{
props
.
dataSource
&&
props
.
dataSource
.
map
((
v
,
i
)
=>
<
Tooltip
title=
{
v
.
label
}
placement=
'leftTop'
key=
{
v
.
value
+
i
}
><
Radio
.
Button
value=
{
v
.
value
}
>
{
v
.
label
}
</
Radio
.
Button
></
Tooltip
>)
}
</
Radio
.
Group
>
)
}
export
default
CustomCheckbox
\ No newline at end of file
src/components/NiceForm/components/CustomUpload.tsx
View file @
312cac1d
...
...
@@ -3,12 +3,14 @@ import UploadImage from "@/components/UploadImage"
const
CustomUpload
=
(
props
)
=>
{
const
{
mutators
}
=
props
const
uploadProps
=
props
.
props
[
'x-component-props'
]
||
{}
return
<
UploadImage
imgUrl=
{
props
.
value
}
onChange=
{
data
=>
{
// 这里能拿到change后的data值
mutators
.
change
(
data
)
}
}
{
...
uploadProps
}
/>
}
...
...
src/components/NiceForm/components/Phone.tsx
0 → 100644
View file @
312cac1d
import
React
from
'react'
import
{
Row
,
Input
,
Col
,
Button
}
from
'antd'
;
import
useCountDown
from
'@/utils/hooks'
;
const
Phone
=
(
props
)
=>
{
const
{
text
,
isActive
,
start
}
=
useCountDown
({
maxTime
:
60
,
minTime
:
0
,
initText
:
'获取验证码'
,
onEnd
:
()
=>
{},
decayRate
:
1
,
delay
:
1
*
1000
})
const
{
value
}
=
props
return
(
<
Row
style=
{
{
width
:
'100%'
}
}
>
<
Col
flex=
{
1
}
>
<
Input
value=
{
value
||
''
}
onChange=
{
e
=>
props
.
mutators
.
change
(
e
.
target
.
value
)
}
{
...
props
.
props
['
x
-
component
-
props
']}
/>
</
Col
>
<
Col
style=
{
{
marginLeft
:
8
}
}
>
<
Button
disabled=
{
isActive
}
style=
{
{
minWidth
:
110
,
marginLeft
:
8
}
}
size=
'large'
onClick=
{
start
}
>
{
text
}
</
Button
>
</
Col
>
</
Row
>
)
}
Phone
.
defaultProps
=
{}
Phone
.
isFieldComponent
=
true
;
export
default
Phone
\ No newline at end of file
src/components/NiceForm/index.tsx
View file @
312cac1d
...
...
@@ -18,8 +18,10 @@ import CustomRegistryPhone from './components/CustomRegistryPhone';
import
CustomRelevance
from
'./components/CustomRelevance'
;
import
Children
from
'./components/Children'
;
import
CircleBox
from
'./components/CircleBox'
;
import
Phone
from
'./components/Phone'
;
import
CustomRadio
from
'./components/CustomRadio'
;
import
'./index.less'
import
{
Input
}
from
'@formily/antd-components'
;
import
{
Checkbox
}
from
'@formily/antd-components'
;
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{}
...
...
@@ -78,10 +80,12 @@ const schemaLayout = createControllerBox("schemaLayout", (_props) => {
const
NiceForm
:
React
.
FC
<
NiceFormProps
>
=
props
=>
{
const
{
children
,
components
,
...
reset
}
=
props
;
const
customComponents
=
{
CheckboxSingle
:
Checkbox
,
CustomUpload
,
CustomStatus
,
CustomAddArray
,
CustomSlider
,
CustomRadio
,
Search
,
CustomInputSearch
,
Submit
,
...
...
@@ -93,7 +97,8 @@ const NiceForm: React.FC<NiceFormProps> = props => {
Children
,
CircleBox
,
SchemaFormButtonGroup
,
FlexBox
FlexBox
,
Phone
,
};
const
defineComponents
=
Object
.
assign
(
customComponents
,
components
);
...
...
src/components/UploadImage/index.tsx
View file @
312cac1d
...
...
@@ -4,6 +4,7 @@ import { LoadingOutlined, PlusOutlined } from '@ant-design/icons'
import
{
UploadFile
,
UploadChangeParam
}
from
'antd/lib/upload/interface'
import
cx
from
'classnames'
import
styles
from
'./index.less'
import
{
UPLOAD_TYPE
}
from
'@/constants'
interface
UploadImagePorpsType
{
imgUrl
:
string
;
...
...
@@ -12,10 +13,11 @@ interface UploadImagePorpsType {
disabled
?:
boolean
;
large
?:
boolean
;
fileMaxSize
?:
number
;
showDesc
?:
boolean
}
const
UploadImage
:
React
.
FC
<
UploadImagePorpsType
>
=
forwardRef
((
props
,
ref
)
=>
{
const
{
imgUrl
,
onChange
,
size
=
"386x256"
,
disabled
=
false
,
large
=
false
,
fileMaxSize
=
200
}
=
props
const
{
imgUrl
,
onChange
,
s
howDesc
=
true
,
s
ize
=
"386x256"
,
disabled
=
false
,
large
=
false
,
fileMaxSize
=
200
}
=
props
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
)
const
beforeUpload
=
(
file
:
UploadFile
)
=>
{
const
isJpgOrPng
=
file
.
type
===
'image/jpeg'
||
file
.
type
===
'image/png'
||
file
.
type
===
'image/jpg'
;
...
...
@@ -34,7 +36,7 @@ const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
action
:
'/api/file/file/upload'
,
headers
:
{},
data
:
{
fileType
:
1
fileType
:
UPLOAD_TYPE
},
disabled
:
loading
||
disabled
,
showUploadList
:
false
,
...
...
@@ -72,9 +74,12 @@ const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
}
</
div
>
}
</
Upload
>
<
div
className=
{
styles
.
size_require
}
>
<
p
>
支持JPG/PNG/JPEG,
<
br
/>
最大不超过
{
fileMaxSize
}
K,
<
br
/>
尺寸:
{
size
}
</
p
>
</
div
>
{
showDesc
&&
<
div
className=
{
styles
.
size_require
}
>
<
p
>
支持JPG/PNG/JPEG,
<
br
/>
最大不超过
{
fileMaxSize
}
K,
<
br
/>
尺寸:
{
size
}
</
p
>
</
div
>
}
</
div
>
)
})
...
...
src/constants/index.ts
View file @
312cac1d
...
...
@@ -9,7 +9,8 @@ export const MALL_TYPE = {
}
// 本地环境跳过权限校验
export
const
isDev
=
process
.
env
.
NODE_ENV
===
"development"
// export const isDev = process.env.NODE_ENV === "development"
export
const
isDev
=
false
export
const
Environment_Status
=
{
0
:
"所有"
,
...
...
src/global/styles/reset.less
View file @
312cac1d
@import './mixins/layout.less';
#root {
// 去除input type为number时的箭头
.ant-input-number-handler-wrap {
display: none;
}
.common_checkbox {
&:hover,
...
...
src/pages/user/components/LoginWrap.tsx
View file @
312cac1d
...
...
@@ -85,7 +85,7 @@ const LoginWrap: React.FC = () => {
</
Form
.
Item
>)
}
<
Form
.
Item
>
<
Button
type=
'primary'
size=
'large'
htmlType=
'submit'
block
>
点击
登录
</
Button
>
<
Button
type=
'primary'
size=
'large'
htmlType=
'submit'
block
>
登录
</
Button
>
</
Form
.
Item
>
</
Form
>
}
...
...
src/pages/user/register.tsx
View file @
312cac1d
This diff is collapsed.
Click to expand it.
src/pages/user/schema/index.ts
0 → 100644
View file @
312cac1d
import
{
ISchema
}
from
'@formily/antd'
;
import
{
PATTERN_MAPS
}
from
'@/constants/regExp'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
export
const
registerStep0Schema
:
ISchema
=
{
type
:
'object'
,
properties
:
{
REGISTER_STEP
:
{
type
:
'object'
,
"x-component"
:
'mega-layout'
,
"x-component-props"
:
{
className
:
'registerForm'
,
full
:
true
},
properties
:
{
phone
:
{
type
:
'string'
,
required
:
true
,
"x-rules"
:
[
{
pattern
:
PATTERN_MAPS
.
phone
,
message
:
'请填写手机号'
}
],
"x-component-props"
:
{
placeholder
:
'请输入您的手机号码'
,
size
:
'large'
},
"x-props"
:
{
addonBefore
:
"{{phoneBefore}}"
}
},
smsCode
:
{
type
:
'string'
,
"x-component"
:
'Phone'
,
required
:
true
,
"x-rules"
:
[
{
pattern
:
PATTERN_MAPS
.
smsCode
,
message
:
'请输入正确的6位验证码'
}
],
"x-component-props"
:
{
size
:
'large'
,
}
},
password
:
{
type
:
'password'
,
required
:
true
,
"x-rules"
:
[
{
pattern
:
PATTERN_MAPS
.
password
,
message
:
'请输入正确的密码'
}
],
"x-component-props"
:
{
placeholder
:
'请设置你的登录密码'
,
size
:
'large'
,
}
},
confirmPassword
:
{
type
:
'password'
,
required
:
true
,
"x-rules"
:
[
{
pattern
:
PATTERN_MAPS
.
password
,
message
:
'请输入正确的密码'
}
],
"x-component-props"
:
{
placeholder
:
'请再次输入你的登录密码'
,
size
:
'large'
,
}
},
email
:
{
type
:
'string'
,
"x-rules"
:
[
{
pattern
:
PATTERN_MAPS
.
email
,
message
:
'请输入正确的邮箱'
}
],
"x-component-props"
:
{
placeholder
:
'请输入你的邮箱(选填)'
,
size
:
'large'
,
type
:
'email'
}
},
isRead
:
{
required
:
true
,
"x-component"
:
'CheckboxSingle'
,
"x-component-props"
:
{
children
:
"{{checkBoxChildren}}"
}
}
}
},
}
}
export
const
registerStep1Schema
:
ISchema
=
{
type
:
'object'
,
properties
:
{
REGISTER_STEP
:
{
type
:
'object'
,
"x-component"
:
'mega-layout'
,
"x-component-props"
:
{
className
:
'formBoxStep2'
},
properties
:
{
BLOCK_LAYOUT1
:
{
type
:
'object'
,
"x-component"
:
'block'
,
"x-component-props"
:
{
title
:
"{{memberTypeTitle}}"
,
className
:
'mr_t-40'
},
properties
:
{
typeId
:
{
type
:
'string'
,
required
:
true
,
"x-component"
:
'CustomRadio'
,
"x-component-props"
:
{
layout
:
'column'
},
enum
:
GlobalConfig
.
userRegister
.
useType
.
memberType
.
map
(
v
=>
{
return
{
value
:
v
.
id
,
label
:
v
.
typeName
}
})
},
}
},
BLOCK_LAYOUT2
:
{
type
:
'object'
,
"x-component"
:
'block'
,
"x-component-props"
:
{
title
:
"{{businessTypeTitle}}"
,
className
:
'mr_t-40'
},
properties
:
{
businessTypeId
:
{
type
:
'string'
,
required
:
true
,
"x-component"
:
'CustomRadio'
,
"x-component-props"
:
{
layout
:
'row'
},
enum
:
GlobalConfig
.
userRegister
.
useType
.
businessType
.
map
(
v
=>
{
return
{
value
:
v
.
id
,
label
:
v
.
typeName
}
})
},
}
}
},
}
}
}
export
default
{
schema0
:
registerStep0Schema
,
schema1
:
registerStep1Schema
}
\ No newline at end of file
src/services/index.ts~2a51756929cf7da4655efbc6177a581462b486b2
View file @
312cac1d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/utils/index.ts
→
src/utils/index.ts
x
View file @
312cac1d
import
{
ReactText
}
from
'react'
;
import
React
,
{
ReactText
}
from
'react'
;
import
moment
from
'moment'
;
import
deepClone
from
'clone'
import
{
ISchema
}
from
'@formily/antd'
;
import
{
UPLOAD_TYPE
}
from
'@/constants'
;
function
isArray
(
arr
:
any
)
{
return
Array
.
isArray
(
arr
)
...
...
@@ -239,6 +241,95 @@ export const findTreeKeys = (arr: any[], keyword?: ReactText) => {
return
results
}
// 转化object 成schema
export
const
transFormSchema
=
(
data
:
any
[]):
ISchema
=>
{
return
{
type
:
'object'
,
properties
:
{
'MEGA_LAYOUT2'
:
{
type
:
'object'
,
"x-component"
:
'mega-layout'
,
"x-component-props"
:
{
className
:
'formBoxStep2'
},
properties
:
{
detail
:
{
type
:
'object'
,
properties
:
data
.
reduce
((
prev
,
next
,
index
)
=>
{
prev
[
`NO_SUBMIT_BLOCK
${
index
}
`
]
=
{
type
:
'object'
,
"x-component"
:
'block'
,
"x-component-props"
:
{
className
:
'mr_t-40'
,
title
:
<
span
className=
{
'commonPanelTitle'
}
>
{
next
.
groupName
}
</
span
>
},
properties
:
{
[
`NO_SUBMIT_BLOCK_MEGA
${
index
}
`
]:
{
type
:
'object'
,
"x-component"
:
'mega-layout'
,
"x-component-props"
:
{
columns
:
2
,
grid
:
true
,
autoRow
:
true
,
size
:
'large'
,
className
:
'mr_t-24'
},
properties
:
next
.
elements
.
reduce
((
subP
,
subN
,
subI
)
=>
{
subP
[
subN
.
fieldName
]
=
getFieldType
(
subN
)
return
subP
},
{})
}
}
}
return
prev
},
{})
}
}
}
}
}
}
// 获取字段类型,改为schema可识别的
export
const
getFieldType
=
(
field
)
=>
{
if
(
field
.
fieldType
===
'upload'
)
{
return
{
type
:
'string'
,
"x-component"
:
"CustomUpload"
,
"x-mega-props"
:
{
span
:
2
},
required
:
field
.
fieldEmpty
===
0
,
title
:
field
.
fieldCNName
,
"x-component-props"
:
{
showDesc
:
false
}
}
}
else
{
return
{
type
:
'string'
,
"x-mega-props"
:
{
span
:
1
},
"x-component"
:
"CustomInput"
,
required
:
field
.
fieldEmpty
===
0
,
"x-rules"
:
field
.
checkRules
.
map
(
v
=>
{
return
{
message
:
v
.
msg
,
pattern
:
v
.
rulePattern
}
}),
maxLength
:
field
.
fieldLength
,
"x-component-props"
:
{
help
:
field
.
fieldRemark
,
placeholder
:
`请输入
${
field
.
fieldCNName
}
`
,
size
:
'large'
}
}
}
}
export
default
{
isArray
,
isObject
,
...
...
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