|
|
|
@ -5,8 +5,8 @@ |
|
|
|
|
<li :class="{active: tabsName == 1}" @click="handleClick(1)"><i class="el-icon-collection-tag"></i> 栏目管理</li> |
|
|
|
|
<li :class="{active: tabsName == 2}" @click="handleClick(2)"><i class="el-icon-document"></i> 内容管理</li> |
|
|
|
|
</ul> |
|
|
|
|
<columnManage class="flex-1" v-if="tabsName === 1" /> |
|
|
|
|
<ContentManage class="flex-1" ref="contentManage" v-if="tabsName === 2" /> |
|
|
|
|
<columnManage class="flex-1" ref="content1" v-if="tabsName == 1" /> |
|
|
|
|
<ContentManage class="flex-1" ref="content2" v-if="tabsName == 2" /> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
@ -25,49 +25,36 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 页面离开的时候如果内容管理的排序没有保存则提示 |
|
|
|
|
beforeRouteLeave(to, from, next) { |
|
|
|
|
const { content } = this.$refs.contentManage.$refs |
|
|
|
|
const { list, originSort } = content |
|
|
|
|
|
|
|
|
|
// 更改了信息才需要提示 |
|
|
|
|
if (JSON.stringify(list) !== JSON.stringify(originSort)) { |
|
|
|
|
this.$confirm(`您已更改了文章排序,是否保存更改?`, '提示', { |
|
|
|
|
type: 'warning' |
|
|
|
|
}).then(() => { |
|
|
|
|
content.sortSubmit() |
|
|
|
|
next() |
|
|
|
|
}).catch(() => { |
|
|
|
|
next() |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
next() |
|
|
|
|
} |
|
|
|
|
this.routeLeave(next, true) |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
switchTab(id) { |
|
|
|
|
this.tabsName = id |
|
|
|
|
this.$store.commit('setInfoTab', id) |
|
|
|
|
}, |
|
|
|
|
handleClick(id) { |
|
|
|
|
if (this.tabsName == 2) { |
|
|
|
|
const { content } = this.$refs.contentManage.$refs |
|
|
|
|
const { list, originSort } = content |
|
|
|
|
|
|
|
|
|
// 页面离开询问保存 |
|
|
|
|
routeLeave(fn, param) { |
|
|
|
|
const tab = this.tabsName |
|
|
|
|
let content = this.$refs['content' + tab] |
|
|
|
|
if (tab == 2) content = content.$refs.content |
|
|
|
|
const { list, originList } = content |
|
|
|
|
// 更改了信息才需要提示 |
|
|
|
|
if (JSON.stringify(list) !== JSON.stringify(originSort)) { |
|
|
|
|
this.$confirm(`您已更改了文章排序,是否保存更改?`, '提示', { |
|
|
|
|
if (JSON.stringify(list) !== JSON.stringify(originList)) { |
|
|
|
|
this.$confirm(`您已更改了${tab == 1 ? '栏目' : '文章'}排序,是否保存更改?`, '提示', { |
|
|
|
|
type: 'warning' |
|
|
|
|
}).then(() => { |
|
|
|
|
content.sortSubmit() |
|
|
|
|
this.switchTab(id) |
|
|
|
|
fn(param) |
|
|
|
|
}).catch(() => { |
|
|
|
|
this.switchTab(id) |
|
|
|
|
fn(param) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.switchTab(id) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.switchTab(id) |
|
|
|
|
fn(param) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// tab回调 |
|
|
|
|
handleClick(id) { |
|
|
|
|
this.routeLeave(this.switchTab, id) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
@ -85,6 +72,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
.column-tab { |
|
|
|
|
width: 120px; |
|
|
|
|
border-right: solid 1px #e6e6e6; |
|
|
|
|
li { |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|