文章管理

This commit is contained in:
hezhengao 2024-07-31 10:34:27 +08:00
parent 2f76fa6f4b
commit a31a2ff1e7
3 changed files with 83 additions and 166 deletions

View File

@ -1,22 +1,12 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px">
<el-form-item label="文章标题" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入文章标题"
clearable
@keyup.enter.native="handleQuery"
/>
<el-input v-model="queryParams.title" placeholder="请输入文章标题" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="文章所属分类" prop="articleCat">
<el-select v-model="queryParams.articleCat" placeholder="请选择文章所属分类" clearable>
<el-option
v-for="dict in dict.type.article_cat"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
<el-option v-for="item in categoryList" :key="item.id" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item>
@ -27,46 +17,20 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:article:add']"
>新增</el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['system:article:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:article:edit']"
>修改</el-button>
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
v-hasPermi="['system:article:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:article:remove']"
>删除</el-button>
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
v-hasPermi="['system:article:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:article:export']"
>导出</el-button>
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['system:article:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -89,31 +53,16 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:article:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:article:remove']"
>删除</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['system:article:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['system:article:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改文章管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
@ -131,13 +80,8 @@
<editor v-model="form.content" :min-height="192" />
</el-form-item>
<el-form-item label="文章所属分类" prop="articleCat">
<el-select v-model="form.articleCat" placeholder="请选择文章所属分类">
<el-option
v-for="dict in dict.type.article_cat"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
<el-select v-model="form.articleCat" placeholder="请选择文章所属分类" clearable>
<el-option v-for="item in categoryList" :key="item.id" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
@ -154,7 +98,7 @@
<script>
import { listArticle, getArticle, delArticle, addArticle, updateArticle } from "@/api/system/article";
import { listCategory } from "@/api/system/category";
export default {
name: "Article",
dicts: ['article_cat'],
@ -174,6 +118,7 @@ export default {
total: 0,
//
articleList: [],
categoryList: [],
//
title: "",
//
@ -183,7 +128,7 @@ export default {
pageNum: 1,
pageSize: 10,
title: null,
articleCat: null,
articleCat: "",
},
//
form: {},
@ -194,8 +139,15 @@ export default {
},
created() {
this.getList();
},
methods: {
//
getfenlei() {
listCategory().then(response => {
this.categoryList = response.rows;
});
},
/** 查询文章管理列表 */
getList() {
this.loading = true;
@ -203,7 +155,9 @@ export default {
this.articleList = response.rows;
this.total = response.total;
this.loading = false;
this.getfenlei();
});
},
//
cancel() {

View File

@ -2,20 +2,12 @@
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="上级分类" prop="parentId">
<el-input
v-model="queryParams.parentId"
placeholder="请输入上级分类"
clearable
@keyup.enter.native="handleQuery"
/>
<el-select v-model="queryParams.parentId" placeholder="请选择文章所属分类" clearable>
<el-option v-for="(item, index) in options" :key="index" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="分类名称" prop="title">
<el-input
v-model="queryParams.title"
placeholder="请输入分类名称"
clearable
@keyup.enter.native="handleQuery"
/>
<el-input v-model="queryParams.title" placeholder="请输入分类名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@ -25,46 +17,20 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:category:add']"
>新增</el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['system:category:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:category:edit']"
>修改</el-button>
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
v-hasPermi="['system:category:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:category:remove']"
>删除</el-button>
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
v-hasPermi="['system:category:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:category:export']"
>导出</el-button>
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['system:category:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@ -72,7 +38,7 @@
<el-table v-loading="loading" :data="categoryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="文章分类" align="center" prop="id" />
<el-table-column label="上级分类" align="center" prop="parentId" />
<el-table-column label="上级分类" align="center" prop="parentName" />
<el-table-column label="分类名称" align="center" prop="title" />
<el-table-column label="封面图" align="center" prop="coverImg" width="100">
<template slot-scope="scope">
@ -83,37 +49,24 @@
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:category:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:category:remove']"
>删除</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['system:category:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['system:category:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改文章分类对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="上级分类" prop="parentId">
<el-input v-model="form.parentId" placeholder="请输入上级分类" />
<el-select v-model="form.parentId" placeholder="请选择文章所属分类" clearable>
<el-option v-for="(item, index) in options" :key="index" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="分类名称" prop="title">
<el-input v-model="form.title" placeholder="请输入分类名称" />
@ -127,9 +80,7 @@
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="" prop="delFlag">
<el-input v-model="form.delFlag" placeholder="请输入" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -146,6 +97,9 @@ export default {
name: "Category",
data() {
return {
options: [],
toplist: [],
optionslist:[],
//
loading: true,
//
@ -168,22 +122,30 @@ export default {
queryParams: {
pageNum: 1,
pageSize: 10,
parentId: null,
title: null,
coverImg: null,
description: null,
parentId: ''
},
//
form: {},
form: {
parentId:''
},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
//
gettop(){
listCategory().then(response => {
this.options=response.rows
});
},
/** 查询文章分类列表 */
getList() {
this.loading = true;
@ -191,6 +153,7 @@ export default {
this.categoryList = response.rows;
this.total = response.total;
this.loading = false;
this.gettop()
});
},
//

View File

@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://localhost:192.168.3.114:8090`,
target: `http://192.168.3.114:8090`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''