antd + vuedraggable 实现行拖动

antd+vuedraggable 实现行拖动

antd的弹窗默认是不支持拖拽的,所以...

app.vue文件

js 复制代码
<template>
  <div style="margin: 24px">
    <a-table :columns="columns" :dataSource="dataSource" :components="components">
      <template v-slot:action>
        <a href="javascript:;" class="drag-handle" style="cursor: move;">拖动</a>
      </template>
    </a-table>
  </div>
</template>

<script>
const CustomWrapper = ()=> import('./components/CustomWrapper.vue');
const columns = [
  {
    title: "id",
    dataIndex: "id",
    sorter: true,
    width: "20%",
    scopedSlots: { customRender: "name" },
  },
  {
    title: "Gender",
    dataIndex: "gender",
    filters: [
      { text: "Male", value: "male" },
      { text: "Female", value: "female" },
    ],
    width: "20%",
  },
  {
    title: "Email",
    dataIndex: "email",
  },
  {
    title: 'Action',
    key: 'action',
    scopedSlots: { customRender: 'action' },
  },
];

export default {
  name: "App",
  provide() {
    return {
      data: this,
    };
  },
  data() {
    return {
      columns,
      components: {
        body: {
          wrapper: CustomWrapper,
        },
      },
      dataSource: [{
        id:1,
        key: 0,
        date: '2018-02-11',
        amount: 120,
        type: 'income',
        note: 'transfer',
      },
      {
        id:2,
        key: 1,
        date: '2018-03-11',
        amount: 243,
        type: 'income',
        note: 'transfer',
      },
      {
        id:3,
        key: 2,
        date: '2018-04-11',
        amount: 98,
        type: 'income',
        note: 'transfer',
      }],
    };
  },
  mounted(){
  
  },
  methods: {
     listChange(list){
       
     }
  },
};
</script>

<style></style>

CustomWrapper.vue文件

js 复制代码
<template>
  <Draggable ghostClass="ghost" tag="tbody" v-model="data.dataSource" @change="onChange" handle=".drag-handle">
    <slot></slot>
  </Draggable>
</template>
<script>
import Draggable from "vuedraggable";

export default {
  name: 'CustomWrapper',
  components: {
    Draggable
  },
  inject: ["data"],
  data() {
    return {
      
    };
  },
  mounted() {
  
  },
  methods: {
    onChange(evt) {
      this.data.listChange(this.data.dataSource)
    }
  }

};
</script>

文章来源:章鱼
http://114.55.234.134/article/6707a6da9a143e8ffe896fb4

相关推荐
蓉妹妹13 分钟前
React微信小程序自定义tabbar
前端·react.js·微信小程序
拿我格子衫来20 分钟前
图形编辑器基于Paper.js教程32:绘制贝塞尔曲线,并进行二次编辑
javascript·图像处理·编辑器·图形渲染
编程大师哥20 分钟前
如何快速上手Django?3 小时从 0 到 1 做出第一个 Web 项目(小白友好版)
前端·django·sqlite
博主花神21 分钟前
【React】路由
前端·react.js·前端框架
曹牧23 分钟前
C#:$ 符号
开发语言·javascript·c#·ecmascript
代码游侠25 分钟前
应用——Linux 标准IO编程
linux·前端·数据库·学习·算法
用户990450177800931 分钟前
微信红包封面制作redbag-cover
前端
2401_8604947032 分钟前
在React Native中开发进度条组件,可以使用多种方式来实现,包括使用内置的`ProgressViewharmony`(仅限harmony)
javascript·react native·react.js
一人の梅雨37 分钟前
淘宝商品详情接口深度解析:从 Sign 签名动态生成到多端数据全息重构
开发语言·javascript·重构
christine-rr38 分钟前
windows系统上node.js安装配置教程
前端·windows·npm·node.js