提交 bd424e21 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 943faa89
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
ref="tree" ref="tree"
:props="defaultProps" :props="defaultProps"
:filter-node-method="filterNode" :filter-node-method="filterNode"
v-loading="submitLoading"
> >
</el-tree> </el-tree>
<template #footer> <template #footer>
<el-button type="text" @click="onCancel">取消</el-button>&nbsp;&nbsp; <el-button type="text" @click="onCancel">取消</el-button>&nbsp;&nbsp;
<el-button type="primary" size="medium" @click="onPrimary">保存</el-button> <el-button type="primary" size="medium" @click="onPrimary" :loading="submitLoading">保存</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
...@@ -34,7 +35,8 @@ export default { ...@@ -34,7 +35,8 @@ export default {
activeName: '2', activeName: '2',
permissions: [], // 所有权限 permissions: [], // 所有权限
currentPermissions: [], // 当前角色权限 currentPermissions: [], // 当前角色权限
defaultProps: { children: 'children', label: 'name' } defaultProps: { children: 'children', label: 'name' },
submitLoading: false
} }
}, },
computed: { computed: {
...@@ -64,7 +66,7 @@ export default { ...@@ -64,7 +66,7 @@ export default {
}, },
// 获取所有权限 // 获取所有权限
getPermissions() { getPermissions() {
getPermissionList({ app_id: this.appid, limit: 500 }).then(res => { return getPermissionList({ app_id: this.appid, limit: 500 }).then(res => {
this.permissions = res.data.data this.permissions = res.data.data
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.tree.filter(this.activeName) this.$refs.tree.filter(this.activeName)
...@@ -76,7 +78,11 @@ export default { ...@@ -76,7 +78,11 @@ export default {
getRolePermissions({ app_id: this.appid, role_id: this.data.id }).then(res => { getRolePermissions({ app_id: this.appid, role_id: this.data.id }).then(res => {
if (res.data.length) { if (res.data.length) {
this.currentPermissions = res.data.map(item => item.id) this.currentPermissions = res.data.map(item => item.id)
this.$refs.tree.setCheckedKeys(this.currentPermissions) // 有bug,暂时不用
// this.$refs.tree.setCheckedKeys(this.currentPermissions)
this.currentPermissions.forEach(id => {
this.$refs.tree.setChecked(id, true)
})
} }
}) })
}, },
...@@ -91,11 +97,16 @@ export default { ...@@ -91,11 +97,16 @@ export default {
role_id: this.data.id, role_id: this.data.id,
permission_ids: JSON.stringify(this.$refs.tree.getCheckedKeys()) permission_ids: JSON.stringify(this.$refs.tree.getCheckedKeys())
} }
updateRolePermissions(params).then(res => { this.submitLoading = true
this.$message.success('配置成功') updateRolePermissions(params)
this.$emit('update:visible', false) .then(res => {
this.$emit('success', res.data) this.$message.success('配置成功')
}) this.$emit('update:visible', false)
this.$emit('success', res.data)
})
.finally(() => {
this.submitLoading = false
})
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论