import Util from '@/libs/util' export default { data() { return { active: +this.$route.query.id, tabs: [], } }, mounted() { this.getColumn() }, methods: { // 获取文章详情 getInfo() { // 预览/详情 this.$post(this.api[this.preview ? 'getRedisCache' : 'findPage'], Util.rsa(this.id)).then(({ data }) => { if (data.length) { // state:已发布(1)则取theEditedJson,草稿(0)则取jsonBeforeEditing const json = JSON.parse(this.preview ? data : data[data.length - 1][data[data.length - 1].state ? 'theEditedJson' : 'jsonBeforeEditing']) this.modules = json } }).catch(err => {}) }, // 获取所有栏目 getColumn() { this.$post(this.api.listWithTreeMenuVisible, Util.rsa({ siteId: this.site, columnName: '', templateId: '', typeId: '', isSort: 1 })) .then(({ data }) => { this.getParent(data) }) .catch((err) => { }); }, // 获取父级 getParent(data, parent = {}) { for (const e of data) { if (e.id == this.id) { this.tabs = parent.children break } else if (e.children.length) { this.getParent(e.children, e) } } }, // tab回调 tabChange(item) { this.$router.push(`/${item.path}?id=${item.id}&siteId=${item.siteId}`) }, } };