vue2-org-tree 基于vue 框架组织框架结构 增删修节点实现
1.下载并引入
import Vue2OrgTree from 'vue2-org-tree'
import {
mapGetters } from 'vuex'
Vue.use(Vue2OrgTree)
2.data 属性命名
data() {
return {
data: {
id: 0,
level: 0,
deptName: '',
list: []
},
horizontal: false,
collapsable: true,
expandAll: false,
formAdd: this.$form.createForm(this),
formUpdate: this.$form.createForm(this),
addShow: false,
updateShow: false,
model: {
},
confirmLoading: false,
parent: {
},
spinning: true
}
3.template模板的HTML
<vue2-org-tree
name="test"
:data="data"
:props="{label:'deptName',children:'list',expand: 'expand'}"
:horizontal="false"
:collapsable="false"
label-class-name="bg-blue"
:render-content="renderContent"
/>
4.方法
computed: {
...mapGetters(['info'])
},
created() {
this.init()
},
init() {
this.spinning = true
api
.queryDepartment({
})
.then(res => {
let json = JSON.stringify(res.t.list).replace(/sonList/g, 'list')