mirror of https://github.com/halo-dev/halo
Complete posts pagination show
parent
fd388444a9
commit
df39513b5f
|
@ -11,4 +11,29 @@ postApi.listLatest = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postApi.query = params => {
|
||||||
|
return service({
|
||||||
|
url: baseUrl,
|
||||||
|
params: params,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
postApi.postStatus = {
|
||||||
|
PUBLISHED: {
|
||||||
|
color: 'green',
|
||||||
|
status: 'success',
|
||||||
|
text: '已发布'
|
||||||
|
},
|
||||||
|
DRAFT: {
|
||||||
|
color: 'yellow',
|
||||||
|
status: 'warning',
|
||||||
|
text: '草稿'
|
||||||
|
},
|
||||||
|
RECYCLE: {
|
||||||
|
color: 'red',
|
||||||
|
status: 'error',
|
||||||
|
text: '回收站'
|
||||||
|
}
|
||||||
|
}
|
||||||
export default postApi
|
export default postApi
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
:bodyStyle="{ padding: '0px' }"
|
:bodyStyle="{ padding: '0px' }"
|
||||||
>
|
>
|
||||||
<a-table
|
<a-table
|
||||||
|
:rowKey="post => post.id"
|
||||||
:columns="postColumns"
|
:columns="postColumns"
|
||||||
:dataSource="formattedPostData"
|
:dataSource="formattedPostData"
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
slot="status"
|
slot="status"
|
||||||
slot-scope="status"
|
slot-scope="status"
|
||||||
>
|
>
|
||||||
<a-badge :status="status.status" />{{ status.statusText }}
|
<a-badge :status="status.status" />{{ status.text }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
:bodyStyle="{ padding: '0px' }"
|
:bodyStyle="{ padding: '0px' }"
|
||||||
>
|
>
|
||||||
<a-table
|
<a-table
|
||||||
|
:rowKey="comment => comment.id"
|
||||||
:columns="commentColumns"
|
:columns="commentColumns"
|
||||||
:dataSource="commentData"
|
:dataSource="commentData"
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
|
@ -107,13 +109,6 @@ const commentColumns = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const postStatus = {
|
|
||||||
PUBLISHED: {
|
|
||||||
status: 'success',
|
|
||||||
statusText: '已发布'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Dashboard',
|
name: 'Dashboard',
|
||||||
components: {},
|
components: {},
|
||||||
|
@ -141,7 +136,7 @@ export default {
|
||||||
formattedPostData() {
|
formattedPostData() {
|
||||||
return Object.assign([], this.postData).map(post => {
|
return Object.assign([], this.postData).map(post => {
|
||||||
// Format the status
|
// Format the status
|
||||||
post.status = postStatus[post.status]
|
post.status = postApi.postStatus[post.status]
|
||||||
return post
|
return post
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,32 +4,63 @@
|
||||||
<div class="table-page-search-wrapper">
|
<div class="table-page-search-wrapper">
|
||||||
<a-form layout="inline">
|
<a-form layout="inline">
|
||||||
<a-row :gutter="48">
|
<a-row :gutter="48">
|
||||||
<a-col :md="6" :sm="24">
|
<a-col
|
||||||
|
:md="6"
|
||||||
|
:sm="24"
|
||||||
|
>
|
||||||
<a-form-item label="关键词">
|
<a-form-item label="关键词">
|
||||||
<a-input v-model="queryParam.id" placeholder />
|
<a-input
|
||||||
|
v-model="queryParam.id"
|
||||||
|
placeholder
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :md="6" :sm="24">
|
<a-col
|
||||||
|
:md="6"
|
||||||
|
:sm="24"
|
||||||
|
>
|
||||||
<a-form-item label="文章状态">
|
<a-form-item label="文章状态">
|
||||||
<a-select v-model="queryParam.status" placeholder="请选择文章状态" defaultValue="0">
|
<a-select
|
||||||
|
v-model="queryParam.status"
|
||||||
|
placeholder="请选择文章状态"
|
||||||
|
defaultValue="0"
|
||||||
|
>
|
||||||
<a-select-option value="0">已发布</a-select-option>
|
<a-select-option value="0">已发布</a-select-option>
|
||||||
<a-select-option value="1">草稿箱</a-select-option>
|
<a-select-option value="1">草稿箱</a-select-option>
|
||||||
<a-select-option value="2">回收站</a-select-option>
|
<a-select-option value="2">回收站</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :md="6" :sm="24">
|
<a-col
|
||||||
|
:md="6"
|
||||||
|
:sm="24"
|
||||||
|
>
|
||||||
<a-form-item label="分类目录">
|
<a-form-item label="分类目录">
|
||||||
<a-select v-model="queryParam.categoryId" placeholder="请选择分类">
|
<a-select
|
||||||
<a-select-option v-for="category in categories" :key="category.id">{{ category.name }}</a-select-option>
|
v-model="queryParam.categoryId"
|
||||||
|
placeholder="请选择分类"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="category in categories"
|
||||||
|
:key="category.id"
|
||||||
|
>{{ category.name }}</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
|
||||||
<a-col :md="6" :sm="24">
|
<a-col
|
||||||
|
:md="6"
|
||||||
|
:sm="24"
|
||||||
|
>
|
||||||
<span class="table-page-search-submitButtons">
|
<span class="table-page-search-submitButtons">
|
||||||
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
|
<a-button
|
||||||
<a-button style="margin-left: 8px;" @click="() => (queryParam = {})">重置</a-button>
|
type="primary"
|
||||||
|
@click="$refs.table.refresh(true)"
|
||||||
|
>查询</a-button>
|
||||||
|
<a-button
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
@click="() => (queryParam = {})"
|
||||||
|
>重置</a-button>
|
||||||
</span>
|
</span>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
@ -38,12 +69,23 @@
|
||||||
|
|
||||||
<div class="table-operator">
|
<div class="table-operator">
|
||||||
<router-link :to="{name:'PostEdit'}">
|
<router-link :to="{name:'PostEdit'}">
|
||||||
<a-button type="primary" icon="plus">写文章</a-button>
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
icon="plus"
|
||||||
|
>写文章</a-button>
|
||||||
</router-link>
|
</router-link>
|
||||||
<a-dropdown>
|
<a-dropdown>
|
||||||
<a-menu slot="overlay">
|
<a-menu slot="overlay">
|
||||||
<a-menu-item key="1" v-if="postStatus==0 || postStatus==1"> <a-icon type="delete" />移到回收站 </a-menu-item>
|
<a-menu-item
|
||||||
<a-menu-item key="1" v-else-if="postStatus==2"> <a-icon type="delete" />永久删除 </a-menu-item>
|
key="1"
|
||||||
|
v-if="postStatus==0 || postStatus==1"
|
||||||
|
>
|
||||||
|
<a-icon type="delete" />移到回收站 </a-menu-item>
|
||||||
|
<a-menu-item
|
||||||
|
key="1"
|
||||||
|
v-else-if="postStatus==2"
|
||||||
|
>
|
||||||
|
<a-icon type="delete" />永久删除 </a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
<a-button style="margin-left: 8px;">
|
<a-button style="margin-left: 8px;">
|
||||||
批量操作
|
批量操作
|
||||||
|
@ -52,11 +94,78 @@
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top:15px">
|
<div style="margin-top:15px">
|
||||||
<a-table :columns="columns">
|
<a-table
|
||||||
<span slot="action" slot-scope="text, record">
|
:rowKey="post => post.id"
|
||||||
<a href="javascript:;" @click="editPost(record.id)">编辑</a>
|
:rowSelection="{
|
||||||
|
onChange: onSelectionChange,
|
||||||
|
getCheckboxProps: getCheckboxProps
|
||||||
|
}"
|
||||||
|
:columns="columns"
|
||||||
|
:dataSource="formattedPosts"
|
||||||
|
:pagination="pagination"
|
||||||
|
:loading="postsLoading"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span
|
||||||
|
slot="status"
|
||||||
|
slot-scope="statusProperty"
|
||||||
|
>
|
||||||
|
<a-badge :status="statusProperty.status" />{{ statusProperty.text }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
slot="categories"
|
||||||
|
slot-scope="categoriesOfPost"
|
||||||
|
>
|
||||||
|
<a-tag
|
||||||
|
v-for="(category,index) in categoriesOfPost"
|
||||||
|
:key="index"
|
||||||
|
color="blue"
|
||||||
|
>
|
||||||
|
{{ category.name }}
|
||||||
|
</a-tag>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
slot="tags"
|
||||||
|
slot-scope="tags"
|
||||||
|
>
|
||||||
|
<a-tag
|
||||||
|
v-for="(tag, index) in tags"
|
||||||
|
:key="index"
|
||||||
|
color="green"
|
||||||
|
>
|
||||||
|
{{ tag.name }}
|
||||||
|
</a-tag>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
slot="createTime"
|
||||||
|
slot-scope="createTime"
|
||||||
|
>
|
||||||
|
{{ createTime | timeAgo }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
slot="updateTime"
|
||||||
|
slot-scope="updateTime"
|
||||||
|
>
|
||||||
|
{{ updateTime | timeAgo }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
slot="action"
|
||||||
|
slot-scope="text, record"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="javascript:;"
|
||||||
|
@click="editPost(record.id)"
|
||||||
|
>编辑</a>
|
||||||
<a-divider type="vertical" />
|
<a-divider type="vertical" />
|
||||||
<a href="javascript:;" @click="deletePost(record.id)">删除</a>
|
<a
|
||||||
|
href="javascript:;"
|
||||||
|
@click="deletePost(record.id)"
|
||||||
|
>删除</a>
|
||||||
</span>
|
</span>
|
||||||
</a-table>
|
</a-table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -66,6 +175,8 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import categoryApi from '@/api/category'
|
import categoryApi from '@/api/category'
|
||||||
|
import postApi from '@/api/post'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PostList',
|
name: 'PostList',
|
||||||
components: {},
|
components: {},
|
||||||
|
@ -73,57 +184,100 @@ export default {
|
||||||
return {
|
return {
|
||||||
mdl: {},
|
mdl: {},
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParam: {},
|
pagination: {},
|
||||||
|
queryParam: {
|
||||||
|
page: 0,
|
||||||
|
size: 10,
|
||||||
|
sort: null,
|
||||||
|
keyword: null,
|
||||||
|
categoryId: null,
|
||||||
|
status: null
|
||||||
|
},
|
||||||
// 表头
|
// 表头
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
title: '#',
|
title: 'ID',
|
||||||
scopedSlots: { customRender: 'serial' }
|
dataIndex: 'id'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '标题',
|
title: '标题',
|
||||||
dataIndex: 'title'
|
dataIndex: 'title'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
className: 'status',
|
||||||
|
dataIndex: 'statusProperty',
|
||||||
|
scopedSlots: { customRender: 'status' }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '分类目录',
|
title: '分类目录',
|
||||||
dataIndex: 'categories'
|
dataIndex: 'categories',
|
||||||
|
scopedSlots: { customRender: 'categories' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '标签',
|
title: '标签',
|
||||||
dataIndex: 'tags'
|
dataIndex: 'tags',
|
||||||
|
scopedSlots: { customRender: 'tags' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '评论量',
|
title: '评论量',
|
||||||
dataIndex: 'comments'
|
dataIndex: 'commentCount'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '访问量',
|
title: '访问量',
|
||||||
dataIndex: 'views'
|
dataIndex: 'visits'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '日期',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime'
|
dataIndex: 'createTime',
|
||||||
|
scopedSlots: { customRender: 'createTime' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '更新时间',
|
||||||
|
dataIndex: 'updateTime',
|
||||||
|
scopedSlots: { customRender: 'updateTime' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'action',
|
|
||||||
width: '150px',
|
width: '150px',
|
||||||
scopedSlots: { customRender: 'action' }
|
scopedSlots: { customRender: 'action' }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
loadData: parameter => {},
|
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
selectedRows: [],
|
selectedRows: [],
|
||||||
options: {},
|
options: {},
|
||||||
optionAlertShow: false,
|
optionAlertShow: false,
|
||||||
categories: [],
|
categories: [],
|
||||||
postStatus: 0
|
postStatus: 0,
|
||||||
|
posts: [],
|
||||||
|
postsLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
formattedPosts() {
|
||||||
|
const postStatus = postApi.postStatus
|
||||||
|
return this.posts.map(post => {
|
||||||
|
post.statusProperty = postStatus[post.status]
|
||||||
|
return post
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.loadCategories()
|
this.loadCategories()
|
||||||
|
this.loadPosts()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
loadPosts() {
|
||||||
|
this.postsLoading = true
|
||||||
|
// Set from pagination
|
||||||
|
this.queryParam.page = this.pagination.current
|
||||||
|
this.queryParam.size = this.pagination.pageSize
|
||||||
|
postApi.query(this.queryParam).then(response => {
|
||||||
|
this.posts = response.data.data.content
|
||||||
|
this.pagination.total = response.data.data.total
|
||||||
|
this.postsLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
loadCategories() {
|
loadCategories() {
|
||||||
categoryApi.listAll().then(response => {
|
categoryApi.listAll().then(response => {
|
||||||
this.categories = response.data.data
|
this.categories = response.data.data
|
||||||
|
@ -134,6 +288,17 @@ export default {
|
||||||
},
|
},
|
||||||
deletePost(id) {
|
deletePost(id) {
|
||||||
this.$message.success('删除')
|
this.$message.success('删除')
|
||||||
|
},
|
||||||
|
onSelectionChange(selectedRowKeys) {
|
||||||
|
this.$log.debug(`SelectedRowKeys: ${selectedRowKeys}`)
|
||||||
|
},
|
||||||
|
getCheckboxProps(post) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
disabled: post.status === 'RECYCLE',
|
||||||
|
name: post.title
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue