refactor: 项目编辑删除使用独立入口
This commit is contained in:
1 parent
496ab91651
commit
a4def95ae0
1 file changed
+24
-16
@@ -11,7 +11,7 @@ import {
|
|||||||
type DataTableColumns,
|
type DataTableColumns,
|
||||||
type DataTableInst
|
type DataTableInst
|
||||||
} from 'naive-ui'
|
} 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 WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||||
import { useQuery } from '../../composables/useQuery'
|
import { useQuery } from '../../composables/useQuery'
|
||||||
import { StatusBadge } from '../../components/ui'
|
import { StatusBadge } from '../../components/ui'
|
||||||
@@ -19,7 +19,8 @@ import { formatDate } from '../../lib/format'
|
|||||||
import { projectsApi } from './api'
|
import { projectsApi } from './api'
|
||||||
import type { Project } from './types'
|
import type { Project } from './types'
|
||||||
import CreateProjectDialog from './components/CreateProjectDialog.vue'
|
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()
|
const router = useRouter()
|
||||||
@@ -32,12 +33,16 @@ const PAGE_SIZE = 20
|
|||||||
const visibleCount = ref(PAGE_SIZE)
|
const visibleCount = ref(PAGE_SIZE)
|
||||||
const table = ref<DataTableInst | null>(null)
|
const table = ref<DataTableInst | null>(null)
|
||||||
const projects = computed(() => query.data.value ?? [])
|
const projects = computed(() => query.data.value ?? [])
|
||||||
const manageOpen = ref(false)
|
const editOpen = ref(false)
|
||||||
|
const deleteOpen = ref(false)
|
||||||
const managedProject = ref<Project | null>(null)
|
const managedProject = ref<Project | null>(null)
|
||||||
/** 打开项目管理,不影响行本身的项目跳转。 */
|
function editProject(project: Project) {
|
||||||
function manageProject(project: Project) {
|
|
||||||
managedProject.value = project
|
managedProject.value = project
|
||||||
manageOpen.value = true
|
editOpen.value = true
|
||||||
|
}
|
||||||
|
function deleteProject(project: Project) {
|
||||||
|
managedProject.value = project
|
||||||
|
deleteOpen.value = true
|
||||||
}
|
}
|
||||||
const filtered = computed(() =>
|
const filtered = computed(() =>
|
||||||
projects.value.filter(item => {
|
projects.value.filter(item => {
|
||||||
@@ -87,13 +92,20 @@ const columns: DataTableColumns<Project> = [
|
|||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
width: 64,
|
width: 104,
|
||||||
render: row =>
|
render: row =>
|
||||||
|
h('div', { class: 'flex items-center gap-1' }, [
|
||||||
h(
|
h(
|
||||||
NButton,
|
NButton,
|
||||||
{ quaternary: true, circle: true, title: '管理项目', 'aria-label': `管理 ${row.title || row.topic}`, onClick: () => manageProject(row) },
|
{ quaternary: true, circle: true, title: '编辑项目', 'aria-label': `编辑 ${row.title || row.topic}`, onClick: () => editProject(row) },
|
||||||
{ icon: () => h(MoreHorizontal, { size: 16 }) }
|
{ 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"
|
<NAlert v-if="query.error.value" type="error" :show-icon="false"
|
||||||
>{{ query.error.value }}<NButton text class="ml-3" @click="query.refresh">重新连接</NButton></NAlert
|
>{{ query.error.value }}<NButton text class="ml-3" @click="query.refresh">重新连接</NButton></NAlert
|
||||||
>
|
>
|
||||||
<ProjectManageDialog
|
<EditProjectDialog v-model:open="editOpen" :project="managedProject" @changed="query.refresh" />
|
||||||
v-model:open="manageOpen"
|
<DeleteProjectDialog v-model:open="deleteOpen" :project="managedProject" @deleted="query.refresh" />
|
||||||
:project="managedProject"
|
|
||||||
@changed="query.refresh"
|
|
||||||
@deleted="query.refresh"
|
|
||||||
/>
|
|
||||||
<div class="project-table-area">
|
<div class="project-table-area">
|
||||||
<NDataTable
|
<NDataTable
|
||||||
ref="table"
|
ref="table"
|
||||||
@@ -174,7 +182,7 @@ function clearFilters() {
|
|||||||
:loading="query.loading.value"
|
:loading="query.loading.value"
|
||||||
flex-height
|
flex-height
|
||||||
table-layout="fixed"
|
table-layout="fixed"
|
||||||
:scroll-x="850"
|
:scroll-x="890"
|
||||||
@scroll="loadMore"
|
@scroll="loadMore"
|
||||||
>
|
>
|
||||||
<template #empty
|
<template #empty
|
||||||
|
|||||||
Reference in new issue
Block a user