feat(表格默认宽度为200,固定列在非固定table中hiden):

This commit is contained in:
wanghaoo 2018-09-13 10:29:44 +08:00
parent e5368300cf
commit bbcb35cc8b
5 changed files with 12 additions and 124 deletions

View File

@ -212,7 +212,10 @@
background: #fff;
position: relative; }
.u-table-fixed-left .u-table-body-inner {
margin-right: -20px; }
margin-right: -20px;
padding-right: 20px; }
.u-table-fixed-header .u-table-fixed-left .u-table-body-inner {
padding-right: 0px; }
.u-table-fixed-header .u-table-body-inner {
height: 100%;
overflow: scroll; }

View File

@ -264,7 +264,11 @@ var Table = function (_Component) {
if (typeof setWidthParam == 'string' && setWidthParam.indexOf('%')) {
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100;
} else {
this.contentWidth = parseInt(setWidthParam);
var numSetWidthParam = parseInt(setWidthParam);
//若传入的宽度小于当前宽度以当前宽度为主。
if (numSetWidthParam > this.contentWidth) {
this.contentWidth = numSetWidthParam;
}
}
}
var computeObj = this.columnManager.getColumnWidth();

View File

@ -164,7 +164,8 @@ var TableHeader = function (_Component) {
var currentDom = document.getElementById("u-table-drag-thead-" + _this.theadKey).getElementsByTagName("th")[_this.drag.currIndex];
currentDom.style.width = newWidth + "px";
// this.contentTableWidth = newTableWidth;
contentTable.style.width = newTableWidth + 'px';
var contentTableDom = document.getElementById("u-table-drag-thead-" + _this.theadKey).parentNode;
contentTableDom.style.width = newTableWidth + 'px';
_this.drag.x = x;
};

View File

@ -1,120 +0,0 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports["default"] = dragWidthColumn;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _util = require('./util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
/**
* 参数: 列拖拽
* @param {*} Table
*/
// 0、定义一个拖拽dom
// 1、当移动到表头可以显示当前操作列的move图标。
// 2、添加start、move事件、drop事件
function dragWidthColumn(Table) {
return function (_Component) {
_inherits(DragWidthColumn, _Component);
function DragWidthColumn(props) {
_classCallCheck(this, DragWidthColumn);
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
_this.setColumOrderByIndex = function (_column) {
_column.forEach(function (da, i) {
da.dragIndex = i;
da.drgHover = false;
});
return _column;
};
_this.onDragStart = function (event, data) {
if (_this.props.onDragStart) {
_this.props.onDragStart(event, data);
}
};
_this.onDragOver = function (event, data) {
if (_this.props.onDragOver) {
_this.props.onDragOver(event, data);
}
};
_this.onDragEnter = function (event, data) {};
_this.onDrop = function (event, data) {};
_this.getTarget = function (evt) {
return evt.target || evt.srcElement;
};
_this.state = {
columns: _this.setColumOrderByIndex(props.columns)
};
return _this;
}
DragWidthColumn.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.columns != this.props.columns) {
this.setState({
columns: this.setColumOrderByIndex(nextProps.columns)
});
}
};
DragWidthColumn.prototype.render = function render() {
var _props = this.props,
data = _props.data,
dragborder = _props.dragborder,
draggable = _props.draggable,
className = _props.className,
columns = _props.columns,
onDragStart = _props.onDragStart,
onDragEnter = _props.onDragEnter,
onDragOver = _props.onDragOver,
onDrop = _props.onDrop,
others = _objectWithoutProperties(_props, ['data', 'dragborder', 'draggable', 'className', 'columns', 'onDragStart', 'onDragEnter', 'onDragOver', 'onDrop']);
var key = new Date().getTime();
return _react2["default"].createElement(Table, _extends({}, others, {
columns: this.state.columns,
data: data,
className: className + ' u-table-drag-border',
onDragStart: this.onDragWidthStart,
onDragOver: this.onDragWidthOver,
onDrop: this.onDropWidth,
onDragEnter: this.onDragWidthEnter,
draggable: draggable
// dragborder={dragborder}
, dragborder: false,
dragborderKey: key
}));
};
return DragWidthColumn;
}(_react.Component);
}
module.exports = exports['default'];

View File

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