123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import React from 'react';
- import { Spin } from 'antd';
- import Sortable from 'sortablejs';
- import './index.less';
- import { generateUUID } from '../../services/Tools';
- export default class DragSortingTable extends React.Component {
-
-
-
-
-
-
-
-
-
- sortableDecorator(componentBackingInstance) {
-
- if (componentBackingInstance) {
- const options = Object.assign({
-
- handle: this.props.handle || '.drag',
- group: this.props.group || generateUUID(),
- ghostClass: 'ghost',
- onEnd: (event) => {
- this.props.onMove(event.oldIndex, event.newIndex);
- },
- }, this.props.sortable || {});
- Sortable.create(componentBackingInstance, options);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- render() {
- return (
- <Spin spinning={this.props.loading}>
- <div className='drag-container'
- ref={(ref) => {
- if (ref) this.sortableDecorator(ref);
- }}>
- {this.props.dataSource.map((item, index) => {
- return <div className={`drag ${this.props.type}`}>{this.props.renderItem(item, index)}</div>;
- })}
- </div></Spin>
- );
- }
- }
|