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
a7ee8cc3
Commit
a7ee8cc3
authored
Aug 14, 2024
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加工内容历史版本优化
parent
70411e92
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
19 deletions
+65
-19
Table.tsx
src/util/Component/Table.tsx
+5
-3
VersionCompareProcess.jsx
src/view/Manage/Model/Component/VersionCompareProcess.jsx
+60
-16
No files found.
src/util/Component/Table.tsx
View file @
a7ee8cc3
...
@@ -69,12 +69,13 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
...
@@ -69,12 +69,13 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
setDefaultWidth
(
columns
,
contentWidth
)
setDefaultWidth
(
columns
,
contentWidth
)
paddingCol
.
current
.
width
=
0
paddingCol
.
current
.
width
=
0
const
c
ols
=
columns
const
newC
ols
=
columns
.
map
((
col
,
index
)
=>
{
.
map
((
col
,
index
)
=>
{
const
render
=
getRender
(
col
);
const
render
=
getRender
(
col
);
const
colWidth
=
col
.
width
??
100
;
const
colWidth
=
col
.
width
??
100
;
return
{
return
{
...
col
,
/* colRef: createRef(), */
width
:
colWidth
,
render
,
ellipsis
:
true
,
ellipsis
:
true
,
...
col
,
/* colRef: createRef(), */
width
:
colWidth
,
render
,
onHeaderCell
:
(
column
:
any
)
=>
({
onHeaderCell
:
(
column
:
any
)
=>
({
width
:
column
.
width
,
width
:
column
.
width
,
// colRef: column.colRef,
// colRef: column.colRef,
...
@@ -82,7 +83,8 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
...
@@ -82,7 +83,8 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
}),
}),
};
};
})
})
setCols
(
cols
)
setCols
(
newCols
)
}
}
},
[
columns
,
tableWidth
,
width
,
extraColWidth
])
},
[
columns
,
tableWidth
,
width
,
extraColWidth
])
...
...
src/view/Manage/Model/Component/VersionCompareProcess.jsx
View file @
a7ee8cc3
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useEffect
,
useState
,
useRef
}
from
'react'
;
import
{
Typography
,
Tooltip
,
Table
}
from
'antd'
;
import
{
Typography
,
Tooltip
}
from
'antd'
;
import
Table
from
'../../../../util/Component/Table'
;
const
{
Text
,
Paragraph
,
Title
}
=
Typography
;
const
{
Text
,
Paragraph
,
Title
}
=
Typography
;
...
@@ -9,43 +10,74 @@ const VersionCompareProcess = (props) => {
...
@@ -9,43 +10,74 @@ const VersionCompareProcess = (props) => {
const
[
columns
,
setColumns
]
=
useState
([]);
const
[
columns
,
setColumns
]
=
useState
([]);
const
[
tableData
,
setTableData
]
=
useState
([]);
const
[
tableData
,
setTableData
]
=
useState
([]);
const
compareTableDataRef
=
useRef
();
const
hiddenDivRef
=
useRef
();
useEffect
(()
=>
{
useEffect
(()
=>
{
const
newColumns
=
[];
const
newColumns
=
[];
(
data
?.
heads
?.
processingHead
||
[]).
forEach
((
item
,
index
)
=>
{
(
data
?.
heads
?.
processingHead
||
[]).
forEach
((
item
,
index
)
=>
{
newColumns
.
push
(
{
const
newColumn
=
{
title
:
item
||
''
,
title
:
item
||
''
,
dataIndex
:
`column
${
index
}
`
,
dataIndex
:
`column
${
index
}
`
,
render
:
(
attrValue
,
record
,
index
)
=>
{
render
:
(
attrValue
,
record
,
_index
)
=>
{
let
stateClassName
=
''
,
height
=
0
,
compareHeight
=
0
;
let
stateClassName
=
''
;
if
(
attrValue
?.
state
===
'ADD'
||
attrValue
?.
state
===
'UPDATE'
)
{
if
(
attrValue
?.
state
===
'ADD'
||
attrValue
?.
state
===
'UPDATE'
)
{
stateClassName
=
'add'
;
stateClassName
=
'add'
;
}
else
if
(
attrValue
?.
state
===
'DELETE'
)
{
}
else
if
(
attrValue
?.
state
===
'DELETE'
)
{
stateClassName
=
'delete'
;
stateClassName
=
'delete'
;
}
}
const
compareValue
=
compareTableDataRef
.
current
?.[
_index
]?.[
`column
${
index
}
`
]?.
value
;
console
.
log
(
'compareValue'
,
compareValue
)
const
_span
=
document
.
createElement
(
'span'
);
_span
.
innerText
=
attrValue
?.
value
??
''
;
hiddenDivRef
.
current
?.
appendChild
(
_span
);
height
=
hiddenDivRef
.
current
?.
getBoundingClientRect
().
height
hiddenDivRef
.
current
?.
removeChild
(
_span
);
_span
.
innerText
=
compareValue
??
''
;
hiddenDivRef
.
current
?.
appendChild
(
_span
);
compareHeight
=
hiddenDivRef
.
current
?.
getBoundingClientRect
().
height
hiddenDivRef
.
current
?.
removeChild
(
_span
);
return
(
return
(
<
Paragraph
>
<
div
style=
{
{
position
:
'relative'
}
}
>
<
Tooltip
title=
{
attrValue
?.
value
||
''
}
>
{
<
Text
className=
{
stateClassName
}
ellipsis=
{
true
}
>
{
attrValue
?.
value
||
''
}
</
Text
>
(
height
>
compareHeight
)
?
<
div
className=
{
stateClassName
}
>
{
attrValue
?.
value
||
''
}
</
div
>
:
<>
</
Tooltip
>
<
div
className=
{
stateClassName
}
style=
{
{
</
Paragraph
>
position
:
'absolute'
,
top
:
'50%'
,
left
:
0
,
transform
:
'translateY(-50%)'
,
}
}
>
{
attrValue
?.
value
||
''
}
</
div
>
<
div
style=
{
{
visibility
:
'hidden'
}
}
>
{
compareValue
}
</
div
>
</>
}
</
div
>
);
);
},
},
width
:
60
,
ellipsis
:
false
,
ellipsis
:
true
,
};
});
newColumns
.
push
(
newColumn
);
})
})
setColumns
(
newColumns
);
setColumns
(
newColumns
);
const
newTableData
=
[];
const
newTableData
=
[]
,
newCompareTableData
=
[]
;
let
processingValue
=
[];
let
processingValue
=
[]
,
compareProcessingValue
=
[]
;
if
(
direction
===
'left'
)
{
if
(
direction
===
'left'
)
{
processingValue
=
data
?.
left
?.
processingValue
||
[];
processingValue
=
data
?.
left
?.
processingValue
||
[];
compareProcessingValue
=
data
?.
right
?.
processingValue
||
[];
}
else
if
(
direction
===
'right'
)
{
}
else
if
(
direction
===
'right'
)
{
processingValue
=
data
?.
right
?.
processingValue
||
[];
processingValue
=
data
?.
right
?.
processingValue
||
[];
compareProcessingValue
=
data
?.
left
?.
processingValue
||
[];
}
}
(
processingValue
||
[]).
forEach
((
attrItem
)
=>
{
(
processingValue
||
[]).
forEach
((
attrItem
)
=>
{
...
@@ -54,8 +86,17 @@ const VersionCompareProcess = (props) => {
...
@@ -54,8 +86,17 @@ const VersionCompareProcess = (props) => {
newAttrItem
[
`column
${
index
}
`
]
=
item
;
newAttrItem
[
`column
${
index
}
`
]
=
item
;
})
})
newTableData
.
push
(
newAttrItem
);
newTableData
.
push
(
newAttrItem
);
});
(
compareProcessingValue
||
[]).
forEach
((
attrItem
)
=>
{
let
newAttrItem
=
{};
(
attrItem
||
[]).
forEach
((
item
,
index
)
=>
{
newAttrItem
[
`column
${
index
}
`
]
=
item
;
})
})
newCompareTableData
.
push
(
newAttrItem
);
});
compareTableDataRef
.
current
=
newCompareTableData
;
setTableData
(
newTableData
);
setTableData
(
newTableData
);
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
...
@@ -73,6 +114,9 @@ const VersionCompareProcess = (props) => {
...
@@ -73,6 +114,9 @@ const VersionCompareProcess = (props) => {
dataSource=
{
tableData
}
dataSource=
{
tableData
}
pagination=
{
false
}
pagination=
{
false
}
/>
/>
<
div
style=
{
{
width
:
0
,
height
:
0
}
}
>
<
div
style=
{
{
width
:
100
}
}
ref=
{
hiddenDivRef
}
></
div
>
</
div
>
</
div
>
</
div
>
);
);
}
}
...
...
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