feat(bee-table): 去掉console,排序修改

This commit is contained in:
liushaozhen 2018-08-02 14:29:34 +08:00
parent 222a935ceb
commit c7528730b7
7 changed files with 1472 additions and 1120 deletions

View File

@ -111,7 +111,6 @@ function newMultiSelect(Table, Checkbox) {
width: 50, width: 50,
render: function render(text, record, index) { render: function render(text, record, index) {
var attr = {}; var attr = {};
console.log("record._disabled---", record._disabled);
record._disabled ? attr.disabled = record._disabled : ""; record._disabled ? attr.disabled = record._disabled : "";
return _react2["default"].createElement(Checkbox, _extends({ return _react2["default"].createElement(Checkbox, _extends({
key: index, key: index,

View File

@ -38,9 +38,9 @@ function sort(Table, Icon) {
_this.toggleSortOrder = function (order, column) { _this.toggleSortOrder = function (order, column) {
var _this$state = _this.state, var _this$state = _this.state,
sortOrder = _this$state.sortOrder,
data = _this$state.data, data = _this$state.data,
oldData = _this$state.oldData; oldData = _this$state.oldData,
columns = _this$state.columns;
var ascend_sort = function ascend_sort(key) { var ascend_sort = function ascend_sort(key) {
return function (a, b) { return function (a, b) {
@ -52,10 +52,10 @@ function sort(Table, Icon) {
return b.key - a.key; return b.key - a.key;
}; };
}; };
if (sortOrder === order) { // if (sortOrder === order) {
// 切换为未排序状态 // // 切换为未排序状态
order = ""; // order = "";
} // }
if (!oldData) { if (!oldData) {
oldData = data.concat(); oldData = data.concat();
} }
@ -70,16 +70,72 @@ function sort(Table, Icon) {
} else { } else {
data = oldData.concat(); data = oldData.concat();
} }
var seleObj = columns.find(function (da) {
return da.key == column.key;
});
seleObj.order = order;
_this.setState({ _this.setState({
sortOrder: order,
data: data, data: data,
oldData: oldData oldData: oldData,
columns: columns
});
};
_this.renderColumnsDropdown = function (columns) {
var prefixCls = _this.props.prefixCls || "bee-table";
return columns.map(function (originColumn) {
var column = _extends({}, originColumn);
var sortButton = void 0;
if (column.sorter) {
var isAscend = column.order && column.order === "ascend";
var isDescend = column.order && column.order === "descend";
sortButton = _react2["default"].createElement(
"div",
{ className: prefixCls + "-column-sorter" },
_react2["default"].createElement(
"span",
{
className: prefixCls + "-column-sorter-up " + (isAscend ? "on" : "off"),
title: "\u2191",
onClick: function onClick() {
_this.toggleSortOrder("ascend", column);
if (column.sorterClick) {
column.sorterClick(column, "up");
}
}
},
_react2["default"].createElement(Icon, { type: "uf-triangle-up" })
),
_react2["default"].createElement(
"span",
{
className: prefixCls + "-column-sorter-down " + (isDescend ? "on" : "off"),
title: "\u2193",
onClick: function onClick() {
_this.toggleSortOrder("descend", column);
if (column.sorterClick) {
column.sorterClick(column, "down");
}
}
},
_react2["default"].createElement(Icon, { type: "uf-triangle-down" })
)
);
}
column.title = _react2["default"].createElement(
"span",
null,
column.title,
sortButton
);
return column;
}); });
}; };
_this.state = { _this.state = {
sortOrder: "", data: _this.props.data,
data: _this.props.data columns: props.columns
}; };
return _this; return _this;
} }
@ -87,70 +143,19 @@ function sort(Table, Icon) {
SortTable.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { SortTable.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.data !== this.props.data) { if (nextProps.data !== this.props.data) {
this.setState({ this.setState({
sortOrder: "",
data: nextProps.data, data: nextProps.data,
oldData: nextProps.data.concat() oldData: nextProps.data.concat()
}); });
} }
}; if (nextProps.columns !== this.props.columns) {
this.setState({
SortTable.prototype.renderColumnsDropdown = function renderColumnsDropdown(columns) { columns: nextProps.columns
var _this2 = this; });
}
var sortOrder = this.state.sortOrder;
var prefixCls = this.props.prefixCls || "bee-table";
return columns.map(function (originColumn) {
var column = _extends({}, originColumn);
var sortButton = void 0;
if (column.sorter) {
var isAscend = sortOrder === "ascend";
var isDescend = sortOrder === "descend";
sortButton = _react2["default"].createElement(
"div",
{ className: prefixCls + "-column-sorter" },
_react2["default"].createElement(
"span",
{
className: prefixCls + "-column-sorter-up " + (isAscend ? "on" : "off"),
title: "\u2191",
onClick: function onClick() {
_this2.toggleSortOrder("ascend", column);
if (column.sorterClick) {
column.sorterClick(column, "up");
}
}
},
_react2["default"].createElement(Icon, { type: "uf-triangle-up" })
),
_react2["default"].createElement(
"span",
{
className: prefixCls + "-column-sorter-down " + (isDescend ? "on" : "off"),
title: "\u2193",
onClick: function onClick() {
_this2.toggleSortOrder("descend", column);
if (column.sorterClick) {
column.sorterClick(column, "down");
}
}
},
_react2["default"].createElement(Icon, { type: "uf-triangle-down" })
)
);
}
column.title = _react2["default"].createElement(
"span",
null,
column.title,
sortButton
);
return column;
});
}; };
SortTable.prototype.render = function render() { SortTable.prototype.render = function render() {
var columns = this.renderColumnsDropdown(this.props.columns.concat()); var columns = this.renderColumnsDropdown(this.state.columns.concat());
return _react2["default"].createElement(Table, _extends({}, this.props, { columns: columns, data: this.state.data })); return _react2["default"].createElement(Table, _extends({}, this.props, { columns: columns, data: this.state.data }));
}; };

File diff suppressed because one or more lines are too long

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

2442
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "bee-table", "name": "bee-table",
"version": "1.3.2", "version": "1.3.3",
"description": "Table ui component for react", "description": "Table ui component for react",
"keywords": [ "keywords": [
"react", "react",