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
a57bc415
Commit
a57bc415
authored
Aug 07, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化table
parent
5f73e904
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
259 additions
and
230 deletions
+259
-230
Column.less
components/apolloTable/component/Column.less
+2
-0
DragFixed.tsx
components/apolloTable/component/DragFixed.tsx
+8
-1
DragResized.tsx
components/apolloTable/component/DragResized.tsx
+28
-11
DragSorted.less
components/apolloTable/component/DragSorted.less
+0
-3
DragSorted.tsx
components/apolloTable/component/DragSorted.tsx
+70
-14
RightDragFixed.tsx
components/apolloTable/component/RightDragFixed.tsx
+8
-1
Table.less
components/apolloTable/component/Table.less
+2
-26
Table.tsx
components/apolloTable/component/Table.tsx
+59
-88
index.tsx
components/apolloTable/component/index.tsx
+20
-17
interface.tsx
components/apolloTable/component/interface.tsx
+52
-53
index.tsx
components/apolloTable/component/operate/index.tsx
+4
-6
index.tsx
components/apolloTable/editForm/index.tsx
+0
-6
memCols.ts
components/apolloTable/utils/memCols.ts
+6
-4
No files found.
components/apolloTable/component/Column.less
View file @
a57bc415
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
//justify-content: space-between;
//justify-content: space-between;
height: 100%;
height: 100%;
width: 100%;
width: 100%;
padding: 0 @paddingLg;
overflow: hidden;
.checkbox {
.checkbox {
margin-right: 10px;
margin-right: 10px;
}
}
...
...
components/apolloTable/component/DragFixed.tsx
View file @
a57bc415
...
@@ -14,6 +14,7 @@ const DragFixed = (props: any) => {
...
@@ -14,6 +14,7 @@ const DragFixed = (props: any) => {
columns
,
columns
,
onResizeStop
,
onResizeStop
,
cachedFeAttr
,
cachedFeAttr
,
onDragFixed
,
}
=
props
;
}
=
props
;
// 表格
// 表格
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
...
@@ -120,6 +121,7 @@ const DragFixed = (props: any) => {
...
@@ -120,6 +121,7 @@ const DragFixed = (props: any) => {
item
.
fixed
=
''
;
item
.
fixed
=
''
;
}
}
}
}
// 缓存
if
(
cachedFeAttr
)
{
if
(
cachedFeAttr
)
{
const
cachedCols
=
getCache
({
tableId
});
const
cachedCols
=
getCache
({
tableId
});
if
(
cachedCols
)
{
if
(
cachedCols
)
{
...
@@ -132,8 +134,13 @@ const DragFixed = (props: any) => {
...
@@ -132,8 +134,13 @@ const DragFixed = (props: any) => {
}
}
newColumns
.
push
(
item
);
newColumns
.
push
(
item
);
});
});
// 业务回调
if
(
typeof
onDragFixed
===
'function'
)
{
onDragFixed
(
newColumns
);
}
// table回调
if
(
typeof
onResizeStop
===
'function'
)
{
if
(
typeof
onResizeStop
===
'function'
)
{
onResizeStop
(
{
columns
:
newColumns
}
);
onResizeStop
(
newColumns
);
}
}
};
};
...
...
components/apolloTable/component/DragResized.tsx
View file @
a57bc415
...
@@ -4,8 +4,10 @@ import { getCache, saveCache } from '../utils/cache';
...
@@ -4,8 +4,10 @@ import { getCache, saveCache } from '../utils/cache';
import
styles
from
'./DragResized.less'
;
import
styles
from
'./DragResized.less'
;
const
DragResized
=
(
props
:
any
)
=>
{
const
DragResized
=
(
props
:
any
)
=>
{
const
{
style
,
columnName
,
tableId
,
onResizeCb
,
cachedFeAttr
}
=
props
;
const
{
style
,
columnName
,
tableId
,
canResized
,
onDragResized
,
onDragResizedCb
,
cachedFeAttr
,
columns
}
=
props
;
if
(
!
canResized
)
{
return
<
div
style=
{
style
}
>
{
props
.
children
}
</
div
>;
}
// 表格
// 表格
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
// 分割线wrap
// 分割线wrap
...
@@ -28,16 +30,31 @@ const DragResized = (props: any) => {
...
@@ -28,16 +30,31 @@ const DragResized = (props: any) => {
// 列伸缩结束
// 列伸缩结束
const
onResizeWidthStop
=
(
e
:
any
,
{
size
}:
{
size
:
{
width
:
number
}
})
=>
{
const
onResizeWidthStop
=
(
e
:
any
,
{
size
}:
{
size
:
{
width
:
number
}
})
=>
{
dividerWrap
.
style
.
display
=
'none'
;
dividerWrap
.
style
.
display
=
'none'
;
const
cachedCols
=
getCache
({
tableId
});
const
newColumns
:
any
=
[];
if
(
cachedFeAttr
&&
cachedCols
)
{
columns
.
map
((
item
:
any
)
=>
{
cachedCols
[
columnName
]
=
{
if
(
item
.
columnName
===
columnName
)
{
...
cachedCols
[
columnName
],
item
.
width
=
size
.
width
;
width
:
size
.
width
,
}
};
newColumns
.
push
(
item
);
saveCache
({
tableId
,
data
:
cachedCols
});
});
// 业务回调
if
(
typeof
onDragResized
===
'function'
)
{
onDragResized
(
newColumns
);
}
}
if
(
typeof
onResizeCb
===
'function'
)
{
// table回调
onResizeCb
(
columnName
,
size
.
width
);
if
(
typeof
onDragResizedCb
===
'function'
)
{
onDragResizedCb
(
newColumns
);
}
// 缓存操作
if
(
cachedFeAttr
)
{
const
cachedCols
=
getCache
({
tableId
});
if
(
cachedCols
)
{
cachedCols
[
columnName
]
=
{
...
cachedCols
[
columnName
],
width
:
size
.
width
,
};
saveCache
({
tableId
,
data
:
cachedCols
});
}
}
}
};
};
...
...
components/apolloTable/component/DragSorted.less
View file @
a57bc415
...
@@ -4,6 +4,3 @@
...
@@ -4,6 +4,3 @@
width: 100%;
width: 100%;
height: 100%;
height: 100%;
}
}
.draggableDiv {
cursor: move;
}
components/apolloTable/component/DragSorted.tsx
View file @
a57bc415
import
React
,
{
useCallback
,
useRef
}
from
'react'
;
import
React
,
{
useCallback
,
useRef
}
from
'react'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
s
from
'./DragSorted.less'
;
import
s
from
'./DragSorted.less'
;
import
{
getCache
,
saveCache
}
from
'@/submodule/components/apolloTable/utils/cache'
;
const
DragSorted
=
(
props
:
any
)
=>
{
const
DragSorted
=
(
props
:
any
)
=>
{
const
{
className
,
columnName
,
orderNo
,
onDropFinish
,
onScroll
,
canDrag
,
tableId
}
=
props
;
const
{
columnName
,
orderNo
,
onDragSortedCb
,
onDragSortedMove
,
tableId
,
canSorted
,
onDragSorted
,
columns
,
cachedFeAttr
,
}
=
props
;
if
(
!
canSorted
)
{
return
<
div
className=
{
s
.
sortedWrap
}
>
{
props
.
children
}
</
div
>;
}
// 长按计时器
// 长按计时器
const
timer
:
any
=
useRef
(
null
);
const
timer
:
any
=
useRef
(
null
);
// 表格滚动计时器
// 表格滚动计时器
...
@@ -59,7 +73,7 @@ const DragSorted = (props: any) => {
...
@@ -59,7 +73,7 @@ const DragSorted = (props: any) => {
}
}
});
});
if
(
typeof
on
Scroll
===
'function'
)
{
if
(
typeof
on
DragSortedMove
===
'function'
)
{
let
dir
=
''
;
let
dir
=
''
;
let
step
=
10
;
let
step
=
10
;
// 设置鼠标超出表格左右固定列两侧时的滚动事件
// 设置鼠标超出表格左右固定列两侧时的滚动事件
...
@@ -84,7 +98,7 @@ const DragSorted = (props: any) => {
...
@@ -84,7 +98,7 @@ const DragSorted = (props: any) => {
clearInterval
(
timerInterval
.
current
);
clearInterval
(
timerInterval
.
current
);
}
}
timerInterval
.
current
=
setInterval
(()
=>
{
timerInterval
.
current
=
setInterval
(()
=>
{
on
Scroll
(
dir
,
step
);
on
DragSortedMove
(
dir
,
step
);
},
350
);
},
350
);
}
else
{
}
else
{
// 需要停止,清除已有计时器
// 需要停止,清除已有计时器
...
@@ -131,20 +145,62 @@ const DragSorted = (props: any) => {
...
@@ -131,20 +145,62 @@ const DragSorted = (props: any) => {
return
;
return
;
}
}
// 拖动回调
// 拖动回调
if
(
typeof
onDropFinish
===
'function'
)
{
const
newColumns
:
any
[]
=
[];
onDropFinish
(
columns
.
map
((
item
:
any
)
=>
{
{
columnName
:
dragColumn
,
orderNo
:
Number
(
dragColumnOrder
)
},
if
(
Number
(
dragColumnOrder
)
>
Number
(
dropColumnOrder
))
{
{
columnName
:
dropColumn
,
orderNo
:
Number
(
dropColumnOrder
)
},
if
(
item
.
orderNo
>=
Number
(
dropColumnOrder
)
&&
item
.
orderNo
<=
Number
(
dragColumnOrder
))
{
);
if
(
item
.
columnName
===
dragColumn
)
{
newColumns
.
push
({
...
item
,
orderNo
:
Number
(
dropColumnOrder
),
});
}
else
{
newColumns
.
push
({
...
item
,
orderNo
:
item
.
orderNo
+
1
,
});
}
}
else
{
newColumns
.
push
(
item
);
}
}
else
{
if
(
item
.
columnName
===
dragColumn
)
{
newColumns
.
push
({
...
item
,
orderNo
:
Number
(
dropColumnOrder
)
-
1
,
});
}
else
if
(
item
.
orderNo
>=
Number
(
dragColumnOrder
)
&&
item
.
orderNo
<=
Number
(
dropColumnOrder
))
{
newColumns
.
push
({
...
item
,
orderNo
:
item
.
orderNo
-
1
,
});
}
else
{
newColumns
.
push
(
item
);
}
}
});
if
(
cachedFeAttr
)
{
const
cachedCols
=
getCache
({
tableId
});
if
(
cachedCols
)
{
newColumns
.
map
((
item
:
any
)
=>
{
cachedCols
[
item
.
columnName
]
=
{
...
cachedCols
[
item
.
columnName
],
orderNo
:
item
.
orderNo
,
};
});
saveCache
({
tableId
,
data
:
cachedCols
});
}
}
if
(
typeof
onDragSorted
===
'function'
)
{
onDragSorted
(
newColumns
);
}
}
},
[
onDropFinish
]);
// if (typeof onDragSortedCb === 'function') {
// onDragSortedCb(newColumns);
// }
},
[
onDragSortedCb
,
onDragSorted
,
columns
]);
// 监听鼠标按下
// 监听鼠标按下
const
onMouseDown
=
useCallback
(
const
onMouseDown
=
useCallback
(
(
e
)
=>
{
(
e
)
=>
{
// 没有拖拽回调,默认不支持拖拽事件
if
(
!
canDrag
)
{
return
;
}
// 不是左键点击不作处理
// 不是左键点击不作处理
if
(
e
.
button
!==
0
)
{
if
(
e
.
button
!==
0
)
{
return
;
return
;
...
@@ -185,7 +241,7 @@ const DragSorted = (props: any) => {
...
@@ -185,7 +241,7 @@ const DragSorted = (props: any) => {
return
(
return
(
<
div
<
div
className=
{
classNames
(
'draggableColumn'
,
s
.
sortedWrap
,
className
)
}
className=
{
classNames
(
'draggableColumn'
,
s
.
sortedWrap
)
}
onMouseDown=
{
onMouseDown
}
onMouseDown=
{
onMouseDown
}
onMouseUp=
{
onMouseUp
}
onMouseUp=
{
onMouseUp
}
data
-
column
-
name=
{
columnName
}
data
-
column
-
name=
{
columnName
}
...
...
components/apolloTable/component/RightDragFixed.tsx
View file @
a57bc415
...
@@ -15,6 +15,7 @@ const DragFixed = (props: any) => {
...
@@ -15,6 +15,7 @@ const DragFixed = (props: any) => {
onResizeStop
,
onResizeStop
,
paddingRight
,
paddingRight
,
cachedFeAttr
,
cachedFeAttr
,
onDragFixed
,
}
=
props
;
}
=
props
;
// 表格
// 表格
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
const
container
:
any
=
document
.
querySelector
(
`#apolloTable_
${
tableId
}
`
);
...
@@ -126,6 +127,7 @@ const DragFixed = (props: any) => {
...
@@ -126,6 +127,7 @@ const DragFixed = (props: any) => {
item
.
fixed
=
''
;
item
.
fixed
=
''
;
}
}
}
}
// 缓存
if
(
cachedFeAttr
)
{
if
(
cachedFeAttr
)
{
const
cachedCols
=
getCache
({
tableId
});
const
cachedCols
=
getCache
({
tableId
});
if
(
cachedCols
)
{
if
(
cachedCols
)
{
...
@@ -138,8 +140,13 @@ const DragFixed = (props: any) => {
...
@@ -138,8 +140,13 @@ const DragFixed = (props: any) => {
}
}
newColumns
.
push
(
item
);
newColumns
.
push
(
item
);
});
});
// 业务回调
if
(
typeof
onDragFixed
===
'function'
)
{
onDragFixed
(
newColumns
);
}
// table回调
if
(
typeof
onResizeStop
===
'function'
)
{
if
(
typeof
onResizeStop
===
'function'
)
{
onResizeStop
(
{
columns
:
newColumns
}
);
onResizeStop
(
newColumns
);
}
}
};
};
...
...
components/apolloTable/component/Table.less
View file @
a57bc415
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
height: 100%;
height: 100%;
.loading {
.loading {
position: absolute;
position: absolute;
// top: 200px;
left: 50%;
left: 50%;
transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: 10;
z-index: 10;
...
@@ -57,15 +56,10 @@
...
@@ -57,15 +56,10 @@
background-color: white;
background-color: white;
}
}
.sideGrid {
.sideGrid,.centerGrid {
// overflow: hidden !important;
outline: none;
outline: none;
}
}
.centerGrid {
outline: none;
}
.bodyRow {
}
.bodyCell {
.bodyCell {
font-size: 20px;
font-size: 20px;
color: @textGeneralColor;
color: @textGeneralColor;
...
@@ -76,24 +70,6 @@
...
@@ -76,24 +70,6 @@
overflow: hidden !important;
overflow: hidden !important;
outline: none;
outline: none;
border-bottom: 1px solid #e8e8e8;
border-bottom: 1px solid #e8e8e8;
.headerCell {
padding: 0 @paddingLg;
display: flex;
justify-content: flex-start;
align-items: center;
box-sizing: border-box;
background: #f7f9fa;
.cellNo {
min-width: 50px;
}
.cellContent {
flex: 1;
height: 100%;
}
}
}
}
.fillHandleWrapper {
.fillHandleWrapper {
...
...
components/apolloTable/component/Table.tsx
View file @
a57bc415
...
@@ -124,21 +124,29 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -124,21 +124,29 @@ export default class AirTable extends Component<TableProps, TableState> {
}
}
return
colWidth
;
return
colWidth
;
};
};
// 重新计算单元格大小
recomputeGridSize
=
()
=>
{
if
(
this
.
grid1
&&
this
.
grid2
)
{
this
.
grid1
.
recomputeGridSize
();
this
.
grid2
.
recomputeGridSize
();
}
if
(
this
.
grid3
&&
this
.
grid4
)
{
this
.
grid3
.
recomputeGridSize
();
this
.
grid4
.
recomputeGridSize
();
}
if
(
this
.
grid5
&&
this
.
grid6
)
{
this
.
grid5
.
recomputeGridSize
();
this
.
grid6
.
recomputeGridSize
();
}
};
// 页面大小变化回调
onResize
=
({
width
,
height
}:
{
width
:
number
;
height
:
number
})
=>
{
onResize
=
({
width
,
height
}:
{
width
:
number
;
height
:
number
})
=>
{
this
.
setState
(
this
.
setState
(
{
{
tableWidth
:
width
,
tableWidth
:
width
,
tableHeight
:
height
,
tableHeight
:
height
,
},
},
()
=>
{
this
.
recomputeGridSize
,
this
.
grid1
&&
this
.
grid1
.
recomputeGridSize
();
this
.
grid2
&&
this
.
grid2
.
recomputeGridSize
();
this
.
grid3
&&
this
.
grid3
.
recomputeGridSize
();
this
.
grid4
&&
this
.
grid4
.
recomputeGridSize
();
this
.
grid5
&&
this
.
grid5
.
recomputeGridSize
();
this
.
grid6
&&
this
.
grid6
.
recomputeGridSize
();
},
);
);
};
};
...
@@ -152,27 +160,12 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -152,27 +160,12 @@ export default class AirTable extends Component<TableProps, TableState> {
};
};
// 列伸缩结束
// 列伸缩结束
onResizeCb
=
(
columnName
:
string
,
width
:
number
)
=>
{
onDragResizedCb
=
(
columns
:
ColumnProps
[])
=>
{
const
{
columns
}
=
this
.
state
;
const
newColumns
:
any
=
[];
columns
.
map
((
item
)
=>
{
if
(
item
.
columnName
===
columnName
)
{
item
.
width
=
width
;
}
newColumns
.
push
(
item
);
});
this
.
setState
(
this
.
setState
(
{
{
columns
:
newColumns
,
columns
,
},
()
=>
{
this
.
grid1
&&
this
.
grid1
.
recomputeGridSize
();
this
.
grid2
&&
this
.
grid2
.
recomputeGridSize
();
this
.
grid3
&&
this
.
grid3
.
recomputeGridSize
();
this
.
grid4
&&
this
.
grid4
.
recomputeGridSize
();
this
.
grid5
&&
this
.
grid5
.
recomputeGridSize
();
this
.
grid6
&&
this
.
grid6
.
recomputeGridSize
();
},
},
this
.
recomputeGridSize
,
);
);
};
};
// 拖拽自定义固定列前置动作
// 拖拽自定义固定列前置动作
...
@@ -183,15 +176,12 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -183,15 +176,12 @@ export default class AirTable extends Component<TableProps, TableState> {
}
}
};
};
// 拖拽自定义固定列后置动作
// 拖拽自定义固定列后置动作
onResizeStopLeftDragFixed
=
(
{
columns
}
)
=>
{
onResizeStopLeftDragFixed
=
(
columns
:
ColumnProps
[]
)
=>
{
this
.
setState
(
this
.
setState
(
{
{
columns
,
columns
,
},
},
()
=>
{
this
.
recomputeGridSize
,
this
.
grid1
&&
this
.
grid1
.
recomputeGridSize
();
this
.
grid2
&&
this
.
grid2
.
recomputeGridSize
();
},
);
);
};
};
// 拖拽自定义固定列前置动作
// 拖拽自定义固定列前置动作
...
@@ -204,19 +194,16 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -204,19 +194,16 @@ export default class AirTable extends Component<TableProps, TableState> {
}
}
};
};
// 拖拽自定义固定列后置动作
// 拖拽自定义固定列后置动作
onResizeStopRightDragFixed
=
(
{
columns
}
)
=>
{
onResizeStopRightDragFixed
=
(
columns
:
ColumnProps
[]
)
=>
{
this
.
setState
(
this
.
setState
(
{
{
columns
,
columns
,
},
},
()
=>
{
this
.
recomputeGridSize
,
this
.
grid5
&&
this
.
grid5
.
recomputeGridSize
();
this
.
grid6
&&
this
.
grid6
.
recomputeGridSize
();
},
);
);
};
};
// 拖拽滚动表格
// 拖拽滚动表格
on
ScrollHor
=
(
direction
:
string
,
step
:
number
)
=>
{
on
DragSortedMove
=
(
direction
:
string
,
step
:
number
)
=>
{
// 拖动超过视图范围,将表格左右滚动
// 拖动超过视图范围,将表格左右滚动
if
(
this
.
grid4
)
{
if
(
this
.
grid4
)
{
if
(
direction
===
'right'
)
{
if
(
direction
===
'right'
)
{
...
@@ -233,49 +220,13 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -233,49 +220,13 @@ export default class AirTable extends Component<TableProps, TableState> {
}
}
};
};
// 拖拽排序回调
// 拖拽排序回调
onDragSorted
=
(
dragColumn
:
any
,
dropColumn
:
any
)
=>
{
onDragSortedCb
=
(
columns
:
ColumnProps
[])
=>
{
const
{
onDragSorted
}
=
this
.
props
;
this
.
setState
(
const
{
columns
}
=
this
.
state
;
{
const
newColumns
:
any
[]
=
[];
columns
,
columns
.
map
((
item
)
=>
{
},
if
(
dragColumn
.
orderNo
>
dropColumn
.
orderNo
)
{
this
.
recomputeGridSize
,
if
(
item
.
orderNo
>=
dropColumn
.
orderNo
&&
item
.
orderNo
<=
dragColumn
.
orderNo
)
{
);
if
(
item
.
columnName
===
dragColumn
.
columnName
)
{
newColumns
.
push
({
...
item
,
orderNo
:
dropColumn
.
orderNo
,
});
}
else
{
newColumns
.
push
({
...
item
,
orderNo
:
item
.
orderNo
+
1
,
});
}
}
else
{
newColumns
.
push
(
item
);
}
}
else
{
if
(
item
.
columnName
===
dragColumn
.
columnName
)
{
newColumns
.
push
({
...
item
,
orderNo
:
dropColumn
.
orderNo
-
1
,
});
}
else
if
(
item
.
orderNo
>=
dragColumn
.
orderNo
&&
item
.
orderNo
<=
dropColumn
.
orderNo
)
{
newColumns
.
push
({
...
item
,
orderNo
:
item
.
orderNo
-
1
,
});
}
else
{
newColumns
.
push
(
item
);
}
}
});
newColumns
.
sort
((
a
,
b
)
=>
{
return
a
.
orderNo
-
b
.
orderNo
;
});
if
(
typeof
onDragSorted
===
'function'
)
{
onDragSorted
(
newColumns
);
}
};
};
// 渲染表头
// 渲染表头
renderHeaderCell
=
(
renderHeaderCell
=
(
...
@@ -283,7 +234,20 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -283,7 +234,20 @@ export default class AirTable extends Component<TableProps, TableState> {
{
columnIndex
,
key
,
style
}:
any
,
{
columnIndex
,
key
,
style
}:
any
,
)
=>
{
)
=>
{
if
(
showColumns
.
length
===
0
)
return
null
;
if
(
showColumns
.
length
===
0
)
return
null
;
const
{
sortConfig
,
showIndex
,
rowSelection
,
dataSource
,
onDragSorted
,
tableId
,
cachedFeAttr
}
=
this
.
props
;
const
{
sortConfig
,
showIndex
,
rowSelection
,
dataSource
,
canResized
,
onDragResized
,
canSorted
,
onDragSorted
,
tableId
,
cachedFeAttr
,
}
=
this
.
props
;
const
{
columns
}
=
this
.
state
;
const
formatColumns
=
this
.
memoizeFormatColumns
(
columns
,
cachedFeAttr
,
tableId
);
const
{
const
{
columnType
=
1
,
columnType
=
1
,
columnName
,
columnName
,
...
@@ -301,17 +265,22 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -301,17 +265,22 @@ export default class AirTable extends Component<TableProps, TableState> {
columnName=
{
columnName
}
columnName=
{
columnName
}
style=
{
style
}
style=
{
style
}
tableId=
{
tableId
}
tableId=
{
tableId
}
canResized=
{
canResized
}
onDragResized=
{
onDragResized
}
cachedFeAttr=
{
cachedFeAttr
}
cachedFeAttr=
{
cachedFeAttr
}
onResizeCb=
{
this
.
onResizeCb
}
onDragResizedCb=
{
this
.
onDragResizedCb
}
columns=
{
formatColumns
}
>
>
<
DragSorted
<
DragSorted
columnName=
{
columnName
}
columnName=
{
columnName
}
orderNo=
{
orderNo
}
orderNo=
{
orderNo
}
onDropFinish=
{
this
.
onDragSorted
}
canSorted=
{
canSorted
}
onScroll=
{
this
.
onScrollHor
}
onDragSorted=
{
onDragSorted
}
className=
{
styles
.
headerCell
}
onDragSortedMove=
{
this
.
onDragSortedMove
}
canDrag=
{
!!
onDragSorted
}
onDragSortedCb=
{
this
.
onDragSortedCb
}
cachedFeAttr=
{
cachedFeAttr
}
tableId=
{
tableId
}
tableId=
{
tableId
}
columns=
{
formatColumns
}
>
>
<
Column
<
Column
columnType=
{
String
(
columnType
)
}
columnType=
{
String
(
columnType
)
}
...
@@ -437,7 +406,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -437,7 +406,7 @@ export default class AirTable extends Component<TableProps, TableState> {
};
};
render
()
{
render
()
{
const
{
loading
,
noDataPlaceholder
,
loadComp
,
canFixed
,
tableId
,
cachedFeAttr
}
=
this
.
props
;
const
{
loading
,
noDataPlaceholder
,
loadComp
,
canFixed
,
tableId
,
cachedFeAttr
,
onDragFixed
}
=
this
.
props
;
const
{
columns
,
dataSource
,
tableWidth
=
0
,
tableHeight
=
0
}
=
this
.
state
;
const
{
columns
,
dataSource
,
tableWidth
=
0
,
tableHeight
=
0
}
=
this
.
state
;
const
{
overscanColumnCount
,
overscanRowCount
,
rowHeight
,
headerHeight
,
columnWidth
}
=
this
.
config
;
const
{
overscanColumnCount
,
overscanRowCount
,
rowHeight
,
headerHeight
,
columnWidth
}
=
this
.
config
;
const
scrollbarWidth
=
scrollbarSize
()
||
0
;
const
scrollbarWidth
=
scrollbarSize
()
||
0
;
...
@@ -567,6 +536,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -567,6 +536,7 @@ export default class AirTable extends Component<TableProps, TableState> {
columns=
{
columns
}
columns=
{
columns
}
onResizeStart=
{
this
.
onResizeStartLeftDragFixed
}
onResizeStart=
{
this
.
onResizeStartLeftDragFixed
}
onResizeStop=
{
this
.
onResizeStopLeftDragFixed
}
onResizeStop=
{
this
.
onResizeStopLeftDragFixed
}
onDragFixed=
{
onDragFixed
}
cachedFeAttr=
{
cachedFeAttr
}
cachedFeAttr=
{
cachedFeAttr
}
/>
/>
)
}
)
}
...
@@ -672,6 +642,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -672,6 +642,7 @@ export default class AirTable extends Component<TableProps, TableState> {
paddingRight=
{
paddingRight
}
paddingRight=
{
paddingRight
}
onResizeStart=
{
this
.
onResizeStartRightDragFixed
}
onResizeStart=
{
this
.
onResizeStartRightDragFixed
}
onResizeStop=
{
this
.
onResizeStopRightDragFixed
}
onResizeStop=
{
this
.
onResizeStopRightDragFixed
}
onDragFixed=
{
onDragFixed
}
cachedFeAttr=
{
cachedFeAttr
}
cachedFeAttr=
{
cachedFeAttr
}
/>
/>
)
}
)
}
...
...
components/apolloTable/component/index.tsx
View file @
a57bc415
...
@@ -82,9 +82,11 @@ class AirTable extends React.Component<CommonProps, CommonState> {
...
@@ -82,9 +82,11 @@ class AirTable extends React.Component<CommonProps, CommonState> {
contentMenu
,
contentMenu
,
onScroll
,
onScroll
,
loadComp
,
loadComp
,
showCondition
,
canResized
,
onDragResized
,
canFixed
,
canFixed
,
id
,
onDragFixed
,
canSorted
,
onDragSorted
,
onDragSorted
,
onEmitMsg
,
onEmitMsg
,
tableId
,
tableId
,
...
@@ -98,16 +100,13 @@ class AirTable extends React.Component<CommonProps, CommonState> {
...
@@ -98,16 +100,13 @@ class AirTable extends React.Component<CommonProps, CommonState> {
return
(
return
(
<
Provider
value=
{
{
locale
:
this
.
getContext
()
}
}
>
<
Provider
value=
{
{
locale
:
this
.
getContext
()
}
}
>
<
div
<
div
id=
{
id
}
className=
{
className=
{
onScroll
onScroll
?
classNames
(
styles
.
container
,
styles
.
scroll
,
className
)
?
classNames
(
styles
.
container
,
styles
.
scroll
,
className
)
:
classNames
(
styles
.
container
,
className
)
:
classNames
(
styles
.
container
,
className
)
}
}
>
>
{
operateConfig
&&
(
{
operateConfig
&&
<
OperateConfig
columns=
{
columns
}
operateConfig=
{
operateConfig
}
/>
}
<
OperateConfig
columns=
{
columns
}
operateConfig=
{
operateConfig
}
showCondition=
{
showCondition
}
/>
)
}
<
div
<
div
className=
{
className=
{
onScroll
onScroll
...
@@ -122,35 +121,39 @@ class AirTable extends React.Component<CommonProps, CommonState> {
...
@@ -122,35 +121,39 @@ class AirTable extends React.Component<CommonProps, CommonState> {
)
}
)
}
<
div
className=
{
styles
.
tableC
}
>
<
div
className=
{
styles
.
tableC
}
>
<
Table
<
Table
tableId=
{
tableId
}
columns=
{
columns
}
columns=
{
columns
}
dataSource=
{
dataSource
}
dataSource=
{
dataSource
}
onScroll=
{
this
.
onScroll
}
rowStyle=
{
rowStyle
}
rowStyle=
{
rowStyle
}
rowClassName=
{
rowClassName
}
rowClassName=
{
rowClassName
}
onScroll=
{
this
.
onScroll
}
distanceToLoad=
{
distanceToLoad
}
distanceToLoad=
{
distanceToLoad
}
cellEditable=
{
cellEditable
}
emitChangeCell=
{
emitChangeCell
}
emitChangeCell=
{
emitChangeCell
}
bordered=
{
bordered
}
bordered=
{
bordered
}
width=
{
width
}
width=
{
width
}
height=
{
height
}
height=
{
height
}
rowHeight=
{
rowHeight
}
headerHeight=
{
headerHeight
}
columnWidth=
{
columnWidth
}
sortConfig=
{
sortConfig
}
sortConfig=
{
sortConfig
}
paginationConfig=
{
paginationConfig
}
paginationConfig=
{
paginationConfig
}
showIndex=
{
showIndex
}
showIndex=
{
showIndex
}
showExpand=
{
showExpand
}
showExpand=
{
showExpand
}
emptyPlaceholder=
{
emptyPlaceholder
}
cellEditable=
{
cellEditable
}
rowHeight=
{
rowHeight
}
headerHeight=
{
headerHeight
}
columnWidth=
{
columnWidth
}
loading=
{
loading
}
rowSelection=
{
rowSelection
}
rowSelection=
{
rowSelection
}
loading=
{
loading
}
loadComp=
{
loadComp
}
noDataPlaceholder=
{
noDataPlaceholder
}
noDataPlaceholder=
{
noDataPlaceholder
}
emptyPlaceholder=
{
emptyPlaceholder
}
contentMenu=
{
contentMenu
}
contentMenu=
{
contentMenu
}
loadComp=
{
loadComp
}
canFixed=
{
canFixed
}
onDragSorted=
{
onDragSorted
}
onEmitMsg=
{
onEmitMsg
}
onEmitMsg=
{
onEmitMsg
}
tableId=
{
tableId
}
cachedFeAttr=
{
cachedFeAttr
}
cachedFeAttr=
{
cachedFeAttr
}
canResized=
{
canResized
}
onDragResized=
{
onDragResized
}
canFixed=
{
canFixed
}
onDragFixed=
{
onDragFixed
}
canSorted=
{
canSorted
}
onDragSorted=
{
onDragSorted
}
/>
/>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
components/apolloTable/component/interface.tsx
View file @
a57bc415
import
React
from
'react'
;
// 列配置
// 列配置
export
interface
ColumnProps
{
export
interface
ColumnProps
{
columnType
:
string
;
columnType
:
string
;
// 组件类型
columnChsName
:
string
;
columnChsName
:
string
;
// 列名
columnName
:
string
;
columnName
:
string
;
// 列key
width
?:
number
;
width
?:
number
;
// 列宽度
columnAttrObj
?:
any
;
columnAttrObj
?:
any
;
// 组件属性
sortFlag
?:
boolean
;
sortFlag
?:
boolean
;
// 是否可排序
sortConfig
?:
any
;
sortConfig
?:
any
;
// 排序配置(当前已有排序及排序功能)
isMobile
?:
boolean
;
columnIndex
?:
number
;
// 列下标
columnIndex
?:
number
;
showIndex
?:
boolean
;
// 是否前面添加序号
showIndex
?:
boolean
;
questionText
?:
string
;
// 后面添加问号解释名称
questionText
?:
string
;
[
propName
:
string
]:
any
;
[
propName
:
string
]:
any
;
}
}
// 单元格基本数据格式
// 单元格基本数据格式
export
interface
CellDataProps
{
export
interface
CellDataProps
{
text
:
string
;
text
:
string
;
// 文本
value
:
any
;
value
:
any
;
// 值
extraData
?:
any
;
extraData
?:
any
;
// 额外数据
readonlyFlag
?:
boolean
;
readonlyFlag
?:
boolean
;
// 单元格只读
}
}
// 行数据格式
// 行数据格式
export
interface
RowDataProps
{
export
interface
RowDataProps
{
colChsName
:
string
;
colChsName
:
string
;
// 列名
colName
:
string
;
colName
:
string
;
// 列key
cellValueList
:
CellDataProps
[];
cellValueList
:
CellDataProps
[];
// 单元格数据
dynamicCellConfigDTO
?:
any
;
dynamicCellConfigDTO
?:
any
;
// 单元格动态配置
linkObjRowDateList
?:
any
;
linkObjRowDateList
?:
any
;
// 关联数据
}
}
// 行记录格式
// 行记录格式
export
interface
RowProps
{
export
interface
RowProps
{
id
:
number
;
id
:
number
;
// 行id(唯一索引)
rowData
:
RowDataProps
[];
rowData
:
RowDataProps
[];
// 行数据
[
propName
:
string
]:
any
;
[
propName
:
string
]:
any
;
}
}
export
interface
OperateConfigProps
{
export
interface
OperateConfigProps
{
menusGroup
?:
Object
[];
menusGroup
?:
Object
[];
// 菜单栏(隐藏、筛选、分组、排序四大功能)
buttonsGroup
?:
Object
[];
buttonsGroup
?:
Object
[];
// 自定义按钮组
moreGroup
?:
Object
[];
moreGroup
?:
Object
[];
// 按钮太多时可按更多分组
renderCustomNode
?:
Function
;
renderCustomNode
?:
Function
;
// 自定义渲染节点
showCondition
?:
boolean
;
// 是否展示筛选条件
}
}
export
interface
LoadConfigProps
{
export
interface
LoadConfigProps
{
onScroll
?:
Function
;
onScroll
?:
Function
;
// 滚动加载功能
distanceToLoad
?:
number
;
distanceToLoad
?:
number
;
// 触发滚动距离
}
}
export
interface
TableProps
extends
LoadConfigProps
{
export
interface
TableProps
extends
LoadConfigProps
{
// 表格必须属性
tableId
:
string
|
number
;
// 表格唯一id
tableId
:
string
|
number
;
// 表格唯一id
columns
:
ColumnProps
[];
// 列配置
columns
:
ColumnProps
[];
// 列配置
dataSource
:
RowProps
[];
// 数据源
dataSource
:
RowProps
[];
// 数据源
// 样式
rowClassName
?:
string
|
Function
;
// 行class
rowClassName
?:
string
|
Function
;
// 行class
rowStyle
?:
Object
|
Function
;
// 行style
rowStyle
?:
Object
|
Function
;
// 行style
rowRenderer
?:
Function
;
bordered
?:
boolean
;
// 是否显示边框
bordered
?:
boolean
;
// 是否显示边框
height
?:
number
;
// 表格高度
height
?:
number
;
// 表格高度
width
?:
number
;
// 表格宽度
width
?:
number
;
// 表格宽度
emitChangeCell
?:
Function
;
// 单元格修改回调
sortConfig
?:
any
;
paginationConfig
?:
any
;
// 分页配置
showIndex
?:
boolean
;
// 是否显示序号
showExpand
?:
any
;
// 是否显示展开详情图标
emptyPlaceholder
?:
string
;
// 数据为空时默认显示
cellEditable
?:
boolean
;
// 单元格是否可编辑
rowHeight
?:
number
;
// 初始化行高
rowHeight
?:
number
;
// 初始化行高
headerHeight
?:
number
;
// 初始化表头高度
headerHeight
?:
number
;
// 初始化表头高度
columnWidth
?:
number
;
// 初始化单元格宽度
columnWidth
?:
number
;
// 初始化单元格宽度
loading
?:
boolean
;
// 是否加载中
rowRenderer
?:
Function
;
// 自定义渲染行(未实现)
// 第一单元格功能
showIndex
?:
boolean
;
// 是否显示序号
showExpand
?:
any
;
// 是否显示展开详情图标
rowSelection
?:
any
;
// 复选配置
rowSelection
?:
any
;
// 复选配置
noDataPlaceholder
?:
any
;
// 无数据时显示文案
// 琐碎功能
cellEditable
?:
boolean
;
// 单元格是否可编辑
emitChangeCell
?:
Function
;
// 单元格修改回调
sortConfig
?:
any
;
// 表头快捷排序(正倒序)
paginationConfig
?:
any
;
// 分页配置(与onScroll互斥)
noDataPlaceholder
?:
any
;
// 表格无数据时显示文案
emptyPlaceholder
?:
string
;
// 单元格数据为空时默认显示
contentMenu
?:
any
;
// 右键菜单
contentMenu
?:
any
;
// 右键菜单
loadComp
?:
any
;
// 加载动画组件
loading
?:
boolean
;
// 是否加载中
loadComp
?:
any
;
// 自定义加载动画组件
canFixed
?:
boolean
;
// 是否可以拖拽自定义固定列
canFixed
?:
boolean
;
// 是否可以拖拽自定义固定列
canSorted
?:
boolean
;
// 是否可以拖拽自定义列排序
canSorted
?:
boolean
;
// 是否可以拖拽自定义列排序
canResized
?:
boolean
;
// 是否可以拖拽自定义列伸缩
canResized
?:
boolean
;
// 是否可以拖拽自定义列伸缩
onDragSorted
?:
Function
;
// 拖拽更改列排序回调
onDragSorted
?:
Function
;
// 拖拽更改列排序回调
onDragFixed
?:
Function
;
// 拖拽更改列排序回调
onDragFixed
?:
Function
;
// 拖拽更改列固定回调
onEmitMsg
?:
Function
;
// 是否支持消息协同
onDragResized
?:
Function
;
// 拖拽更改列伸缩回调
cachedFeAttr
?:
boolean
;
// 是否启用前端缓存
onEmitMsg
?:
Function
;
// 是否支持消息协同
cachedFeAttr
?:
boolean
;
// 是否启用前端缓存
}
}
export
interface
TableState
{
export
interface
TableState
{
columns
:
ColumnProps
[];
columns
:
ColumnProps
[];
...
@@ -89,15 +92,11 @@ export interface TableState {
...
@@ -89,15 +92,11 @@ export interface TableState {
tableWidth
?:
number
;
tableWidth
?:
number
;
}
}
export
interface
CommonProps
extends
TableProps
{
export
interface
CommonProps
extends
TableProps
{
operateConfig
?:
OperateConfigProps
;
operateConfig
?:
OperateConfigProps
;
// 操作栏
tableOperateConfig
?:
OperateConfigProps
;
tableOperateConfig
?:
OperateConfigProps
;
// 表格顶部操作栏
paginationConfig
?:
any
;
locale
?:
any
;
// 语言
locale
?:
any
;
className
?:
string
;
// 整体wrap样式
className
?:
string
;
tableClassName
?:
string
;
// 表格wrap样式
tableClassName
?:
string
;
showCondition
?:
boolean
;
id
?:
string
;
onEmitMsg
?:
Function
;
}
}
export
interface
CommonState
extends
TableState
{}
export
interface
CommonState
extends
TableState
{}
...
...
components/apolloTable/component/operate/index.tsx
View file @
a57bc415
...
@@ -12,7 +12,6 @@ import { OperateConfigProps, ColumnProps } from '../interface';
...
@@ -12,7 +12,6 @@ import { OperateConfigProps, ColumnProps } from '../interface';
interface
Props
{
interface
Props
{
operateConfig
?:
OperateConfigProps
;
operateConfig
?:
OperateConfigProps
;
columns
:
ColumnProps
[];
columns
:
ColumnProps
[];
showCondition
?:
boolean
;
}
}
/**
/**
* 操作栏
* 操作栏
...
@@ -48,12 +47,11 @@ export default class Operate extends Component<Props> {
...
@@ -48,12 +47,11 @@ export default class Operate extends Component<Props> {
};
};
render
()
{
render
()
{
const
{
operateConfig
,
columns
,
showCondition
}
=
this
.
props
;
const
{
operateConfig
,
columns
}
=
this
.
props
;
const
{
menusGroup
,
buttonsGroup
,
renderCustomNode
}:
any
=
operateConfig
||
{};
const
{
menusGroup
,
buttonsGroup
,
renderCustomNode
,
showCondition
}:
any
=
operateConfig
||
{};
const
filter
:
any
=
const
filter
:
any
=
menusGroup
menusGroup
&&
&&
menusGroup
.
find
((
item
:
any
)
=>
{
menusGroup
.
find
((
item
:
any
)
=>
{
return
item
.
type
===
'filter'
;
return
item
.
type
===
'filter'
;
});
});
return
(
return
(
...
...
components/apolloTable/editForm/index.tsx
View file @
a57bc415
...
@@ -46,9 +46,6 @@ const EditForm = (props: any) => {
...
@@ -46,9 +46,6 @@ const EditForm = (props: any) => {
...(
columnAttrObj
||
{}),
...(
columnAttrObj
||
{}),
};
};
const
transferColumn
=
transferAttr
(
columnType
,
newProps
);
const
transferColumn
=
transferAttr
(
columnType
,
newProps
);
// if(item.columnName==='emails'){
// debugger
// }
return
(
return
(
<
FormItem
<
FormItem
name=
{
columnName
}
name=
{
columnName
}
...
@@ -83,9 +80,6 @@ const EditForm = (props: any) => {
...
@@ -83,9 +80,6 @@ const EditForm = (props: any) => {
}
else
{
}
else
{
detailConfig
=
config
[
String
(
columnType
)]
||
config
[
'1'
];
detailConfig
=
config
[
String
(
columnType
)]
||
config
[
'1'
];
}
}
// if(key==='contactList'){
// debugger
// }
const
cellValueList
=
setFormat
(
detailConfig
,
item
,
values
[
key
],
value
);
const
cellValueList
=
setFormat
(
detailConfig
,
item
,
values
[
key
],
value
);
newValues
.
push
({
newValues
.
push
({
columnCode
:
key
,
columnCode
:
key
,
...
...
components/apolloTable/utils/memCols.ts
View file @
a57bc415
...
@@ -69,9 +69,6 @@ export const getLeftWidth = (
...
@@ -69,9 +69,6 @@ export const getLeftWidth = (
// 格式化列数据(添加缓存的前端属性)
// 格式化列数据(添加缓存的前端属性)
export
const
getFormatColumns
=
(
columns
:
ColumnProps
[],
cachedFeAttr
:
boolean
,
tableId
:
number
|
string
)
=>
{
export
const
getFormatColumns
=
(
columns
:
ColumnProps
[],
cachedFeAttr
:
boolean
,
tableId
:
number
|
string
)
=>
{
columns
.
sort
((
a
,
b
)
=>
{
return
a
.
orderNo
-
b
.
orderNo
;
});
if
(
cachedFeAttr
)
{
if
(
cachedFeAttr
)
{
const
cachedCols
=
getCache
({
tableId
});
const
cachedCols
=
getCache
({
tableId
});
if
(
cachedCols
)
{
if
(
cachedCols
)
{
...
@@ -93,8 +90,13 @@ export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean,
...
@@ -93,8 +90,13 @@ export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean,
orderNo
:
item
.
orderNo
,
orderNo
:
item
.
orderNo
,
};
};
});
});
saveCache
({
tableId
,
data
});
if
(
columns
.
length
>
0
)
{
saveCache
({
tableId
,
data
});
}
}
}
}
}
columns
.
sort
((
a
,
b
)
=>
{
return
a
.
orderNo
-
b
.
orderNo
;
});
return
columns
;
return
columns
;
};
};
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