v1.6.1 拖拽bugfix

This commit is contained in:
“jonyshi” 2018-12-03 14:37:15 +08:00
parent b2b307f673
commit f9f4dcfdf5
3 changed files with 133 additions and 130 deletions

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"
],
"engines": {
"node": ">=4.0.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx"
"name": "bee-table",
"version": "1.6.1",
"description": "Table ui component for react",
"keywords": [
"react",
"react-component",
"bee-table",
"iuap-design",
"tinper-bee",
"Table"
],
"transform": {
"^.+\\.js$": "babel-jest"
"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"
}
},
"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

@ -12,33 +12,18 @@ const propTypes = {
rows: PropTypes.array
};
const grap = 16; //偏移数值
class TableHeader extends Component {
constructor(props) {
super(props);
this.currentObj = null;
//拖拽宽度处理
if (!props.dragborder) return;
this.border = false;
this.currentObj = null;
this.theadKey = new Date().getTime();
this.drag = {
initPageLeftX: 0,
initLeft: 0,
x: 0,
width: 0,
option:''
};
this.minWidth = 80;//确定最小宽度就是80
this.table = null;
let _row = [];
this.props.rows[0] &&
this.props.rows[0].forEach(item => {
let newItem = item.key != "checkbox" ? ObjectAssign(item) : item;
_row.push(newItem);
});
this.drag.data = _row; //JSON.parse(JSON.stringify(this.props.rows[0]));
}
static defaultProps = {
contentWidthDiff: 0
};
@ -53,8 +38,15 @@ class TableHeader extends Component {
for (let index = 0; index < ths.length; index++) {
const element = ths[index];//.getAttribute('data-type');
if(!element.getAttribute('data-th-fixed')){
const colLine = element.children.length > 1?element.lastElementChild:element.children[0];
// const colLine = element.children[0];
let 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 (let i = 0; i < events.length; i++) {
const _event = events[i];
let _dataSource = eventSource?element:colLine;

View File

@ -1,5 +1,6 @@
import React, { Component } from "react";
import {compare,ObjectAssign} from './util';
let cloneDeep = require('lodash.clonedeep');
/**
* 参数: 列拖拽
* @param {*} Table
@ -65,26 +66,36 @@ export default function dragColumn(Table) {
columns[index] = dragSourceColum;
}
}
let titles = [];
columns.forEach(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));
}
// 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);
}
}
getTarget=(evt)=>{