mirror of https://github.com/halo-dev/halo
feat: support remove in batch api for post.
parent
5347289091
commit
c697fa66f2
|
@ -65,6 +65,14 @@ postApi.delete = postId => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postApi.deleteInBatch = ids => {
|
||||||
|
return service({
|
||||||
|
url: `${baseUrl}`,
|
||||||
|
data: ids,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
postApi.preview = postId => {
|
postApi.preview = postId => {
|
||||||
return service({
|
return service({
|
||||||
url: `${baseUrl}/preview/${postId}`,
|
url: `${baseUrl}/preview/${postId}`,
|
||||||
|
@ -74,21 +82,25 @@ postApi.preview = postId => {
|
||||||
|
|
||||||
postApi.postStatus = {
|
postApi.postStatus = {
|
||||||
PUBLISHED: {
|
PUBLISHED: {
|
||||||
|
value: 'PUBLISHED',
|
||||||
color: 'green',
|
color: 'green',
|
||||||
status: 'success',
|
status: 'success',
|
||||||
text: '已发布'
|
text: '已发布'
|
||||||
},
|
},
|
||||||
DRAFT: {
|
DRAFT: {
|
||||||
|
value: 'DRAFT',
|
||||||
color: 'yellow',
|
color: 'yellow',
|
||||||
status: 'warning',
|
status: 'warning',
|
||||||
text: '草稿'
|
text: '草稿'
|
||||||
},
|
},
|
||||||
RECYCLE: {
|
RECYCLE: {
|
||||||
|
value: 'RECYCLE',
|
||||||
color: 'red',
|
color: 'red',
|
||||||
status: 'error',
|
status: 'error',
|
||||||
text: '回收站'
|
text: '回收站'
|
||||||
},
|
},
|
||||||
INTIMATE: {
|
INTIMATE: {
|
||||||
|
value: 'INTIMATE',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
status: 'success',
|
status: 'success',
|
||||||
text: '私密'
|
text: '私密'
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
:sm="24"
|
:sm="24"
|
||||||
>
|
>
|
||||||
<a-form-item label="关键词">
|
<a-form-item label="关键词">
|
||||||
<a-input v-model="queryParam.keyword" @keyup.enter="handleQuery()"/>
|
<a-input
|
||||||
|
v-model="queryParam.keyword"
|
||||||
|
@keyup.enter="handleQuery()"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col
|
<a-col
|
||||||
|
@ -81,11 +84,11 @@
|
||||||
<a-menu slot="overlay">
|
<a-menu slot="overlay">
|
||||||
<a-menu-item
|
<a-menu-item
|
||||||
key="1"
|
key="1"
|
||||||
v-if="queryParam.status === 'DRAFT'"
|
v-if="queryParam.status === 'DRAFT' || queryParam.status === 'RECYCLE'"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
@click="handlePublishMore"
|
@click="handleEditStatusMore(postStatus.PUBLISHED.value)"
|
||||||
>
|
>
|
||||||
<span>发布</span>
|
<span>发布</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -96,14 +99,25 @@
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
@click="handleRecycleMore"
|
@click="handleEditStatusMore(postStatus.RECYCLE.value)"
|
||||||
>
|
>
|
||||||
<span>移到回收站</span>
|
<span>移到回收站</span>
|
||||||
</a>
|
</a>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item
|
<a-menu-item
|
||||||
key="3"
|
key="3"
|
||||||
v-if="queryParam.status === 'RECYCLE'"
|
v-if="queryParam.status === 'RECYCLE' || queryParam.status === 'PUBLISHED' || queryParam.status === 'INTIMATE'"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="javascript:void(0);"
|
||||||
|
@click="handleEditStatusMore(postStatus.DRAFT.value)"
|
||||||
|
>
|
||||||
|
<span>草稿</span>
|
||||||
|
</a>
|
||||||
|
</a-menu-item>
|
||||||
|
<a-menu-item
|
||||||
|
key="4"
|
||||||
|
v-if="queryParam.status === 'RECYCLE' || queryParam.status === 'DRAFT'"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0);"
|
href="javascript:void(0);"
|
||||||
|
@ -607,10 +621,12 @@ export default {
|
||||||
columns,
|
columns,
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
categories: [],
|
categories: [],
|
||||||
selectedPostMetas: [{
|
selectedPostMetas: [
|
||||||
key: '',
|
{
|
||||||
value: ''
|
key: '',
|
||||||
}],
|
value: ''
|
||||||
|
}
|
||||||
|
],
|
||||||
posts: [],
|
posts: [],
|
||||||
postsLoading: false,
|
postsLoading: false,
|
||||||
postSettingVisible: false,
|
postSettingVisible: false,
|
||||||
|
@ -706,29 +722,15 @@ export default {
|
||||||
this.loadPosts()
|
this.loadPosts()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handlePublishMore() {
|
handleEditStatusMore(status) {
|
||||||
if (this.selectedRowKeys.length <= 0) {
|
if (this.selectedRowKeys.length <= 0) {
|
||||||
this.$message.success('请至少选择一项!')
|
this.$message.success('请至少选择一项!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (let index = 0; index < this.selectedRowKeys.length; index++) {
|
for (let index = 0; index < this.selectedRowKeys.length; index++) {
|
||||||
const element = this.selectedRowKeys[index]
|
const element = this.selectedRowKeys[index]
|
||||||
postApi.updateStatus(element, 'PUBLISHED').then(response => {
|
postApi.updateStatus(element, status).then(response => {
|
||||||
this.$log.debug(`postId: ${element}, status: PUBLISHED`)
|
this.$log.debug(`postId: ${element}, status: ${status}`)
|
||||||
this.selectedRowKeys = []
|
|
||||||
this.loadPosts()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleRecycleMore() {
|
|
||||||
if (this.selectedRowKeys.length <= 0) {
|
|
||||||
this.$message.success('请至少选择一项!')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for (let index = 0; index < this.selectedRowKeys.length; index++) {
|
|
||||||
const element = this.selectedRowKeys[index]
|
|
||||||
postApi.updateStatus(element, 'RECYCLE').then(response => {
|
|
||||||
this.$log.debug(`postId: ${element}, status: RECYCLE`)
|
|
||||||
this.selectedRowKeys = []
|
this.selectedRowKeys = []
|
||||||
this.loadPosts()
|
this.loadPosts()
|
||||||
})
|
})
|
||||||
|
@ -739,14 +741,11 @@ export default {
|
||||||
this.$message.success('请至少选择一项!')
|
this.$message.success('请至少选择一项!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (let index = 0; index < this.selectedRowKeys.length; index++) {
|
postApi.deleteInBatch(this.selectedRowKeys).then(response => {
|
||||||
const element = this.selectedRowKeys[index]
|
this.$log.debug(`delete: ${this.selectedRowKeys}`)
|
||||||
postApi.delete(element).then(response => {
|
this.selectedRowKeys = []
|
||||||
this.$log.debug(`delete: ${element}`)
|
this.loadPosts()
|
||||||
this.selectedRowKeys = []
|
})
|
||||||
this.loadPosts()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
handleShowPostSettings(post) {
|
handleShowPostSettings(post) {
|
||||||
postApi.get(post.id).then(response => {
|
postApi.get(post.id).then(response => {
|
||||||
|
|
Loading…
Reference in New Issue