diff --git a/src/App.vue b/src/App.vue index c5ebdfb..872aff8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,7 +10,6 @@ import util from '@/libs/util'; export default { name: 'App', created() { - console.log('i18n=>',this.$i18n.locale) //在页面加载时读取localStorage里的状态信息 if (util.local.get(Setting.storeKey)) { this.$store.replaceState(Object.assign({}, this.$store.state, util.local.get(Setting.storeKey))); @@ -91,7 +90,6 @@ export default { window.onbeforeunload = function(){ sessionStorage.removeItem('navPageSize') } - console.log('document.body.clientWidth=>', document.body.clientWidth) if(document.body.clientWidth > 1600 ) { sessionStorage.setItem('navPageSize', 10) }else if(document.body.clientWidth > 1500 && document.body.clientWidth <= 1600) { diff --git a/src/layouts/navbar/index.vue b/src/layouts/navbar/index.vue index 34963ef..1b5eebe 100644 --- a/src/layouts/navbar/index.vue +++ b/src/layouts/navbar/index.vue @@ -71,7 +71,7 @@ export default { // 栏目列表 getColumn() { this.$post(this.api.listWithTree, { - siteId: this.$route.query.siteId || this.site, + siteId: this.site, columnName: '', templateId: '', typeId : '', diff --git a/src/mixins/article/index.js b/src/mixins/article/index.js index 6db219b..0170a97 100644 --- a/src/mixins/article/index.js +++ b/src/mixins/article/index.js @@ -18,9 +18,6 @@ export default { // 点击栏目回调 columnTo(to) { const { typeId,menuVisible } = to - console.log('typeId=>' ,typeId) - console.log('to=>' ,to) - console.log('menuVisible=>' ,menuVisible) // 跳转链接 if (typeId === 2) { if ( menuVisible === 1 && to.children.find(i=>i.menuVisible ===1)) return diff --git a/src/mixins/estate/index.js b/src/mixins/estate/index.js index 86de08c..475d9f7 100644 --- a/src/mixins/estate/index.js +++ b/src/mixins/estate/index.js @@ -1,9 +1,13 @@ export default { data() { return { - tabs: ['产业光源概况', '大事记', '机构设置', '地理位置'], + active: +this.$route.query.id, + tabs: [], } }, + mounted() { + this.getColumn() + }, methods: { // 获取文章详情 getInfo() { @@ -19,35 +23,33 @@ export default { } }).catch(err => {}) }, - // tab回调 - tabChange(i) { - this.active = i - // 跳转到固定的长页,这里的id不能变 - let path = '/overviewIntro?id=220' - if (i == 1) path = '/overviewDevHistory?id=214' - if (i == 2) path = '/overviewTrailer?id=215' - if (i == 3) path = '/overviewLocation?id=216' - this.$router.push(path + '&siteId=3') + // 获取所有栏目 + getColumn() { + this.$post(this.api.listWithTreeMenuVisible, { + siteId: this.site, + columnName: '', + templateId: '', + typeId: '', + isSort: 1 + }) + .then(({ data }) => { + this.getParent(data) + }) + .catch((err) => { }); }, - tabChangeNewPage(i) { - console.log("process.env.NODE_ENV === 'development'",) - const devServer = process.env.NODE_ENV === 'development' - let path - if (devServer) { - path = '/estate/survey?id=258' - if (i == 1) path = '/estate/event?id=259' - if (i == 2) path = '/estate/orgSetup?id=270' - if (i == 3) path = '/estate/location?id=261' - }else { - path = '/estate/survey?id=233' - if (i == 1) path = '/estate/event?id=234' - if (i == 2) path = '/estate/orgSetup?id=235' - if (i == 3) path = '/estate/location?id=236' + // 获取父级 + getParent(data, parent = {}) { + for (const e of data) { + if (e.id == this.id) { + this.tabs = parent.children + } else if (e.children.length) { + this.getParent(e.children, e) + } } - this.active = i - // 跳转到固定的长页,这里的id不能变 - console.log('path=>',path) - this.$router.push(path + '&siteId=5') - } + }, + // tab回调 + tabChange(item) { + this.$router.push(`/${item.path}?id=${item.id}&siteId=${item.siteId}`) + }, } }; \ No newline at end of file diff --git a/src/mixins/overview/index.js b/src/mixins/overview/index.js index 64e792d..1c4cc84 100644 --- a/src/mixins/overview/index.js +++ b/src/mixins/overview/index.js @@ -1,9 +1,13 @@ export default { data() { return { - tabs: ['S³FEL介绍', '发展历程', 'S³FEL宣传片', '地理位置', '机构设置'], + active: +this.$route.query.id, + tabs: [], } }, + mounted() { + this.getColumn() + }, methods: { // 获取文章详情 getInfo() { @@ -14,41 +18,38 @@ export default { const json = JSON.parse(this.preview ? data : data[data.length - 1][data[data.length - 1].state ? 'theEditedJson' : 'jsonBeforeEditing']) - console.log('json=》',json) this.modules = json console.log("🚀 ~ file: index.vue ~ line 180 ~ this.$post ~ json", json) } }).catch(err => {}) }, + // 获取所有栏目 + getColumn() { + this.$post(this.api.listWithTreeMenuVisible, { + 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 + } else if (e.children.length) { + this.getParent(e.children, e) + } + } + }, // tab回调 - tabChange(i) { - this.active = i - // 跳转到固定的长页,这里的id不能变 - let path = '/overviewIntro?id=378' - if (i == 1) path = '/overviewDevHistory?id=379' - if (i == 2) path = '/overviewTrailer?id=380' - if (i == 3) path = '/overviewLocation?id=381' - if (i == 4) path = '/overviewSetup?id=382' - this.$router.push(path + '&siteId=4') + tabChange(item) { + this.$router.push(`/${item.path}?id=${item.id}&siteId=${item.siteId}`) }, }, - filters: { - i18nName(name,type) { - switch (name) { - case 'S³FEL介绍': - return type.t('column.sfeLintroduce') - case '发展历程': - return type.t('column.develHistory') - case 'S³FEL宣传片': - return type.t('column.sfeltrailer') - case '地理位置': - return type.t('column.geographicLocation') - case '机构设置': - return type.t('column.organization') - - default: - return name - } - } - } }; \ No newline at end of file diff --git a/src/mixins/page/index.js b/src/mixins/page/index.js index 2770c50..e055816 100644 --- a/src/mixins/page/index.js +++ b/src/mixins/page/index.js @@ -3,13 +3,17 @@ import Util from '@/libs/util' export default { data() { return { - site: this.$store.state.content.site, id: this.$route.query.id, preview: this.$route.query.preview, modules: [], articles: [] } }, + computed: { + site() { + return this.$route.query.siteId || this.$store.state.content.site + } + }, mounted() { this.getInfo && this.id && this.getInfo() }, @@ -32,7 +36,7 @@ export default { } else { // 栏目 href = '/column?id=' + link.columnId[link.columnId.length - 1] } - href += '&siteId=' + (this.$route.query.siteId || this.site) + href += '&siteId=' + (this.site) if (!link.articleId) href = this.$router.resolve(href).href } else if (type === 3) { // 站外链接 if (link.otherArticleId) { // 文章 @@ -83,7 +87,7 @@ export default { const ids = href.split('-') // 栏目文章是用-分割的,栏目是必选,文章不是必选。选择了文章则跳转到文章页,否则跳转到栏目页 // 站点id:站内链接取当前站点,其他站点链接取siteSelection const site = cType === 1 ? - (this.$route.query.siteId || this.site) : + (this.site) : item.siteSelection if (ids[1]) { // 文章 href = '/article?articleId=' + ids[1] @@ -95,7 +99,7 @@ export default { } this.toHref(item.isOpen, href) } else { - this.$router.push(`/article?articleId=${item.id}&siteId=${this.$route.query.siteId || this.site}&id=${this.id}&columnName=${form.columnTitle === 2 ? form.columnTitleCustom : form.columnName}&path=${this.$route.path.replace('/', '')}`) + this.$router.push(`/article?articleId=${item.id}&siteId=${this.site}&id=${this.id}&columnName=${form.columnTitle === 2 ? form.columnTitleCustom : form.columnName}&path=${this.$route.path.replace('/', '')}`) } }, // 关联栏目的查看全部跳转 diff --git a/src/pages/column/index.vue b/src/pages/column/index.vue index 961c2eb..fca3ab7 100644 --- a/src/pages/column/index.vue +++ b/src/pages/column/index.vue @@ -473,10 +473,8 @@ export default { if (typeId === 4 && !fromColumn) { id = [this.deepestId]; } - console.log('id=>',id) this.getAllId = id this.getArticle(id); - console.log('data=>',data) this.columns = data; // 如果没上传banner if (!this.info.columnBanner) { @@ -518,7 +516,6 @@ export default { siteId: this.site }) .then(({ data }) => { - console.log(99122) this.news = Util.removeTag(data.records); }) .catch((res) => { }); @@ -592,7 +589,6 @@ export default { this.labels.map((e) => { if (this.lableId.includes(e.id)) labelName.push(e.labelName); }); - console.log('====>',columnIds) this.$post(this.api.newlyPublishedArticles, { siteId: this.site, columnIds, @@ -629,7 +625,6 @@ export default { filter() { this.page = 1; this.isFilter = !!(this.form.classificationId || this.form.title || this.form.convokeType || this.lableId.length); // 是否在筛选 - console.log('this.isFilter=>' ,this.isFilter) let id = []; if (this.isFilter) { this.getIds(this.columns, id); diff --git a/src/pages/estate/event/index.vue b/src/pages/estate/event/index.vue index df06781..b0637a2 100644 --- a/src/pages/estate/event/index.vue +++ b/src/pages/estate/event/index.vue @@ -10,7 +10,7 @@ @@ -53,7 +53,6 @@ export default { mixins: [mixins, overview], data() { return { - active: 1, curYear: 0 } }, diff --git a/src/pages/estate/location/index.vue b/src/pages/estate/location/index.vue index a8f8400..de80a6c 100644 --- a/src/pages/estate/location/index.vue +++ b/src/pages/estate/location/index.vue @@ -10,7 +10,7 @@ @@ -54,7 +54,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 3 + } }, mounted() { diff --git a/src/pages/estate/orgSetup/index.vue b/src/pages/estate/orgSetup/index.vue index 5350431..1ceeed3 100644 --- a/src/pages/estate/orgSetup/index.vue +++ b/src/pages/estate/orgSetup/index.vue @@ -10,7 +10,7 @@ @@ -37,7 +37,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 2 + } }, mounted() { diff --git a/src/pages/estate/survey/index.vue b/src/pages/estate/survey/index.vue index 82aebfe..4854a32 100644 --- a/src/pages/estate/survey/index.vue +++ b/src/pages/estate/survey/index.vue @@ -10,7 +10,7 @@ @@ -37,7 +37,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 0 + } }, mounted() { diff --git a/src/pages/news/index.vue b/src/pages/news/index.vue index 8605641..0e52b1e 100644 --- a/src/pages/news/index.vue +++ b/src/pages/news/index.vue @@ -250,7 +250,7 @@ export default { const ids = href.split('-') // 栏目文章是用-分割的,栏目是必选,文章不是必选。选择了文章则跳转到文章页,否则跳转到栏目页 // 站点id:站内链接取当前站点,其他站点链接取siteSelection const site = cType === 1 ? - (this.$route.query.siteId || this.site) : + (this.site) : data.siteSelection if (ids[1]) { // 文章 href = '/article?id=' + ids[1] diff --git a/src/pages/overviewDevHistory/index.vue b/src/pages/overviewDevHistory/index.vue index cd6b719..2f7f2fc 100644 --- a/src/pages/overviewDevHistory/index.vue +++ b/src/pages/overviewDevHistory/index.vue @@ -9,7 +9,7 @@ @@ -72,7 +72,6 @@ export default { mixins: [mixins, overview], data() { return { - active: 1, curYear: 0 } }, diff --git a/src/pages/overviewIntro/index.vue b/src/pages/overviewIntro/index.vue index 851a8cb..178c9c5 100644 --- a/src/pages/overviewIntro/index.vue +++ b/src/pages/overviewIntro/index.vue @@ -9,7 +9,7 @@ @@ -43,7 +43,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 0, + } }, mounted() { diff --git a/src/pages/overviewLocation/index.vue b/src/pages/overviewLocation/index.vue index d5eb9ee..ca95c45 100644 --- a/src/pages/overviewLocation/index.vue +++ b/src/pages/overviewLocation/index.vue @@ -9,7 +9,7 @@ @@ -27,7 +27,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 3 + } }, mounted() { diff --git a/src/pages/overviewSetup/index.vue b/src/pages/overviewSetup/index.vue index a958715..4d24a90 100644 --- a/src/pages/overviewSetup/index.vue +++ b/src/pages/overviewSetup/index.vue @@ -9,7 +9,7 @@ @@ -37,7 +37,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 4 + } }, mounted() { diff --git a/src/pages/overviewTrailer/index.vue b/src/pages/overviewTrailer/index.vue index 8402463..3ff3b02 100644 --- a/src/pages/overviewTrailer/index.vue +++ b/src/pages/overviewTrailer/index.vue @@ -9,7 +9,7 @@ @@ -33,7 +33,7 @@ export default { mixins: [mixins, overview], data() { return { - active: 2 + } }, mounted() { diff --git a/src/pages/publication/index.vue b/src/pages/publication/index.vue index 6778ed2..a0e9a8a 100644 --- a/src/pages/publication/index.vue +++ b/src/pages/publication/index.vue @@ -37,6 +37,7 @@ export default { info: {}, active: 0, curId: '', + tab: this.$route.query.tab, tabs: [] } }, @@ -63,8 +64,14 @@ export default { // 获取子级栏目 getColumn() { this.$post(`${this.api.getsSublevelColumnsUnderALevel}?id=${this.id}&siteId=${this.site}`).then(({ data }) => { - if (data.length) { - this.tabs = data + this.tabs = data + // 如果url里有tab参数,则自动切换到这个tab,这个tab就是三个出版页中的其中一个id + if (this.tab) { + const id = +this.tab + const item = data.find(e => e.id == id) + this.active = item ? item.listStyleId : '' + this.curId = id + } else if (data.length) { this.active = data[0].listStyleId this.curId = data[0].id } diff --git a/src/pages/publication/single.vue b/src/pages/publication/single.vue index ac33441..ecebaab 100644 --- a/src/pages/publication/single.vue +++ b/src/pages/publication/single.vue @@ -40,6 +40,7 @@ export default { ], info: {}, type: +this.$route.query.type, // 栏目的listStyleId + parent: null } }, components: { @@ -49,6 +50,7 @@ export default { Monograph }, mounted() { + this.getColumn() this.getInfo() }, methods: { @@ -61,6 +63,32 @@ export default { }) .catch((res) => { }) }, + // 获取所有栏目 + getColumn() { + this.$post(this.api.listWithTreeMenuVisible, { + siteId: this.site, + columnName: '', + templateId: '', + typeId: '', + isSort: 1 + }) + .then(({ data }) => { + this.getParent(data) + const list = this.parent.children + list && list.length && list.every(e => e.templateId == 11) && this.$router.push(`/publication?siteId=${this.site}&id=${this.parent.id}&tab=${this.id}`) // 如果子级每个栏目都是出版物类型 + }) + .catch((err) => { }); + }, + // 获取父级 + getParent(data, parent = {}) { + for (const e of data) { + if (e.id == this.id) { + this.parent = parent + } else if (e.children.length) { + this.getParent(e.children, e) + } + } + }, } }; diff --git a/src/pages/publish/index.vue b/src/pages/publish/index.vue index 3f3fc0a..2e9c027 100644 --- a/src/pages/publish/index.vue +++ b/src/pages/publish/index.vue @@ -57,9 +57,7 @@ export default { // 查询文章列表 getArticle() { this.$post(this.api.newlyPublishedArticles, { - - - siteId: this.$route.query.siteId || this.site, + siteId: this.site, columnIds: [this.id], pageNum: this.page, pageSize: this.pageSize,