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
a29f385b
Commit
a29f385b
authored
Sep 11, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
a346e562
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
Cell.tsx
components/apolloTable/component/Cell.tsx
+18
-16
index.tsx
components/apolloTable/editFormV3/index.tsx
+1
-2
No files found.
components/apolloTable/component/Cell.tsx
View file @
a29f385b
...
...
@@ -48,6 +48,7 @@ const Cell = (props: CellProps) => {
renderEditCell
,
cellRenderProps
,
readOnlyFlag
,
columnAttrObj
,
}
=
columnConfig
;
const
cellUnit
=
useRef
(
null
);
const
[
status
,
setStatus
]
=
useState
(
'detail'
);
...
...
@@ -94,22 +95,6 @@ const Cell = (props: CellProps) => {
};
const
changeValue
=
async
(
changedValue
:
any
,
optionValue
:
any
)
=>
{
// 校验必填项
if
(
requiredFlag
)
{
if
(
!
changedValue
||
changedValue
.
length
===
0
)
{
message
.
error
(
'该字段为必填项'
);
resetEditStatus
();
return
;
}
if
(
changedValue
.
length
===
1
)
{
const
data
=
changedValue
[
0
];
if
(
!
data
.
value
&&
!
data
.
text
&&
data
.
value
!==
0
)
{
message
.
error
(
'该字段为必填项'
);
resetEditStatus
();
return
;
}
}
}
const
extraData
=
FormHelper
.
changeTableData
({
item
:
columnConfig
,
changedKey
:
columnName
,
...
...
@@ -367,6 +352,23 @@ const Cell = (props: CellProps) => {
onChange=
{
changeCellData
}
rowData=
{
record
}
onEmitChange=
{
(
changedValue
:
any
,
optionValue
:
any
,
reset
?:
boolean
)
=>
{
// 校验必填项
if
(
requiredFlag
&&!
changedValue
)
{
message
.
error
(
'该字段为必填项'
);
resetEditStatus
();
return
;
}
// 校验规则
if
(
columnAttrObj
.
rules
)
{
for
(
let
i
=
0
;
i
<
columnAttrObj
.
rules
.
length
;
i
++
)
{
const
rule
=
columnAttrObj
.
rules
[
i
];
if
(
rule
.
pattern
&&
!
rule
.
pattern
.
test
(
changedValue
))
{
message
.
error
(
rule
.
message
||
'请按正确格式填写'
);
resetEditStatus
();
return
;
}
}
}
const
value
=
setFormat
(
editConfig
,
columnConfig
,
changedValue
,
optionValue
);
emitChangeCellData
(
value
,
optionValue
,
reset
);
}
}
...
...
components/apolloTable/editFormV3/index.tsx
View file @
a29f385b
...
...
@@ -125,7 +125,6 @@ class FormWrap extends Component {
value
,
renderEditForm
,
readOnlyFlag
,
rules
=
[],
validateFirst
=
true
,
validateTrigger
=
'onChange'
,
dynamicCellConfigDTO
,
...
...
@@ -196,7 +195,7 @@ class FormWrap extends Component {
rules
:
[
{
required
:
!!
item
.
requiredFlag
,
message
:
'必填项不能为空'
},
{
validator
:
this
.
validateRequired
.
bind
(
this
,
item
)
},
...
rules
,
...
(
item
.
columnAttrObj
.
rules
||
[])
,
],
initialValue
:
getFormat
(
detailConfig
,
item
,
value
),
})(
...
...
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