优化文章管理模块

This commit is contained in:
zjl 2024-08-30 14:29:08 +08:00
parent 19f3cdc025
commit 148e0f7679
5 changed files with 54 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import { h } from 'vue'; import { h } from 'vue';
import { ElTag } from 'element-plus'; import { ElAvatar, ElTag } from 'element-plus';
export const columns = [ export const columns = [
{ {
@ -7,22 +7,41 @@ export const columns = [
}, },
{ {
label: 'ID', label: 'ID',
prop: 'id' prop: 'id',
width: 100,
}, },
{ {
label: '文章标题', label: '文章标题',
prop: 'title', prop: 'title',
width: 300,
render(record) { render(record) {
return h('a', { return h('a', {
href: 'http://www.baidu.com', href: 'http://www.baidu.com',
target:"_blank" target:"_blank"
},record.row.title); }, record.row.title);
}, },
}, },
{
label: '文章封面',
prop: 'cover',
render(record) {
return h(ElAvatar, {
size: 48,
src: record.row.cover,
shape: 'square',
fit: 'fill',
});
},
width: 100,
},
{ {
label: '文章分类', label: '文章分类',
prop: 'categoryName', prop: 'categoryName',
}, },
{
label: '文章作者',
prop: 'author',
},
// { // {
// label: '文章链接', // label: '文章链接',
// value:'articelLink', // value:'articelLink',
@ -32,8 +51,24 @@ export const columns = [
label: '文章状态', label: '文章状态',
prop: 'status', prop: 'status',
render(record) { render(record) {
return h('span', record.row.status === 1 ? '下架' : '正常') return h(
ElTag,
{
type: record.row.status === 0 ? 'success' : 'danger',
}, },
{
default: () => (record.row.status === 0 ? '正常' : '下架'),
},
);
},
},
{
label: '点击率',
prop: 'click',
},
{
label: '文章排序',
prop: 'sort',
}, },
{ {
label: '创建人', label: '创建人',
@ -42,5 +77,6 @@ export const columns = [
{ {
label: '创建时间', label: '创建时间',
prop: 'createTime', prop: 'createTime',
width: 180,
}, },
]; ];

View File

@ -21,6 +21,13 @@
> >
<el-input placeholder="请输入文章标题" :maxlength="50" v-model="formData.title"></el-input> <el-input placeholder="请输入文章标题" :maxlength="50" v-model="formData.title"></el-input>
</el-form-item> </el-form-item>
<el-form-item
label="文章作者"
prop="author"
:rules="{ required: true,message: '请输入文章作者', trigger: 'blur' }"
>
<el-input placeholder="请输入文章作者" :maxlength="50" v-model="formData.author"></el-input>
</el-form-item>
<el-form-item label="文章分类" prop="categoryId" :rules="{ required: true, message: '请选择文章分类', trigger: 'change' }"> <el-form-item label="文章分类" prop="categoryId" :rules="{ required: true, message: '请选择文章分类', trigger: 'change' }">
<el-tree-select <el-tree-select
v-model="formData.categoryId" v-model="formData.categoryId"
@ -107,6 +114,7 @@ const formData = reactive({
id:"", id:"",
categoryId: "", categoryId: "",
title: "", title: "",
author: "",
cover:'', cover:'',
intro:'', intro:'',
content:'', content:'',

View File

@ -68,7 +68,7 @@ const selectionData = ref([])
status:'' status:''
}); });
const actionColumn = reactive({ const actionColumn = reactive({
width: 250, width: 200,
label: '操作', label: '操作',
prop: 'action', prop: 'action',
fixed: 'right', fixed: 'right',

View File

@ -7,7 +7,8 @@ export const columns = [
}, },
{ {
label: 'ID', label: 'ID',
prop: 'id' prop: 'id',
width: 100,
}, },
{ {
label: '标签名称', label: '标签名称',
@ -24,5 +25,6 @@ export const columns = [
{ {
label: '创建时间', label: '创建时间',
prop: 'createTime', prop: 'createTime',
width: 180,
}, },
]; ];

View File

@ -64,7 +64,7 @@ const selectionData = ref([])
name:'' name:''
}); });
const actionColumn = reactive({ const actionColumn = reactive({
width: 250, width: 200,
label: '操作', label: '操作',
prop: 'action', prop: 'action',
fixed: 'right', fixed: 'right',