Browse Source

fix: 优化 防止修改自己权限

zhangrenyuan/feature-20250714163943-金币前端二期
lihui 2 weeks ago
parent
commit
862d28754d
  1. 37
      src/views/permissions/permission.vue

37
src/views/permissions/permission.vue

@ -69,7 +69,18 @@ const addRole = ref({
})
//
const permissionSelect = ref()
//
const adminData = ref({})
const getAdminData = async function () {
try {
const result = await API({ url: '/admin/userinfo', data: {} })
adminData.value = result
// console.log('', result)
console.log('管理员用户信息', adminData.value)
} catch (error) {
console.log('请求失败', error)
}
}
//
const permissionEditObj = ref({
@ -606,13 +617,7 @@ const editStatus = async function (row) {
}
}
//
onMounted(async function () {
await get()
await getArea()
await getStore()
await getRoleList()
})
const handlePageSizeChange = function (val) {
getObj.value.pageSize = val
get()
@ -698,6 +703,16 @@ const resetPassword = async function (row) {
ElMessage.error('请求失败', error)
}
}
//
onMounted(async function () {
await get()
await getArea()
await getStore()
await getRoleList()
await getAdminData()
})
</script>
<template>
@ -774,12 +789,12 @@ const resetPassword = async function (row) {
重置密码
</el-button>
<el-button type="primary" text @click="permissionEditInit(scope.row)"
:disabled="scope.row.adminStatus === 0">
:disabled="scope.row.adminStatus === 0 ||scope.row.account === adminData.account ">
修改权限
</el-button>
<el-popconfirm title="确定将此用户删除吗?" @confirm="delRoleConfirm">
<template #reference>
<el-button type="danger" text @click="del(scope.row)" :disabled="scope.row.adminStatus === 0">
<el-button type="danger" text @click="del(scope.row)" :disabled="scope.row.adminStatus === 0 || scope.row.account === adminData.account">
删除
</el-button>
</template>
@ -794,7 +809,7 @@ const resetPassword = async function (row) {
</el-table-column>
<el-table-column prop="adminStatus" label="状态">
<template #default="scope">
<el-switch v-model="scope.row.adminStatus" :active-value="1" :inactive-value="0" size="large"
<el-switch v-model="scope.row.adminStatus" :active-value="1" :inactive-value="0" size="large" :disabled="scope.row.account === adminData.account"
@change="editStatus(scope.row)" style="
--el-switch-on-color: #13ce66;
--el-switch-off-color: #ff4949;

Loading…
Cancel
Save