fix: report
This commit is contained in:
1 parent
07e83132c0
commit
4445ff68d4
46 files changed
+3904
-897
No files matched your search
@@ -5,17 +5,20 @@
|
||||
* 逻辑:路由 /admin/permissions;左侧用户相关列 sticky,右侧为各应用权限列。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, FileText, Users } from 'lucide-vue-next';
|
||||
import BatchPermissionModal from '@/features/admin/modules/users/components/BatchPermissionModal.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import { usePermissionsAdmin } from './composables/usePermissionsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
agents,
|
||||
users,
|
||||
appRows,
|
||||
permissionFilters,
|
||||
selectedUserIds,
|
||||
paginatedUsers,
|
||||
@@ -40,6 +43,45 @@ const { t } = useI18n();
|
||||
importPermissions,
|
||||
} = usePermissionsAdmin();
|
||||
|
||||
const permissionView = ref<'apps' | 'members'>('apps');
|
||||
const selectedApp = ref<(typeof agents.value)[number] | null>(null);
|
||||
const appMemberSearch = ref('');
|
||||
const appMemberPage = ref(1);
|
||||
const appMemberPageSize = ref(10);
|
||||
const appMemberPageSizeOptions = [10, 20, 50, 100];
|
||||
|
||||
/** 应用成员弹窗:已授权人员优先展示,同时可搜索全部有效人员以便增删权限。 */
|
||||
const appMembers = computed(() => {
|
||||
const appId = selectedApp.value?.id;
|
||||
const keyword = appMemberSearch.value.trim().toLowerCase();
|
||||
if (!appId) return [];
|
||||
return users.value
|
||||
.filter((user) => user.status !== 'pending')
|
||||
.filter((user) => !keyword || [user.username, user.real_name, user.department, user.employee_id]
|
||||
.filter(Boolean)
|
||||
.some((value) => String(value).toLowerCase().includes(keyword)))
|
||||
.sort((a, b) => Number(b.agent_ids.includes(appId)) - Number(a.agent_ids.includes(appId)));
|
||||
});
|
||||
|
||||
const appMemberTotalPages = computed(() => Math.max(1, Math.ceil(appMembers.value.length / appMemberPageSize.value)));
|
||||
const paginatedAppMembers = computed(() => {
|
||||
const page = Math.min(Math.max(1, appMemberPage.value), appMemberTotalPages.value);
|
||||
const start = (page - 1) * appMemberPageSize.value;
|
||||
return appMembers.value.slice(start, start + appMemberPageSize.value);
|
||||
});
|
||||
watch(appMemberSearch, () => { appMemberPage.value = 1; });
|
||||
|
||||
const openAppMembers = (app: (typeof agents.value)[number]): void => {
|
||||
selectedApp.value = app;
|
||||
appMemberSearch.value = '';
|
||||
appMemberPage.value = 1;
|
||||
};
|
||||
|
||||
const closeAppMembers = (): void => {
|
||||
selectedApp.value = null;
|
||||
appMemberSearch.value = '';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
@@ -85,7 +127,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-filters--inline">
|
||||
<div v-if="permissionView === 'members'" class="admin-table-filters--inline">
|
||||
<input
|
||||
v-model="permissionFilters.username"
|
||||
:placeholder="t('admin.perm.filterName')"
|
||||
@@ -104,11 +146,37 @@ onMounted(() => {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<div class="flex gap-6 border-b border-default">
|
||||
<button type="button" class="border-b-2 px-1 py-3 text-sm font-medium transition-colors" :class="permissionView === 'apps' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-primary'" @click="permissionView = 'apps'">
|
||||
{{ t('admin.perm.views.apps') }}
|
||||
</button>
|
||||
<button type="button" class="border-b-2 px-1 py-3 text-sm font-medium transition-colors" :class="permissionView === 'members' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-primary'" @click="permissionView = 'members'">
|
||||
{{ t('admin.perm.views.members') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="permissionView === 'apps'" class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table min-w-[680px]">
|
||||
<thead><tr>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.perm.appHeaders.app') }}</th>
|
||||
<th class="px-4 py-4 text-center text-sm">{{ t('admin.perm.appHeaders.type') }}</th>
|
||||
<th class="px-4 py-4 text-center text-sm">{{ t('admin.perm.appHeaders.authorized') }}</th>
|
||||
<th class="px-6 py-4 text-right text-sm">{{ t('admin.perm.appHeaders.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody><tr v-for="app in appRows" :key="app.id">
|
||||
<td class="px-6 py-4"><div class="font-medium text-primary">{{ app.name }}</div><div class="mt-1 text-xs text-muted">{{ t('admin.perm.appHeaders.accessHint') }}</div></td>
|
||||
<td class="px-4 py-4 text-center text-sm text-muted">{{ app.type || 'API' }}</td>
|
||||
<td class="px-4 py-4 text-center text-sm font-medium text-primary">{{ app.authorizedCount }}</td>
|
||||
<td class="px-6 py-4 text-right"><button type="button" class="text-sm font-medium text-brand-600 hover:text-brand-700" @click="openAppMembers(app)">{{ t('admin.perm.appHeaders.viewMembers') }}</button></td>
|
||||
</tr></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table min-w-max">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-4 w-12 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<th class="w-[3rem] px-2 py-4 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
@@ -117,27 +185,17 @@ onMounted(() => {
|
||||
/>
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-12 admin-table-sticky-head z-20 w-56"
|
||||
class="w-[18rem] min-w-[18rem] px-4 py-4 text-left text-sm sticky left-[3rem] admin-table-sticky-head z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]"
|
||||
>
|
||||
{{ t('admin.perm.headers.user') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-[17rem] admin-table-sticky-head z-20 w-36"
|
||||
>
|
||||
{{ t('admin.perm.headers.realName') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-[26rem] admin-table-sticky-head z-20 w-40 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]"
|
||||
>
|
||||
{{ t('admin.perm.headers.dept') }}
|
||||
</th>
|
||||
<th
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center text-sm min-w-[100px]"
|
||||
class="w-[7.5rem] min-w-[7.5rem] px-3 py-4 text-center text-sm"
|
||||
>
|
||||
<div class="flex flex-col items-center gap-1">
|
||||
<span>{{ agent.name }}</span>
|
||||
<div class="flex min-h-14 flex-col items-center justify-center gap-1">
|
||||
<span class="line-clamp-2 max-w-[6.5rem] break-words leading-tight" :title="agent.name">{{ agent.name }}</span>
|
||||
<span class="text-[10px] text-muted font-normal border border-default px-1 rounded">
|
||||
{{ agent.type }}
|
||||
</span>
|
||||
@@ -147,7 +205,7 @@ onMounted(() => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in paginatedUsers" :key="user.id">
|
||||
<td class="px-4 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<td class="w-[3rem] px-2 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
@@ -155,34 +213,29 @@ onMounted(() => {
|
||||
@change="toggleUserSelection(user.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-12 admin-table-sticky-cell z-20">
|
||||
<td class="w-[18rem] min-w-[18rem] px-4 py-3 sticky left-[3rem] admin-table-sticky-cell z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.05)]">
|
||||
<div class="flex items-center gap-3">
|
||||
<div
|
||||
class="w-8 h-8 rounded-full bg-gradient-to-br from-brand-100 to-indigo-100 text-brand-600 flex items-center justify-center font-bold text-sm"
|
||||
>
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="font-medium text-primary text-sm truncate max-w-[120px]" :title="user.username">
|
||||
{{ user.username }}
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-medium text-primary" :title="user.real_name || user.username">
|
||||
{{ user.real_name || user.username }}
|
||||
</div>
|
||||
<div class="mt-1 flex min-w-0 items-center gap-2 text-xs text-muted">
|
||||
<span class="max-w-[7rem] truncate" :title="user.username">{{ user.username }}</span>
|
||||
<span class="h-3 w-px shrink-0 bg-border" />
|
||||
<span class="max-w-[8rem] truncate" :title="user.department || '-'">{{ user.department || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-[17rem] admin-table-sticky-cell z-20">
|
||||
<div class="text-sm text-primary truncate" :title="user.real_name || '-'">
|
||||
{{ user.real_name || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="px-6 py-4 sticky left-[26rem] admin-table-sticky-cell z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.05)]"
|
||||
>
|
||||
<div class="text-sm text-muted truncate" :title="user.department">
|
||||
{{ user.department || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center border-l border-dashed border-subtle"
|
||||
class="w-[7.5rem] min-w-[7.5rem] px-3 py-3 text-center border-l border-dashed border-subtle"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -215,5 +268,33 @@ onMounted(() => {
|
||||
@close="closeBatchPermissionModal"
|
||||
@save="submitBatchPermission"
|
||||
/>
|
||||
|
||||
<div v-if="selectedApp" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/30 p-4" @click.self="closeAppMembers">
|
||||
<section class="flex max-h-[min(720px,calc(100vh-2rem))] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-default bg-surface shadow-2xl">
|
||||
<header class="flex items-start justify-between border-b border-default px-6 py-5"><div><h3 class="text-lg font-semibold text-primary">{{ selectedApp.name }}</h3><p class="mt-1 text-sm text-muted">{{ t('admin.perm.appHeaders.memberHint') }}</p></div><button type="button" class="text-sm text-muted hover:text-primary" @click="closeAppMembers">{{ t('admin.close') }}</button></header>
|
||||
<div class="border-b border-subtle bg-surface-soft px-6 py-4"><input v-model="appMemberSearch" :placeholder="t('admin.perm.appHeaders.memberSearch')" class="admin-table-filter-input w-full" /></div>
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<div v-for="member in paginatedAppMembers" :key="member.id" class="flex items-center justify-between gap-4 border-b border-subtle px-6 py-3 last:border-b-0"><div class="flex min-w-0 items-center gap-3"><div class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-brand-100 text-sm font-bold text-brand-600">{{ getUserAvatarLabel(member) }}</div><div class="min-w-0"><div class="truncate text-sm font-medium text-primary">{{ member.real_name || member.username }}</div><div class="truncate text-xs text-muted">{{ member.username }} · {{ member.department || '-' }}</div></div></div><button type="button" class="shrink-0 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors" :class="member.agent_ids.includes(selectedApp.id) ? 'text-red-600 hover:bg-red-50' : 'text-brand-600 hover:bg-brand-50'" @click="toggleUserAgentPermission(member, selectedApp.id)">{{ member.agent_ids.includes(selectedApp.id) ? t('admin.perm.appHeaders.removeMember') : t('admin.perm.appHeaders.addMember') }}</button></div>
|
||||
<p v-if="appMembers.length === 0" class="px-6 py-12 text-center text-sm text-muted">{{ t('admin.perm.appHeaders.noMembers') }}</p>
|
||||
</div>
|
||||
<PaginationBar v-if="appMembers.length > 0" v-model:page="appMemberPage" v-model:page-size="appMemberPageSize" :total="appMembers.length" :pages="appMemberTotalPages" :page-size-options="appMemberPageSizeOptions" class="app-member-pagination rounded-none border-x-0 border-b-0" />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 查看成员弹窗宽度固定,分页摘要与翻页操作保持在同一行。 */
|
||||
:deep(.app-member-pagination) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
:deep(.app-member-pagination > div) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.app-member-pagination > div:last-child) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user