refactor: 项目编辑删除使用独立入口
This commit is contained in:
1 parent
496ab91651
commit
a4def95ae0
1 file changed
+27
-19
@@ -11,7 +11,7 @@ import {
|
||||
type DataTableColumns,
|
||||
type DataTableInst
|
||||
} from 'naive-ui'
|
||||
import { MoreHorizontal, RefreshCw, Search } from '@lucide/vue'
|
||||
import { Pencil, RefreshCw, Search, Trash2 } from '@lucide/vue'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { StatusBadge } from '../../components/ui'
|
||||
@@ -19,7 +19,8 @@ import { formatDate } from '../../lib/format'
|
||||
import { projectsApi } from './api'
|
||||
import type { Project } from './types'
|
||||
import CreateProjectDialog from './components/CreateProjectDialog.vue'
|
||||
import ProjectManageDialog from './components/ProjectManageDialog.vue'
|
||||
import EditProjectDialog from './components/EditProjectDialog.vue'
|
||||
import DeleteProjectDialog from './components/DeleteProjectDialog.vue'
|
||||
|
||||
/** 项目表格使用固定表头与独立滚动;搜索筛选仍作用于真实接口数据。 */
|
||||
const router = useRouter()
|
||||
@@ -32,12 +33,16 @@ const PAGE_SIZE = 20
|
||||
const visibleCount = ref(PAGE_SIZE)
|
||||
const table = ref<DataTableInst | null>(null)
|
||||
const projects = computed(() => query.data.value ?? [])
|
||||
const manageOpen = ref(false)
|
||||
const editOpen = ref(false)
|
||||
const deleteOpen = ref(false)
|
||||
const managedProject = ref<Project | null>(null)
|
||||
/** 打开项目管理,不影响行本身的项目跳转。 */
|
||||
function manageProject(project: Project) {
|
||||
function editProject(project: Project) {
|
||||
managedProject.value = project
|
||||
manageOpen.value = true
|
||||
editOpen.value = true
|
||||
}
|
||||
function deleteProject(project: Project) {
|
||||
managedProject.value = project
|
||||
deleteOpen.value = true
|
||||
}
|
||||
const filtered = computed(() =>
|
||||
projects.value.filter(item => {
|
||||
@@ -87,13 +92,20 @@ const columns: DataTableColumns<Project> = [
|
||||
{
|
||||
title: '',
|
||||
key: 'actions',
|
||||
width: 64,
|
||||
width: 104,
|
||||
render: row =>
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, title: '管理项目', 'aria-label': `管理 ${row.title || row.topic}`, onClick: () => manageProject(row) },
|
||||
{ icon: () => h(MoreHorizontal, { size: 16 }) }
|
||||
)
|
||||
h('div', { class: 'flex items-center gap-1' }, [
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, title: '编辑项目', 'aria-label': `编辑 ${row.title || row.topic}`, onClick: () => editProject(row) },
|
||||
{ icon: () => h(Pencil, { size: 15 }) }
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, type: 'error', title: '删除项目', 'aria-label': `删除 ${row.title || row.topic}`, onClick: () => deleteProject(row) },
|
||||
{ icon: () => h(Trash2, { size: 15 }) }
|
||||
)
|
||||
])
|
||||
}
|
||||
]
|
||||
/** 创建回执只用于跳转,生成进度以后端查询为准。 */
|
||||
@@ -155,12 +167,8 @@ function clearFilters() {
|
||||
<NAlert v-if="query.error.value" type="error" :show-icon="false"
|
||||
>{{ query.error.value }}<NButton text class="ml-3" @click="query.refresh">重新连接</NButton></NAlert
|
||||
>
|
||||
<ProjectManageDialog
|
||||
v-model:open="manageOpen"
|
||||
:project="managedProject"
|
||||
@changed="query.refresh"
|
||||
@deleted="query.refresh"
|
||||
/>
|
||||
<EditProjectDialog v-model:open="editOpen" :project="managedProject" @changed="query.refresh" />
|
||||
<DeleteProjectDialog v-model:open="deleteOpen" :project="managedProject" @deleted="query.refresh" />
|
||||
<div class="project-table-area">
|
||||
<NDataTable
|
||||
ref="table"
|
||||
@@ -174,7 +182,7 @@ function clearFilters() {
|
||||
:loading="query.loading.value"
|
||||
flex-height
|
||||
table-layout="fixed"
|
||||
:scroll-x="850"
|
||||
:scroll-x="890"
|
||||
@scroll="loadMore"
|
||||
>
|
||||
<template #empty
|
||||
|
||||
Reference in new issue
Block a user