Commit 519753ea by zhaochengxiang

定位

parent 906ad613
......@@ -131,6 +131,7 @@ function FC<RowType extends object = any>({ width, maxHeight, pageSize, pageNum,
}}
onRow={(record, index) => {
return {
id: record.id,
onClick: event => {
onRowClick?.(event, record)
},
......
......@@ -7,7 +7,7 @@ import { debounceTime, Subject } from 'rxjs'
import { defaultPage, usePage } from '../../../util/hooks/page'
import Table from '../../../util/Component/Table'
import { dispatch } from '../../../model'
import { getAssetRange, getAssetType, isSzseEnv, showMessage, showNotifaction } from '../../../util'
import { getAssetRange, getAssetType, getQueryParam, isSzseEnv, showMessage, showNotifaction } from '../../../util'
import { ResourceManageReference } from '../../../util/constant'
import PermissionButton from '../../../util/Component/PermissionButton'
import PermissionMenuItem from '../../../util/Component/PermissionMenuItem'
......@@ -96,6 +96,9 @@ const FC = (props) => {
const [page, setPage] = usePage()
const [ modal, contextHolder ] = Modal.useModal()
const locationIdRef = React.useRef('id', props?.location?.search)
const locationDidRef = React.useRef('did', props?.location?.search)
const setArgsAndPage = React.useCallback((params) => {
// 设置查询参数时将分页置为1
setPage(prevpg => {
......@@ -121,6 +124,12 @@ const FC = (props) => {
const storageChange = (e) => {
if (e.key === 'editAssetsChange') {
getAssets()
} else if (e.key === 'assetRelationOnClickEvent') {
locationIdRef.current = e.relation?.dataAssetId
locationDidRef.current = e.relation?.dirId
} else if (e.key === 'assetPathOnClickEvent') {
locationIdRef.current = e.id
locationDidRef.current = e.dirId
}
}
......@@ -161,7 +170,11 @@ const FC = (props) => {
if (node) {
setRow()
setSelectedRows([])
setPageAndArgs({ pageNum: 1, pageSize: page.pageSize })
if (locationIdRef.current && locationDidRef.current) {
getDataAssetLocation()
} else {
setPageAndArgs({ pageNum: 1, pageSize: page.pageSize })
}
}
}, [node])
......@@ -434,22 +447,49 @@ const FC = (props) => {
setLoading(false)
setData(data?.data)
setTotal(data?.total)
setRow(prevRow => {
if (!prevRow || (data?.data??[]).findIndex(item => item.id === prevRow.id) === -1) {
if (locationIdRef.current) {
const index = (data?.data??[]).findIndex(item => item.id === locationIdRef.current)
console.log('index', index)
if (index !== -1) {
onClick?.(data?.data[index])
setRow(data?.data[index])
} else {
if ((data?.data??[]).length > 0) {
onClick?.(data?.data[0])
return data?.data[0]
setRow(data?.data[0])
} else {
onClick?.(undefined)
return undefined
setRow()
}
}
return prevRow
})
}
setTimeout(() => {
var anchor = document.getElementById(`${locationIdRef.current}`)
anchor?.scrollIntoView()
locationIdRef.current = null
locationDidRef.current = null
}, 500)
} else {
setRow(prevRow => {
if (!prevRow || (data?.data??[]).findIndex(item => item.id === prevRow.id) === -1) {
if ((data?.data??[]).length > 0) {
onClick?.(data?.data[0])
return data?.data[0]
} else {
onClick?.(undefined)
return undefined
}
}
return prevRow
})
}
},
error: () => {
setLoading(false)
locationIdRef.current = null
locationDidRef.current = null
}
})
}
......@@ -475,6 +515,27 @@ const FC = (props) => {
}
}
const getDataAssetLocation = () => {
setLoading(true)
dispatch({
type: 'assetmanage.getDataAssetLocation',
payload: {
dataAssetId: locationIdRef.current,
dirId: locationDidRef.current,
},
callback: data => {
const newPageNum = parseInt(data.offset/page.pageSize + ((data.offset%page.pageSize===0)?0:1))
setPageAndArgs({ ...page, pageNum: newPageNum })
},
error: () => {
setLoading(false)
locationIdRef.current = null
locationDidRef.current = null
setPageAndArgs({ ...page, pageNum: 1 })
}
})
}
const onAddClick = () => {
setAddAssetParams({
visible: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment