diff --git a/src/components/access/roles.vue b/src/components/access/roles.vue index 50c2ac5..bc4f7c4 100644 --- a/src/components/access/roles.vue +++ b/src/components/access/roles.vue @@ -44,10 +44,26 @@ + + + + + 取消 + 确定 + + @@ -57,10 +73,50 @@ export default { name: 'roles', data () { return { - data: [] + data: [], + selectKey: [], + dialogVisible: false, + rights: [], + id: 0, + props: { + children: 'children', + label: 'authName' + } } }, methods: { + sub () { + const keys = [...this.$refs.treeRef.getCheckedKeys(), + ...this.$refs.treeRef.getHalfCheckedKeys()].join(',') + this.$http.post(`roles/${this.id}/rights`, { rids: keys }).then(response => { + const res = response.data + if (res.meta.status !== 200) { + return this.$message.error(res.meta.msg) + } + this.$message.success(res.meta.msg) + this.list() + this.dialogVisible = false + }) + }, + select (v) { + if (v) { + v.forEach(vv => { + this.selectKey.push(vv.id) + if (vv.children) { + this.select(vv.children) + } + }) + } + }, + setRole (row) { + this.id = row.id + this.select(row.children) + this.dialogVisible = true + this.$http.get('rights/tree').then(response => { + const res = response.data + this.rights = res.data + }).catch(error => error) + }, edit (id) { },