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,
render: function render(text, record, index) {
var attr = {};
console.log("record._disabled---", record._disabled);
record._disabled ? attr.disabled = record._disabled : "";
return _react2["default"].createElement(Checkbox, _extends({
key: index,

View File

@ -38,9 +38,9 @@ function sort(Table, Icon) {
_this.toggleSortOrder = function (order, column) {
var _this$state = _this.state,
sortOrder = _this$state.sortOrder,
data = _this$state.data,
oldData = _this$state.oldData;
oldData = _this$state.oldData,
columns = _this$state.columns;
var ascend_sort = function ascend_sort(key) {
return function (a, b) {
@ -52,10 +52,10 @@ function sort(Table, Icon) {
return b.key - a.key;
};
};
if (sortOrder === order) {
// 切换为未排序状态
order = "";
}
// if (sortOrder === order) {
// // 切换为未排序状态
// order = "";
// }
if (!oldData) {
oldData = data.concat();
}
@ -70,16 +70,72 @@ function sort(Table, Icon) {
} else {
data = oldData.concat();
}
var seleObj = columns.find(function (da) {
return da.key == column.key;
});
seleObj.order = order;
_this.setState({
sortOrder: order,
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 = {
sortOrder: "",
data: _this.props.data
data: _this.props.data,
columns: props.columns
};
return _this;
}
@ -87,70 +143,19 @@ function sort(Table, Icon) {
SortTable.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.data !== this.props.data) {
this.setState({
sortOrder: "",
data: nextProps.data,
oldData: nextProps.data.concat()
});
}
};
SortTable.prototype.renderColumnsDropdown = function renderColumnsDropdown(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;
});
if (nextProps.columns !== this.props.columns) {
this.setState({
columns: nextProps.columns
});
}
};
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 }));
};

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",
"version": "1.3.2",
"version": "1.3.3",
"description": "Table ui component for react",
"keywords": [
"react",
@ -88,4 +88,4 @@
"react-addons-test-utils": "^15.5.0",
"react-dom": "^15.5.0"
}
}
}