拖拽优化测试

This commit is contained in:
jonyshi 2019-04-19 10:59:38 +08:00
parent 4b1f55415f
commit 43b650d9a2
1 changed files with 1 additions and 25 deletions

View File

@ -1,6 +1,5 @@
import React, { Component } from "react";
import {compare,ObjectAssign} from './util';
let cloneDeep = require('lodash.clonedeep');
/**
* 参数: 列拖拽
* @param {*} Table
@ -33,14 +32,6 @@ export default function dragColumn(Table) {
return _column;
}
cloneDeep(obj){
if( typeof obj !== 'object' || Object.keys(obj).length === 0 ){
return obj
}
let resultData = {}
return this.recursion(obj, resultData)
}
recursion(obj, data={}){
for(key in obj){
if( typeof obj[key] == 'object' && Object.keys(obj[key].length>0 )){
@ -59,15 +50,6 @@ export default function dragColumn(Table) {
sourceIndex = columns.findIndex((da,i)=>da.key == dragSource.key);
targetIndex = columns.findIndex((da,i)=>da.key == dragTarg.key);
// for (let index = 0; index < columns.length; index++) {
// const da = columns[index];
// if(da.key === dragSource.key){
// columns[index] = dragTargColum;
// }
// if(da.key === dragTarg.key){
// columns[index] = dragSourceColum;
// }
// }
// 向前移动
if(targetIndex < sourceIndex){
targetIndex = targetIndex + 1;
@ -77,9 +59,6 @@ export default function dragColumn(Table) {
0,
columns.splice(sourceIndex, 1)[0]
);
// this.setState({
// columns:cloneDeep(columns)
// });
let _newColumns = [];
columns.forEach((da,i)=>{
let newDate = Object.assign(da,{});
@ -114,7 +93,6 @@ export default function dragColumn(Table) {
onDrop,
...others
} = this.props;
let key = new Date().getTime();
return (
<Table
{...others}
@ -127,8 +105,6 @@ export default function dragColumn(Table) {
onDragEnter={this.onDragEnter}
draggable={draggable}
dragborder={dragborder}
// dragborder={false}
dragborderKey={key}
/>)
}
};