Commit 45cc51ab by zhujian

fix:排序

parent 65495721
......@@ -26,16 +26,33 @@ function StudyTable(props: any) {
const [list, setList] = useState<any[]>([]);
const [total, setTotal] = useState<any>(0);
const [name, setName] = useState<any>('');
const timer = useRef<any>(null)
const [orderFiled, setOrderFiled] = useState<any>(null);
const [sort, setSort] = useState<any>(null);
const timer = useRef<any>(null);
const sortNameMap: any = {
learnPercentage: 'LEARN_NUM',
latelyLearnTime: 'LATE_LEARN_TIME',
startLearnTime: 'START_LEARN_TIME',
}
useEffect(() => {
getList()
}, [query])
}, [query, orderFiled, sort])
function getList() {
Service.Hades('public/hades/getTaskCustomerRecordPage', query).then((res: any) => {
const _query = { ...query };
delete _query.sortMap;
if (sort) {
_query.sortMap = {
[sortNameMap[orderFiled]]: sort === "ascend" ? 'SORT_ASC' : 'SORT_DESC'
}
}
Service.Hades('public/hades/getTaskCustomerRecordPage', _query).then((res: any) => {
res.result.records.map((item: any) => {
item.department =item.departmentNameList.map((_item:any)=>{
item.department = item.departmentNameList.map((_item: any) => {
if (_item == '1000') {
return '微信'
} else {
......@@ -49,11 +66,6 @@ function StudyTable(props: any) {
})
}
const columns = [
{
title: '学员',
......@@ -75,11 +87,11 @@ function StudyTable(props: any) {
render: (val: any, record: any) => {
return <div>
{
record.department.map((item:any,index:number)=>{
if((index+1) ==record.department.length){
record.department.map((item: any, index: number) => {
if ((index + 1) == record.department.length) {
return item
}else{
return [item,';']
} else {
return [item, ';']
}
})
......@@ -105,7 +117,9 @@ function StudyTable(props: any) {
{
title: '学习进度',
key: 'learnPercentage',
sorter: true,
dataIndex: 'learnPercentage',
sortOrder: (orderFiled == 'learnPercentage') ? sort : null,
render: (val: any, record: any) => {
return `${val}%`;
},
......@@ -117,8 +131,8 @@ function StudyTable(props: any) {
dataIndex: 'latelyLearnTime',
sorter: true,
width: 240,
sortOrder: (orderFiled == 'latelyLearnTime') ? sort : null,
render: (val: any, record: any) => {
return `${formatDate('YYYY-MM-DD H:i', parseInt(record.latelyLearnTime))}`;
},
},
......@@ -128,6 +142,8 @@ function StudyTable(props: any) {
dataIndex: 'startLearnTime',
width: 240,
sorter: true,
field: 'yuiooo',
sortOrder: (orderFiled == 'startLearnTime') ? sort : null,
render: (val: any, record: any) => {
return <div>{formatDate('YYYY-MM-DD H:i', val)}</div>;
},
......@@ -154,6 +170,13 @@ function StudyTable(props: any) {
},
];
function onChange(pagination: any, filters: any, sorter: any, extra: any) {
console.log(sorter)
setOrderFiled(sorter.field || null)
setSort(sorter.order)
}
return <div className="study_Table">
<div className="filter">
......@@ -256,6 +279,7 @@ function StudyTable(props: any) {
storeUserId: User.getStoreUserId(),
userId: User.getStoreUserId(),
})
setSort('')
}}>
&#xe61b;{' '}
</span>
......@@ -275,7 +299,7 @@ function StudyTable(props: any) {
columns={columns}
pagination={false}
className='user-learning-table'
onChange={() => { }}
onChange={onChange}
showSorterTooltip={false}
bordered
/>
......
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