Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
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
Administrator
bkunyun
Commits
c938c0d7
Commit
c938c0d7
authored
Oct 14, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 表格增加禁用功能
parent
28b78e92
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
index.tsx
src/components/BusinessComponents/QueueSelect/index.tsx
+5
-0
MyTableNew.tsx
src/components/mui/MyTableNew.tsx
+19
-4
No files found.
src/components/BusinessComponents/QueueSelect/index.tsx
View file @
c938c0d7
...
@@ -18,6 +18,7 @@ export type IQueueLi = {
...
@@ -18,6 +18,7 @@ export type IQueueLi = {
memory
:
number
;
memory
:
number
;
total
:
number
;
total
:
number
;
partition
:
string
;
partition
:
string
;
enabled
:
boolean
;
};
};
type
IQueueSelectProps
=
{
type
IQueueSelectProps
=
{
...
@@ -44,6 +45,7 @@ export type IShowCPULi = {
...
@@ -44,6 +45,7 @@ export type IShowCPULi = {
cpuName
:
string
;
cpuName
:
string
;
coreNum
:
number
;
coreNum
:
number
;
partition
:
string
;
partition
:
string
;
enabled
:
boolean
;
memoryList
:
Array
<
IMemoryLi
>
;
memoryList
:
Array
<
IMemoryLi
>
;
};
};
...
@@ -153,6 +155,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
...
@@ -153,6 +155,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
cpuName
:
item
.
cpuName
,
cpuName
:
item
.
cpuName
,
coreNum
:
item
.
coreNum
,
coreNum
:
item
.
coreNum
,
partition
:
item
.
partition
,
partition
:
item
.
partition
,
enabled
:
item
.
enabled
,
memoryList
:
[
memoryList
:
[
{
{
memory
:
item
.
memory
,
memory
:
item
.
memory
,
...
@@ -347,6 +350,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
...
@@ -347,6 +350,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
activeId=
{
activePartition
}
activeId=
{
activePartition
}
tableKey=
"partition"
tableKey=
"partition"
loading=
{
cpuLoading
}
loading=
{
cpuLoading
}
disableFn=
{
(
row
:
any
)
=>
!
row
.
enabled
}
></
MyTable
>
></
MyTable
>
)
}
)
}
{
queueType
===
"GPU"
&&
(
{
queueType
===
"GPU"
&&
(
...
@@ -364,6 +368,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
...
@@ -364,6 +368,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
activeId=
{
activePartition
}
activeId=
{
activePartition
}
tableKey=
"partition"
tableKey=
"partition"
loading=
{
gpuLoading
}
loading=
{
gpuLoading
}
disableFn=
{
(
row
:
any
)
=>
!
row
.
enabled
}
></
MyTable
>
></
MyTable
>
)
}
)
}
</
div
>
</
div
>
...
...
src/components/mui/MyTableNew.tsx
View file @
c938c0d7
...
@@ -46,6 +46,7 @@ interface IMyTableProps {
...
@@ -46,6 +46,7 @@ interface IMyTableProps {
nodataText
?:
any
;
// 无数据文案
nodataText
?:
any
;
// 无数据文案
handleRow
?:
any
;
// 点击一行
handleRow
?:
any
;
// 点击一行
activeId
?:
string
;
// 选中的一行的id
activeId
?:
string
;
// 选中的一行的id
disableFn
?:
any
;
// 禁用时根据disableFn来判断是否禁用
}
}
const
MyTable
=
(
props
:
IMyTableProps
)
=>
{
const
MyTable
=
(
props
:
IMyTableProps
)
=>
{
...
@@ -71,6 +72,7 @@ const MyTable = (props: IMyTableProps) => {
...
@@ -71,6 +72,7 @@ const MyTable = (props: IMyTableProps) => {
nodataText
,
nodataText
,
handleRow
,
handleRow
,
activeId
,
activeId
,
disableFn
,
}
=
props
;
}
=
props
;
const
theme
=
useMemo
(()
=>
{
const
theme
=
useMemo
(()
=>
{
...
@@ -236,6 +238,17 @@ const MyTable = (props: IMyTableProps) => {
...
@@ -236,6 +238,17 @@ const MyTable = (props: IMyTableProps) => {
[
selectItems
,
setSelectItems
]
[
selectItems
,
setSelectItems
]
);
);
const
handleRowFn
=
useCallback
(
(
row
:
any
)
=>
{
if
(
!
disableFn
)
{
handleRow
&&
handleRow
(
row
);
}
else
{
!
disableFn
(
row
)
&&
handleRow
&&
handleRow
(
row
);
}
},
[
disableFn
,
handleRow
]
);
const
handleSort
=
useCallback
(
const
handleSort
=
useCallback
(
(
field
:
string
)
=>
{
(
field
:
string
)
=>
{
if
(
sortState
?.
field
===
field
)
{
if
(
sortState
?.
field
===
field
)
{
...
@@ -370,10 +383,13 @@ const MyTable = (props: IMyTableProps) => {
...
@@ -370,10 +383,13 @@ const MyTable = (props: IMyTableProps) => {
{
rows
.
map
((
row
,
rowIndex
)
=>
(
{
rows
.
map
((
row
,
rowIndex
)
=>
(
<
TableRow
<
TableRow
key=
{
row
[
tableKey
]
||
rowIndex
}
key=
{
row
[
tableKey
]
||
rowIndex
}
onClick=
{
()
=>
handleRow
&&
handleRow
(
row
)
}
// onClick=
{()
=
>
handleRow
&&
handleRow(row)}
onClick=
{
()
=>
handleRowFn
(
row
)
}
sx=
{
{
sx=
{
{
background
:
background
:
activeId
===
row
[
tableKey
]
?
"rgba(237, 244, 255, 1)"
:
""
,
activeId
===
row
[
tableKey
]
?
"rgba(237, 244, 255, 1)"
:
""
,
cursor
:
disableFn
&&
disableFn
(
row
)
?
"no-drop"
:
""
,
opacity
:
disableFn
&&
disableFn
(
row
)
?
"0.3"
:
""
,
}
}
}
}
>
>
{
hasCheckbox
&&
(
{
hasCheckbox
&&
(
...
@@ -393,12 +409,10 @@ const MyTable = (props: IMyTableProps) => {
...
@@ -393,12 +409,10 @@ const MyTable = (props: IMyTableProps) => {
)
}
)
}
{
headCells
.
map
((
headCell
,
index
)
=>
(
{
headCells
.
map
((
headCell
,
index
)
=>
(
<
TableCell
key=
{
index
}
align=
"left"
width=
{
headCell
.
width
}
>
<
TableCell
key=
{
index
}
align=
"left"
width=
{
headCell
.
width
}
>
{
/* {row[headCell.id]} */
}
{
headCell
.
showOverflowTooltip
&&
(
{
headCell
.
showOverflowTooltip
&&
(
<
MyTooltip
title=
{
row
[
headCell
.
id
]
}
>
<
MyTooltip
title=
{
row
[
headCell
.
id
]
}
>
<
div
<
div
style=
{
{
style=
{
{
// width: headCell.width,
width
:
Number
(
headCell
.
width
)
-
32
||
""
,
width
:
Number
(
headCell
.
width
)
-
32
||
""
,
overflow
:
"hidden"
,
overflow
:
"hidden"
,
textOverflow
:
"ellipsis"
,
textOverflow
:
"ellipsis"
,
...
@@ -433,8 +447,9 @@ const MyTable = (props: IMyTableProps) => {
...
@@ -433,8 +447,9 @@ const MyTable = (props: IMyTableProps) => {
headCells
,
headCells
,
nodataText
,
nodataText
,
loading
,
loading
,
handleRow
,
handleRow
Fn
,
activeId
,
activeId
,
disableFn
,
]);
]);
const
randerTableFooter
=
useMemo
(()
=>
{
const
randerTableFooter
=
useMemo
(()
=>
{
...
...
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