Upgrade frontend to Schema V2: Admin management pages
新增功能: - OIDC 登入流程完整實現(LoginPage → AuthCallbackPage) - 6 個管理頁面:系統、模組、公司、站台、會員、權限群組 - 權限群組管理:群組 CRUD + 綁定會員 + 群組授權/撤銷 - 新 API 層:systems、modules、companies、sites、members、permission-groups - admin store:統一管理公共清單資料 調整既有頁面: - PermissionSnapshotPage:表格新增 system 欄位 - PermissionAdminPage: - 新增 system 必填欄位 - scope_type 改為 company/site 下拉選單 - module 改為選填(空值代表系統層權限) - Router:補 6 條新管理路由 - App.vue:導覽列新增管理員群組下拉菜單 驗收條件達成: ✓ 可新增 system/module/company/site ✓ 可做用戶直接 grant/revoke(新 payload) ✓ 可建立 permission-group、加會員、群組 grant/revoke ✓ /me/permissions/snapshot 表格可顯示 system + module + action Build:成功(0 errors) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
96
frontend/src/pages/admin/SystemsPage.vue
Normal file
96
frontend/src/pages/admin/SystemsPage.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h2 class="text-xl font-bold text-gray-800">系統管理</h2>
|
||||
<el-button type="primary" @click="showDialog = true" :icon="Plus">新增系統</el-button>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="error"
|
||||
:title="errorMsg"
|
||||
type="error"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="mb-4"
|
||||
/>
|
||||
|
||||
<el-skeleton v-if="loading" :rows="4" animated />
|
||||
|
||||
<el-table v-else :data="systems" stripe border class="w-full shadow-sm">
|
||||
<el-empty v-if="systems.length === 0" slot="empty" description="目前無系統" />
|
||||
<el-table-column prop="system_key" label="System Key" width="200" />
|
||||
<el-table-column prop="name" label="名稱" min-width="180" />
|
||||
</el-table>
|
||||
|
||||
<!-- 新增 Dialog -->
|
||||
<el-dialog v-model="showDialog" title="新增系統" @close="resetForm">
|
||||
<el-form :model="form" label-width="100px">
|
||||
<el-form-item label="System Key">
|
||||
<el-input v-model="form.system_key" placeholder="mkt" />
|
||||
</el-form-item>
|
||||
<el-form-item label="名稱">
|
||||
<el-input v-model="form.name" placeholder="行銷平台" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="showDialog = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="handleCreate">確認</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { getSystems, createSystem } from '@/api/systems'
|
||||
|
||||
const systems = ref([])
|
||||
const loading = ref(false)
|
||||
const error = ref(false)
|
||||
const errorMsg = ref('')
|
||||
const showDialog = ref(false)
|
||||
const submitting = ref(false)
|
||||
|
||||
const form = ref({ system_key: '', name: '' })
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = false
|
||||
try {
|
||||
const res = await getSystems()
|
||||
systems.value = res.data || []
|
||||
} catch (err) {
|
||||
error.value = true
|
||||
errorMsg.value = '載入失敗,請稍後再試'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = { system_key: '', name: '' }
|
||||
}
|
||||
|
||||
async function handleCreate() {
|
||||
if (!form.value.system_key || !form.value.name) {
|
||||
ElMessage.warning('請填寫完整資訊')
|
||||
return
|
||||
}
|
||||
submitting.value = true
|
||||
try {
|
||||
await createSystem(form.value)
|
||||
ElMessage.success('新增成功')
|
||||
showDialog.value = false
|
||||
resetForm()
|
||||
await load()
|
||||
} catch (err) {
|
||||
ElMessage.error('新增失敗,請稍後再試')
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
Reference in New Issue
Block a user