管理端用户修改角色
parent
5dedcbc2ef
commit
d645df58c2
|
@ -325,3 +325,12 @@ export function useUserIDGetDoctorID(data) {
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 管理端修改用户角色
|
||||||
|
export function updateUserRoleInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: `/User/updateUserRoleInfo`,
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -85,11 +85,32 @@
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:disabled="user.CanEditUserType === false || type === 1"
|
:disabled="user.CanEditUserType === false || type === 1"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
|
v-if="type === 0"
|
||||||
>
|
>
|
||||||
<template v-for="(userType, key) of userTypeOptions">
|
<template v-for="userType of userTypeOptions">
|
||||||
<el-option
|
<el-option
|
||||||
v-if="userType.UserTypeEnum !== 20"
|
v-if="userType.UserTypeEnum !== 20"
|
||||||
:key="key"
|
:key="userType.Id"
|
||||||
|
:label="userType.UserType"
|
||||||
|
:value="userType.Id"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-select>
|
||||||
|
<el-select
|
||||||
|
ref="userType"
|
||||||
|
v-model="Roles"
|
||||||
|
size="small"
|
||||||
|
placeholder="Please select"
|
||||||
|
multiple
|
||||||
|
style="width: 100%"
|
||||||
|
:disabled="user.CanEditUserType === false || type === 1"
|
||||||
|
@change="handleChange"
|
||||||
|
v-else
|
||||||
|
>
|
||||||
|
<template v-for="userType of userTypeOptions">
|
||||||
|
<el-option
|
||||||
|
v-if="userType.UserTypeEnum !== 20"
|
||||||
|
:key="userType.Id"
|
||||||
:label="userType.UserType"
|
:label="userType.UserType"
|
||||||
:value="userType.Id"
|
:value="userType.Id"
|
||||||
/>
|
/>
|
||||||
|
@ -162,9 +183,10 @@
|
||||||
<roleList
|
<roleList
|
||||||
v-if="visible"
|
v-if="visible"
|
||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
:list="user.UserRoleList"
|
:userId="userId"
|
||||||
:roles.sync="user.Roles"
|
:list="userRoleList"
|
||||||
:userTypeOptions="userTypeOptions"
|
:userTypeOptions="userTypeOptions"
|
||||||
|
@getRoleList="getRoleList"
|
||||||
/>
|
/>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -193,6 +215,10 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openRoleList() {
|
openRoleList() {
|
||||||
|
this.userRoleList = []
|
||||||
|
this.user.UserRoleList.forEach((item) => {
|
||||||
|
this.userRoleList.push(Object.assign({}, item))
|
||||||
|
})
|
||||||
this.visible = true
|
this.visible = true
|
||||||
},
|
},
|
||||||
handleChange(val) {
|
handleChange(val) {
|
||||||
|
@ -274,10 +300,33 @@ export default {
|
||||||
IdentityUserId: this.userId,
|
IdentityUserId: this.userId,
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
this.user = res.Result
|
this.user = res.Result
|
||||||
|
this.Roles = []
|
||||||
this.user.Roles = []
|
this.user.Roles = []
|
||||||
this.user.UserRoleList = []
|
this.user.UserRoleList = []
|
||||||
res.Result.AccountList.forEach((item) => {
|
res.Result.AccountList.forEach((item) => {
|
||||||
if (!item.IsUserRoleDisabled) {
|
if (!item.IsUserRoleDisabled) {
|
||||||
|
this.Roles.push(item.UserTypeId)
|
||||||
|
this.user.Roles.push(item.UserTypeId)
|
||||||
|
}
|
||||||
|
this.user.UserRoleList.push({
|
||||||
|
UserTypeEnum: item.UserTypeEnum,
|
||||||
|
UserTypeId: item.UserTypeId,
|
||||||
|
IsUserRoleDisabled: item.IsUserRoleDisabled,
|
||||||
|
UserTypeShortName: item.UserTypeShortName,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getRoleList() {
|
||||||
|
getUser({
|
||||||
|
IdentityUserId: this.userId,
|
||||||
|
}).then((res) => {
|
||||||
|
this.Roles = []
|
||||||
|
this.user.Roles = []
|
||||||
|
this.user.UserRoleList = []
|
||||||
|
res.Result.AccountList.forEach((item) => {
|
||||||
|
if (!item.IsUserRoleDisabled) {
|
||||||
|
this.Roles.push(item.UserTypeId)
|
||||||
this.user.Roles.push(item.UserTypeId)
|
this.user.Roles.push(item.UserTypeId)
|
||||||
}
|
}
|
||||||
this.user.UserRoleList.push({
|
this.user.UserRoleList.push({
|
||||||
|
@ -315,6 +364,8 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
userRoleList: [],
|
||||||
|
Roles: [],
|
||||||
user: {
|
user: {
|
||||||
Roles: [],
|
Roles: [],
|
||||||
UserRoleList: [],
|
UserRoleList: [],
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:close-on-press-escape="false"
|
:close-on-press-escape="false"
|
||||||
append-to-body
|
append-to-body
|
||||||
:show-close="false"
|
|
||||||
:title="$t('system:userlist:roleList:title')"
|
:title="$t('system:userlist:roleList:title')"
|
||||||
:before-close="cancel"
|
:before-close="cancel"
|
||||||
>
|
>
|
||||||
|
@ -19,7 +18,12 @@
|
||||||
>
|
>
|
||||||
{{ $t('common:button:new') }}
|
{{ $t('common:button:new') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-table :data="list" style="width: 100%" max-height="300px">
|
<el-table
|
||||||
|
:data="list"
|
||||||
|
style="width: 100%"
|
||||||
|
max-height="300px"
|
||||||
|
v-loading="loading"
|
||||||
|
>
|
||||||
<el-table-column type="index" width="40" />
|
<el-table-column type="index" width="40" />
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="UserTypeShortName"
|
prop="UserTypeShortName"
|
||||||
|
@ -56,9 +60,13 @@
|
||||||
</el-table>
|
</el-table>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<!-- 保存 -->
|
<!-- 保存 -->
|
||||||
<el-button type="primary" size="small" @click="save">
|
<el-button type="primary" :loading="loading" size="small" @click="save">
|
||||||
{{ $t('common:button:confirm') }}
|
{{ $t('common:button:confirm') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<!-- 取消 -->
|
||||||
|
<el-button size="small" @click="cancel">
|
||||||
|
{{ $t('common:button:cancel') }}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-if="addVisible"
|
v-if="addVisible"
|
||||||
|
@ -103,9 +111,11 @@
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { updateUserRoleInfo } from '@/api/admin.js'
|
||||||
export default {
|
export default {
|
||||||
name: 'roleList',
|
name: 'roleList',
|
||||||
props: {
|
props: {
|
||||||
|
userId: { type: String, default: '' },
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -116,12 +126,6 @@ export default {
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
roles: {
|
|
||||||
type: Array,
|
|
||||||
default: () => {
|
|
||||||
return []
|
|
||||||
},
|
|
||||||
},
|
|
||||||
userTypeOptions: {
|
userTypeOptions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => {
|
default: () => {
|
||||||
|
@ -132,6 +136,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
addVisible: false,
|
addVisible: false,
|
||||||
|
loading: false,
|
||||||
form: {
|
form: {
|
||||||
roles: [],
|
roles: [],
|
||||||
},
|
},
|
||||||
|
@ -161,15 +166,24 @@ export default {
|
||||||
openAdd() {
|
openAdd() {
|
||||||
this.addVisible = true
|
this.addVisible = true
|
||||||
},
|
},
|
||||||
save() {
|
async save() {
|
||||||
let roles = []
|
try {
|
||||||
this.list.forEach((item) => {
|
let data = {
|
||||||
if (!item.IsUserRoleDisabled) {
|
Id: this.userId,
|
||||||
roles.push(item.UserTypeId)
|
UserRoleList: this.list,
|
||||||
}
|
}
|
||||||
})
|
this.loading = true
|
||||||
this.$emit('update:roles', roles)
|
let res = await updateUserRoleInfo(data)
|
||||||
|
this.loading = false
|
||||||
|
if (res.IsSuccess) {
|
||||||
|
this.$message.success(this.$t('common:message:updatedSuccessfully'))
|
||||||
this.$emit('update:visible', false)
|
this.$emit('update:visible', false)
|
||||||
|
this.$emit('getRoleList')
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.loading = false
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async saveAdd() {
|
async saveAdd() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue