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() {
this.postSettingVisible = false
this.selectedPost = {}
this.loadPosts()
},
onRefreshPostFromSetting(post) {
this.selectedPost = post

View File

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

View File

@ -18,6 +18,12 @@
<h3 class="post-setting-drawer-title">基本设置</h3>
<div class="post-setting-drawer-item">
<a-form layout="vertical">
<a-form-item
label="页面标题:"
v-if="needTitle"
>
<a-input v-model="selectedSheet.title" />
</a-form-item>
<a-form-item
label="页面路径:"
:help="options.blog_url+'/s/'+ (selectedSheet.url ? selectedSheet.url : '{auto_generate}')"
@ -130,6 +136,11 @@ export default {
type: Object,
required: true
},
needTitle: {
type: Boolean,
required: false,
default: false
},
visible: {
type: Boolean,
required: false,