Commit 1f2792f6 by 放生的三文鱼

草稿完成排序

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