feat: support preset post meta field.

pull/3445/head
ruibaby 2019-12-07 20:33:29 +08:00
parent 1f80452b10
commit 0618a34d68
5 changed files with 107 additions and 82 deletions

View File

@ -9,7 +9,7 @@
title="待审核评论" title="待审核评论"
> >
<template slot="content"> <template slot="content">
<a-spin :spinning="loadding"> <a-spin :spinning="loading">
<div class="custom-tab-wrapper"> <div class="custom-tab-wrapper">
<a-tabs> <a-tabs>
<a-tab-pane <a-tab-pane
@ -99,7 +99,7 @@ export default {
name: 'HeaderComment', name: 'HeaderComment',
data() { data() {
return { return {
loadding: false, loading: false,
visible: false, visible: false,
postComments: [], postComments: [],
sheetComments: [] sheetComments: []
@ -125,21 +125,21 @@ export default {
methods: { methods: {
fetchComment() { fetchComment() {
if (!this.visible) { if (!this.visible) {
this.loadding = true this.loading = true
this.getComment() this.getComment()
} else { } else {
this.loadding = false this.loading = false
} }
this.visible = !this.visible this.visible = !this.visible
}, },
getComment() { getComment() {
commentApi.latestComment('posts', 5, 'AUDITING').then(response => { commentApi.latestComment('posts', 5, 'AUDITING').then(response => {
this.postComments = response.data.data this.postComments = response.data.data
this.loadding = false this.loading = false
}) })
commentApi.latestComment('sheets', 5, 'AUDITING').then(response => { commentApi.latestComment('sheets', 5, 'AUDITING').then(response => {
this.sheetComments = response.data.data this.sheetComments = response.data.data
this.loadding = false this.loading = false
}) })
} }
} }

View File

@ -477,11 +477,6 @@ body {
} }
// 数据列表 样式
.table-alert {
margin-bottom: 16px;
}
.table-page-search-wrapper { .table-page-search-wrapper {
.ant-form-inline { .ant-form-inline {
@ -518,6 +513,10 @@ body {
} }
.ant-table-thead > tr > th{
background: #fff !important;
}
.content { .content {
.table-operator { .table-operator {

View File

@ -80,7 +80,7 @@
<div class="table-operator" style="margin-bottom: 0;"> <div class="table-operator" style="margin-bottom: 0;">
<a-button <a-button
type="primary" type="primary"
icon="plus" icon="cloud-upload"
@click="()=>this.uploadVisible = true" @click="()=>this.uploadVisible = true"
>上传</a-button> >上传</a-button>
</div> </div>

View File

@ -94,10 +94,7 @@ export default {
postToStage: {}, postToStage: {},
selectedTagIds: [], selectedTagIds: [],
selectedCategoryIds: [], selectedCategoryIds: [],
selectedPostMetas: [{ selectedPostMetas: [],
key: '',
value: ''
}],
isSaved: false isSaved: false
} }
}, },

View File

@ -73,50 +73,50 @@
<div :style="{ marginBottom: '16px' }"> <div :style="{ marginBottom: '16px' }">
<h3 class="post-setting-drawer-title">分类目录</h3> <h3 class="post-setting-drawer-title">分类目录</h3>
<div class="post-setting-drawer-item"> <div class="post-setting-drawer-item">
<category-tree <a-form layout="vertical">
v-model="selectedCategoryIds" <a-form-item>
:categories="categories" <category-tree
/> v-model="selectedCategoryIds"
<div> :categories="categories"
<a-form layout="vertical"> />
<a-form-item v-if="categoryFormVisible"> </a-form-item>
<category-select-tree <a-form-item v-if="categoryFormVisible">
:categories="categories" <category-select-tree
v-model="categoryToCreate.parentId" :categories="categories"
/> v-model="categoryToCreate.parentId"
</a-form-item> />
<a-form-item v-if="categoryFormVisible"> </a-form-item>
<a-input <a-form-item v-if="categoryFormVisible">
placeholder="分类名称" <a-input
v-model="categoryToCreate.name" placeholder="分类名称"
/> v-model="categoryToCreate.name"
</a-form-item> />
<a-form-item v-if="categoryFormVisible"> </a-form-item>
<a-input <a-form-item v-if="categoryFormVisible">
placeholder="分类路径" <a-input
v-model="categoryToCreate.slugNames" placeholder="分类路径"
/> v-model="categoryToCreate.slugNames"
</a-form-item> />
<a-form-item> </a-form-item>
<a-button <a-form-item>
type="primary" <a-button
style="marginRight: 8px" type="primary"
v-if="categoryFormVisible" style="marginRight: 8px"
@click="handlerCreateCategory" v-if="categoryFormVisible"
>保存</a-button> @click="handlerCreateCategory"
<a-button >保存</a-button>
type="dashed" <a-button
style="marginRight: 8px" type="dashed"
v-if="!categoryFormVisible" style="marginRight: 8px"
@click="toggleCategoryForm" v-if="!categoryFormVisible"
>新增</a-button> @click="toggleCategoryForm"
<a-button >新增</a-button>
v-if="categoryFormVisible" <a-button
@click="toggleCategoryForm" v-if="categoryFormVisible"
>取消</a-button> @click="toggleCategoryForm"
</a-form-item> >取消</a-button>
</a-form> </a-form-item>
</div> </a-form>
</div> </div>
</div> </div>
<a-divider /> <a-divider />
@ -167,28 +167,40 @@
</div> </div>
</div> </div>
</div> </div>
<a-divider />
<div :style="{ marginBottom: '16px' }"> <div :style="{ marginBottom: '16px' }">
<h3 class="post-setting-drawer-title">元数据</h3> <h3 class="post-setting-drawer-title">元数据</h3>
<a-form-item <a-form layout="vertical">
v-for="(postMeta, index) in selectedPostMetas" <a-form-item
:key="index" v-for="(postMeta, index) in selectedPostMetas"
:prop="'postMetas.' + index + '.value'" :key="index"
> :prop="'postMetas.' + index + '.value'"
<a-row :gutter="10"> >
<a-col :span="11"> <a-row :gutter="5">
<a-input v-model="postMeta.key"><i slot="addonBefore">K</i></a-input> <a-col :span="12">
</a-col> <a-input v-model="postMeta.key"><i slot="addonBefore">K</i></a-input>
<a-col :span="11"> </a-col>
<a-input v-model="postMeta.value"><i slot="addonBefore">V</i></a-input> <a-col :span="12">
</a-col> <a-input v-model="postMeta.value">
<a-col :span="2"> <i slot="addonBefore">V</i>
<a-icon type="close" @click.prevent="removePostMeta(postMeta)"/> <a
</a-col> href="javascript:void(0);"
</a-row> slot="addonAfter"
</a-form-item> @click.prevent="handleRemovePostMeta(postMeta)"
<a-form-item> >
<a-button @click="addPostMeta"></a-button> <a-icon type="close" />
</a-form-item> </a>
</a-input>
</a-col>
</a-row>
</a-form-item>
<a-form-item>
<a-button
type="dashed"
@click="handleInsertPostMeta"
>新增</a-button>
</a-form-item>
</a-form>
</div> </div>
<a-divider class="divider-transparent" /> <a-divider class="divider-transparent" />
</div> </div>
@ -227,6 +239,7 @@ import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelect
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
import themeApi from '@/api/theme'
export default { export default {
name: 'PostSettingDrawer', name: 'PostSettingDrawer',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
@ -317,6 +330,7 @@ export default {
if (newValue) { if (newValue) {
this.loadSkeleton() this.loadSkeleton()
this.loadCategories() this.loadCategories()
this.loadPresetMetasField()
} }
} }
}, },
@ -347,6 +361,21 @@ export default {
this.categories = response.data.data this.categories = response.data.data
}) })
}, },
loadPresetMetasField() {
if (this.postMetas.length <= 0) {
themeApi.getActivatedTheme().then(response => {
const fields = response.data.data.postMetaField
if (fields && fields.length > 0) {
for (let i = 0, len = fields.length; i < len; i++) {
this.selectedPostMetas.push({
value: '',
key: fields[i]
})
}
}
})
}
},
handleSelectPostThumb(data) { handleSelectPostThumb(data) {
this.selectedPost.thumbnail = encodeURI(data.path) this.selectedPost.thumbnail = encodeURI(data.path)
this.thumbDrawerVisible = false this.thumbDrawerVisible = false
@ -433,13 +462,13 @@ export default {
onPostDateOk(value) { onPostDateOk(value) {
this.selectedPost.createTime = value.valueOf() this.selectedPost.createTime = value.valueOf()
}, },
removePostMeta(item) { handleRemovePostMeta(item) {
var index = this.selectedPostMetas.indexOf(item) var index = this.selectedPostMetas.indexOf(item)
if (index !== -1) { if (index !== -1) {
this.selectedPostMetas.splice(index, 1) this.selectedPostMetas.splice(index, 1)
} }
}, },
addPostMeta() { handleInsertPostMeta() {
this.selectedPostMetas.push({ this.selectedPostMetas.push({
value: '', value: '',
key: '' key: ''