Commit 33dbe6b6 by 放生的三文鱼

管理和浏览端完成排序

parent 7c4f8953
...@@ -32,8 +32,11 @@ export function listFilterElements() { ...@@ -32,8 +32,11 @@ export function listFilterElements() {
return GetJSON("/dataassetmanager/elementApi/listFilterElements"); return GetJSON("/dataassetmanager/elementApi/listFilterElements");
} }
// export function listFilterElementsGroupByType(payload) {
// return GetJSON("/dataassetmanager/elementApi/listFilterElementsGroupByType", payload);
// }
export function listFilterElementsGroupByType(payload) { export function listFilterElementsGroupByType(payload) {
return GetJSON("/dataassetmanager/elementApi/listFilterElementsGroupByType", payload); return GetJSON("/dataassetmanager/elementApi/listFilterElements", payload);
} }
export function setupFilterElementIds(payload) { export function setupFilterElementIds(payload) {
......
...@@ -5,7 +5,7 @@ import { Resizable } from 'react-resizable'; ...@@ -5,7 +5,7 @@ import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer'; import ResizeObserver from 'rc-resize-observer';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify"; import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import LocalStorage from 'local-storage'; import LocalStorage from 'local-storage';
import { Subject } from "rxjs"; import { filter, Subject } from "rxjs";
import produce from 'immer' import produce from 'immer'
import { useDebounceEffect } from 'ahooks' import { useDebounceEffect } from 'ahooks'
...@@ -166,6 +166,10 @@ const AssetTable = (props) => { ...@@ -166,6 +166,10 @@ const AssetTable = (props) => {
id: undefined id: undefined
}) })
const [permissions, setPermissions] = React.useState([]) const [permissions, setPermissions] = React.useState([])
const [sorterParams, setSorterParams] = React.useState({
sortField:'',
sortDirection:''
})
const [ modal, contextHolder ] = Modal.useModal(); const [ modal, contextHolder ] = Modal.useModal();
const anchorId = getQueryParam(AnchorId, props?.location?.search); const anchorId = getQueryParam(AnchorId, props?.location?.search);
...@@ -265,6 +269,8 @@ const AssetTable = (props) => { ...@@ -265,6 +269,8 @@ const AssetTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
useEffect(() => { useEffect(() => {
setSelectItem({}); setSelectItem({});
setCheckedKeys([]); setCheckedKeys([]);
...@@ -358,7 +364,6 @@ const AssetTable = (props) => { ...@@ -358,7 +364,6 @@ const AssetTable = (props) => {
let [allowChangeDirectory, allowDelete, allowOffline, allowAddTag, allowSubscribe,allowAddDir] = [true, true, true, true, true,true] let [allowChangeDirectory, allowDelete, allowOffline, allowAddTag, allowSubscribe,allowAddDir] = [true, true, true, true, true,true]
for (const row of selectedRows??[]) { for (const row of selectedRows??[]) {
console.log('tt',row)
const changeDirecotoryIndex = (row.allowButtons??[]).findIndex(item => item==='changeDir') const changeDirecotoryIndex = (row.allowButtons??[]).findIndex(item => item==='changeDir')
const deleteIndex = (row.allowButtons??[]).findIndex(item => item==='delete') const deleteIndex = (row.allowButtons??[]).findIndex(item => item==='delete')
const offlineIndex = (row.allowButtons??[]).findIndex(item => item==='offline') const offlineIndex = (row.allowButtons??[]).findIndex(item => item==='offline')
...@@ -394,30 +399,23 @@ const AssetTable = (props) => { ...@@ -394,30 +399,23 @@ const AssetTable = (props) => {
setAddDir?.(adddirAble) setAddDir?.(adddirAble)
},[adddirAble]) },[adddirAble])
const realAssets = useMemo(() => {
const newAssets = [...assets];
// if (users?.length > 0 && assets?.length > 0 && columns?.length > 0) {
// const specialCol = ['数据关键用户', '业务数据owner', 'it责任人', '创建人', '更新人'];
// const indexArray = [];
// columns.forEach((item, index) => {
// if (specialCol.indexOf(item.title?.toLowerCase()) !== -1) {
// indexArray.push(index);
// }
// });
// newAssets?.forEach((item) => { // 直接使用数组作为数据源,添加key
// indexArray?.forEach(index => { const dataSource = useMemo(()=>{
// const user = users?.filter((user)=>(user.pernr===item[`element${index+1}`])); let data = []
// if (user && user.length > 0) { assets?.map((asset) => {
// item[`element${index+1}`] = user[0].nachn?`${user[0].nachn}(${user[0].pernr})`:user[0].pernr; let temp = {}
// } asset?.elementValuesWithoutTypeAttribute?.map((row,rowIndex)=>{
// }) const key = columns?.[rowIndex]?.dataIndex
// }) temp[key] = row
// } })
temp = {...asset,...temp}
data.push(temp)
});
console.log('data',data);
return newAssets; return data
}, [users, assets, columns]) },[assets,columns])
const menuData = React.useMemo(() => { const menuData = React.useMemo(() => {
const newMenuData = [] const newMenuData = []
...@@ -564,14 +562,14 @@ const AssetTable = (props) => { ...@@ -564,14 +562,14 @@ const AssetTable = (props) => {
let index = 0, _metadataIndex = ''; let index = 0, _metadataIndex = '';
(data||[]).forEach(group => { (data||[]).forEach(group => {
(group.names||[]).forEach((name, i) => {
index++; index++;
const name = group.name
const params = { const params = {
title: name, title: name,
dataIndex: `element${index}`, dataIndex: group.enName,
ellipsis: true, ellipsis: true,
width: 150, width: 150,
sorter:true,
render: (text, record) => { render: (text, record) => {
return ( return (
<Tooltip title={text||''}> <Tooltip title={text||''}>
...@@ -632,7 +630,7 @@ const AssetTable = (props) => { ...@@ -632,7 +630,7 @@ const AssetTable = (props) => {
_columns.push(params); _columns.push(params);
}) })
}) console.log('columns',_columns);
setAssets([]); setAssets([]);
...@@ -657,6 +655,7 @@ const AssetTable = (props) => { ...@@ -657,6 +655,7 @@ const AssetTable = (props) => {
currentDirIsCustom: nodeType==='custom', currentDirIsCustom: nodeType==='custom',
pageNum, pageNum,
pageSize, pageSize,
...sorterParams,
range: getAssetRange(reference), range: getAssetRange(reference),
keyword: encodeURIComponent(keyword) keyword: encodeURIComponent(keyword)
}; };
...@@ -695,7 +694,7 @@ const AssetTable = (props) => { ...@@ -695,7 +694,7 @@ const AssetTable = (props) => {
(data.data||[]).forEach(asset => { (data.data||[]).forEach(asset => {
let _asset = {...asset}, index = 0; let _asset = {...asset}, index = 0;
(asset.elementValues||[]).forEach((elementValue) => { (asset.elementValuesWithoutTypeAttribute||[]).forEach((elementValue) => {
(elementValue.values||[]).forEach((value, i) => { (elementValue.values||[]).forEach((value, i) => {
...@@ -1208,6 +1207,28 @@ const AssetTable = (props) => { ...@@ -1208,6 +1207,28 @@ const AssetTable = (props) => {
} }
} }
const handleTableChange = (pagination, filters, sorter) => {
const temp = sorter?.order; // 或 'descend' 或 ''
let sortDirection;
if (temp === 'ascend') {
sortDirection = 'ASC';
} else if (temp === 'descend') {
sortDirection = 'DESC';
} else {
sortDirection = ''; // 或者其他默认值
}
setSorterParams({
sortField:sorter?.field,
sortDirection
})
};
useEffect(()=>{
if(sorterParams.sortDirection||sorterParams.sortField) {
getDataAssets()
}
},[sorterParams])
return( return(
<div className={classes}> <div className={classes}>
<div <div
...@@ -1393,8 +1414,10 @@ const AssetTable = (props) => { ...@@ -1393,8 +1414,10 @@ const AssetTable = (props) => {
// columns={reference===AssetManageReference?[indexCol, ...columns, tagCol]:[indexCol, ...columns]} // columns={reference===AssetManageReference?[indexCol, ...columns, tagCol]:[indexCol, ...columns]}
columns={reference===AssetManageReference?[indexCol, ...columns, tagCol]:[indexCol, ...columns, tagCol]} columns={reference===AssetManageReference?[indexCol, ...columns, tagCol]:[indexCol, ...columns, tagCol]}
rowKey='id' rowKey='id'
dataSource={realAssets} dataSource={dataSource}
pagination={false} pagination={false}
onChange={handleTableChange}
sortDirections={['ascend', 'descend','']}
size='default' size='default'
scroll={{ y: scrollY }} scroll={{ y: scrollY }}
/> />
......
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