bee-table/demo/demolist/Demo1001.js

92 lines
2.1 KiB
JavaScript
Raw Normal View History

2018-12-21 09:58:52 +08:00
/**
*
2019-04-16 13:35:25 +08:00
* @title 拖拽改变列顺序
2019-04-18 10:50:38 +08:00
* @parent 列操作-拖拽 Drag
* @description 点击选择表头并左右拖拽可以改变表格列顺序 onDragEnd 方法是拖拽交换列后触发的回调函数注意固定列不可以交换
2019-04-23 20:11:38 +08:00
* demo1001
2018-12-21 09:58:52 +08:00
*/
2019-03-20 17:44:05 +08:00
import React, { Component } from 'react';
import {Icon} from "tinper-bee";
2018-12-21 09:58:52 +08:00
2019-03-20 17:44:05 +08:00
import Table from '../../src';
import dragColumn from '../../src/lib/dragColumn';
2018-12-21 09:58:52 +08:00
2019-04-22 15:44:14 +08:00
const columns = [
2019-03-20 17:44:05 +08:00
{
2019-04-23 20:11:38 +08:00
title: "订单编号",
2019-03-20 17:44:05 +08:00
dataIndex: "a",
key: "a",
width: 100
},
{
2019-04-23 20:11:38 +08:00
title: "单据日期",
2019-03-20 17:44:05 +08:00
dataIndex: "b",
key: "b",
width: 200
},
{
2019-04-23 20:11:38 +08:00
title: "供应商",
2019-03-20 17:44:05 +08:00
dataIndex: "c",
key: "c",
width: 200,
sumCol: true,
sorter: (a, b) => a.c - b.c
},
{
2019-04-23 20:11:38 +08:00
title: "联系人",
2019-03-20 17:44:05 +08:00
dataIndex: "d",
key: "d",
2019-06-26 16:32:17 +08:00
width: 500,
},
{
title: "操作",
dataIndex: "e",
key: "e",
2019-03-20 17:44:05 +08:00
width: 200,
2019-06-26 16:32:17 +08:00
fixed: 'right',
2019-03-20 17:44:05 +08:00
}
];
2019-04-22 15:44:14 +08:00
const data = [
2019-06-26 16:32:17 +08:00
{ a: "NU0391001", b: "2019-03-01", c: 'xx供应商',d:'Tom',e:'...', key: "2" },
{ a: "NU0391002", b: "2018-11-02", c: 'yy供应商',d:'Jack',e:'...', key: "1" },
{ a: "NU0391003", b: "2019-05-03", c: 'zz供应商',d:'Jane',e:'...', key: "3" }
2019-03-20 17:44:05 +08:00
];
const DragColumnTable = dragColumn(Table);
const defaultProps22 = {
prefixCls: "bee-table"
};
class Demo22 extends Component {
constructor(props) {
super(props);
}
render() {
2019-04-22 15:44:14 +08:00
return <DragColumnTable
columns={columns}
data={data}
bordered
draggable={true}
2019-04-22 15:44:14 +08:00
onDrop ={(event,data,columns)=>{
console.log("--拖拽交换列onDrop触发事件");
console.log("event.target:",event.target);
console.log("data:",data);
console.log("拖拽完成后的columns:",columns);
}}
onDragEnd ={(event,data,columns)=>{
2019-04-22 15:44:14 +08:00
console.log("--拖拽交换列后触发事件");
console.log("event.target:",event.target);
console.log("data:",data);
console.log("拖拽完成后的columns:",columns);
}}
2019-03-20 17:44:05 +08:00
/>;
2018-12-21 09:58:52 +08:00
}
2019-03-20 17:44:05 +08:00
}
2018-12-21 09:58:52 +08:00
2019-04-22 15:44:14 +08:00
Demo22.defaultProps = defaultProps22;
2019-03-20 17:44:05 +08:00
export default Demo22;