publish 1.6.2

This commit is contained in:
“jonyshi” 2018-12-03 16:03:32 +08:00
parent f9f4dcfdf5
commit de51cfedc0
7 changed files with 2008 additions and 191 deletions

BIN
build.zip Normal file

Binary file not shown.

View File

@ -46,8 +46,6 @@ var propTypes = {
rows: _propTypes2["default"].array
};
var grap = 16; //偏移数值
var TableHeader = function (_Component) {
_inherits(TableHeader, _Component);
@ -156,7 +154,10 @@ var TableHeader = function (_Component) {
if (_this.drag.option === 'border') {
return;
}
var currentIndex = parseInt(_utils.Event.getTarget(event).getAttribute("data-line-index"));
// console.log('-------onDragStart----------',event.target);
var th = _this.getThDome(event.target);
if (!th) return;
var currentIndex = parseInt(th.getAttribute("data-line-index"));
var currentKey = event.target.getAttribute('data-line-key');
event.dataTransfer.effectAllowed = "move";
@ -176,6 +177,7 @@ var TableHeader = function (_Component) {
}
var data = _this.getCurrentEventData(e);
if (!data) return;
// console.log('-------onDrop----------',event.target);
if (!_this.currentObj || _this.currentObj.key == data.key) return;
if (!_this.props.onDrop) return;
_this.props.onDrop(event, { dragSource: _this.currentObj, dragTarg: data });
@ -299,25 +301,12 @@ var TableHeader = function (_Component) {
};
_this.currentObj = null;
//拖拽宽度处理
if (!props.dragborder) return _possibleConstructorReturn(_this);
_this.border = false;
_this.theadKey = new Date().getTime();
_this.drag = {
initPageLeftX: 0,
initLeft: 0,
x: 0,
width: 0,
option: ''
};
_this.minWidth = 80; //确定最小宽度就是80
_this.table = null;
var _row = [];
_this.props.rows[0] && _this.props.rows[0].forEach(function (item) {
var newItem = item.key != "checkbox" ? (0, _utils.ObjectAssign)(item) : item;
_row.push(newItem);
});
_this.drag.data = _row; //JSON.parse(JSON.stringify(this.props.rows[0]));
return _this;
}
@ -334,8 +323,15 @@ var TableHeader = function (_Component) {
for (var index = 0; index < ths.length; index++) {
var element = ths[index]; //.getAttribute('data-type');
if (!element.getAttribute('data-th-fixed')) {
var colLine = element.children.length > 1 ? element.lastElementChild : element.children[0];
// const colLine = element.children[0];
var colLine = null;
if (element.children.length === 0) {
colLine = element;
} else if (element.children.length > 0) {
colLine = element.lastElementChild;
} else if (element.children.length === 1) {
colLine = element.children[0];
}
// const colLine = element.children.length > 1?element.lastElementChild:element.children[0];
for (var i = 0; i < events.length; i++) {
var _event = events[i];
var _dataSource = eventSource ? element : colLine;
@ -483,7 +479,12 @@ var TableHeader = function (_Component) {
TableHeader.prototype.getCurrentEventData = function getCurrentEventData(e) {
var event = _utils.Event.getEvent(e);
var key = event.target.getAttribute('data-line-key');
var th = this.getThDome(event.target);
if (!th) {
console.log(" event target is not th ! ");
return null;
}
var key = th.getAttribute('data-line-key');
var data = this.props.rows[0].find(function (da) {
return da.key == key;
});
@ -494,7 +495,27 @@ var TableHeader = function (_Component) {
return null;
}
};
/**
*根据拖拽获取当前的Th属性
* @param {*} element
* @returns
* @memberof TableHeader
*/
TableHeader.prototype.getThDome = function getThDome(element) {
var _tagName = element.tagName.toLowerCase();
if (_tagName === 'i') return null;
if (_tagName != 'th') {
return this.getThDome(element.parentElement);
} else {
return element;
}
};
//---拖拽列交换----end-----
/**
* 过滤输入后或下拉条件的回调函数
*/

View File

@ -28,6 +28,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
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); }
var cloneDeep = require('lodash.clonedeep');
/**
* 参数: 列拖拽
* @param {*} Table
@ -71,26 +72,36 @@ function dragColumn(Table) {
columns[index] = dragSourceColum;
}
}
var titles = [];
columns.forEach(function (da) {
if (typeof da.title != "string") {
titles.push(da.title);
delete da.title;
}
});
var newColumns = null;
if (titles.length != 0) {
newColumns = JSON.parse(JSON.stringify(columns));
for (var _index = 0; _index < newColumns.length; _index++) {
newColumns[_index].title = titles[_index];
}
console.log("----columns----", newColumns);
} else {
newColumns = JSON.parse(JSON.stringify(columns));
}
// let titles = [];
// columns.forEach(da=>{
// for(let attr of da){
// }
// if(typeof da.title != "string"){
// titles.push(da.title);
// delete da.title;
// }
// });
// let newColumns = null;
// if(titles.length != 0){
// newColumns = JSON.parse(JSON.stringify(columns));
// for (let index = 0; index < newColumns.length; index++) {
// newColumns[index].title = titles[index];
// }
// console.log("----columns----",newColumns);
// }else{
// newColumns = JSON.parse(JSON.stringify(columns));
// }
// this.setState({
// columns:newColumns
// });
_this.setState({
columns: newColumns
columns: cloneDeep(columns)
});
if (_this.props.dragDrop) {
_this.props.dragDrop(event, data, newColumns);
}
};
_this.getTarget = function (evt) {

1874
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,96 +1,96 @@
{
"name": "bee-table",
"version": "1.6.1",
"description": "Table ui component for react",
"keywords": [
"react",
"react-component",
"bee-table",
"iuap-design",
"tinper-bee",
"Table"
"name": "bee-table",
"version": "1.6.2",
"description": "Table ui component for react",
"keywords": [
"react",
"react-component",
"bee-table",
"iuap-design",
"tinper-bee",
"Table"
],
"engines": {
"node": ">=4.0.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx"
],
"engines": {
"node": ">=4.0.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx"
],
"transform": {
"^.+\\.js$": "babel-jest"
}
},
"homepage": "https://github.com/tinper-bee/bee-table.git",
"author": "Yonyou FED",
"repository": "http://github.com/tinper-bee/bee-table",
"bugs": "https://github.com/tinper-bee/bee-table.git/issues",
"license": "MIT",
"main": "./build/index.js",
"config": {
"port": 3000,
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"scripts": {
"dev": "bee-tools run start",
"build": "bee-tools run build",
"lint": "bee-tools run lint",
"test": "jest",
"chrome": "bee-tools run chrome",
"coveralls": "jest",
"browsers": "bee-tools run browsers",
"pub": "bee-tools run pub",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"dependencies": {
"bee-button": "^1.0.6",
"bee-datepicker": "latest",
"bee-dnd": "^1.0.2",
"bee-dropdown": "^1.0.1",
"bee-form-control": "latest",
"bee-icon": "^1.0.5",
"bee-input-number": "^1.1.15",
"bee-loading": "^1.0.3",
"bee-locale": "0.0.11",
"bee-menus": "^1.0.7",
"bee-popover": "^1.0.2",
"bee-select": "^1.0.21",
"classnames": "^2.2.5",
"lodash.clonedeep": "^4.5.0",
"object-path": "^0.11.3",
"shallowequal": "^1.0.2",
"throttle-debounce": "^2.0.1",
"tinper-bee-core": "latest",
"warning": "^3.0.0"
},
"peerDependencies": {
"react": "^15.3.0 || ^16.0",
"react-dom": "^15.3.0 || ^16.0",
"prop-types": "^15.6.0"
},
"devDependencies": {
"babel-jest": "^22.0.4",
"bee-animate": "latest",
"bee-checkbox": "^1.1.1",
"bee-form": "1.1.10",
"bee-input-group": "latest",
"bee-layout": "latest",
"bee-pagination": "latest",
"bee-panel": "^1.2.12",
"bee-popconfirm": "^1.0.2",
"bee-tools": "latest",
"bee-tooltip": "^1.0.2",
"chai": "^3.5.0",
"console-polyfill": "~0.2.1",
"cz-conventional-changelog": "^2.1.0",
"enzyme": "^2.9.1",
"es5-shim": "~4.1.10",
"jest": "^22.0.4",
"react": "^15.5.0",
"react-addons-test-utils": "^15.5.0",
"react-dom": "^15.5.0"
"transform": {
"^.+\\.js$": "babel-jest"
}
}
},
"homepage": "https://github.com/tinper-bee/bee-table.git",
"author": "Yonyou FED",
"repository": "http://github.com/tinper-bee/bee-table",
"bugs": "https://github.com/tinper-bee/bee-table.git/issues",
"license": "MIT",
"main": "./build/index.js",
"config": {
"port": 3000,
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"scripts": {
"dev": "bee-tools run start",
"build": "bee-tools run build",
"lint": "bee-tools run lint",
"test": "jest",
"chrome": "bee-tools run chrome",
"coveralls": "jest",
"browsers": "bee-tools run browsers",
"pub": "bee-tools run pub",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"dependencies": {
"bee-button": "^1.0.6",
"bee-datepicker": "latest",
"bee-dnd": "^1.0.2",
"bee-dropdown": "^1.0.1",
"bee-form-control": "latest",
"bee-icon": "^1.0.5",
"bee-input-number": "^1.1.15",
"bee-loading": "^1.0.3",
"bee-locale": "0.0.11",
"bee-menus": "^1.0.7",
"bee-popover": "^1.0.2",
"bee-select": "^1.0.21",
"classnames": "^2.2.5",
"lodash.clonedeep": "^4.5.0",
"object-path": "^0.11.3",
"shallowequal": "^1.0.2",
"throttle-debounce": "^2.0.1",
"tinper-bee-core": "latest",
"warning": "^3.0.0"
},
"peerDependencies": {
"react": "^15.3.0 || ^16.0",
"react-dom": "^15.3.0 || ^16.0",
"prop-types": "^15.6.0"
},
"devDependencies": {
"babel-jest": "^22.0.4",
"bee-animate": "latest",
"bee-checkbox": "^1.1.1",
"bee-form": "1.1.10",
"bee-input-group": "latest",
"bee-layout": "latest",
"bee-pagination": "latest",
"bee-panel": "^1.2.12",
"bee-popconfirm": "^1.0.2",
"bee-tools": "latest",
"bee-tooltip": "^1.0.2",
"chai": "^3.5.0",
"console-polyfill": "~0.2.1",
"cz-conventional-changelog": "^2.1.0",
"enzyme": "^2.9.1",
"es5-shim": "~4.1.10",
"jest": "^22.0.4",
"react": "^15.5.0",
"react-addons-test-utils": "^15.5.0",
"react-dom": "^15.5.0"
}
}

View File

@ -271,7 +271,10 @@ class TableHeader extends Component {
let event = Event.getEvent(e);
if (!this.props.draggable) return;
if(this.drag.option === 'border'){return;}
let currentIndex = parseInt(Event.getTarget(event).getAttribute("data-line-index"));
// console.log('-------onDragStart----------',event.target);
let th = this.getThDome(event.target);
if(!th)return;
let currentIndex = parseInt(th.getAttribute("data-line-index"));
let currentKey = event.target.getAttribute('data-line-key');
event.dataTransfer.effectAllowed = "move";
@ -304,6 +307,7 @@ class TableHeader extends Component {
if(this.drag.option === 'border'){return;}
let data = this.getCurrentEventData(e);
if(!data)return;
// console.log('-------onDrop----------',event.target);
if (!this.currentObj || this.currentObj.key == data.key) return;
if(!this.props.onDrop)return;
this.props.onDrop(event,{dragSource:this.currentObj,dragTarg:data});
@ -311,7 +315,12 @@ class TableHeader extends Component {
getCurrentEventData(e){
let event = Event.getEvent(e);
let key = event.target.getAttribute('data-line-key');
let th = this.getThDome(event.target)
if(!th){
console.log(" event target is not th ! ");
return null;
}
let key = th.getAttribute('data-line-key');
let data = this.props.rows[0].find(da=>da.key == key);
if(data){
return data;
@ -320,7 +329,25 @@ class TableHeader extends Component {
return null;
}
}
/**
*根据拖拽获取当前的Th属性
* @param {*} element
* @returns
* @memberof TableHeader
*/
getThDome(element){
let _tagName = element.tagName.toLowerCase();
if(_tagName === 'i')return null;
if(_tagName != 'th'){
return this.getThDome(element.parentElement);
}else{
return element;
}
}
//---拖拽列交换----end-----
/**
* 过滤输入后或下拉条件的回调函数
*/