([])
// Form data
const form = reactive({
title: '',
categoryId: 0,
+ columnId: 0,
date: new Date().toISOString().split('T')[0],
excerpt: '',
content: '',
@@ -254,7 +266,7 @@ const handleSubmit = async () => {
try {
// Construct payload
- const payload = {
+ const payload: any = {
title: form.title,
categoryId: form.categoryId,
date: form.date,
@@ -264,6 +276,13 @@ const handleSubmit = async () => {
tags: form.tagIds.map(id => ({ id } as any)) // Backend expects objects with ID
}
+ // Add columnId if selected
+ if (form.columnId > 0) {
+ payload.columnId = form.columnId
+ } else {
+ payload.columnId = null
+ }
+
if (isEditing.value) {
// Update existing post
await updatePost(route.params.id as string, payload)
@@ -292,9 +311,10 @@ const handleCancel = () => {
// Load initial data
const loadData = async () => {
try {
- // Fetch categories and tags in parallel
- const [cats, tags] = await Promise.all([
+ // Fetch categories, columns and tags in parallel
+ const [cats, cols, tagList] = await Promise.all([
fetchCategories(),
+ fetchColumns(),
fetchTags()
])
@@ -303,7 +323,12 @@ const loadData = async () => {
label: c.name
}))
- availableTags.value = tags
+ columns.value = cols.map(c => ({
+ value: c.id,
+ label: c.name
+ }))
+
+ availableTags.value = tagList
// If editing, load post data
if (isEditing.value) {
@@ -313,6 +338,7 @@ const loadData = async () => {
// Populate form with post data
form.title = post.title
form.categoryId = post.categoryId
+ form.columnId = post.columnId || 0
form.date = post.date
form.excerpt = post.excerpt || ''
form.content = post.content || ''
diff --git a/client/src/pages/admin/Posts.vue b/client/src/pages/admin/Posts.vue
index 9b4b5fb..4f859ec 100644
--- a/client/src/pages/admin/Posts.vue
+++ b/client/src/pages/admin/Posts.vue
@@ -16,6 +16,8 @@
| ID |
标题 |
分类 |
+ 专栏 |
+ 标签 |
发布日期 |
状态 |
操作 |
@@ -26,6 +28,25 @@
#{{ post.id }} |
{{ post.title }} |
{{ post.categoryName || post.category?.name || '未分类' }} |
+
+
+ {{ post.columnName || post.column?.name }}
+
+ -
+ |
+
+
+
+ #{{ tag.name }}
+
+ +{{ post.tags.length - 3 }}
+
+ -
+ |
{{ post.date }} |
|