Skip to content

Commit

Permalink
修改bug
Browse files Browse the repository at this point in the history
  • Loading branch information
luoluoTH committed Feb 19, 2024
1 parent 90f8424 commit 02d5099
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const PortAssetTable: React.FC<PortAssetTableProp> = (props) => {
// params.ComplexSelect 此条件搜索点击频繁
const query = onGetQueryProcessing()
setParams({...query})
setIsRefresh(!isRefresh)
}, [queryList, advancedConfig])
useEffect(() => {
getPortsGroup()
Expand Down Expand Up @@ -165,7 +166,7 @@ export const PortAssetTable: React.FC<PortAssetTableProp> = (props) => {
...cloneDeep(defQueryPortsRequest),
State: props.closed ? "closed" : "open"
})
setKeywords('')
setKeywords("")
setQueryList(undefined)
setIsRefresh(!isRefresh)
})
Expand Down
58 changes: 45 additions & 13 deletions app/renderer/src/main/src/pages/assetViewer/PortTable/PortTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ export const PortTable: React.FC<PortTableProps> = React.memo(
}
apiQueryPortsBase(params)
.then((rsp: QueryGeneralResponse<PortAsset>) => {
// console.log('rsp,prePage.current',prePage.current,params,rsp.Pagination,rsp.Data.map(ele=>ele.Id))
console.log(
"rsp,prePage.current",
prePage.current,
params,
rsp.Pagination,
rsp.Data.map((ele) => ele.Id)
)
const d = init ? rsp.Data : response.Data.concat(rsp.Data)
prePage.current += 1
if (init) {
Expand Down Expand Up @@ -275,26 +281,42 @@ export const PortTable: React.FC<PortTableProps> = React.memo(
}
const scrollTop = getScrollTop()
if (scrollTop < 10 && offsetDataInTop?.length > 0) {
const newResData = response.Data.filter((ele) => !offsetDataInTop.find((ele2) => ele.Id === ele2.Id))
// 滚动条滚动到顶部的时候,如果偏移缓存数据中有数据,第一次优先将缓存数据放在总的数据中
setResponse((oldResponse) => ({
...oldResponse,
Data: [...offsetDataInTop, ...oldResponse.Data]
}))

setResponse({
...response,
Data: [...offsetDataInTop, ...response.Data]
})
setAllResponse({
...allResponse,
Data: [...offsetDataInTop, ...allResponse.Data]
})
setOffsetDataInTop([])
return
}
apiQueryPortsIncrementOrderAsc(params).then((rsp) => {
// console.log('getIncrementInTop',params,rsp.Pagination,rsp.Data.map(ele=>ele.Id))
console.log(
"getIncrementInTop",
params,
rsp.Pagination,
rsp.Data.map((ele) => ele.Id)
)
if (rsp.Data.length > 0) {
afterId.current = rsp.Data[0].Id
}
const newData = rsp.Data
const newTotal = total + rsp.Data.length
if (scrollTop < 10) {
setResponse((oldResponse) => ({
...oldResponse,
Data: [...newData, ...oldResponse.Data]
}))
// const newResData=response.Data.filter(ele=>!newData.find(ele2=>ele.Id===ele2.Id))
setResponse({
...response,
Data: [...newData, ...response.Data]
})
setAllResponse({
...allResponse,
Data: [...newData, ...allResponse.Data]
})
setTotal(newTotal)
} else {
setOffsetDataInTop([...newData, ...offsetDataInTop])
Expand All @@ -305,7 +327,7 @@ export const PortTable: React.FC<PortTableProps> = React.memo(
const columns: ColumnsTypeProps[] = useMemo<ColumnsTypeProps[]>(() => {
return [
{
title: "Id",
title: "序号",
dataKey: "Id",
fixed: "left",
ellipsis: false,
Expand Down Expand Up @@ -380,11 +402,19 @@ export const PortTable: React.FC<PortTableProps> = React.memo(
header.push(item.title)
filterVal.push(item.dataKey)
})
exportData = portAssetFormatJson(filterVal, allResponse)
exportData = portAssetFormatJson(filterVal, allResponse.Data)
resolve({
header,
exportData,
response: response
response: {
...allResponse,
Pagination: {
Page: 1,
Limit: total,
OrderBy: query.Pagination.OrderBy,
Order: query.Pagination.Order
}
}
})
})
})
Expand Down Expand Up @@ -457,6 +487,7 @@ export const PortTable: React.FC<PortTableProps> = React.memo(
defLimitRef.current = limit
if (total === 0) {
// init
setInterval(undefined)
update(true)
return
} else if (tableBodyHeightRef.current <= height) {
Expand Down Expand Up @@ -596,6 +627,7 @@ export const PortTable: React.FC<PortTableProps> = React.memo(
}
}}
enableDrag={true}
useUpAndDown
containerClassName={containerClassName}
onChange={onTableChange}
/>
Expand Down

0 comments on commit 02d5099

Please sign in to comment.