¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | width="582px" |
| | | title="é
ç½®ç¨æ·è§è²" |
| | | @confirm="confirm" |
| | | > |
| | | <p class="tip" v-if="user != null">ä¸ºç¨æ· <em>{{user.realname}}</em> é
ç½®è§è²</p> |
| | | <el-transfer |
| | | v-model="selectedIds" |
| | | :titles="['æªææè§è²', 'å·²ææè§è²']" |
| | | :props="{ |
| | | key: 'id', |
| | | label: 'name' |
| | | }" |
| | | :data="roles"> |
| | | </el-transfer> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BasePage from '@/components/base/BasePage' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { createUserRole } from '@/api/system/user' |
| | | import { fetchAll as fetchAllRoles } from '@/api/system/role' |
| | | export default { |
| | | name: 'RoleConfigWindow', |
| | | extends: BasePage, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | visible: false, |
| | | isWorking: false, |
| | | // ç¨æ· |
| | | user: null, |
| | | // è§è²å表 |
| | | roles: null, |
| | | // å·²éä¸çè§è²ID |
| | | selectedIds: [] |
| | | } |
| | | }, |
| | | methods: { |
| | | /** |
| | | * æå¼çªå£ |
| | | * |
| | | * @param user ç®æ ç¨æ· |
| | | */ |
| | | open (user) { |
| | | fetchAllRoles() |
| | | .then(records => { |
| | | this.roles = records |
| | | this.user = user |
| | | // å¦æä¸ºåºå®ç¨æ·ï¼ååºå®è§è²ä¸å¯æ´æ¹ |
| | | if (this.user.fixed) { |
| | | for (const role of this.roles) { |
| | | if (role.fixed) { |
| | | role.disabled = true |
| | | } |
| | | } |
| | | } |
| | | // 妿å½åç¨æ·ä¸ºéè¶
级管çåç¨æ·ï¼åä¸å
许ææè¶
级管çåè§è² |
| | | if (!this.isAdmin) { |
| | | for (const role of this.roles) { |
| | | if (role.code === this.adminCode) { |
| | | role.disabled = true |
| | | } |
| | | } |
| | | } |
| | | this.selectedIds = this.user.roles.map(r => r.id) |
| | | this.visible = true |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | }, |
| | | /** |
| | | * ç¡®è®¤éæ©è§è² |
| | | */ |
| | | confirm () { |
| | | if (this.isWorking) { |
| | | return |
| | | } |
| | | this.isWorking = true |
| | | createUserRole({ |
| | | userId: this.user.id, |
| | | roleIds: this.selectedIds |
| | | }) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$emit('success') |
| | | setTimeout(() => { |
| | | this.$dialog.attentionConfirm('è§è²é
ç½®æåï¼ç¨æ·ééæ°ç»å½åçæ').then(() => {}) |
| | | }, 300) |
| | | }) |
| | | .catch(e => { |
| | | this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | }, |
| | | // å
³é |
| | | close () { |
| | | this.$emit('update:visible', false) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | @import "@/assets/style/variables.scss"; |
| | | // è§è²é
ç½® |
| | | .global-window { |
| | | .tip { |
| | | em { |
| | | font-style: normal; |
| | | color: $primary-color; |
| | | font-weight: bold; |
| | | } |
| | | } |
| | | } |
| | | </style> |