Skip to content

Commit f9d8ec0

Browse files
author
piexl
committed
1 parent d119c35 commit f9d8ec0

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

web/src/view/superAdmin/user/user.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
collapse-tags
2929
:props="{ multiple:true,checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
3030
:clearable="false"
31-
@visible-change="(flag)=>{changeAuthority(scope.row,flag)}"
32-
@remove-tag="()=>{changeAuthority(scope.row,false)}"
31+
@visible-change="(flag)=>{changeAuthority(scope.row,flag,0)}"
32+
@remove-tag="(removeAuth)=>{changeAuthority(scope.row,false,removeAuth)}"
3333
/>
3434
</template>
3535
</el-table-column>
@@ -348,18 +348,29 @@ const addUser = () => {
348348
dialogFlag.value = 'add'
349349
addUserDialog.value = true
350350
}
351-
const changeAuthority = async(row, flag) => {
351+
352+
const tempAuth = {}
353+
const changeAuthority = async(row, flag, removeAuth) => {
352354
if (flag) {
355+
if (!removeAuth) {
356+
tempAuth[row.ID] = [...row.authorityIds]
357+
}
353358
return
354359
}
355-
356360
await nextTick()
357361
const res = await setUserAuthorities({
358362
ID: row.ID,
359363
authorityIds: row.authorityIds
360364
})
361365
if (res.code === 0) {
362366
ElMessage({ type: 'success', message: '角色设置成功' })
367+
} else {
368+
if (!removeAuth) {
369+
row.authorityIds = [...tempAuth[row.ID]]
370+
delete tempAuth[row.ID]
371+
} else {
372+
row.authorityIds = [removeAuth, ...row.authorityIds]
373+
}
363374
}
364375
}
365376

0 commit comments

Comments
 (0)