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
afd9d15d
Commit
afd9d15d
authored
Aug 28, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抽离公共虚拟布局组件
parent
df636ee2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
57 deletions
+63
-57
app.tsx
src/app.tsx
+5
-3
index.tsx
src/components/NiceForm/index.tsx
+0
-54
index.tsx
src/components/NiceForm/public/index.tsx
+58
-0
No files found.
src/app.tsx
View file @
afd9d15d
...
...
@@ -12,6 +12,8 @@ import { isDev } from '@/constants'
import
{
setup
}
from
'@formily/antd-components'
;
import
{
getRouters
,
getAuth
,
asyncRouter
,
setAuth
,
setRouters
,
removeAuth
,
removeRouters
}
from
'./utils/auth'
;
import
{
PublicApi
}
from
'./services/api'
;
// 全局注册虚拟组件
import
'@/components/NiceForm/public'
setup
()
...
...
@@ -107,10 +109,10 @@ export function render(oldRender: Function) {
export
function
onRouteChange
({
routes
,
matchedRoutes
,
location
,
action
})
{
console
.
log
(
'onRouteChange'
)
//
if (isDev) {
if
(
isDev
)
{
//
return;
//
}
return
;
}
// 是否登录
if
(
getAuth
())
{
...
...
src/components/NiceForm/index.tsx
View file @
afd9d15d
...
...
@@ -4,7 +4,6 @@ import SchemaForm, {
}
from
'@formily/antd'
;
import
{
Input
}
from
'@formily/antd-components'
;
import
{
Button
,
Space
,
Row
,
Col
}
from
'antd'
;
import
styled
from
'styled-components'
import
CustomUpload
from
'./components/CustomUpload'
;
import
CustomStatus
from
'./components/CustomStatus'
;
import
CustomAddArray
from
'./components/CustomAddArray'
;
...
...
@@ -25,62 +24,9 @@ import SearchSelect from './components/SearchSelect';
import
TableTagList
from
'./components/TableTagList'
;
import
'./index.less'
import
{
Checkbox
}
from
'@formily/antd-components'
;
import
cx
from
'classnames'
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{}
const
RowLayout
=
styled
(
props
=>
<
Row
justify=
'end'
{
...
props
}
/>)
`
.mega-layout-item {
margin-bottom: 20px !important;
}
.mega-layout-container {
margin-bottom: 0;
}
`
const
renderCol
=
(
schema
,
isLast
)
=>
{
const
{
flexcol
=
{}
}
=
schema
[
'x-component-props'
]
return
<
Col
style=
{
isLast
?
{}
:
{
marginRight
:
24
}
}
{
...
flexcol
}
key=
{
schema
.
path
}
>
<
SchemaField
schema=
{
schema
.
toJSON
()
}
path=
{
schema
.
path
}
/>
</
Col
>
}
// 自定义flex布局容器
registerVirtualBox
(
'flex-box'
,
props
=>
{
const
childProperties
=
props
.
schema
.
getOrderProperties
()
const
{
title
,
required
}
=
props
.
props
const
{
labelcol
,
wrappercol
}
=
props
.
schema
.
getExtendsComponentProps
()
return
<
Row
>
{
title
&&
<
Col
span=
{
labelcol
}
className=
{
cx
(
required
?
'flex-layout-label-required'
:
''
)
}
>
{
title
}
</
Col
>
}
<
Col
span=
{
wrappercol
}
>
<
Row
>
{
childProperties
.
map
((
v
,
i
,
arr
)
=>
renderCol
(
v
.
schema
,
arr
.
length
-
1
===
i
))
}
</
Row
>
</
Col
>
</
Row
>
})
registerVirtualBox
(
'flex-layout'
,
(
_props
)
=>
{
const
{
children
,
props
}
=
_props
const
rowStyle
=
props
[
'x-component-props'
]
?
props
[
'x-component-props'
].
rowStyle
:
{}
const
colStyle
=
props
[
'x-component-props'
]
?
props
[
'x-component-props'
].
colStyle
:
{}
return
(
<
RowLayout
style=
{
rowStyle
}
>
{
children
.
map
((
v
,
i
)
=>
<
Col
style=
{
colStyle
}
key=
{
i
}
>
{
v
}
</
Col
>)
}
</
RowLayout
>
)
})
registerVirtualBox
(
'empty-layout'
,
(
_props
)
=>
{
const
{
children
,
props
}
=
_props
return
(
<
div
>
{
children
}
</
div
>
)
})
const
SchemaFormButtonGroup
=
createVirtualBox
(
'schemaButtonGroup'
,
FormButtonGroup
)
const
SchemaButton
=
createVirtualBox
(
'schemaButton'
,
Button
)
const
SchemaSubmit
=
createVirtualBox
(
'schemaSubmit'
,
Submit
)
...
...
src/components/NiceForm/public/index.tsx
0 → 100644
View file @
afd9d15d
// 全局注册虚拟布局组件
import
React
from
'react'
import
{
registerVirtualBox
,
SchemaField
}
from
"@formily/antd"
import
{
Col
,
Row
}
from
'antd'
import
cx
from
'classnames'
import
styled
from
'styled-components'
const
RowLayout
=
styled
(
props
=>
<
Row
justify=
'end'
{
...
props
}
/>)
`
.mega-layout-item {
margin-bottom: 20px !important;
}
.mega-layout-container {
margin-bottom: 0;
}
`
const
renderCol
=
(
schema
,
isLast
)
=>
{
const
{
flexcol
=
{}
}
=
schema
[
'x-component-props'
]
return
<
Col
style=
{
isLast
?
{}
:
{
marginRight
:
24
}
}
{
...
flexcol
}
key=
{
schema
.
path
}
>
<
SchemaField
schema=
{
schema
.
toJSON
()
}
path=
{
schema
.
path
}
/>
</
Col
>
}
// 自定义flex布局容器
registerVirtualBox
(
'flex-box'
,
props
=>
{
const
childProperties
=
props
.
schema
.
getOrderProperties
()
const
{
title
,
required
}
=
props
.
props
const
{
labelcol
,
wrappercol
}
=
props
.
schema
.
getExtendsComponentProps
()
return
<
Row
>
{
title
&&
<
Col
span=
{
labelcol
}
className=
{
cx
(
required
?
'flex-layout-label-required'
:
''
)
}
>
{
title
}
</
Col
>
}
<
Col
span=
{
wrappercol
}
>
<
Row
>
{
childProperties
.
map
((
v
,
i
,
arr
)
=>
renderCol
(
v
.
schema
,
arr
.
length
-
1
===
i
))
}
</
Row
>
</
Col
>
</
Row
>
})
registerVirtualBox
(
'flex-layout'
,
(
_props
)
=>
{
const
{
children
,
props
}
=
_props
const
rowStyle
=
props
[
'x-component-props'
]
?
props
[
'x-component-props'
].
rowStyle
:
{}
const
colStyle
=
props
[
'x-component-props'
]
?
props
[
'x-component-props'
].
colStyle
:
{}
return
(
<
RowLayout
style=
{
rowStyle
}
>
{
children
.
map
((
v
,
i
)
=>
<
Col
style=
{
colStyle
}
key=
{
i
}
>
{
v
}
</
Col
>)
}
</
RowLayout
>
)
})
registerVirtualBox
(
'empty-layout'
,
(
_props
)
=>
{
const
{
children
,
props
}
=
_props
return
(
<
div
>
{
children
}
</
div
>
)
})
\ No newline at end of file
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