v1.6.1 拖拽bugfix
This commit is contained in:
parent
b2b307f673
commit
f9f4dcfdf5
184
package.json
184
package.json
|
@ -1,96 +1,96 @@
|
||||||
{
|
{
|
||||||
"name": "bee-table",
|
"name": "bee-table",
|
||||||
"version": "1.6.1",
|
"version": "1.6.1",
|
||||||
"description": "Table ui component for react",
|
"description": "Table ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-component",
|
"react-component",
|
||||||
"bee-table",
|
"bee-table",
|
||||||
"iuap-design",
|
"iuap-design",
|
||||||
"tinper-bee",
|
"tinper-bee",
|
||||||
"Table"
|
"Table"
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0.0"
|
|
||||||
},
|
|
||||||
"jest": {
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"js",
|
|
||||||
"jsx"
|
|
||||||
],
|
],
|
||||||
"transform": {
|
"engines": {
|
||||||
"^.+\\.js$": "babel-jest"
|
"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"
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -12,33 +12,18 @@ const propTypes = {
|
||||||
rows: PropTypes.array
|
rows: PropTypes.array
|
||||||
};
|
};
|
||||||
|
|
||||||
const grap = 16; //偏移数值
|
|
||||||
|
|
||||||
class TableHeader extends Component {
|
class TableHeader extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.currentObj = null;
|
this.currentObj = null;
|
||||||
//拖拽宽度处理
|
|
||||||
if (!props.dragborder) return;
|
|
||||||
this.border = false;
|
|
||||||
this.theadKey = new Date().getTime();
|
this.theadKey = new Date().getTime();
|
||||||
this.drag = {
|
this.drag = {
|
||||||
initPageLeftX: 0,
|
|
||||||
initLeft: 0,
|
|
||||||
x: 0,
|
|
||||||
width: 0,
|
|
||||||
option:''
|
option:''
|
||||||
};
|
};
|
||||||
this.minWidth = 80;//确定最小宽度就是80
|
this.minWidth = 80;//确定最小宽度就是80
|
||||||
this.table = null;
|
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 = {
|
static defaultProps = {
|
||||||
contentWidthDiff: 0
|
contentWidthDiff: 0
|
||||||
};
|
};
|
||||||
|
@ -53,8 +38,15 @@ class TableHeader extends Component {
|
||||||
for (let index = 0; index < ths.length; index++) {
|
for (let index = 0; index < ths.length; index++) {
|
||||||
const element = ths[index];//.getAttribute('data-type');
|
const element = ths[index];//.getAttribute('data-type');
|
||||||
if(!element.getAttribute('data-th-fixed')){
|
if(!element.getAttribute('data-th-fixed')){
|
||||||
const colLine = element.children.length > 1?element.lastElementChild:element.children[0];
|
let colLine = null;
|
||||||
// const colLine = element.children[0];
|
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++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
const _event = events[i];
|
const _event = events[i];
|
||||||
let _dataSource = eventSource?element:colLine;
|
let _dataSource = eventSource?element:colLine;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import {compare,ObjectAssign} from './util';
|
import {compare,ObjectAssign} from './util';
|
||||||
|
let cloneDeep = require('lodash.clonedeep');
|
||||||
/**
|
/**
|
||||||
* 参数: 列拖拽
|
* 参数: 列拖拽
|
||||||
* @param {*} Table
|
* @param {*} Table
|
||||||
|
@ -65,26 +66,36 @@ export default function dragColumn(Table) {
|
||||||
columns[index] = dragSourceColum;
|
columns[index] = dragSourceColum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let titles = [];
|
// let titles = [];
|
||||||
columns.forEach(da=>{
|
// columns.forEach(da=>{
|
||||||
if(typeof da.title != "string"){
|
// for(let attr of da){
|
||||||
titles.push(da.title);
|
|
||||||
delete da.title;
|
// }
|
||||||
}
|
// if(typeof da.title != "string"){
|
||||||
});
|
// titles.push(da.title);
|
||||||
let newColumns = null;
|
// delete da.title;
|
||||||
if(titles.length != 0){
|
// }
|
||||||
newColumns = JSON.parse(JSON.stringify(columns));
|
// });
|
||||||
for (let index = 0; index < newColumns.length; index++) {
|
// let newColumns = null;
|
||||||
newColumns[index].title = titles[index];
|
// if(titles.length != 0){
|
||||||
}
|
// newColumns = JSON.parse(JSON.stringify(columns));
|
||||||
console.log("----columns----",newColumns);
|
// for (let index = 0; index < newColumns.length; index++) {
|
||||||
}else{
|
// newColumns[index].title = titles[index];
|
||||||
newColumns = JSON.parse(JSON.stringify(columns));
|
// }
|
||||||
}
|
// console.log("----columns----",newColumns);
|
||||||
|
// }else{
|
||||||
|
// newColumns = JSON.parse(JSON.stringify(columns));
|
||||||
|
// }
|
||||||
|
// this.setState({
|
||||||
|
// columns:newColumns
|
||||||
|
// });
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
columns:newColumns
|
columns:cloneDeep(columns)
|
||||||
});
|
});
|
||||||
|
if(this.props.dragDrop){
|
||||||
|
this.props.dragDrop(event,data,newColumns);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getTarget=(evt)=>{
|
getTarget=(evt)=>{
|
||||||
|
|
Loading…
Reference in New Issue