[代码完善](v2.5): v2.5 beta 菜单管理、部门管理,列表和弹窗数据懒加载

1、菜单管理表格,弹窗数据懒加载
2、部门管理表格,弹窗数据懒加载
3、角色管理,菜单分配数据懒加载
4、用户管理,左侧部门数据懒加载

2.5 Beta 详情:https://www.ydyno.com/archives/1225.html
This commit is contained in:
ZhengJie
2020-05-10 20:44:05 +08:00
parent 8393f74046
commit 38429e6f93
8 changed files with 378 additions and 67 deletions

View File

@@ -132,6 +132,11 @@ function CRUD(options) {
crud.loading = true
// 请求数据
initData(crud.url, crud.getQueryParams()).then(data => {
const table = crud.getTable()
if (table.lazy) { // 懒加载子节点数据,清掉已加载的数据
table.store.states.treeData = {}
table.store.states.lazyTreeNodeMap = {}
}
crud.page.total = data.totalElements
crud.data = data.content
crud.resetDataStatus()
@@ -437,7 +442,7 @@ function CRUD(options) {
crud.selectChange(selection, val)
})
} else {
crud.findVM('presenter').$refs['table'].clearSelection()
crud.getTable().clearSelection()
}
},
/**
@@ -447,10 +452,10 @@ function CRUD(options) {
*/
selectChange(selection, row) {
// 如果selection中存在row代表是选中否则是取消选中
if (selection.find(val => { return this.getDataId(val) === this.getDataId(row) })) {
if (selection.find(val => { return crud.getDataId(val) === crud.getDataId(row) })) {
if (row.children) {
row.children.forEach(val => {
crud.findVM('presenter').$refs['table'].toggleRowSelection(val, true)
crud.getTable().toggleRowSelection(val, true)
selection.push(val)
if (val.children) {
crud.selectChange(selection, val)
@@ -469,7 +474,7 @@ function CRUD(options) {
toggleRowSelection(selection, data) {
if (data.children) {
data.children.forEach(val => {
crud.findVM('presenter').$refs['table'].toggleRowSelection(val, false)
crud.getTable().toggleRowSelection(val, false)
if (val.children) {
crud.toggleRowSelection(selection, val)
}
@@ -492,8 +497,11 @@ function CRUD(options) {
getDataId(data) {
return data[this.idField]
},
getTable() {
return this.findVM('presenter').$refs.table
},
attchTable() {
const table = this.findVM('presenter').$refs.table
const table = this.getTable()
const columns = []
table.columns.forEach((e, index) => {
if (!e.property || e.type !== 'default') {
@@ -509,6 +517,25 @@ function CRUD(options) {
})
this.updateProp('tableColumns', columns)
this.updateProp('table', table)
const that = this
table.$on('expand-change', (row, expanded) => {
if (!expanded) {
return
}
const lazyTreeNodeMap = table.store.states.lazyTreeNodeMap
const children = lazyTreeNodeMap[row.id]
row.children = children
children.forEach(ele => {
const id = crud.getDataId(ele)
if (that.dataStatus[id] === undefined) {
that.dataStatus[id] = {
delete: 0,
edit: 0
}
}
})
})
}
}
const crud = Object.assign({}, data)