Files
syops/frontend/src/features/admin/modules/approvals/ApprovalsPage.vue
T

95 lines
3.6 KiB
Vue

/**
* features/admin/modules/approvals/ApprovalsPage.vue
* 用途:用户注册审批列表。一张卡片里放标题和待审表格。
* 依赖:AdminListPage、useApprovalsAdmin、useElementProvider、element-plus、roleLabel。
* 逻辑:路由未挂进当前菜单。通过和拒绝由 composable 弹出 Element 确认框后调接口。
*/
<script setup lang="ts">
import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { CircleCheck, Delete } from '@element-plus/icons-vue';
import { ElButton, ElConfigProvider, ElTable, ElTableColumn, ElTag } from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
import type { AdminUserRow } from '@/features/admin/types/admin.types';
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const {
pendingUsers,
isLoading,
loadAll,
approveUser,
rejectUser,
} = useApprovalsAdmin();
onMounted(() => {
void loadAll();
});
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
<p class="section-desc">{{ t('admin.approval.subtitle') }}</p>
</template>
<ElTable
class="hx-admin-table"
:data="pendingUsers"
row-key="id"
:empty-text="t('admin.approval.noPending')"
>
<ElTableColumn :label="t('admin.approval.headers.username')" min-width="200">
<template #default="{ row }">
<div>{{ (row as AdminUserRow).username }}</div>
<p class="hx-element-hint">{{ (row as AdminUserRow).email }}</p>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.nameId')" min-width="160">
<template #default="{ row }">
<div>{{ (row as AdminUserRow).real_name || '-' }}</div>
<p class="hx-element-hint">{{ (row as AdminUserRow).employee_id || '-' }}</p>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.contact')" min-width="140">
<template #default="{ row }">{{ (row as AdminUserRow).phone_number || '-' }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.role')" min-width="120">
<template #default="{ row }">
<ElTag effect="light" type="warning">
{{ adminRoleLabel(t, (row as AdminUserRow).role, (row as AdminUserRow).role_name) }}
</ElTag>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.actions')" width="120" align="right">
<template #default="{ row }">
<ElButton
link
type="primary"
:icon="CircleCheck"
:title="t('admin.approval.confirmApprove')"
@click="approveUser((row as AdminUserRow).id)"
/>
<ElButton
link
type="danger"
:icon="Delete"
:title="t('admin.approval.confirmReject')"
@click="rejectUser((row as AdminUserRow).id)"
/>
</template>
</ElTableColumn>
</ElTable>
</AdminListPage>
</ElConfigProvider>
</template>