Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
Project
Project
Details
Activity
Releases
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
web_component
submodule
Commits
32e2c45f
Commit
32e2c45f
authored
Jul 20, 2020
by
李晓静
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑form增加onblur方法
parent
56b17bd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
27 deletions
+50
-27
index.tsx
components/apolloTable/editFormV3/index.tsx
+50
-27
No files found.
components/apolloTable/editFormV3/index.tsx
View file @
32e2c45f
...
@@ -8,6 +8,10 @@
...
@@ -8,6 +8,10 @@
* 监听表单值发生变化是的回掉:onValuesChange:Function
* 监听表单值发生变化是的回掉:onValuesChange:Function
*
*
* 样式:propClass:object
* 样式:propClass:object
*
* 增加字段:hideOperateBtn,有该字段,隐藏表单底部操作按钮
*
* 失去焦点:onBlurFn
* */
* */
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
{
Form
,
Button
}
from
'antd'
;
import
{
Form
,
Button
}
from
'antd'
;
...
@@ -16,6 +20,7 @@ import { config } from '../component/base/config';
...
@@ -16,6 +20,7 @@ import { config } from '../component/base/config';
import
{
transferAttr
}
from
'../component/base/_utils/transferAttr'
;
import
{
transferAttr
}
from
'../component/base/_utils/transferAttr'
;
import
{
getFormat
,
setFormat
}
from
'../component/base'
;
import
{
getFormat
,
setFormat
}
from
'../component/base'
;
import
{
Provider
}
from
'../component/context'
;
import
{
Provider
}
from
'../component/context'
;
import
{
emptyModel
}
from
'@/submodule/components/apolloTable/component/base/_utils/setFormatter'
;
import
{
defaultLocale
}
from
'@/submodule/components/apolloTable/locale'
;
import
{
defaultLocale
}
from
'@/submodule/components/apolloTable/locale'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
...
@@ -27,6 +32,7 @@ class FormWrap extends Component {
...
@@ -27,6 +32,7 @@ class FormWrap extends Component {
e
.
stopPropagation
();
e
.
stopPropagation
();
const
{
rowId
,
form
,
handleSubmit
,
data
,
rowData
}
=
this
.
props
;
const
{
rowId
,
form
,
handleSubmit
,
data
,
rowData
}
=
this
.
props
;
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
console
.
log
(
data
,
8888
)
if
(
!
err
)
{
if
(
!
err
)
{
const
newValues
:
any
[]
=
[];
const
newValues
:
any
[]
=
[];
_
.
keys
(
values
).
map
((
key
)
=>
{
_
.
keys
(
values
).
map
((
key
)
=>
{
...
@@ -82,7 +88,7 @@ class FormWrap extends Component {
...
@@ -82,7 +88,7 @@ class FormWrap extends Component {
renderEditForm
=
(
item
)
=>
{
renderEditForm
=
(
item
)
=>
{
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
const
{
rowData
}
=
this
.
props
;
const
{
rowData
,
onBlurFn
,
rowId
}
=
this
.
props
;
const
{
const
{
columnType
,
columnType
,
columnName
,
columnName
,
...
@@ -108,7 +114,20 @@ class FormWrap extends Component {
...
@@ -108,7 +114,20 @@ class FormWrap extends Component {
};
};
const
transferColumn
=
transferAttr
(
columnType
,
newProps
);
const
transferColumn
=
transferAttr
(
columnType
,
newProps
);
const
disabled
=
readOnlyFlag
||
(
dynamicCellConfigDTO
&&
dynamicCellConfigDTO
.
readonlyFlag
);
const
disabled
=
readOnlyFlag
||
(
dynamicCellConfigDTO
&&
dynamicCellConfigDTO
.
readonlyFlag
);
const
onBlurFn1
=
(
changedValue
:
any
,
newVal
:
any
)
=>
{
let
temp
:
any
[]
=
[];
value
.
map
((
item
:
any
)
=>
{
temp
.
push
({
text
:
item
.
text
,
value
:
item
.
value
});
});
if
(
temp
.
length
===
0
)
{
temp
=
emptyModel
;
}
if
(
_
.
isEqual
(
temp
,
newVal
))
{
return
;
}
onBlurFn
(
changedValue
)
}
return
(
return
(
<
FormItem
key=
{
columnName
}
label=
{
this
.
renderLabel
(
item
)
}
>
<
FormItem
key=
{
columnName
}
label=
{
this
.
renderLabel
(
item
)
}
>
{
getFieldDecorator
(
columnName
,
{
{
getFieldDecorator
(
columnName
,
{
...
@@ -121,8 +140,10 @@ class FormWrap extends Component {
...
@@ -121,8 +140,10 @@ class FormWrap extends Component {
{
...
transferColumn
}
{
...
transferColumn
}
columnConfig=
{
item
}
columnConfig=
{
item
}
disabled=
{
disabled
}
disabled=
{
disabled
}
rowId=
{
rowId
}
origin=
"editForm"
origin=
"editForm"
form=
{
this
.
props
.
form
}
form=
{
this
.
props
.
form
}
onBlurFn=
{
onBlurFn1
}
/>,
/>,
)
}
)
}
</
FormItem
>
</
FormItem
>
...
@@ -143,7 +164,7 @@ class FormWrap extends Component {
...
@@ -143,7 +164,7 @@ class FormWrap extends Component {
};
};
render
()
{
render
()
{
const
{
loading
,
isShowDelBtn
,
data
,
btnWrapStyle
,
name
,
colsNum
,
delLabel
}
=
this
.
props
;
const
{
loading
,
isShowDelBtn
,
data
,
btnWrapStyle
,
name
,
colsNum
,
delLabel
,
hideOperateBtn
}
=
this
.
props
;
return
(
return
(
<
Provider
value=
{
{
locale
:
this
.
getContext
()
}
}
>
<
Provider
value=
{
{
locale
:
this
.
getContext
()
}
}
>
...
@@ -174,27 +195,32 @@ class FormWrap extends Component {
...
@@ -174,27 +195,32 @@ class FormWrap extends Component {
})
}
})
}
</
Form
>
</
Form
>
</
div
>
</
div
>
<
div
className=
{
styles
.
buttonWrap
}
style=
{
btnWrapStyle
}
>
{
<
div
style=
{
{
display
:
'flex'
,
justifyContent
:
'center'
}
}
>
hideOperateBtn
?
null
:
(
{
isShowDelBtn
?
(
<
div
className=
{
styles
.
buttonWrap
}
style=
{
btnWrapStyle
}
>
<
Button
onClick=
{
this
.
handleDelete
}
type=
"link"
className=
{
styles
.
delBtnCls
}
>
<
div
style=
{
{
display
:
'flex'
,
justifyContent
:
'center'
}
}
>
{
delLabel
||
'删除'
}
{
isShowDelBtn
?
(
<
Button
onClick=
{
this
.
handleDelete
}
type=
"link"
className=
{
styles
.
delBtnCls
}
>
{
delLabel
||
'删除'
}
</
Button
>
)
:
null
}
<
Button
onClick=
{
this
.
handleCancel
}
className=
{
styles
.
btnCls
}
>
取消
</
Button
>
</
Button
>
)
:
null
}
<
Button
<
Button
onClick=
{
this
.
handleCancel
}
className=
{
styles
.
btnCls
}
>
onClick=
{
this
.
handleSubmit
}
取消
type=
"primary"
</
Button
>
className=
{
styles
.
btnCls
}
<
Button
loading=
{
loading
}
onClick=
{
this
.
handleSubmit
}
id=
"submitBtn"
// 用于业务监听此dom节点
type=
"primary"
>
className=
{
styles
.
btnCls
}
确定
loading=
{
loading
}
</
Button
>
id=
"submitBtn"
// 用于业务监听此dom节点
</
div
>
>
</
div
>
确定
)
</
Button
>
}
</
div
>
</
div
>
</
div
>
</
div
>
</
Provider
>
</
Provider
>
);
);
...
@@ -219,11 +245,8 @@ function mapPropsToFields(props) {
...
@@ -219,11 +245,8 @@ function mapPropsToFields(props) {
});
});
return
returnObj
;
return
returnObj
;
}
}
function
onValuesChange
(
props
:
any
,
changedValues
:
any
,
allValues
:
any
)
{
function
onValuesChange
(
props
,
changedValues
,
allValues
)
{
if
(
props
.
changeValue
)
{
}
if
(
props
.
changeValue
)
{
props
.
changeValue
(
changedValues
,
allValues
);
}
}
}
export
default
Form
.
create
({
name
:
'form_view'
})(
FormWrap
);
export
default
Form
.
create
({
name
:
'form_view'
})(
FormWrap
);
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