U 优化表格支持部分字段排序

This commit is contained in:
vapao 2020-06-14 17:30:17 +08:00
parent 56df2145a2
commit 5a8fbf48a2
6 changed files with 10 additions and 5 deletions

View File

@ -78,7 +78,8 @@ class ComTable extends React.Component {
dataIndex: 'created_by_user',
}, {
title: '申请时间',
dataIndex: 'created_at'
dataIndex: 'created_at',
sorter: (a, b) => a['created_at'].localeCompare(b['created_at'])
}, {
title: '操作',
render: info => {

View File

@ -29,9 +29,11 @@ class ComTable extends React.Component {
}, {
title: '主机名称',
dataIndex: 'name',
sorter: (a, b) => a.name.localeCompare(b.name)
}, {
title: '连接地址',
dataIndex: 'hostname',
sorter: (a, b) => a.name.localeCompare(b.name)
}, {
title: '端口',
dataIndex: 'port'

View File

@ -83,7 +83,8 @@ class ComTable extends React.Component {
}
}, {
title: '更新于',
dataIndex: 'latest_run_time',
dataIndex: 'latest_run_time_alias',
sorter: (a, b) => a.latest_run_time.localeCompare(b.latest_run_time)
}, {
title: '操作',
render: info => (

View File

@ -26,7 +26,7 @@ class Store {
res.map(item => {
tmp.add(item['type_alias']);
const value = item['latest_run_time'];
item['latest_run_time'] = value ? moment(value).fromNow() : null;
item['latest_run_time_alias'] = value ? moment(value).fromNow() : null;
return null
});
this.types = Array.from(tmp);

View File

@ -65,7 +65,8 @@ class ComTable extends React.Component {
},
}, {
title: '更新于',
dataIndex: 'latest_run_time',
dataIndex: 'latest_run_time_alias',
sorter: (a, b) => a.latest_run_time.localeCompare(b.latest_run_time)
}, {
title: '描述信息',
dataIndex: 'desc',

View File

@ -27,7 +27,7 @@ class Store {
.then(({types, tasks}) => {
tasks.map(item => {
const value = item['latest_run_time'];
item['latest_run_time'] = value ? moment(value).fromNow() : null;
item['latest_run_time_alias'] = value ? moment(value).fromNow() : null;
return null
});
this.records = tasks;