bee-table7/demo/demolist/Demo0901.js

74 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-12-21 09:58:52 +08:00
/**
2019-03-20 17:44:05 +08:00
* @title 列排序
2019-04-18 10:50:38 +08:00
* @parent 列操作-排序 Sort
2019-03-20 17:44:05 +08:00
* @description column中增加sorter: (a, b) => a.c - b.c 这里的a,b代表前后两个数据c代表比较当前对象的字段名称
2019-04-23 20:11:38 +08:00
* demo0901
2018-12-21 09:58:52 +08:00
*/
import React, { Component } from 'react';
2019-03-20 17:44:05 +08:00
import {Icon} from "tinper-bee";
2018-12-21 09:58:52 +08:00
import Table from '../../src';
2019-03-20 17:44:05 +08:00
import sort from "../../src/lib/sort.js";
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
let ComplexTable = sort(Table, Icon);
const columns11 = [
2018-12-21 09:58:52 +08:00
{
2019-04-23 20:11:38 +08:00
title: "单据编号",
dataIndex: "num",
key: "num",
width: 120,
fixed: "left"
2018-12-21 09:58:52 +08:00
},
{
2019-04-23 20:11:38 +08:00
title: "单据日期",
dataIndex: "date",
key: "date",
width: 200,
},
{
title: "供应商",
dataIndex: "supplier",
key: "supplier",
2019-03-20 17:44:05 +08:00
width: 100
2018-12-21 09:58:52 +08:00
},
{
2019-04-23 20:11:38 +08:00
title: "联系人",
dataIndex: "contact",
key: "contact",
2018-12-21 09:58:52 +08:00
},
{
2019-04-23 20:11:38 +08:00
title: "整单数量",
dataIndex: "total",
key: "total",
width: 150,
sorter: (a, b) => a.total - b.total
2018-12-21 09:58:52 +08:00
}
];
2019-03-20 17:44:05 +08:00
const data11 = [
2019-04-23 20:11:38 +08:00
{ num: "NU0391001", date: "2019-03-01", supplier: 'xx供应商',contact:'Tom', total:30 ,key: "1" },
{ num: "NU0391002", date: "2018-11-02", supplier: 'yy供应商',contact:'Jack', total:41 ,key: "2" },
{ num: "NU0391003", date: "2019-05-03", supplier: 'zz供应商',contact:'Jane', total:25 ,key: "3" }
2019-03-20 17:44:05 +08:00
];
const defaultProps11 = {
prefixCls: "bee-table"
};
class Demo11 extends Component {
constructor(props) {
super(props);
this.state = {
sortOrder: "",
data: data11
};
}
2018-12-21 09:58:52 +08:00
render() {
2019-03-20 17:44:05 +08:00
return <ComplexTable columns={columns11} data={this.state.data} />;
2018-12-21 09:58:52 +08:00
}
}
2019-03-20 17:44:05 +08:00
Demo11.defaultProps = defaultProps11;
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
export default Demo11;