代码更新

This commit is contained in:
2022-12-08 10:29:29 +08:00
parent c0c50900db
commit d4dfe5c07d
16 changed files with 133 additions and 92 deletions

View File

@@ -173,11 +173,11 @@
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-key"><span @click="resetPassword(scope.row)">重置密码</span></el-dropdown-item>
<el-dropdown-item icon="el-icon-key">
<span @click="openDeptDrawer(scope.row)">部门权限</span>
</el-dropdown-item>
<el-dropdown-item icon="el-icon-key">数据权限</el-dropdown-item>
<el-dropdown-item icon="el-icon-key"><span @click="resetPassword(scope.row)">重置密码</span></el-dropdown-item>
<el-dropdown-item icon="el-icon-key"><span @click="changeEnabled(scope.row)">{{ enabledTypeOptions.find(item => {return item.key !== scope.row.is_used}).display_name }}账号</span></el-dropdown-item>
<el-dropdown-item icon="el-icon-circle-check">
<span @click="openRoleDrawer(scope.row)">分配角色</span>
@@ -193,7 +193,7 @@
</el-row>
<el-drawer
:title="drawerTitle"
:visible.sync="deptDrawer"
:visible.sync="syncDrawer"
direction="rtl"
:before-close="handleClose"
:wrapper-closable="false"
@@ -202,22 +202,12 @@
>
<div style="margin: 0 20px 0 20px; height: 100%">
<div style="height: 90%">
<!-- <div class="head-container">-->
<!-- <el-input-->
<!-- v-model="deptName"-->
<!-- clearable-->
<!-- size="mini"-->
<!-- placeholder="请输入部门名称"-->
<!-- prefix-icon="el-icon-search"-->
<!-- class="filter-item"-->
<!-- @input="getDeptDatas"-->
<!-- />-->
<!-- </div>-->
<el-tree
v-if="flag"
ref="deptUser"
show-checkbox
default-expand-all
:data="drawerDatas"
:data="deptsDatas"
:default-checked-keys="depChecked"
:props="deptProps"
:node-key="nodeKey"
@@ -225,11 +215,23 @@
check-strictly
@check="handCheck"
@check-change="checkChange"
@close="clearCheck"
/>
<el-table
v-if="!flag"
highlight-current-row
ref="roleTable"
style="width: 100%;"
:data="rolesDatas"
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55"/>
<el-table-column prop="name" label="角色名称" min-width="100" show-overflow-tooltip/>
</el-table>
</div>
<div style="height: 10%">
<el-button @click="cancelForm">取 消</el-button>
<el-button type="primary" @click="saveChecked">保存</el-button>
<el-button type="primary" @click="saveChecked">保 存</el-button>
</div>
</div>
</el-drawer>
@@ -297,13 +299,13 @@ export default {
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
]
},
deptDrawer: false,
syncDrawer: false,
depChecked: [],
depCheckedId: '',
drawerDatas: [], // ?
deptsDatas: [],
rolesDatas: [],
drawerTitle: '',
drawerHint: '',
nodeKey: '',
nodeKey: 'dept_id',
flag: true
}
},
@@ -535,32 +537,44 @@ export default {
},
openDeptDrawer(row) {
crudDept.getDeptTree().then(res => {
this.drawerDatas = res.content
this.deptsDatas = res.content
})
this.drawerTitle = '分配部门权限'
this.drawerHint = '请选择部门'
this.nodeKey = 'dept_id'
this.openDrawer()
this.drawerTitle = '分配部门权限'
this.flag = true
this.deptDrawer = true
this.depChecked = []
this.depCheckedId = ''
console.log(row)
// 默认选中
this.depChecked = row.depts
this.depCheckedId = row.user_id
this.giveValue(row)
},
openRoleDrawer(row) {
this.rolesDatas = []
getAll().then(res => {
this.drawerDatas = res
this.rolesDatas = res
// 回显默认选中
console.log(res)
console.log(row.roles)
this.$nextTick(function() {
for (let i = 0; i < this.rolesDatas.length; i++) {
for (let j = 0; j < row.roles.length; j++) {
if (this.rolesDatas[i].role_id == row.roles[j]) {
this.$refs.roleTable.toggleRowSelection(this.rolesDatas[i], true)
}
}
}
})
})
this.deptDrawer = true
this.openDrawer()
this.drawerTitle = '分配角色权限'
this.drawerHint = '请选择角色'
this.nodeKey = 'role_id'
this.flag = false
this.depChecked = []
this.giveValue(row)
},
openDrawer() {
this.syncDrawer = true
this.depCheckedId = ''
console.log(row)
this.depChecked = row.roles
this.depChecked = []
},
giveValue(row) {
this.depCheckedId = row.user_id
},
clearCheck() {
@@ -574,19 +588,21 @@ export default {
.catch(_ => {})
},
cancelForm() { // 关闭
this.deptDrawer = false
this.syncDrawer = false
if (this.flag) this.clearCheck()
},
saveChecked() {
console.log(this.depCheckedId)
console.log(this.$refs.deptUser.getCheckedKeys())
const user = {
user_id: this.depCheckedId,
user_id: this.depCheckedId
}
if (this.flag) {
user.depts = this.$refs.deptUser.getCheckedKeys()
} else {
user.roles = this.$refs.deptUser.getCheckedKeys()
user.roles = this.crud.selections.map(item => (item.role_id))
}
console.log('user', user)
console.log(this.flag)
console.log(this.crud.selections)
crudUser.edit(user).then(res => {
this.cancelForm()
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)