refactor(admin): 部门管理树形页控件换用 Element Plus
This commit is contained in:
1 parent
ec47e012a7
commit
9dd7184aa7
5 files changed
+494
-411
No files matched your search
@@ -1,33 +1,40 @@
|
||||
/**
|
||||
* features/admin/modules/departments/DepartmentsPage.vue
|
||||
* 用途:部门管理独立页面——左树(公司虚拟分组 + 部门层级)右成员面板(OA 组织结构口径)。
|
||||
* 依赖:useDepartmentsAdmin、DepartmentFormModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/departments;左侧点击部门节点后,右侧按分页 + 关键词展示该部门成员
|
||||
* (含下级口径可切换);原「员工」计数列已剔除,成员展示方式对齐 OA 组织结构页。
|
||||
* 依赖:useDepartmentsAdmin、DepartmentFormModal、element-plus、@element-plus/icons-vue。
|
||||
* 逻辑:路由 /admin/departments。左侧点击部门节点后,右侧按分页 + 关键词展示该部门成员
|
||||
* (含下级口径可切换);删除确认走 ElMessageBox。控件按 ELEMENT_MIGRATION.md 全量 Element 化,
|
||||
* 树本身是自定义层级结构,不是 ElTable/ElTree 列表页,故不走 AdminListPage 骨架。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElCheckbox, ElConfigProvider, ElEmpty, ElIcon, ElInput, ElLoading, ElPagination, ElTable, ElTableColumn, ElTag } from 'element-plus';
|
||||
import {
|
||||
Building2,
|
||||
ChevronDown,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ArrowDown,
|
||||
ArrowRight,
|
||||
Delete,
|
||||
Edit,
|
||||
EyeOff,
|
||||
FolderPlus,
|
||||
ListTree,
|
||||
Expand,
|
||||
Fold,
|
||||
FolderAdd,
|
||||
Hide,
|
||||
OfficeBuilding,
|
||||
Plus,
|
||||
Search,
|
||||
Trash2,
|
||||
Users,
|
||||
} from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
} from '@element-plus/icons-vue';
|
||||
import DepartmentFormModal from './components/DepartmentFormModal.vue';
|
||||
import { useDepartmentsAdmin } from './composables/useDepartmentsAdmin';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import type { AdminDepartmentTreeNode } from '@/features/admin/types/admin.types';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
|
||||
const {
|
||||
displayRows,
|
||||
@@ -37,8 +44,6 @@ const {
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
toggleNode,
|
||||
toggleCompany,
|
||||
@@ -49,8 +54,6 @@ const {
|
||||
closeFormModal,
|
||||
saveDepartment,
|
||||
deleteDepartment,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
selectedDeptId,
|
||||
selectedDept,
|
||||
selectedDeptPath,
|
||||
@@ -67,6 +70,18 @@ const {
|
||||
setMemberPageSize,
|
||||
} = useDepartmentsAdmin();
|
||||
|
||||
/** 成员面板总页数(由 total / page_size 推导)。 */
|
||||
const memberTotalPages = computed(() => {
|
||||
const data = memberData.value;
|
||||
if (!data || data.page_size <= 0) return 1;
|
||||
return Math.max(1, Math.ceil(data.total / data.page_size));
|
||||
});
|
||||
|
||||
/** 左树空状态文案:搜索无结果或尚无部门。 */
|
||||
const treeEmptyText = computed(() => (
|
||||
searchQuery.value.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts')
|
||||
));
|
||||
|
||||
/** 成员状态 → 本地化标签;未知状态回退显示原值。 */
|
||||
const statusLabel = (status?: string): string => {
|
||||
if (!status) return '-';
|
||||
@@ -74,12 +89,12 @@ const statusLabel = (status?: string): string => {
|
||||
return te(key) ? t(key) : status;
|
||||
};
|
||||
|
||||
/** 成员面板总页数(由 total / page_size 推导)。 */
|
||||
const memberTotalPages = computed(() => {
|
||||
const data = memberData.value;
|
||||
if (!data || data.page_size <= 0) return 1;
|
||||
return Math.max(1, Math.ceil(data.total / data.page_size));
|
||||
});
|
||||
/** 成员状态 → ElTag 类型:启用 success,待审核 warning,其余 info。 */
|
||||
const statusTagType = (status?: string): 'success' | 'warning' | 'info' => {
|
||||
if (status === 'active') return 'success';
|
||||
if (status === 'pending') return 'warning';
|
||||
return 'info';
|
||||
};
|
||||
|
||||
/** 公司虚拟分组行 key 去前缀,得到分组 key(用于展开状态)。 */
|
||||
const companyGroupKey = (rowKey: string): string => rowKey.slice('company:'.length);
|
||||
@@ -90,257 +105,189 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<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 admin-table-header--stacked">
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="admin-table-section">
|
||||
<header class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.dept.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.dept.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal()"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.dept.add') }}</span>
|
||||
</button>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateModal()">
|
||||
{{ t('admin.dept.add') }}
|
||||
</ElButton>
|
||||
</header>
|
||||
|
||||
<!-- 筛选条:左树搜索 + 展开/收起,一条分隔线与内容区分开 -->
|
||||
<div class="admin-dept-filter">
|
||||
<ElInput
|
||||
v-model="searchQuery"
|
||||
class="admin-dept-filter__search"
|
||||
:prefix-icon="Search"
|
||||
clearable
|
||||
:placeholder="t('admin.dept.searchPlaceholder')"
|
||||
/>
|
||||
<ElButton text :icon="Expand" :title="t('admin.dept.expandAll')" @click="expandAll" />
|
||||
<ElButton text :icon="Fold" :title="t('admin.dept.collapseAll')" @click="collapseAll" />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col lg:flex-row gap-4 items-start">
|
||||
<div v-loading="isLoading" class="admin-dept-body">
|
||||
<!-- 左侧:组织树(公司虚拟分组 + 层级缩进) -->
|
||||
<div class="w-full lg:w-[340px] shrink-0 rounded-2xl border border-subtle bg-surface flex flex-col gap-3 p-4 lg:max-h-[calc(100vh-230px)] overflow-hidden">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="relative flex-1 min-w-0">
|
||||
<Search class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted pointer-events-none" />
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="search"
|
||||
class="admin-table-filter-input w-full pl-9"
|
||||
:placeholder="t('admin.dept.searchPlaceholder')"
|
||||
<div class="admin-dept-tree">
|
||||
<ElEmpty v-if="displayRows.length === 0" :description="treeEmptyText" :image-size="80" />
|
||||
<template v-for="row in displayRows" :key="row.key">
|
||||
<!-- 公司虚拟分组行(不入库,前端按 company 字段归堆) -->
|
||||
<div
|
||||
v-if="row.kind === 'company'"
|
||||
class="admin-dept-tree__row admin-dept-tree__row--company"
|
||||
@click="toggleCompany(companyGroupKey(row.key))"
|
||||
>
|
||||
<ElIcon class="admin-dept-tree__chevron">
|
||||
<component :is="row.expanded ? ArrowDown : ArrowRight" />
|
||||
</ElIcon>
|
||||
<ElIcon class="admin-dept-tree__company-icon"><OfficeBuilding /></ElIcon>
|
||||
<span class="admin-dept-tree__name" :title="row.company">{{ row.company }}</span>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="FolderAdd"
|
||||
:title="t('admin.dept.addChild')"
|
||||
@click.stop="openCreateModal(null, row.company)"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 text-muted hover:text-primary hover:bg-subtle rounded-lg transition-colors shrink-0"
|
||||
:title="t('admin.dept.expandAll')"
|
||||
@click="expandAll"
|
||||
><ListTree class="w-4 h-4" /></button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 text-muted hover:text-primary hover:bg-subtle rounded-lg transition-colors shrink-0"
|
||||
:title="t('admin.dept.collapseAll')"
|
||||
@click="collapseAll"
|
||||
><ChevronDown class="w-4 h-4" /></button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-y-auto min-h-0 -mx-1 px-1 space-y-0.5">
|
||||
<div v-if="displayRows.length === 0" class="py-12 text-center text-sm text-muted">
|
||||
{{ searchQuery.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts') }}
|
||||
</div>
|
||||
<template v-for="row in displayRows" :key="row.key">
|
||||
<!-- 公司虚拟分组行(不入库,前端按 company 字段归堆) -->
|
||||
<div
|
||||
v-if="row.kind === 'company'"
|
||||
class="group flex items-center gap-1.5 py-2 pr-1 rounded-lg cursor-pointer select-none hover:bg-subtle/70"
|
||||
@click="toggleCompany(companyGroupKey(row.key))"
|
||||
<!-- 部门行(层级缩进;点击选中 → 右侧出成员面板) -->
|
||||
<div
|
||||
v-else
|
||||
class="admin-dept-tree__row"
|
||||
:class="{ 'is-selected': selectedDeptId === row.node!.id }"
|
||||
:style="{ paddingLeft: `${(row.depth - 1) * 16 + 4}px` }"
|
||||
@click="selectDept(row.node!)"
|
||||
>
|
||||
<button
|
||||
v-if="row.hasChildren"
|
||||
type="button"
|
||||
class="admin-dept-tree__toggle"
|
||||
:title="row.expanded ? t('admin.dept.collapse') : t('admin.dept.expand')"
|
||||
@click.stop="toggleNode(row.node!.id)"
|
||||
>
|
||||
<component
|
||||
:is="row.expanded ? ChevronDown : ChevronRight"
|
||||
class="w-4 h-4 text-muted shrink-0"
|
||||
/>
|
||||
<Building2 class="w-4 h-4 text-brand-600 shrink-0" />
|
||||
<span class="font-semibold text-primary text-sm truncate" :title="row.company">{{ row.company }}</span>
|
||||
<span class="flex-1" />
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-emerald-600 hover:bg-emerald-50 rounded-lg transition-colors shrink-0"
|
||||
<ElIcon>
|
||||
<component :is="row.expanded ? ArrowDown : ArrowRight" />
|
||||
</ElIcon>
|
||||
</button>
|
||||
<span v-else class="admin-dept-tree__toggle" />
|
||||
<span class="admin-dept-tree__name" :title="row.node!.name">{{ row.node!.name }}</span>
|
||||
<ElTag
|
||||
v-if="row.node!.is_hidden"
|
||||
type="warning"
|
||||
effect="light"
|
||||
size="small"
|
||||
:icon="Hide"
|
||||
:title="t('admin.dept.fields.hiddenHint')"
|
||||
>
|
||||
{{ t('admin.dept.tags.hidden') }}
|
||||
</ElTag>
|
||||
<span class="admin-dept-tree__spacer" />
|
||||
<span class="admin-dept-tree__actions" @click.stop>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="FolderAdd"
|
||||
:title="t('admin.dept.addChild')"
|
||||
@click.stop="openCreateModal(null, row.company)"
|
||||
>
|
||||
<FolderPlus class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<!-- 部门行(层级缩进;点击选中 → 右侧出成员面板) -->
|
||||
<div
|
||||
v-else
|
||||
class="group flex items-center gap-1.5 py-2 pr-1 rounded-lg cursor-pointer select-none transition-colors"
|
||||
:class="selectedDeptId === row.node!.id ? 'bg-brand-50 dark:bg-brand-900/30' : 'hover:bg-subtle/70'"
|
||||
:style="{ paddingLeft: `${(row.depth - 1) * 16 + 4}px` }"
|
||||
@click="selectDept(row.node!)"
|
||||
>
|
||||
<button
|
||||
v-if="row.hasChildren"
|
||||
type="button"
|
||||
class="p-0.5 text-muted hover:text-primary rounded transition-colors shrink-0"
|
||||
:title="row.expanded ? t('admin.dept.collapse') : t('admin.dept.expand')"
|
||||
@click.stop="toggleNode(row.node!.id)"
|
||||
>
|
||||
<component :is="row.expanded ? ChevronDown : ChevronRight" class="w-4 h-4" />
|
||||
</button>
|
||||
<span v-else class="w-5 shrink-0" />
|
||||
<span class="font-medium text-sm truncate" :class="selectedDeptId === row.node!.id ? 'text-brand-700' : 'text-primary'" :title="row.node!.name">{{ row.node!.name }}</span>
|
||||
<span
|
||||
v-if="row.node!.is_hidden"
|
||||
class="inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-amber-50 text-amber-700 shrink-0"
|
||||
:title="t('admin.dept.fields.hiddenHint')"
|
||||
><EyeOff class="w-3 h-3" />{{ t('admin.dept.tags.hidden') }}</span>
|
||||
<span class="flex-1" />
|
||||
<span class="hidden group-hover:flex items-center gap-0.5 shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1 text-emerald-600 hover:bg-emerald-50 rounded-lg transition-colors"
|
||||
:title="t('admin.dept.addChild')"
|
||||
@click.stop="openCreateModal(row.node as AdminDepartmentTreeNode)"
|
||||
>
|
||||
<FolderPlus class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1 text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
|
||||
:title="t('admin.dept.actions.edit')"
|
||||
@click.stop="openEditModal(row.node!)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
:title="t('admin.dept.actions.delete')"
|
||||
@click.stop="deleteDepartment(row.node!.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@click="openCreateModal(row.node as AdminDepartmentTreeNode)"
|
||||
/>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="Edit"
|
||||
:title="t('admin.dept.actions.edit')"
|
||||
@click="openEditModal(row.node!)"
|
||||
/>
|
||||
<ElButton
|
||||
link
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
:title="t('admin.dept.actions.delete')"
|
||||
@click="deleteDepartment(row.node!.id)"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:选中部门的成员面板(OA 口径) -->
|
||||
<div class="flex-1 min-w-0 w-full rounded-2xl border border-subtle bg-surface flex flex-col lg:max-h-[calc(100vh-230px)] overflow-hidden">
|
||||
<div class="admin-dept-members">
|
||||
<template v-if="!selectedDept">
|
||||
<div class="flex-1 flex flex-col items-center justify-center py-24 text-muted">
|
||||
<Users class="w-10 h-10 mb-3 opacity-50" />
|
||||
<p class="text-sm">{{ t('admin.dept.members.hint') }}</p>
|
||||
</div>
|
||||
<ElEmpty class="admin-dept-members__empty" :description="t('admin.dept.members.hint')" :image-size="80" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<header class="px-5 py-4 border-b border-subtle flex items-start justify-between gap-4 flex-wrap">
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-base font-bold text-primary truncate">{{ selectedDept.name }}</h3>
|
||||
<p class="text-xs text-muted mt-0.5 truncate" :title="selectedDeptPath.join(' / ')">
|
||||
{{ selectedDeptPath.join(' / ') }}
|
||||
</p>
|
||||
<header class="admin-dept-members__header">
|
||||
<div class="admin-dept-members__title">
|
||||
<h3>{{ selectedDept.name }}</h3>
|
||||
<p :title="selectedDeptPath.join(' / ')">{{ selectedDeptPath.join(' / ') }}</p>
|
||||
</div>
|
||||
<label class="flex items-center gap-2 text-sm text-muted cursor-pointer select-none shrink-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="accent-brand-600 w-4 h-4"
|
||||
:checked="memberIncludeDescendants"
|
||||
@change="setMemberIncludeDescendants(($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<ElCheckbox
|
||||
:model-value="memberIncludeDescendants"
|
||||
@change="setMemberIncludeDescendants($event as boolean)"
|
||||
>
|
||||
{{ t('admin.dept.members.includeDescendants') }}
|
||||
</label>
|
||||
</ElCheckbox>
|
||||
</header>
|
||||
|
||||
<div class="px-5 py-3 border-b border-subtle">
|
||||
<div class="relative max-w-sm">
|
||||
<Search class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted pointer-events-none" />
|
||||
<input
|
||||
:value="memberKeyword"
|
||||
type="search"
|
||||
class="admin-table-filter-input w-full pl-9"
|
||||
:placeholder="t('admin.dept.members.searchPlaceholder')"
|
||||
@input="setMemberKeyword(($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
</div>
|
||||
<div class="admin-dept-members__toolbar">
|
||||
<ElInput
|
||||
:model-value="memberKeyword"
|
||||
class="admin-dept-members__search"
|
||||
:prefix-icon="Search"
|
||||
clearable
|
||||
:placeholder="t('admin.dept.members.searchPlaceholder')"
|
||||
@input="setMemberKeyword(String($event))"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<table class="w-full table-fixed text-sm">
|
||||
<colgroup>
|
||||
<col class="w-[24%]" />
|
||||
<col class="w-[26%]" />
|
||||
<col class="w-[16%]" />
|
||||
<col class="w-[18%]" />
|
||||
<col class="w-[16%]" />
|
||||
</colgroup>
|
||||
<!-- sticky 放在 th 上(thead 级 sticky 在部分浏览器不生效,行会从表头上方滚出) -->
|
||||
<thead class="text-xs text-muted">
|
||||
<tr>
|
||||
<th class="px-5 py-3 text-left font-medium sticky top-0 z-10 admin-table-sticky-head">{{ t('admin.dept.members.columns.name') }}</th>
|
||||
<th class="px-5 py-3 text-left font-medium sticky top-0 z-10 admin-table-sticky-head">{{ t('admin.dept.members.columns.contact') }}</th>
|
||||
<th class="px-5 py-3 text-left font-medium sticky top-0 z-10 admin-table-sticky-head">{{ t('admin.dept.members.columns.employeeId') }}</th>
|
||||
<th class="px-5 py-3 text-left font-medium sticky top-0 z-10 admin-table-sticky-head">{{ t('admin.dept.members.columns.department') }}</th>
|
||||
<th class="px-5 py-3 text-left font-medium sticky top-0 z-10 admin-table-sticky-head">{{ t('admin.dept.members.columns.status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="memberLoading">
|
||||
<td colspan="5" class="px-5 py-10 text-center text-muted">
|
||||
<div class="animate-spin rounded-full h-7 w-7 border-b-2 border-brand-600 mx-auto" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="!memberData || memberData.members.length === 0">
|
||||
<td colspan="5" class="px-5 py-10 text-center text-muted">{{ t('admin.dept.members.empty') }}</td>
|
||||
</tr>
|
||||
<template v-else>
|
||||
<tr v-for="member in memberData.members" :key="member.id" class="border-t border-subtle hover:bg-subtle/40">
|
||||
<td class="px-5 py-3">
|
||||
<div class="font-medium text-primary truncate">{{ member.real_name || member.username }}</div>
|
||||
<div class="text-xs text-muted truncate">{{ member.username }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-3 text-muted truncate">{{ member.phone_number || member.email || '-' }}</td>
|
||||
<td class="px-5 py-3 text-muted font-mono truncate">{{ member.employee_id || '-' }}</td>
|
||||
<td class="px-5 py-3 text-muted truncate">{{ member.department || '-' }}</td>
|
||||
<td class="px-5 py-3">
|
||||
<span class="inline-flex px-2 py-0.5 rounded-full text-xs bg-blue-50 text-blue-600 whitespace-nowrap">{{ statusLabel(member.status) }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ElTable
|
||||
v-loading="memberLoading"
|
||||
:data="memberData?.members ?? []"
|
||||
row-key="id"
|
||||
stripe
|
||||
:empty-text="t('admin.dept.members.empty')"
|
||||
class="admin-dept-members__table"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.dept.members.columns.name')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<div class="admin-dept-member__name">{{ row.real_name || row.username }}</div>
|
||||
<div class="admin-dept-member__sub">{{ row.username }}</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.dept.members.columns.contact')" min-width="170">
|
||||
<template #default="{ row }">{{ row.phone_number || row.email || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="employee_id" :label="t('admin.dept.members.columns.employeeId')" min-width="110" />
|
||||
<ElTableColumn prop="department" :label="t('admin.dept.members.columns.department')" min-width="130" />
|
||||
<ElTableColumn :label="t('admin.dept.members.columns.status')" width="90">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType(row.status)" effect="light" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<footer v-if="memberData" class="px-5 py-3 border-t border-subtle flex items-center justify-between gap-3 flex-wrap text-sm text-muted">
|
||||
<span>{{ t('admin.dept.members.total', { total: memberData.total }) }}</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<!-- 全局样式已为 select 绘制背景箭头(右缘 8~29px),pr-10 让文字止于 40px,避开箭头区 -->
|
||||
<select
|
||||
:value="memberPageSize"
|
||||
class="admin-table-filter-input pr-10 cursor-pointer"
|
||||
@change="setMemberPageSize(Number(($event.target as HTMLSelectElement).value))"
|
||||
>
|
||||
<option :value="20">20</option>
|
||||
<option :value="50">50</option>
|
||||
<option :value="100">100</option>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg hover:bg-subtle disabled:opacity-40 disabled:pointer-events-none"
|
||||
:disabled="memberPage <= 1"
|
||||
:title="t('admin.dept.members.prevPage')"
|
||||
@click="setMemberPage(memberPage - 1)"
|
||||
><ChevronLeft class="w-4 h-4" /></button>
|
||||
<span class="whitespace-nowrap">{{ memberPage }} / {{ memberTotalPages }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg hover:bg-subtle disabled:opacity-40 disabled:pointer-events-none"
|
||||
:disabled="memberPage >= memberTotalPages"
|
||||
:title="t('admin.dept.members.nextPage')"
|
||||
@click="setMemberPage(memberPage + 1)"
|
||||
><ChevronRight class="w-4 h-4" /></button>
|
||||
</div>
|
||||
<footer v-if="memberData" class="admin-dept-members__footer">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="memberData.total"
|
||||
:current-page="memberPage"
|
||||
:page-size="memberPageSize"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
@current-change="setMemberPage"
|
||||
@size-change="setMemberPageSize"
|
||||
/>
|
||||
<span class="admin-dept-members__pages">{{ memberPage }} / {{ memberTotalPages }}</span>
|
||||
</footer>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
<DepartmentFormModal
|
||||
:visible="showFormModal"
|
||||
@@ -350,12 +297,156 @@ onMounted(() => {
|
||||
@close="closeFormModal"
|
||||
@save="saveDepartment"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 页内布局(非 Element 控件内部),间距对齐迁移规范:筛选条、面板分隔、分页右侧 */
|
||||
.admin-dept-filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.admin-dept-filter__search {
|
||||
width: 16rem;
|
||||
}
|
||||
.admin-dept-body {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
min-height: 24rem;
|
||||
}
|
||||
.admin-dept-tree {
|
||||
width: 320px;
|
||||
flex-shrink: 0;
|
||||
padding: 12px 8px 12px 32px;
|
||||
border-right: 1px solid var(--el-border-color-lighter);
|
||||
max-height: calc(100vh - 280px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.admin-dept-tree__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 4px;
|
||||
border-radius: var(--el-border-radius-base);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
min-width: 0;
|
||||
}
|
||||
.admin-dept-tree__row:hover {
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
.admin-dept-tree__row--company {
|
||||
font-weight: 600;
|
||||
}
|
||||
.admin-dept-tree__row.is-selected {
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
.admin-dept-tree__row.is-selected .admin-dept-tree__name {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.admin-dept-tree__chevron,
|
||||
.admin-dept-tree__toggle {
|
||||
flex-shrink: 0;
|
||||
width: 20px;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.admin-dept-tree__company-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.admin-dept-tree__name {
|
||||
font-size: var(--el-font-size-base);
|
||||
color: var(--el-text-color-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.admin-dept-tree__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.admin-dept-tree__actions {
|
||||
display: none;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.admin-dept-tree__row:hover .admin-dept-tree__actions {
|
||||
display: inline-flex;
|
||||
}
|
||||
.admin-dept-members {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.admin-dept-members__empty {
|
||||
margin: auto;
|
||||
}
|
||||
.admin-dept-members__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
padding: 16px 32px 8px;
|
||||
}
|
||||
.admin-dept-members__title {
|
||||
min-width: 0;
|
||||
}
|
||||
.admin-dept-members__title h3 {
|
||||
font-size: var(--el-font-size-large);
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.admin-dept-members__title p {
|
||||
font-size: var(--el-font-size-small);
|
||||
color: var(--el-text-color-secondary);
|
||||
margin: 2px 0 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.admin-dept-members__toolbar {
|
||||
padding: 8px 32px 12px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.admin-dept-members__search {
|
||||
width: 16rem;
|
||||
}
|
||||
.admin-dept-members__table {
|
||||
flex: 1;
|
||||
}
|
||||
.admin-dept-members__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
padding: 12px 32px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
.admin-dept-members__pages {
|
||||
font-size: var(--el-font-size-small);
|
||||
color: var(--el-text-color-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.admin-dept-member__name {
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.admin-dept-member__sub {
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
color: var(--el-text-color-secondary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user