v1.6.1 拖拽bugfix
This commit is contained in:
parent
b2b307f673
commit
f9f4dcfdf5
|
@ -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.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;
|
||||
|
|
|
@ -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)=>{
|
||||
|
|
Loading…
Reference in New Issue