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
98f42885
Commit
98f42885
authored
Aug 03, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加编辑单元格重置兼容
parent
5c0d3fbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
7 deletions
+34
-7
Cell.tsx
components/apolloTable/component/Cell.tsx
+13
-3
index.tsx
...nents/apolloTable/component/base/edit/container/index.tsx
+21
-4
No files found.
components/apolloTable/component/Cell.tsx
View file @
98f42885
...
@@ -68,7 +68,17 @@ const Cell = (props: CellProps) => {
...
@@ -68,7 +68,17 @@ const Cell = (props: CellProps) => {
};
};
const
changeCellData
=
(
changedValue
:
any
,
option
?:
any
)
=>
{};
const
changeCellData
=
(
changedValue
:
any
,
option
?:
any
)
=>
{};
const
emitChangeCellData
=
(
changedValue
:
any
,
optionValue
:
any
)
=>
{
/**
*
* @param changedValue 修改的值
* @param optionValue 修改的原始数据
* @param reset 是否重置编辑状态
*/
const
emitChangeCellData
=
(
changedValue
:
any
,
optionValue
:
any
,
reset
?:
boolean
)
=>
{
if
(
reset
)
{
resetEditStatus
();
return
;
}
let
temp
:
CellDataProps
[]
=
[];
let
temp
:
CellDataProps
[]
=
[];
cellData
.
map
((
item
:
CellDataProps
)
=>
{
cellData
.
map
((
item
:
CellDataProps
)
=>
{
temp
.
push
({
text
:
item
.
text
,
value
:
item
.
value
});
temp
.
push
({
text
:
item
.
text
,
value
:
item
.
value
});
...
@@ -349,9 +359,9 @@ const Cell = (props: CellProps) => {
...
@@ -349,9 +359,9 @@ const Cell = (props: CellProps) => {
columnConfig=
{
columnConfig
}
columnConfig=
{
columnConfig
}
onChange=
{
changeCellData
}
onChange=
{
changeCellData
}
rowData=
{
record
}
rowData=
{
record
}
onEmitChange=
{
(
changedValue
:
any
,
optionValue
:
any
)
=>
{
onEmitChange=
{
(
changedValue
:
any
,
optionValue
:
any
,
reset
?:
boolean
)
=>
{
const
value
=
setFormat
(
editConfig
,
columnConfig
,
changedValue
,
optionValue
);
const
value
=
setFormat
(
editConfig
,
columnConfig
,
changedValue
,
optionValue
);
emitChangeCellData
(
value
,
optionValue
);
emitChangeCellData
(
value
,
optionValue
,
reset
);
}
}
}
}
tableId=
{
tableId
}
tableId=
{
tableId
}
cellRenderProps=
{
cellRenderProps
}
cellRenderProps=
{
cellRenderProps
}
...
...
components/apolloTable/component/base/edit/container/index.tsx
View file @
98f42885
...
@@ -4,7 +4,7 @@ import { antiAssign } from '../../../../utils/utils';
...
@@ -4,7 +4,7 @@ import { antiAssign } from '../../../../utils/utils';
interface
Props
{
interface
Props
{
onEmitChange
:
Function
;
onEmitChange
:
Function
;
tableId
:
string
|
number
;
tableId
:
string
|
number
;
}
}
interface
State
{
interface
State
{
value
:
any
;
value
:
any
;
...
@@ -43,6 +43,26 @@ export default function CellContainer<P extends Props>(Comp) {
...
@@ -43,6 +43,26 @@ export default function CellContainer<P extends Props>(Comp) {
this
.
setState
({
value
,
option
});
this
.
setState
({
value
,
option
});
};
};
onBlur
=
(
e
:
any
)
=>
{
onBlur
=
(
e
:
any
)
=>
{
const
{
tableId
,
onEmitChange
}
=
this
.
props
;
const
{
value
,
option
}
=
this
.
state
;
const
doms
=
document
.
querySelectorAll
(
`.cellUnit.table_
${
tableId
}
`
);
let
editing
=
false
;
if
(
doms
)
{
for
(
let
i
=
0
;
i
<
doms
.
length
;
i
++
)
{
// 检测当前是否有编辑中的组件,没有则重置编辑框(因业务需求,可能直接删除掉当前编辑单元格的编辑状态)
if
(
doms
[
i
].
getAttribute
(
'data-editing-cell'
)
===
'1'
)
{
editing
=
true
;
break
;
}
}
}
if
(
!
editing
)
{
if
(
typeof
onEmitChange
===
'function'
)
{
onEmitChange
(
value
,
option
,
1
);
}
return
;
}
let
currTarget
=
e
.
target
;
let
currTarget
=
e
.
target
;
while
(
currTarget
&&
currTarget
!=
document
)
{
while
(
currTarget
&&
currTarget
!=
document
)
{
let
editing
=
currTarget
.
getAttribute
(
'data-editing-cell'
);
let
editing
=
currTarget
.
getAttribute
(
'data-editing-cell'
);
...
@@ -52,12 +72,9 @@ export default function CellContainer<P extends Props>(Comp) {
...
@@ -52,12 +72,9 @@ export default function CellContainer<P extends Props>(Comp) {
}
}
currTarget
=
currTarget
.
parentNode
;
currTarget
=
currTarget
.
parentNode
;
}
}
const
{
onEmitChange
,
tableId
}
=
this
.
props
;
const
{
value
,
option
}
=
this
.
state
;
if
(
typeof
onEmitChange
===
'function'
)
{
if
(
typeof
onEmitChange
===
'function'
)
{
onEmitChange
(
value
,
option
);
onEmitChange
(
value
,
option
);
// 清除所有dom的编辑状态
// 清除所有dom的编辑状态
const
doms
=
document
.
querySelectorAll
(
`.cellUnit.table_
${
tableId
}
`
);
if
(
doms
)
{
if
(
doms
)
{
doms
.
forEach
((
item
)
=>
{
doms
.
forEach
((
item
)
=>
{
item
.
setAttribute
(
'data-editing-cell'
,
'0'
);
item
.
setAttribute
(
'data-editing-cell'
,
'0'
);
...
...
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