GithubHelp home page GithubHelp logo

libin1991 / vue-drag-tree-table Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mafengwo/vue-drag-tree-table

0.0 1.0 0.0 17.87 MB

vue 可以拖拽的树形表格,基于Vue实现可以拖拽排序的树形表格(已开源)

Home Page: https://juejin.im/post/5bc9355a5188255c3853955c

HTML 1.00% Vue 83.00% JavaScript 16.00%

vue-drag-tree-table's Introduction

tree

基于vue实现的可以拖拽排序的树形表格 star传送门

实现思路见博客被风吹雪的博客

drag-tree-table

Build Setup

# install dependencies
npm i drag-tree-table --save-dev
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build

使用方式


import dragTreeTable from 'drag-tree-table'
<dragTreeTable :data="treeData" :onDrag="onTreeDataChange"></dragTreeTable>
treeData: {
  lists: [],
  columns: []
}

�数据源(lists)配置

参数 可选值 描述
id String 唯一标志
parent_id String 父节点ID
order Number 排序,0开始,onDrag后�order会重置
name String 默认显示内容
open Boolean true展开,false收起
lists Array 子节点

lists 配置示例

[
 {
   "id":40,
   "parent_id":0,
   "order":0,
   "name":"动物类",
   "uri":"/masd/ds",
   "open":true,
   "lists":[]
 },{
   "id":5,
   "parent_id":0,
   "order":1,
   "name":"昆虫类",
   "uri":"/masd/ds",
   "open":true,
   "lists":[
     {
       "id":12,
       "parent_id":5,
       "open":true,
       "order":0,
       "name":"蚂蚁",
       "uri":"/masd/ds",
       "lists":[]
     }
   ]
 },
 {
   "id":19,
   "parent_id":0,
   "order":2,
   "name":"植物类",
   "uri":"/masd/ds",
   "open":true,
   "lists":[]
 }
]

�列(columns)配置

参数 可选值 描述
type 'selection', 'actions' selection会显示折叠图标,actions指操作栏
title String 表格标题
field String 单元格内容取值使用
width Number 单元格宽度
align left,center,right 单元格对齐方式,默认局左对齐
formatter Function 自定义单元格显示内容,参数为当前行数据

columns 配置示例

[
 {
   type: 'selection',
   title: '菜单名称',
   field: 'name',
   width: 200,
   align: 'center',
   formatter: (item) => {
     return '<a>'+item.name+'</a>'
   }
 },
 {
   title: '链接',
   field: 'url',
   width: 200,
   align: 'center'
 },
 {
   title: '操作',
   type: 'action',
   width: 350,
   align: 'center',
   actions: [
     {
       text: '查看角色',
       onclick: this.onDetail,
       formatter: (item) => {
         return '<i>查看角色</i>'
       }
     },
     {
       text: '编辑',
       onclick: this.onEdit,
       formatter: (item) => {
         return '<i>编辑</i>'
       }
     }
   ]
 },
]

vue-drag-tree-table's People

Contributors

coldday avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.