feat(admin): implement group-centric relations and system/module/company linkage views

This commit is contained in:
Chris
2026-03-30 19:38:49 +08:00
parent 37a69081e3
commit ea5285501a
15 changed files with 753 additions and 263 deletions

View File

@@ -13,9 +13,10 @@
<el-table-column prop="company_key" label="Company Key" width="220" />
<el-table-column prop="name" label="名稱" min-width="200" />
<el-table-column prop="status" label="狀態" width="120" />
<el-table-column label="操作" width="120">
<el-table-column label="操作" width="200">
<template #default="{ row }">
<el-button size="small" @click="openEdit(row)">編輯</el-button>
<el-button size="small" @click="openSites(row)">站台</el-button>
</template>
</el-table-column>
</el-table>
@@ -47,6 +48,18 @@
<el-button type="primary" :loading="savingEdit" @click="handleEdit">儲存</el-button>
</template>
</el-dialog>
<el-dialog v-model="showSitesDialog" :title="`公司站台:${selectedCompanyKey}`" width="900px">
<el-table :data="companySites" border stripe v-loading="sitesLoading">
<template #empty><el-empty description="此公司目前沒有站台" /></template>
<el-table-column prop="site_key" label="Site Key" width="220" />
<el-table-column prop="name" label="名稱" min-width="220" />
<el-table-column prop="status" label="狀態" width="120" />
</el-table>
<template #footer>
<el-button @click="showSitesDialog = false">關閉</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -54,7 +67,7 @@
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { Plus } from '@element-plus/icons-vue'
import { getCompanies, createCompany, updateCompany } from '@/api/companies'
import { getCompanies, createCompany, updateCompany, getCompanySites } from '@/api/companies'
const companies = ref([])
const loading = ref(false)
@@ -73,6 +86,11 @@ const rules = {
name: [{ required: true, message: '請輸入名稱', trigger: 'blur' }]
}
const showSitesDialog = ref(false)
const sitesLoading = ref(false)
const selectedCompanyKey = ref('')
const companySites = ref([])
async function load() {
loading.value = true
error.value = false
@@ -133,5 +151,19 @@ async function handleEdit() {
}
}
async function openSites(row) {
selectedCompanyKey.value = row.company_key
showSitesDialog.value = true
sitesLoading.value = true
try {
const res = await getCompanySites(row.company_key)
companySites.value = res.data?.items || []
} catch (err) {
ElMessage.error('載入公司站台失敗')
} finally {
sitesLoading.value = false
}
}
onMounted(load)
</script>