Add setting button to sheet list.

pull/40/head
ruibaby 2019-08-28 08:29:11 +08:00
parent 8aa2d5119f
commit a15d780870
3 changed files with 53 additions and 11 deletions

View File

@ -504,6 +504,7 @@ export default {
onPostSettingsClose() { onPostSettingsClose() {
this.postSettingVisible = false this.postSettingVisible = false
this.selectedPost = {} this.selectedPost = {}
this.loadPosts()
}, },
onRefreshPostFromSetting(post) { onRefreshPostFromSetting(post) {
this.selectedPost = post this.selectedPost = post

View File

@ -95,15 +95,17 @@
:columns="customColumns" :columns="customColumns"
:dataSource="formattedSheets" :dataSource="formattedSheets"
:pagination="false" :pagination="false"
:loading="sheetsLoading"
> >
<span <span
slot="sheetTitle" slot="sheetTitle"
slot-scope="text,record" slot-scope="text,record"
class="sheet-title" style="max-width: 150px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"
> >
<a <a
:href="options.blog_url+'/s/'+record.url" :href="options.blog_url+'/s/'+record.url"
target="_blank" target="_blank"
style="text-decoration: none;"
> >
<a-tooltip <a-tooltip
placement="topLeft" placement="topLeft"
@ -181,6 +183,12 @@
>更多</a> >更多</a>
<a-menu slot="overlay"> <a-menu slot="overlay">
<a-menu-item key="1"> <a-menu-item key="1">
<a
href="javascript:void(0);"
@click="handleShowSheetSettings(sheet)"
>设置</a>
</a-menu-item>
<a-menu-item key="2">
<a-popconfirm <a-popconfirm
:title="'你确定要添加【' + sheet.title + '】到菜单?'" :title="'你确定要添加【' + sheet.title + '】到菜单?'"
@confirm="handleSheetToMenu(sheet)" @confirm="handleSheetToMenu(sheet)"
@ -199,11 +207,21 @@
</div> </div>
</a-col> </a-col>
</a-row> </a-row>
<SheetSetting
:sheet="selectedSheet"
:visible="sheetSettingVisible"
:needTitle="true"
@close="onSheetSettingsClose"
@onRefreshSheet="onRefreshSheetFromSetting"
/>
</div> </div>
</template> </template>
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import SheetSetting from './components/SheetSetting'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
import optionApi from '@/api/option' import optionApi from '@/api/option'
import menuApi from '@/api/menu' import menuApi from '@/api/menu'
@ -262,11 +280,17 @@ const customColumns = [
] ]
export default { export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
components: {
SheetSetting
},
data() { data() {
return { return {
sheetsLoading: false,
sheetStatus: sheetApi.sheetStatus, sheetStatus: sheetApi.sheetStatus,
internalColumns, internalColumns,
customColumns, customColumns,
selectedSheet: {},
sheetSettingVisible: false,
internalSheets: [], internalSheets: [],
sheets: [], sheets: [],
options: [], options: [],
@ -289,8 +313,10 @@ export default {
}, },
methods: { methods: {
loadSheets() { loadSheets() {
this.sheetsLoading = true
sheetApi.list().then(response => { sheetApi.list().then(response => {
this.sheets = response.data.data.content this.sheets = response.data.data.content
this.sheetsLoading = false
}) })
}, },
loadInternalSheets() { loadInternalSheets() {
@ -325,19 +351,23 @@ export default {
this.$message.success('添加到菜单成功!') this.$message.success('添加到菜单成功!')
this.menu = {} this.menu = {}
}) })
},
handleShowSheetSettings(sheet) {
sheetApi.get(sheet.id).then(response => {
this.selectedSheet = response.data.data
this.sheetSettingVisible = true
})
},
onSheetSettingsClose() {
this.sheetSettingVisible = false
this.selectedSheet = {}
this.loadSheets()
},
onRefreshSheetFromSetting(sheet) {
this.selectedSheet = sheet
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
a {
text-decoration: none;
}
.sheet-title {
max-width: 300px;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style> </style>

View File

@ -18,6 +18,12 @@
<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">
<a-form layout="vertical"> <a-form layout="vertical">
<a-form-item
label="页面标题:"
v-if="needTitle"
>
<a-input v-model="selectedSheet.title" />
</a-form-item>
<a-form-item <a-form-item
label="页面路径:" label="页面路径:"
:help="options.blog_url+'/s/'+ (selectedSheet.url ? selectedSheet.url : '{auto_generate}')" :help="options.blog_url+'/s/'+ (selectedSheet.url ? selectedSheet.url : '{auto_generate}')"
@ -130,6 +136,11 @@ export default {
type: Object, type: Object,
required: true required: true
}, },
needTitle: {
type: Boolean,
required: false,
default: false
},
visible: { visible: {
type: Boolean, type: Boolean,
required: false, required: false,