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
133f9e6b
Commit
133f9e6b
authored
Feb 20, 2021
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加分组全选、展开
parent
fe9b0f1d
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
552 additions
and
358 deletions
+552
-358
Cell.less
components/apolloTable/component/Cell.less
+31
-4
Cell.tsx
components/apolloTable/component/Cell.tsx
+152
-42
Column.tsx
components/apolloTable/component/Column.tsx
+5
-7
Table.tsx
components/apolloTable/component/Table.tsx
+330
-293
index.tsx
components/apolloTable/component/index.tsx
+24
-7
interface.tsx
components/apolloTable/component/interface.tsx
+4
-0
memCols.ts
components/apolloTable/utils/memCols.ts
+6
-5
No files found.
components/apolloTable/component/Cell.less
View file @
133f9e6b
...
...
@@ -76,15 +76,42 @@
.groupLevel {
position: absolute;
left: 0;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
min-width: 100%;
white-space: nowrap;
font-size: @textFontGen;
height: 40px;
line-height: 40px;
color: @textPrimaryColor;
z-index: 5;
.groupContainer{
display: flex;
align-items: center;
height: 100%;
.groupCheck{
width: 16px;
margin-right: @marginSm;
}
.groupExpand{
width: 16px;
margin-right: @marginSm;
cursor: pointer;
}
.groupContent{
flex: 1;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
font-size: @textFontSm;
.groupText{
color: @textPrimaryColor;
overflow: hidden;
text-overflow: ellipsis;
}
.groupCount{
color: @textSupplyColor;
}
}
}
}
}
...
...
components/apolloTable/component/Cell.tsx
View file @
133f9e6b
This diff is collapsed.
Click to expand it.
components/apolloTable/component/Column.tsx
View file @
133f9e6b
...
...
@@ -4,6 +4,7 @@ import { Checkbox, Tooltip } from 'antd';
import
_
from
'lodash'
;
import
s
from
'./Column.less'
;
import
{
ColumnProps
}
from
'./interface'
;
import
{
memoSelected
}
from
'./Cell'
;
export
default
class
TableColumn
extends
PureComponent
<
ColumnProps
>
{
changeSort
=
(
type
:
string
)
=>
{
...
...
@@ -29,14 +30,11 @@ export default class TableColumn extends PureComponent<ColumnProps> {
getCheckbox
=
()
=>
{
const
{
rowSelection
,
dataSource
}
=
this
.
props
;
const
{
selectedRows
,
onChange
}
=
rowSelection
;
const
selectIds
=
memoSelected
(
selectedRows
);
let
checked
=
false
;
if
(
dataSource
.
length
>
0
&&
selectedRows
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
dataSource
.
length
;
i
++
)
{
if
(
!
selectedRows
.
some
((
item
)
=>
{
return
item
.
id
===
dataSource
[
i
].
id
;
})
)
{
if
(
!
selectIds
.
includes
(
dataSource
[
i
].
id
))
{
break
;
}
if
(
i
===
dataSource
.
length
-
1
)
{
...
...
@@ -46,10 +44,10 @@ export default class TableColumn extends PureComponent<ColumnProps> {
}
const
onToggle
=
()
=>
{
if
(
typeof
onChange
===
'function'
)
{
const
data
=
_
.
cloneDeep
(
select
edRow
s
);
const
data
=
_
.
cloneDeep
(
select
Id
s
);
dataSource
.
map
((
item
:
any
)
=>
{
const
index
=
data
.
findIndex
((
temp
:
any
)
=>
{
return
temp
.
id
===
item
.
id
;
return
temp
===
item
.
id
;
});
if
(
checked
)
{
index
>
-
1
&&
data
.
splice
(
index
,
1
);
...
...
components/apolloTable/component/Table.tsx
View file @
133f9e6b
This diff is collapsed.
Click to expand it.
components/apolloTable/component/index.tsx
View file @
133f9e6b
...
...
@@ -47,11 +47,11 @@ const formatData = (config: string[], dataSource: any[]) => {
}
const
map
:
any
=
{};
// 一级分组条件
const
group1
=
config
[
0
];
const
group1
:
any
=
config
[
0
];
// 二级分组条件
const
group2
=
config
[
1
];
const
group2
:
any
=
config
[
1
];
// 三级分组条件
const
group3
=
config
[
2
];
const
group3
:
any
=
config
[
2
];
// 遍历数据默认已排序,根据分组级别给每行添加分组class
return
dataSource
.
map
((
row
:
any
)
=>
{
const
groupKeyArr
:
string
[]
=
[];
...
...
@@ -79,37 +79,52 @@ const formatData = (config: string[], dataSource: any[]) => {
const
group1Key
=
groupKeyArr
[
0
];
const
group1Text
=
groupTextArr
[
0
];
if
(
!
map
[
group1Key
])
{
map
[
group1Key
]
=
group1Text
;
map
[
group1Key
]
=
{
text
:
group1Text
,
children
:
[],
};
if
(
row
.
classList
)
{
row
.
classList
[
0
]
=
'groupLevel1'
;
}
else
{
row
.
classList
=
[
'groupLevel1'
];
}
row
.
group1Children
=
map
[
group1Key
].
children
;
}
map
[
group1Key
].
children
.
push
(
row
.
id
);
}
if
(
groupKeyArr
[
1
])
{
const
group2Key
=
`
${
groupKeyArr
[
0
]}
-
${
groupKeyArr
[
1
]}
`
;
const
group2Text
=
`
${
groupTextArr
[
0
]}
-
${
groupTextArr
[
1
]}
`
;
if
(
!
map
[
group2Key
])
{
map
[
group2Key
]
=
group2Text
;
map
[
group2Key
]
=
{
text
:
group2Text
,
children
:
[],
};
if
(
row
.
classList
)
{
row
.
classList
[
1
]
=
'groupLevel2'
;
}
else
{
row
.
classList
=
[
''
,
'groupLevel2'
,
''
];
}
row
.
group2Children
=
map
[
group2Key
].
children
;
}
map
[
group2Key
].
children
.
push
(
row
.
id
);
}
if
(
groupKeyArr
[
2
])
{
const
group3Key
=
groupKeyArr
.
join
(
'-'
);
const
group3Text
=
groupTextArr
.
join
(
'-'
);
if
(
!
map
[
group3Key
])
{
map
[
group3Key
]
=
group3Text
;
map
[
group3Key
]
=
{
text
:
group3Text
,
children
:
[],
};
if
(
row
.
classList
)
{
row
.
classList
[
2
]
=
'groupLevel3'
;
}
else
{
row
.
classList
=
[
''
,
''
,
'groupLevel3'
];
}
row
.
group3Children
=
map
[
group3Key
].
children
;
}
map
[
group3Key
].
children
.
push
(
row
.
id
);
}
row
.
groupLevel
=
groupKeyArr
.
length
;
row
.
groupKeyArr
=
groupKeyArr
;
...
...
@@ -224,7 +239,9 @@ class AirTable extends React.Component<CommonProps, CommonState> {
return
(
<
Provider
value=
{
{
locale
:
this
.
getContext
()
}
}
>
<
div
className=
{
classNames
(
styles
.
container
,
className
)
}
>
{
operateConfig
&&
<
OperateConfig
selfClass=
{
selfClass
}
columns=
{
columns
}
operateConfig=
{
operateConfig
}
/>
}
{
operateConfig
&&
(
<
OperateConfig
selfClass=
{
selfClass
}
columns=
{
columns
}
operateConfig=
{
operateConfig
}
/>
)
}
<
div
className=
{
classNames
(
styles
.
tableContainer
,
tableClassName
)
}
>
{
tableOperateConfig
&&
(
<
div
className=
{
styles
.
tableOperateContainer
}
>
...
...
components/apolloTable/component/interface.tsx
View file @
133f9e6b
...
...
@@ -94,6 +94,8 @@ export interface TableState {
groupConfig
?:
any
[];
tableHeight
?:
number
;
tableWidth
?:
number
;
toggleGroup
?:
number
;
prevPropsDataSource
?:
RowProps
[];
}
export
interface
CommonProps
extends
TableProps
{
operateConfig
?:
OperateConfigProps
;
// 操作栏
...
...
@@ -142,6 +144,8 @@ export interface CellProps {
tableId
?:
string
|
number
;
maxPopHeight
?:
string
|
number
;
renderFirstLeft
?:
Function
;
toggleGroup
:
Function
;
dataSource
:
RowProps
[];
}
export
interface
EditCellProps
{
...
...
components/apolloTable/utils/memCols.ts
View file @
133f9e6b
import
memoizeOne
from
'memoize-one'
;
import
{
ColumnProps
,
RowProps
}
from
'../component/interface'
;
import
{
getCache
,
saveCache
}
from
'@/submodule/components/apolloTable/utils/cache'
;
import
{
ColumnProps
,
RowProps
}
from
'../component/interface'
;
// 获取左侧固定列数量
export
const
getLeftColumns
=
(
columns
:
ColumnProps
[])
=>
{
...
...
@@ -64,8 +64,8 @@ export const getRowHeight = (
{
dataSource
,
rowHeight
}:
{
dataSource
:
RowProps
[];
rowHeight
:
number
},
{
index
}:
{
index
:
number
},
)
=>
{
const
{
classList
}
=
dataSource
[
index
];
let
len
=
1
;
const
{
classList
,
hidden
}
=
dataSource
[
index
];
let
len
=
0
;
if
(
classList
)
{
classList
.
map
((
item
)
=>
{
if
(
item
)
{
...
...
@@ -73,11 +73,12 @@ export const getRowHeight = (
}
});
}
return
rowHeight
*
len
;
const
basic
=
hidden
?
0
:
rowHeight
;
return
40
*
len
+
basic
;
};
// 获取数据总高度
export
const
getTotalHeight
=
(
dataSource
:
RowProps
[],
rowHeight
:
number
)
=>
{
export
const
getTotalHeight
=
(
dataSource
:
RowProps
[],
rowHeight
:
number
,
toggleGroup
:
boolean
)
=>
{
let
height
=
0
;
dataSource
.
map
((
item
:
any
,
index
:
number
)
=>
{
height
+=
getRowHeight
({
dataSource
,
rowHeight
},
{
index
});
...
...
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