109 lines
3.9 KiB
Vue
109 lines
3.9 KiB
Vue
/**
|
|
* features/admin/modules/approvals/ApprovalsPage.vue
|
|
* 用户注册审批独立页面。路由:/admin/approvals
|
|
*/
|
|
<script setup lang="ts">
|
|
import { onMounted } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { ShieldCheck, Trash2 } from 'lucide-vue-next';
|
|
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog.vue';
|
|
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
|
|
|
|
const { t } = useI18n();
|
|
|
|
const {
|
|
pendingUsers,
|
|
isLoading,
|
|
showConfirmDialog,
|
|
confirmMessage,
|
|
loadAll,
|
|
approveUser,
|
|
rejectUser,
|
|
closeConfirm,
|
|
confirmActionHandler,
|
|
} = useApprovalsAdmin();
|
|
|
|
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.approval.title') }}</h2>
|
|
<p class="section-desc mt-1">{{ t('admin.approval.subtitle') }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="admin-table-wrap">
|
|
<table class="admin-table">
|
|
<thead>
|
|
<tr>
|
|
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.username') }}</th>
|
|
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.nameId') }}</th>
|
|
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.contact') }}</th>
|
|
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.role') }}</th>
|
|
<th class="px-8 py-4 text-right text-xs">{{ t('admin.approval.headers.actions') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-if="pendingUsers.length === 0">
|
|
<td colspan="5" class="px-8 admin-table-empty">{{ t('admin.approval.noPending') }}</td>
|
|
</tr>
|
|
<tr v-for="user in pendingUsers" :key="user.id">
|
|
<td class="px-8 py-5 text-sm font-medium text-primary">
|
|
<div>{{ user.username }}</div>
|
|
<div class="text-xs text-muted font-normal">{{ user.email }}</div>
|
|
</td>
|
|
<td class="px-8 py-5 text-sm text-muted">
|
|
<div>{{ user.real_name || '-' }}</div>
|
|
<div class="text-xs text-muted font-mono">{{ user.employee_id || '-' }}</div>
|
|
</td>
|
|
<td class="px-8 py-5 text-sm text-muted">{{ user.phone_number || '-' }}</td>
|
|
<td class="px-8 py-5">
|
|
<span
|
|
class="px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 border border-yellow-200"
|
|
>
|
|
{{ t('admin.role.' + user.role) }}
|
|
</span>
|
|
</td>
|
|
<td class="px-8 py-5 text-right flex items-center justify-end gap-2">
|
|
<button
|
|
type="button"
|
|
class="p-2 text-green-600 bg-green-50 rounded-lg hover:bg-green-100 transition-colors"
|
|
:title="t('admin.approval.confirmApprove')"
|
|
@click="approveUser(user.id)"
|
|
>
|
|
<ShieldCheck class="w-4 h-4" />
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="p-2 text-red-600 bg-red-50 rounded-lg hover:bg-red-100 transition-colors"
|
|
:title="t('admin.approval.confirmReject')"
|
|
@click="rejectUser(user.id)"
|
|
>
|
|
<Trash2 class="w-4 h-4" />
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</template>
|
|
|
|
<DeleteConfirmDialog
|
|
v-model="showConfirmDialog"
|
|
:message="confirmMessage"
|
|
@cancel="closeConfirm"
|
|
@confirm="confirmActionHandler"
|
|
/>
|
|
</section>
|
|
</template>
|