refactor: 简化博客文章表单配置

This commit is contained in:
sunlei 2026-06-05 16:21:25 +08:00
parent f951edc816
commit 95c194e842

View File

@ -168,8 +168,8 @@ export default defineComponent({
];
const api: KtTableApi<WordpressBlogApi.Article, ArticleSearchValues> = {
list: async (params) => {
return await getArticleList({
list: (params) =>
getArticleList({
categories: Array.isArray(params.categories)
? params.categories.join(',')
: params.categories,
@ -180,8 +180,7 @@ export default defineComponent({
tags: Array.isArray(params.tags)
? params.tags.join(',')
: params.tags,
});
},
}),
};
const buttons: Array<
KtTableButton<WordpressBlogApi.Article, ArticleSearchValues>
@ -235,7 +234,15 @@ export default defineComponent({
buttons,
columns,
formOptions: {
schema: [
schema: getArticleSearchSchema(),
},
immediate: false,
rowActions,
tableTitle: '文章管理',
});
function getArticleSearchSchema() {
return [
{
component: 'Input',
componentProps: {
@ -274,12 +281,8 @@ export default defineComponent({
fieldName: 'tags',
label: '文章标签',
},
],
},
immediate: false,
rowActions,
tableTitle: '文章管理',
});
];
}
function getRenderedText(value?: string | WordpressBlogApi.RenderedField) {
if (!value) return '';
@ -342,46 +345,7 @@ export default defineComponent({
}));
tableApi.setProps({
formOptions: {
schema: [
{
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '搜索标题或内容',
},
fieldName: 'search',
label: '关键词',
},
{
component: 'Select',
componentProps: {
allowClear: true,
options: articleStatusOptions,
},
fieldName: 'status',
label: '文章状态',
},
{
component: 'Select',
componentProps: {
allowClear: true,
mode: 'tags',
options: categoryOptions.value,
},
fieldName: 'categories',
label: '文章分类',
},
{
component: 'Select',
componentProps: {
allowClear: true,
mode: 'tags',
options: tagOptions.value,
},
fieldName: 'tags',
label: '文章标签',
},
],
schema: getArticleSearchSchema(),
},
});
}