update RoleEdit style
This commit is contained in:
@@ -4,20 +4,27 @@
|
||||
<t-form-item label="名称">
|
||||
<t-input v-model.trim="formModel.name" placeholder="角色名称" borderless :disabled="!canEditRoleInfo" />
|
||||
</t-form-item>
|
||||
<t-form-item label="代码">
|
||||
<t-form-item label="代码" :help="isBuiltinRole ? '内建角色代码不可修改' : ''">
|
||||
<t-input v-model.trim="formModel.code" placeholder="如 front-desk" borderless :disabled="!canEditRoleCode" />
|
||||
<div v-if="isBuiltinRole" class="hint" v-text="'内建角色代码不可修改'" />
|
||||
</t-form-item>
|
||||
<t-form-item label="模块">
|
||||
<t-input v-model.trim="formModel.moduleCode" placeholder="模块代码" borderless disabled />
|
||||
</t-form-item>
|
||||
<t-form-item label="上级" :arrow="canEditParentRole" @click="openParentRolePicker">
|
||||
<t-form-item
|
||||
label="上级"
|
||||
:arrow="canEditParentRole"
|
||||
@click.stop="openParentRolePicker"
|
||||
>
|
||||
<div class="picker-text" v-text="selectedParentRoleName" />
|
||||
</t-form-item>
|
||||
<t-form-item label="说明">
|
||||
<t-textarea v-model.trim="formModel.description" class="textarea" placeholder="角色说明" autosize borderless :disabled="!canEditRoleInfo" />
|
||||
</t-form-item>
|
||||
<t-form-item label="继承角色" :arrow="canEditRoleRelation" @click="openChildRolePicker">
|
||||
<t-form-item
|
||||
label="继承角色"
|
||||
:arrow="canEditRoleRelation"
|
||||
@click.stop="openChildRolePicker"
|
||||
>
|
||||
<div class="picker-text" v-text="selectedChildRoleName" />
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
@@ -45,20 +52,17 @@
|
||||
</t-cell-group>
|
||||
<template v-if="aggregatePermissionList.length">
|
||||
<section>
|
||||
<card-title title="聚合权限 P" description="该角色拥有以下权限,可执行权限对应的功能,这些权限来自上级角色直接授权或子角色继承。" />
|
||||
<card-title title="聚合权限 P">
|
||||
<div>该角色拥有以下权限,可执行权限对应的功能,这些权限来自上级角色直接授权或子角色继承。</div>
|
||||
<permission-legend />
|
||||
</card-title>
|
||||
<t-cell-group class="permission-list" theme="card">
|
||||
<t-cell
|
||||
<permission-cell
|
||||
v-for="item in aggregatePermissionList"
|
||||
:key="item.id"
|
||||
:title="item.name"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<span class="source" :class="`source-${item.source}`" />
|
||||
</template>
|
||||
<template #note>
|
||||
<span class="code" v-text="formatPermissionCode(item)" />
|
||||
</template>
|
||||
</t-cell>
|
||||
:permission="item"
|
||||
:source="item.source"
|
||||
/>
|
||||
</t-cell-group>
|
||||
</section>
|
||||
</template>
|
||||
@@ -73,29 +77,27 @@
|
||||
@confirm="confirmParentRolePicker"
|
||||
/>
|
||||
</t-popup>
|
||||
<t-popup v-model="childRolePickerVisible" placement="bottom">
|
||||
<div class="role-picker bg-white">
|
||||
<div class="picker-header">
|
||||
<t-button variant="text" size="small" @click="cancelChildRolePicker">取消</t-button>
|
||||
<span class="title" v-text="'继承角色'" />
|
||||
<t-button theme="primary" variant="text" size="small" :loading="savingTarget === 'inherit'" @click="saveRoleInherit">保存</t-button>
|
||||
</div>
|
||||
<div class="picker-body">
|
||||
<t-checkbox-group v-if="childOptions.length" v-model="childRolePickerDraft" class="group">
|
||||
<t-checkbox
|
||||
v-for="item in childOptions"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
:value="item.id"
|
||||
:label="item.name || item.code"
|
||||
icon="line"
|
||||
borderless
|
||||
/>
|
||||
</t-checkbox-group>
|
||||
<t-empty v-else description="暂无可继承角色" />
|
||||
</div>
|
||||
</div>
|
||||
</t-popup>
|
||||
<bottom-popup
|
||||
v-model="childRolePickerVisible"
|
||||
title="继承角色"
|
||||
left-button-text="取消"
|
||||
right-button-text="保存"
|
||||
@leftButtonClick="cancelChildRolePicker"
|
||||
@rightButtonClick="saveRoleInherit"
|
||||
>
|
||||
<t-checkbox-group v-if="childOptions.length" v-model="childRolePickerDraft" class="role-options">
|
||||
<t-checkbox
|
||||
v-for="item in childOptions"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
:value="item.id"
|
||||
:label="item.name || item.code"
|
||||
icon="line"
|
||||
borderless
|
||||
/>
|
||||
</t-checkbox-group>
|
||||
<t-empty v-else description="暂无可继承角色" />
|
||||
</bottom-popup>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -111,6 +113,8 @@ import {
|
||||
usePermissionSettingsStore
|
||||
} from "@/store/permissionSettingsStore";
|
||||
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
|
||||
import PermissionCell from "@/pages/permission/component/PermissionCell.vue";
|
||||
import PermissionLegend from "@/pages/permission/component/PermissionLegend.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "RoleEdit"
|
||||
@@ -198,9 +202,6 @@ const aggregatePermissionList = computed<PermissionWithSource[]>(() => {
|
||||
source: directPermissionIdSet.has(permission.id) ? "direct" : "inherited"
|
||||
}));
|
||||
});
|
||||
function formatPermissionCode(permission: Permission): string {
|
||||
return `${permission.moduleCode}:${permission.code}`;
|
||||
}
|
||||
|
||||
// ---------- 选择器 ----------
|
||||
type PickerValue = string | number;
|
||||
@@ -257,7 +258,6 @@ function openChildRolePicker(): void {
|
||||
if (!canEditRoleRelation.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
childRolePickerDraft.value = [...formModel.childRoleIdList];
|
||||
childRolePickerVisible.value = true;
|
||||
}
|
||||
@@ -492,114 +492,29 @@ onUnmounted(() => navBarStore.clearRight());
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.permission-list {
|
||||
--source-direct-color: #2563EB;
|
||||
--source-inherited-color: #14B8A6;
|
||||
|
||||
:deep(.t-cell) {
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__title {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title-text {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&__note {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
max-width: 56%;
|
||||
text-align: right;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.code {
|
||||
width: 100%;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.source {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
display: block;
|
||||
border-radius: .25rem;
|
||||
|
||||
&-direct {
|
||||
background: var(--source-direct-color);
|
||||
}
|
||||
|
||||
&-inherited {
|
||||
background: var(--source-inherited-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.picker-text {
|
||||
color: var(--td-text-color-primary);
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
|
||||
.group {
|
||||
--td-checkbox-vertical-padding: 10px;
|
||||
|
||||
background: #fff;
|
||||
border-radius: .75rem;
|
||||
|
||||
.item:not(:last-child)::after {
|
||||
left: 16px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
pointer-events: none;
|
||||
border-bottom: 1px solid var(--td-component-stroke, var(--td-gray-color-3, #e7e7e7));
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.role-picker {
|
||||
display: flex;
|
||||
height: 70vh;
|
||||
padding-top: 1rem;
|
||||
border-radius: 1.25rem 1.25rem 0 0;
|
||||
flex-direction: column;
|
||||
.role-options {
|
||||
--td-checkbox-vertical-padding: 10px;
|
||||
|
||||
.picker-header {
|
||||
padding: 0 1rem;
|
||||
display: grid;
|
||||
grid-template-columns: 4rem 1fr 4rem;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: .75rem;
|
||||
|
||||
.title {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.picker-body {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
padding: .75rem 1rem env(safe-area-inset-bottom, 0);
|
||||
}
|
||||
|
||||
.group {
|
||||
background: #fff;
|
||||
border-radius: .75rem;
|
||||
.item:not(:last-child)::after {
|
||||
left: 16px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
pointer-events: none;
|
||||
border-bottom: 1px solid var(--td-component-stroke, var(--td-gray-color-3, #e7e7e7));
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,29 +530,10 @@ onUnmounted(() => navBarStore.clearRight());
|
||||
}
|
||||
}
|
||||
|
||||
.code {
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.permission-list {
|
||||
.source {
|
||||
&-direct {
|
||||
background: #60a5fa;
|
||||
}
|
||||
|
||||
&-inherited {
|
||||
background: #2dd4bf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.role-picker {
|
||||
.role-options {
|
||||
background: #0f172a;
|
||||
|
||||
.group {
|
||||
background: #0f172a;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user