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
e16b0b50
Commit
e16b0b50
authored
Jul 27, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5a27c7e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
Cell.tsx
components/apolloTable/component/Cell.tsx
+32
-16
No files found.
components/apolloTable/component/Cell.tsx
View file @
e16b0b50
...
@@ -56,6 +56,19 @@ const Cell = (props: CellProps) => {
...
@@ -56,6 +56,19 @@ const Cell = (props: CellProps) => {
// useEffect(() => {
// useEffect(() => {
// setStatus('detail');
// setStatus('detail');
// }, [cellData]);
// }, [cellData]);
const
resetEditStatus
=
()
=>
{
setStatus
(
'detail'
);
if
(
typeof
onEmitMsg
===
'function'
)
{
onEmitMsg
({
status
:
EDIT_STATUS
.
FREE
});
}
};
const
turnIntoEditStatus
=
(
data
)
=>
{
setStatus
(
'edit'
);
if
(
typeof
onEmitMsg
===
'function'
)
{
onEmitMsg
({
...
data
,
status
:
EDIT_STATUS
.
EDITING
});
}
};
const
changeCellData
=
(
changedValue
:
any
,
option
?:
any
)
=>
{};
const
changeCellData
=
(
changedValue
:
any
,
option
?:
any
)
=>
{};
const
emitChangeCellData
=
(
changedValue
:
any
,
optionValue
:
any
)
=>
{
const
emitChangeCellData
=
(
changedValue
:
any
,
optionValue
:
any
)
=>
{
...
@@ -68,10 +81,7 @@ const Cell = (props: CellProps) => {
...
@@ -68,10 +81,7 @@ const Cell = (props: CellProps) => {
}
}
if
(
_
.
isEqual
(
temp
,
changedValue
))
{
if
(
_
.
isEqual
(
temp
,
changedValue
))
{
setStatus
(
'detail'
);
resetEditStatus
();
if
(
typeof
onEmitMsg
===
'function'
)
{
onEmitMsg
({
status
:
EDIT_STATUS
.
FREE
});
}
return
;
return
;
}
}
changeValue
(
changedValue
,
optionValue
);
changeValue
(
changedValue
,
optionValue
);
...
@@ -82,14 +92,14 @@ const Cell = (props: CellProps) => {
...
@@ -82,14 +92,14 @@ const Cell = (props: CellProps) => {
if
(
requiredFlag
)
{
if
(
requiredFlag
)
{
if
(
!
changedValue
||
changedValue
.
length
===
0
)
{
if
(
!
changedValue
||
changedValue
.
length
===
0
)
{
message
.
error
(
'该字段为必填项'
);
message
.
error
(
'该字段为必填项'
);
setStatus
(
'detail'
);
resetEditStatus
(
);
return
;
return
;
}
}
if
(
changedValue
.
length
===
1
)
{
if
(
changedValue
.
length
===
1
)
{
const
data
=
changedValue
[
0
];
const
data
=
changedValue
[
0
];
if
(
!
data
.
value
&&
!
data
.
text
)
{
if
(
!
data
.
value
&&
!
data
.
text
)
{
message
.
error
(
'该字段为必填项'
);
message
.
error
(
'该字段为必填项'
);
setStatus
(
'detail'
);
resetEditStatus
(
);
return
;
return
;
}
}
}
}
...
@@ -110,10 +120,7 @@ const Cell = (props: CellProps) => {
...
@@ -110,10 +120,7 @@ const Cell = (props: CellProps) => {
value
:
extraData
,
value
:
extraData
,
});
});
}
}
setStatus
(
'detail'
);
resetEditStatus
();
if
(
typeof
onEmitMsg
===
'function'
)
{
onEmitMsg
({
status
:
EDIT_STATUS
.
FREE
});
}
};
};
// 添加行hover样式
// 添加行hover样式
const
onMouseEnter
=
()
=>
{
const
onMouseEnter
=
()
=>
{
...
@@ -246,10 +253,7 @@ const Cell = (props: CellProps) => {
...
@@ -246,10 +253,7 @@ const Cell = (props: CellProps) => {
}
}
if
(
selected
)
{
if
(
selected
)
{
// 当前已选中,则进入编辑状态
// 当前已选中,则进入编辑状态
setStatus
(
'edit'
);
turnIntoEditStatus
({
rowId
:
record
.
id
,
columnCode
:
columnName
});
if
(
typeof
onEmitMsg
===
'function'
)
{
onEmitMsg
({
rowId
:
record
.
id
,
columnCode
:
columnName
,
status
:
EDIT_STATUS
.
EDITING
});
}
if
(
dom
)
{
if
(
dom
)
{
// 给当前dom添加编辑状态
// 给当前dom添加编辑状态
dom
.
setAttribute
(
'data-editing-cell'
,
'1'
);
dom
.
setAttribute
(
'data-editing-cell'
,
'1'
);
...
@@ -366,7 +370,13 @@ const Cell = (props: CellProps) => {
...
@@ -366,7 +370,13 @@ const Cell = (props: CellProps) => {
return
(
return
(
<
div
<
div
className=
{
classNames
(
s
.
cellContainer
,
`table_${tableId}`
,
`row_${rowIndex}`
,
`col_${columnIndex}`
,
cellClassName
)
}
className=
{
classNames
(
s
.
cellContainer
,
`table_${tableId}`
,
`row_${rowIndex}`
,
`col_${columnIndex}`
,
cellClassName
,
)
}
style=
{
cellStyle
}
style=
{
cellStyle
}
onMouseEnter=
{
onMouseEnter
}
onMouseEnter=
{
onMouseEnter
}
onMouseLeave=
{
onMouseLeave
}
onMouseLeave=
{
onMouseLeave
}
...
@@ -374,7 +384,13 @@ const Cell = (props: CellProps) => {
...
@@ -374,7 +384,13 @@ const Cell = (props: CellProps) => {
{
columnIndex
===
0
&&
(
rowSelection
||
showExpand
||
showIndex
)
&&
renderFirst
()
}
{
columnIndex
===
0
&&
(
rowSelection
||
showExpand
||
showIndex
)
&&
renderFirst
()
}
<
div
<
div
id=
{
`cellUnit_${record.id}_${columnName}`
}
id=
{
`cellUnit_${record.id}_${columnName}`
}
className=
{
classNames
(
s
.
cellData
,
'cellUnit'
,
`table_${tableId}`
,
`row_${rowIndex}`
,
`col_${columnIndex}`
)
}
className=
{
classNames
(
s
.
cellData
,
'cellUnit'
,
`table_${tableId}`
,
`row_${rowIndex}`
,
`col_${columnIndex}`
,
)
}
data
-
selected
-
cell=
"0"
data
-
selected
-
cell=
"0"
data
-
editing
-
cell=
"0"
data
-
editing
-
cell=
"0"
ref=
{
cellUnit
}
ref=
{
cellUnit
}
...
...
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