feat: 项目列表增加编辑删除入口
This commit is contained in:
1 parent
68e73d2cbc
commit
c07325a955
1 file changed
+28
-3
@@ -11,7 +11,7 @@ import {
|
||||
type DataTableColumns,
|
||||
type DataTableInst
|
||||
} from 'naive-ui'
|
||||
import { RefreshCw, Search } from '@lucide/vue'
|
||||
import { MoreHorizontal, RefreshCw, Search } from '@lucide/vue'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { StatusBadge } from '../../components/ui'
|
||||
@@ -19,6 +19,7 @@ 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'
|
||||
|
||||
/** 项目表格使用固定表头与独立滚动;搜索筛选仍作用于真实接口数据。 */
|
||||
const router = useRouter()
|
||||
@@ -31,6 +32,13 @@ 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 managedProject = ref<Project | null>(null)
|
||||
/** 打开项目管理,不影响行本身的项目跳转。 */
|
||||
function manageProject(project: Project) {
|
||||
managedProject.value = project
|
||||
manageOpen.value = true
|
||||
}
|
||||
const filtered = computed(() =>
|
||||
projects.value.filter(item => {
|
||||
const matches = ((item.title ?? '') + ' ' + item.topic + ' ' + (item.style ?? ''))
|
||||
@@ -75,7 +83,18 @@ const columns: DataTableColumns<Project> = [
|
||||
},
|
||||
{ title: '风格', key: 'style', width: 200, ellipsis: { tooltip: true }, render: row => row.style || '未设置' },
|
||||
{ title: '状态', key: 'status', width: 120, render: row => h(StatusBadge, { status: row.status }) },
|
||||
{ title: '最近更新', key: 'updatedAt', width: 165, render: row => formatDate(row.updatedAt) }
|
||||
{ title: '最近更新', key: 'updatedAt', width: 165, render: row => formatDate(row.updatedAt) },
|
||||
{
|
||||
title: '',
|
||||
key: 'actions',
|
||||
width: 64,
|
||||
render: row =>
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, title: '管理项目', 'aria-label': `管理 ${row.title || row.topic}`, onClick: () => manageProject(row) },
|
||||
{ icon: () => h(MoreHorizontal, { size: 16 }) }
|
||||
)
|
||||
}
|
||||
]
|
||||
/** 创建回执只用于跳转,生成进度以后端查询为准。 */
|
||||
function openProject(id: string) {
|
||||
@@ -136,6 +155,12 @@ 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"
|
||||
/>
|
||||
<div class="project-table-area">
|
||||
<NDataTable
|
||||
ref="table"
|
||||
@@ -149,7 +174,7 @@ function clearFilters() {
|
||||
:loading="query.loading.value"
|
||||
flex-height
|
||||
table-layout="fixed"
|
||||
:scroll-x="785"
|
||||
:scroll-x="850"
|
||||
@scroll="loadMore"
|
||||
>
|
||||
<template #empty
|
||||
|
||||
Reference in new issue
Block a user