Browse Source

优化部门管理页面展示

master
李磊 3 years ago
parent
commit
2ae62e42b3
  1. 61
      src/views/user/department.vue

61
src/views/user/department.vue

@ -26,6 +26,8 @@
highlight-current-row
@row-click="onRowClick"
@selection-change="handleSelectionChange"
@select="rowSelect"
@select-all="selectAll"
>
<el-table-column type="selection" width="40" />
<el-table-column type="index" align="center" label="序号" width="80" />
@ -117,8 +119,10 @@ export default {
method: 'get',
params: this.listQuery
}).then(data => {
data.forEach(row => {
row.isChecked = false
})
this.list = data
this.totalCount = data.total
})
},
showCreate() {
@ -227,6 +231,61 @@ export default {
closeDialog() {
this.unAllotUserList = []
this.departmentUserList = []
},
/**
* 注意在获取初始数据时所有节点包括子节点都增加一个isChecked 标志参数
*
* @param selection
* @param row
*/
rowSelect(selection, row) {
if (row.children) { //
if (!row.isChecked) { // isChecked
row.children.map((item) => { //
this.$refs.list.toggleRowSelection(item, true) //
/*
方法名 说明 参数
用于多选表格切换某一行的选中状态 row, selected
toggleRowSelection 如果使用了第二个参数则是设置这一行
选中与否selected true 则选中
*/
item.isChecked = true
})
row.isChecked = true // isCheckedfalse
} else {
row.children.map((item) => {
this.$refs.list.toggleRowSelection(item, false)
item.isChecked = false
})
row.isChecked = false
}
// console.log(this.multipleSelection, row);
}
},
selectAll(selection) {
// selection
this.$refs.list.data.map((items) => { // 使$refdatamap
if (items.children) {
if (!items.isChecked) { //
this.$refs.list.toggleRowSelection(items, true) //
items.isChecked = true //
items.children.map((item) => { //
this.$refs.list.toggleRowSelection(item, true)
item.isChecked = true
})
} else { //
this.$refs.list.toggleRowSelection(items, false)
items.isChecked = false
items.children.map((item) => {
this.$refs.list.toggleRowSelection(item, false)
item.isChecked = false
})
}
} else {
items.isChecked = !items.isChecked
}
})
// console.log(this.orgs)
}
}
}

Loading…
Cancel
Save