feat(admin): add delete APIs and UI actions for all admin resources

This commit is contained in:
Chris
2026-03-31 20:58:20 +08:00
parent c71003d244
commit 22c71eff6f
14 changed files with 126 additions and 14 deletions

View File

@@ -29,6 +29,7 @@
<el-button size="small" @click="openEdit(row)">編輯</el-button>
<el-button size="small" @click="openRelations(row, 'groups')">群組</el-button>
<el-button size="small" @click="openRelations(row, 'members')">會員</el-button>
<el-button size="small" type="danger" @click="handleDelete(row)">刪除</el-button>
</template>
</el-table-column>
</el-table>
@@ -102,9 +103,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 { getModules, createModule, updateModule, getModuleGroups, getModuleMembers } from '@/api/modules'
import { getModules, createModule, updateModule, deleteModule, getModuleGroups, getModuleMembers } from '@/api/modules'
import { getSystems } from '@/api/systems'
const modules = ref([])
@@ -200,6 +201,18 @@ async function handleEdit() {
}
}
async function handleDelete(row) {
try {
await ElMessageBox.confirm(`確認刪除模組 ${row.name}${row.module_key}`, '刪除確認', { type: 'warning' })
await deleteModule(row.module_key)
ElMessage.success('刪除成功')
await load()
} catch (err) {
if (err === 'cancel') return
ElMessage.error(err.response?.data?.detail || '刪除失敗')
}
}
async function openRelations(row, tab) {
relationModuleKey.value = row.module_key
relationTab.value = tab