feat(admin): add delete APIs and UI actions for all admin resources
This commit is contained in:
@@ -13,10 +13,11 @@
|
||||
<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="200">
|
||||
<el-table-column label="操作" width="280">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" @click="openEdit(row)">編輯</el-button>
|
||||
<el-button size="small" @click="openSites(row)">站台</el-button>
|
||||
<el-button size="small" type="danger" @click="handleDelete(row)">刪除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -64,9 +65,9 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { getCompanies, createCompany, updateCompany, getCompanySites } from '@/api/companies'
|
||||
import { getCompanies, createCompany, updateCompany, deleteCompany, getCompanySites } from '@/api/companies'
|
||||
|
||||
const companies = ref([])
|
||||
const loading = ref(false)
|
||||
@@ -163,5 +164,21 @@ async function openSites(row) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`確認刪除公司 ${row.name}(${row.company_key})?此操作會一併刪除旗下站台與相關授權。`,
|
||||
'刪除確認',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
await deleteCompany(row.company_key)
|
||||
ElMessage.success('刪除成功')
|
||||
await load()
|
||||
} catch (err) {
|
||||
if (err === 'cancel') return
|
||||
ElMessage.error(err.response?.data?.detail || '刪除失敗')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user