From 9057e04efad1b7d61c77a72e5c37a504d0aee935 Mon Sep 17 00:00:00 2001 From: doum <doum> Date: 星期五, 26 九月 2025 09:24:03 +0800 Subject: [PATCH] H5静态化 --- admin/src/components/system/user/RoleConfigWindow.vue | 123 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 123 insertions(+), 0 deletions(-) diff --git a/admin/src/components/system/user/RoleConfigWindow.vue b/admin/src/components/system/user/RoleConfigWindow.vue new file mode 100644 index 0000000..96cf087 --- /dev/null +++ b/admin/src/components/system/user/RoleConfigWindow.vue @@ -0,0 +1,123 @@ +<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, + // 宸查�変腑鐨勮鑹睮D + 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> -- Gitblit v1.9.3