!20 Merge branch 'dev' into snow

Merge pull request !20 from 王瑞雪/snow
This commit is contained in:
sophie authored and Gitee committed 2026-09-29 05:13:46 +00:00
commit 2065b73610
56 files changed
+4501 -1110

No files matched your search

@@ -8,10 +8,9 @@
<script setup lang="ts">
import { computed, ref, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { Bot, Plus, SquarePen, Trash2, Users } from 'lucide-vue-next';
import { Bot, Plus, SquarePen, Trash2 } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import AgentFormModal from './components/AgentFormModal.vue';
import AgentPermissionModal from './components/AgentPermissionModal.vue';
import AgentTestModal from './components/AgentTestModal.vue';
import { useAgentsAdmin } from './composables/useAgentsAdmin';
import { useAgentsTableColumnResize } from './composables/useAgentsTableColumnResize';
@@ -29,7 +28,6 @@ const {
contentProfileOptions,
scheduleTasks,
trainingExamPdfGuides,
activeUsers,
isLoading,
isSaving,
isImportingTrainingPdf,
@@ -40,9 +38,6 @@ const {
isTesting,
testingAgent,
testResult,
showPermissionModal,
permissionAgent,
permissionUserIds,
showDeleteConfirmDialog,
deleteConfirmMessage,
loadAll,
@@ -59,9 +54,6 @@ const {
deleteAgent,
openTestModal,
runAgentTest,
openPermissionModal,
togglePermissionUser,
savePermissions,
closeDeleteConfirm,
confirmDelete,
} = useAgentsAdmin();
@@ -75,13 +67,11 @@ const {
const tableHeaderColumns = computed(() => [
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
{ key: 'type', label: t('admin.agent.headers.type'), align: 'left' as const },
{ key: 'aggregation', label: t('admin.agent.headers.aggregation'), align: 'left' as const },
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
]);
/* 列表仅展示名称、状态和操作;类型/聚合/配置仍由编辑弹窗维护。 */
const formatAgentCode = (agent: AgentRow) => agent.agent_code || 'generic';
const formatAgentAggregationPrimary = (agent: AgentRow) => (
@@ -131,6 +121,8 @@ const formatRuntimeProviderLabel = (agent: AgentRow) => {
const translated = t(key);
return translated === key ? provider : translated;
};
void [formatAgentAggregationPrimary, formatAgentAggregationSecondary, formatAgentConfigPrimary,
formatAgentConfigSecondary, formatAgentTypeLabel, formatRuntimeProviderLabel];
const showFormDialog = ref(false);
@@ -241,43 +233,6 @@ onMounted(() => {
</p>
</div>
</td>
<td class="px-4 py-4 align-middle">
<div class="agent-list-cell">
<p class="truncate text-sm text-primary" :title="formatAgentTypeLabel(agent)">
{{ formatAgentTypeLabel(agent) }}
</p>
<p class="truncate text-xs text-muted" :title="formatRuntimeProviderLabel(agent)">
{{ formatRuntimeProviderLabel(agent) }}
</p>
</div>
</td>
<td class="px-4 py-4 align-middle">
<div class="agent-list-cell">
<p
class="truncate text-sm font-medium"
:class="agent.is_aggregate ? 'text-brand-700' : 'text-secondary'"
:title="formatAgentAggregationPrimary(agent)"
>
{{ formatAgentAggregationPrimary(agent) }}
</p>
<p class="truncate text-xs text-muted" :title="formatAgentAggregationSecondary(agent)">
{{ formatAgentAggregationSecondary(agent) }}
</p>
</div>
</td>
<td class="px-4 py-4 align-middle">
<div class="agent-list-cell">
<p
class="truncate font-mono text-sm text-primary"
:title="formatAgentConfigPrimary(agent)"
>
{{ formatAgentConfigPrimary(agent) }}
</p>
<p class="truncate text-xs text-muted">
{{ formatAgentConfigSecondary(agent) }}
</p>
</div>
</td>
<td class="px-4 py-4 align-middle">
<div class="agent-list-cell">
<span
@@ -300,14 +255,6 @@ onMounted(() => {
<SquarePen class="w-4 h-4 shrink-0" />
{{ t('admin.edit') }}
</button>
<button
type="button"
class="inline-flex shrink-0 items-center justify-center p-2 text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-lg transition-all"
:title="t('admin.agent.manageAccess')"
@click.stop="openPermissionModal(agent)"
>
<Users class="w-5 h-5 shrink-0" />
</button>
<button
type="button"
class="inline-flex shrink-0 items-center whitespace-nowrap p-2 text-emerald-600 bg-emerald-50 hover:bg-emerald-100 rounded-lg transition-all"
@@ -367,17 +314,6 @@ onMounted(() => {
@import-training-pdf="importTrainingQuestionBankFromPdf"
/>
<AgentPermissionModal
:visible="showPermissionModal"
:agent="permissionAgent"
:users="activeUsers()"
:selected-user-ids="permissionUserIds"
:is-saving="isSaving"
@close="showPermissionModal = false"
@save="savePermissions"
@toggle-user="togglePermissionUser"
/>
<DeleteConfirmDialog
v-model="showDeleteConfirmDialog"
:message="deleteConfirmMessage"
@@ -8,12 +8,14 @@
import { computed, onBeforeUnmount, ref } from 'vue';
const STORAGE_KEY = 'hxops.admin.agents.tableColumnWidths';
// 列结构已移除权限操作,升级缓存键以废弃旧的拖拽宽度,避免旧值继续撑出横向滚动。
const STORAGE_KEY = 'hxops.admin.agents.tableColumnWidths.v4';
/** 名称 / 类型 / 分类 / 配置 / 状态 / 操作 */
const DEFAULT_WIDTHS = [220, 168, 128, 140, 96, 220] as const;
// 列宽只根据字段和操作控件确定;描述始终在名称单元格内截断,不参与宽度计算。
const DEFAULT_WIDTHS = [400, 140, 240] as const;
const MIN_WIDTHS = [140, 120, 100, 120, 80, 200] as const;
const MIN_WIDTHS = [220, 110, 220] as const;
const COLUMN_COUNT = DEFAULT_WIDTHS.length;
@@ -5,15 +5,22 @@
* 逻辑:路由 /admin/departments;表头排序复用 shared SortableTableHeader + useTableSort。
*/
<script setup lang="ts">
import { onMounted } from 'vue';
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { Edit, Plus, Search, Trash2 } from 'lucide-vue-next';
import { Edit, Plus, Search, Trash2, Users } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
import DepartmentFormModal from './components/DepartmentFormModal.vue';
import DepartmentMembersModal from './components/DepartmentMembersModal.vue';
import { useDepartmentsAdmin } from './composables/useDepartmentsAdmin';
import { listAdminDepartmentMembers } from '@/features/admin/api/admin.api';
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
import { useMessage } from '@/shared/composables/useMessage';
const { t } = useI18n();
const msg = useMessage();
const showMembersModal = ref(false);
const departmentMembers = ref<AdminDepartmentMembersResponse | null>(null);
const {
filteredDepartments,
@@ -40,6 +47,16 @@ const {
onMounted(() => {
void loadAll();
});
/** 加载并展示指定部门的员工名单。 */
const openDepartmentMembers = async (departmentId: number): Promise<void> => {
try {
departmentMembers.value = await listAdminDepartmentMembers(departmentId) as AdminDepartmentMembersResponse;
showMembersModal.value = true;
} catch (error) {
msg.error((error as Error).message || t('admin.msg.requestFailed'));
}
};
</script>
<template>
@@ -77,13 +94,14 @@ onMounted(() => {
</div>
<div class="admin-table-wrap">
<!-- 列宽:名称 / 编码 / 公司 / 操作 -->
<!-- 列宽:名称 / 编码 / 公司 / 员工 / 操作 -->
<table class="admin-table table-fixed">
<colgroup>
<col class="w-[25%]" />
<col class="w-[20%]" />
<col class="w-[35%]" />
<col class="w-[15%]" />
<col class="w-[30%]" />
<col class="w-[12%]" />
<col class="w-[13%]" />
</colgroup>
<thead>
<tr>
@@ -114,12 +132,13 @@ onMounted(() => {
@sort="toggleSort"
/>
</th>
<th class="px-6 py-4 text-center text-xs">{{ t('admin.dept.headers.members') }}</th>
<th class="px-6 py-4 text-right text-xs">{{ t('admin.dept.headers.actions') }}</th>
</tr>
</thead>
<tbody>
<tr v-if="filteredDepartments.length === 0">
<td colspan="4" class="px-6 admin-table-empty">
<td colspan="5" class="px-6 admin-table-empty">
{{ searchQuery.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts') }}
</td>
</tr>
@@ -140,6 +159,14 @@ onMounted(() => {
<td class="px-6 py-4 text-sm text-muted truncate" :title="d.company || '-'">
{{ d.company || '-' }}
</td>
<td class="px-6 py-4 text-center">
<button
type="button"
class="inline-flex items-center justify-center rounded-lg bg-blue-50 p-2 text-blue-600 hover:bg-blue-100"
:title="t('admin.dept.actions.viewMembers')"
@click="openDepartmentMembers(d.id)"
><Users class="w-5 h-5" /><span class="ml-1 text-xs">{{ d.member_count || 0 }}</span></button>
</td>
<td class="px-6 py-4">
<div class="flex justify-end gap-1">
<button
@@ -173,6 +200,11 @@ onMounted(() => {
@close="closeFormModal"
@save="saveDepartment"
/>
<DepartmentMembersModal
:visible="showMembersModal"
:data="departmentMembers"
@close="showMembersModal = false"
/>
<DeleteConfirmDialog
v-model="showDeleteConfirmDialog"
@@ -0,0 +1,44 @@
/**
* features/admin/modules/departments/components/DepartmentMembersModal.vue
* 用途:展示部门对应的员工数量和名单。
* 依赖:部门成员只读 API 响应与 Vue 事件。
* 逻辑:DepartmentsPage 点击员工图标后传入数据,本组件只负责呈现与关闭。
*/
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { Users, X } from 'lucide-vue-next';
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
defineProps<{ visible: boolean; data: AdminDepartmentMembersResponse | null }>();
const emit = defineEmits<{ close: [] }>();
const { t } = useI18n();
</script>
<template>
<div v-if="visible && data" class="admin-modal-overlay items-center" @click.self="emit('close')">
<section class="admin-modal-panel max-w-2xl max-h-[90vh] animate-fade-in-up">
<header class="px-8 py-6 border-b border-subtle flex items-center justify-between">
<div>
<h3 class="text-lg font-bold text-primary">{{ t('admin.dept.members.title', { name: data.department.name }) }}</h3>
<p class="text-sm text-muted mt-1">{{ t('admin.dept.members.count', { count: data.count }) }}</p>
</div>
<button type="button" class="btn-icon-ds rounded-full" :title="t('admin.close')" @click="emit('close')"><X class="w-5 h-5" /></button>
</header>
<div class="max-h-[60vh] overflow-y-auto p-6">
<div v-if="data.members.length === 0" class="py-12 text-center text-muted">
<Users class="w-9 h-9 mx-auto mb-3 opacity-60" />
{{ t('admin.dept.members.empty') }}
</div>
<ul v-else class="divide-y divide-subtle">
<li v-for="member in data.members" :key="member.id" class="py-3 flex items-center justify-between gap-4">
<div class="min-w-0">
<p class="font-medium text-primary">{{ member.real_name || member.username }}</p>
<p class="text-xs text-muted truncate">{{ member.employee_id || member.username }} · {{ member.email || '-' }}</p>
</div>
<span class="text-xs text-muted whitespace-nowrap">{{ member.status }}</span>
</li>
</ul>
</div>
</section>
</div>
</template>
@@ -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>
@@ -39,6 +39,12 @@ export function usePermissionsAdmin() {
const activeUsers = computed(() => users.value.filter((u) => u.status !== 'pending'));
/** 按应用视图行:复用已加载用户权限,统计每个应用的有效授权人数。 */
const appRows = computed(() => agents.value.map((agent) => ({
...agent,
authorizedCount: activeUsers.value.filter((user) => user.agent_ids.includes(agent.id)).length,
})));
const filteredUsers = computed(() =>
activeUsers.value.filter((u) => {
const matchName =
@@ -216,6 +222,7 @@ export function usePermissionsAdmin() {
return {
users,
agents,
appRows,
permissionFilters,
selectedUserIds,
filteredUsers,
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,100 +0,0 @@
/**
* features/admin/modules/requests/RequestsPage.vue
* 权限申请管理独立页面。路由:/admin/requests
*/
<script setup lang="ts">
import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { ShieldCheck } from 'lucide-vue-next';
import { useRequestsAdmin } from './composables/useRequestsAdmin';
const { t } = useI18n();
const {
requests,
isLoading,
loadAll,
approveRequest,
rejectRequest,
} = useRequestsAdmin();
onMounted(() => {
void loadAll();
});
</script>
<template>
<section class="admin-table-section">
<div v-if="isLoading" class="flex items-center justify-center py-20">
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
</div>
<template v-else>
<div class="admin-table-header">
<div>
<h2 class="section-title">{{ t('admin.request.title') }}</h2>
<p class="section-desc mt-1">{{ t('admin.request.subtitle') }}</p>
</div>
</div>
<div
v-if="requests.length === 0"
class="flex flex-col items-center justify-center py-16 text-muted"
>
<div class="w-16 h-16 bg-surface-soft rounded-full flex items-center justify-center mb-4">
<ShieldCheck class="w-8 h-8 text-muted" />
</div>
<p>{{ t('admin.request.noPending') }}</p>
</div>
<table v-else class="admin-table">
<thead>
<tr>
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.userId') }}</th>
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.targetAgent') }}</th>
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.reason') }}</th>
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.status') }}</th>
<th class="px-8 py-4 text-xs text-right">{{ t('admin.request.headers.actions') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="req in requests" :key="req.id">
<td class="px-8 py-4 text-sm font-medium text-primary">{{ req.user_id }}</td>
<td class="px-8 py-4 text-sm text-secondary">{{ req.agent_id }}</td>
<td
class="px-8 py-4 text-sm text-muted max-w-xs truncate"
:title="req.reason"
>
{{ req.reason || '-' }}
</td>
<td class="px-8 py-4">
<span
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-50 text-yellow-700 border border-yellow-100"
>
{{ t('admin.status.' + req.status) }}
</span>
</td>
<td class="px-8 py-4 text-right">
<div class="flex justify-end gap-3">
<button
type="button"
class="text-green-600 hover:text-green-800 text-sm font-medium hover:underline"
@click="approveRequest(req.id)"
>
{{ t('admin.request.approve') }}
</button>
<button
type="button"
class="text-red-500 hover:text-red-700 text-sm font-medium hover:underline"
@click="rejectRequest(req.id)"
>
{{ t('admin.request.reject') }}
</button>
</div>
</td>
</tr>
</tbody>
</table>
</template>
</section>
</template>
@@ -1,68 +0,0 @@
/**
* features/admin/modules/requests/composables/useRequestsAdmin.ts
* 权限申请管理:列表、通过、拒绝。
*/
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import {
approveAdminPermissionRequest,
listAdminPermissionRequests,
rejectAdminPermissionRequest,
} from '@/features/admin/api/admin.api';
import { useMessage } from '@/shared/composables/useMessage';
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
import type { AdminPermissionRequestRow } from '@/features/admin/types/request.types';
export function useRequestsAdmin() {
const { t } = useI18n();
const msg = useMessage();
const { refreshBadges } = useAdminNavBadges();
const requests = ref<AdminPermissionRequestRow[]>([]);
const isLoading = ref(true);
const loadRequests = async (): Promise<void> => {
try {
requests.value = await listAdminPermissionRequests();
} catch (e) {
console.error('Error loading permission requests:', e);
requests.value = [];
}
};
const loadAll = async (): Promise<void> => {
isLoading.value = true;
await loadRequests();
isLoading.value = false;
};
const approveRequest = async (id: number): Promise<void> => {
try {
await approveAdminPermissionRequest(id);
await loadRequests();
await refreshBadges();
} catch (e) {
console.error(e);
msg.error((e as Error).message || t('admin.msg.failed'));
}
};
const rejectRequest = async (id: number): Promise<void> => {
try {
await rejectAdminPermissionRequest(id);
await loadRequests();
await refreshBadges();
} catch (e) {
console.error(e);
msg.error((e as Error).message || t('admin.msg.failed'));
}
};
return {
requests,
isLoading,
loadAll,
approveRequest,
rejectRequest,
};
}
@@ -11,6 +11,7 @@ import { Edit, Plus, Trash2, Users } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
import BatchEditUserModal from './components/BatchEditUserModal.vue';
import BatchPermissionModal from './components/BatchPermissionModal.vue';
import UserFormModal from './components/UserFormModal.vue';
@@ -199,7 +200,7 @@ onMounted(() => {
<td class="px-6 py-4">
<div class="flex items-center">
<div class="h-9 w-9 rounded-full bg-gradient-to-br from-brand-500 to-indigo-600 text-white flex items-center justify-center text-xs font-bold shadow-sm">
{{ user.username.charAt(0).toUpperCase() }}
{{ getUserAvatarLabel(user) }}
</div>
<div class="ml-3 text-sm font-medium text-primary">{{ user.username }}</div>
</div>