Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
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
zhaochengxiang
szse
Commits
e89086ec
Commit
e89086ec
authored
Jan 11, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模型支持排序
parent
caf227d9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
index.less
src/index.less
+1
-1
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+34
-4
No files found.
src/index.less
View file @
e89086ec
...
@@ -116,7 +116,7 @@ div[id^='__qiankun_microapp_wrapper_'] {
...
@@ -116,7 +116,7 @@ div[id^='__qiankun_microapp_wrapper_'] {
}
}
.yy-table-tbody > tr > td {
.yy-table-tbody > tr > td {
padding:
12
px 8px !important;
padding:
8
px 8px !important;
}
}
.yy-table-tbody > .yy-table-measure-row > td {
.yy-table-tbody > .yy-table-measure-row > td {
...
...
src/view/Manage/Model/Component/ModelTable.jsx
View file @
e89086ec
...
@@ -38,6 +38,7 @@ const ModelTable = (props) => {
...
@@ -38,6 +38,7 @@ const ModelTable = (props) => {
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
subSelectedRowKeys
,
setSubSelectedRowKeys
]
=
useState
([]);
const
[
subSelectedRowKeys
,
setSubSelectedRowKeys
]
=
useState
([]);
// const [ mouseEnterKey, setMouseEnterKey ] = useState(null);
// const [ mouseEnterKey, setMouseEnterKey ] = useState(null);
const
[
sortRule
,
setSortRule
]
=
useState
(
null
);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
subData
,
setSubData
]
=
useState
([]);
const
[
subData
,
setSubData
]
=
useState
([]);
...
@@ -81,6 +82,8 @@ const ModelTable = (props) => {
...
@@ -81,6 +82,8 @@ const ModelTable = (props) => {
dataIndex
:
'name'
,
dataIndex
:
'name'
,
width
:
isSzseEnv
?
360
:
160
,
width
:
isSzseEnv
?
360
:
160
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
text
,
record
,
_
)
=>
{
render
:
(
text
,
record
,
_
)
=>
{
return
(
return
(
<
Tooltip
title=
{
text
||
''
}
>
<
Tooltip
title=
{
text
||
''
}
>
...
@@ -96,6 +99,8 @@ const ModelTable = (props) => {
...
@@ -96,6 +99,8 @@ const ModelTable = (props) => {
dataIndex
:
'cnName'
,
dataIndex
:
'cnName'
,
width
:
isSzseEnv
?
420
:
160
,
width
:
isSzseEnv
?
420
:
160
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
<
Tooltip
title=
{
text
||
''
}
>
<
Tooltip
title=
{
text
||
''
}
>
...
@@ -108,6 +113,8 @@ const ModelTable = (props) => {
...
@@ -108,6 +113,8 @@ const ModelTable = (props) => {
title
:
'模型描述'
,
title
:
'模型描述'
,
dataIndex
:
'remark'
,
dataIndex
:
'remark'
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
width
:
200
,
width
:
200
,
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
...
@@ -146,6 +153,8 @@ const ModelTable = (props) => {
...
@@ -146,6 +153,8 @@ const ModelTable = (props) => {
dataIndex
:
'editor'
,
dataIndex
:
'editor'
,
width
:
100
,
width
:
100
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
},
},
// {
// {
// title: '标签',
// title: '标签',
...
@@ -331,13 +340,27 @@ const ModelTable = (props) => {
...
@@ -331,13 +340,27 @@ const ModelTable = (props) => {
})
})
useEffect
(()
=>
{
useEffect
(()
=>
{
const
_data
=
paginate
(
data
||
[],
pageNum
,
pageSize
);
const
newData
=
[...
data
];
if
(
sortRule
)
{
if
(
sortRule
.
order
===
'ascend'
)
{
newData
.
sort
((
item1
,
item2
)
=>
{
return
item1
[
sortRule
.
field
].
localeCompare
(
item2
[
sortRule
.
field
]);
})
}
else
if
(
sortRule
.
order
===
'descend'
)
{
newData
.
sort
((
item1
,
item2
)
=>
{
return
item2
[
sortRule
.
field
].
localeCompare
(
item1
[
sortRule
.
field
]);
})
}
}
const
_data
=
paginate
(
newData
||
[],
pageNum
,
pageSize
);
autoResizeColumns
(
_data
);
autoResizeColumns
(
_data
);
setFilterData
(
_data
);
setFilterData
(
_data
);
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
data
,
pagination
])
},
[
data
,
pagination
,
sortRule
])
const
autoResizeColumns
=
(
val
)
=>
{
const
autoResizeColumns
=
(
val
)
=>
{
if
((
val
||
[]).
length
>
0
)
{
if
((
val
||
[]).
length
>
0
)
{
...
@@ -359,8 +382,8 @@ const ModelTable = (props) => {
...
@@ -359,8 +382,8 @@ const ModelTable = (props) => {
})
})
let
newColumns
=
[...
columns
];
let
newColumns
=
[...
columns
];
newColumns
[
1
].
width
=
getTextWidth
(
name
)
+
2
4
;
newColumns
[
1
].
width
=
getTextWidth
(
name
)
+
2
0
;
newColumns
[
2
].
width
=
getTextWidth
(
cnName
)
+
2
4
;
newColumns
[
2
].
width
=
getTextWidth
(
cnName
)
+
2
0
;
let
minWidth
=
isSzseEnv
?
200
:
120
;
let
minWidth
=
isSzseEnv
?
200
:
120
;
...
@@ -527,6 +550,12 @@ const ModelTable = (props) => {
...
@@ -527,6 +550,12 @@ const ModelTable = (props) => {
setColumns
(
nextColumns
);
setColumns
(
nextColumns
);
};
};
const
onTableChange
=
(
pagination
,
filters
,
sorter
,
extra
)
=>
{
if
(
sorter
)
{
setSortRule
(
sorter
);
}
}
const
rowSelection
=
{
const
rowSelection
=
{
selectedRowKeys
,
selectedRowKeys
,
onChange
:
onSelectChange
,
onChange
:
onSelectChange
,
...
@@ -604,6 +633,7 @@ const ModelTable = (props) => {
...
@@ -604,6 +633,7 @@ const ModelTable = (props) => {
style
:
{
backgroundColor
:
(
record
?.
id
===
anchorId
)?
'#e7f7ff'
:
'transparent'
},
style
:
{
backgroundColor
:
(
record
?.
id
===
anchorId
)?
'#e7f7ff'
:
'transparent'
},
}
}
}
}
}
}
onChange=
{
onTableChange
}
expandable=
{
expandable
}
expandable=
{
expandable
}
sticky=
{
!
modelId
}
sticky=
{
!
modelId
}
/>
/>
...
...
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