Commit 1f2792f6 by 放生的三文鱼

草稿完成排序

parent 33dbe6b6
......@@ -376,7 +376,7 @@ export function getDrafts(payload) {
}
export function listDraftFilterElementsGroupByType(payload) {
return GetJSON("/dataassetmanager/elementApi/listDraftFilterElementsGroupByType", payload);
return GetJSON("/dataassetmanager/elementApi/listDraftFilterElements", payload);
}
......
......@@ -84,6 +84,10 @@ const FC = (props) => {
visible: false,
ids: undefined
})
const [sorterParams, setSorterParams] = React.useState({
sortField:'',
sortDirection:''
})
const [rightRow, setRightRow] = React.useState()
const [modal, contextHolder] = Modal.useModal();
......@@ -212,14 +216,14 @@ const FC = (props) => {
const [columns, tableData, total] = React.useMemo(() => {
let [newColumns, newTableData] = [[], []]
for (const element of filterElements??[]) {
for (const name of element.names??[]) {
filterElements?.forEach(item => {
const name = item?.name
const column = {
title: name,
dataIndex: name,
dataIndex: item?.enName,
ellipsis: true,
width: 120,
sorter:true,
render: (text, record) => {
return (
<Tooltip title={text}>
......@@ -230,10 +234,7 @@ const FC = (props) => {
);
}
}
if (name === '编号') {
column.width = 60
} else if (name === '中文名称'|| name === '岗位中文名') {
if (name === '中文名称'|| name === '岗位中文名') {
column.width = isSzseEnv ? 230 : 160
} else if (name === '英文名称' || name === '岗位英文名') {
column.width = isSzseEnv ? 224 : 160
......@@ -253,10 +254,10 @@ const FC = (props) => {
}
newColumns.push(column)
}
}
});
if (!loadingFilterElements) {
for (const item of (data?.data??[])) {
let index = 0
let newItem = {}
......@@ -265,7 +266,6 @@ const FC = (props) => {
if ((newColumns??[]).length > index) {
const name = newColumns[index].dataIndex
newItem[name] = value
if (specialCol.indexOf((name??'').toLowerCase()) !== -1) {
const user = users?.filter((user)=>(user.pernr===value))
if ((user??[]).length > 0) {
......@@ -273,15 +273,15 @@ const FC = (props) => {
}
}
}
index++
}
}
console.log('newitem',newItem);
newTableData.push({...item, ...newItem})
}
}
return [[indexCol, pathCol, ...newColumns, ...fixedCols]
, newTableData, data?.total??0]
}, [filterElements, data, loadingFilterElements, users, fixedCols, keyword, pathCol, indexCol, pagination])
......@@ -382,6 +382,7 @@ const FC = (props) => {
templateType: currentTemplateValue,
keyword: encodeURIComponent(keyword??''),
state: code,
...sorterParams,
pageNum: pagination.pageNum,
pageSize: pagination.pageSize,
},
......@@ -558,6 +559,28 @@ const FC = (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
})
};
React.useEffect(()=>{
if(sorterParams.sortDirection||sorterParams.sortField) {
getDrafts()
}
},[sorterParams])
return (
<div style={{ backgroundColor: '#fff', height: '100%' }}>
<div className='flex p-3' style={{
......@@ -687,6 +710,8 @@ const FC = (props) => {
menuPermissions={menuData}
onMenuItemClick={onRightMenuItemClick}
scroll={{ y: 'calc(100vh - 209px - 72px - 57px)' }}
onChange={handleTableChange}
sortDirections={['ascend', 'descend','']}
/>
<Pagination
className="text-center mt-3"
......
......@@ -5,7 +5,7 @@ import { Resizable } from 'react-resizable';
import ResizeObserver from 'rc-resize-observer';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import LocalStorage from 'local-storage';
import { filter, Subject } from "rxjs";
import { Subject } from "rxjs";
import produce from 'immer'
import { useDebounceEffect } from 'ahooks'
......
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