|
|
|
@ -10,26 +10,10 @@ |
|
|
|
|
:default-active="defaultIndex" |
|
|
|
|
@select="initData"> |
|
|
|
|
<template v-for="item in menuList"> |
|
|
|
|
<template v-if="item.secondColumn.length"> |
|
|
|
|
<el-submenu :index="item.id" :key="item.id"> |
|
|
|
|
<template slot="title"> |
|
|
|
|
<i :class="item.icon"></i> |
|
|
|
|
<span slot="title">{{ item.name }}</span> |
|
|
|
|
</template> |
|
|
|
|
<template v-for="subItem in item.secondColumn"> |
|
|
|
|
<el-menu-item |
|
|
|
|
:index="subItem.id" |
|
|
|
|
:key="subItem.id" |
|
|
|
|
>{{ subItem.name }}</el-menu-item> |
|
|
|
|
</template> |
|
|
|
|
</el-submenu> |
|
|
|
|
</template> |
|
|
|
|
<template v-else> |
|
|
|
|
<el-menu-item :index="item.id" :key="item.id"> |
|
|
|
|
<i :class="item.icon"></i> |
|
|
|
|
<span slot="title">{{ item.name }}</span> |
|
|
|
|
</el-menu-item> |
|
|
|
|
</template> |
|
|
|
|
<el-menu-item :index="item.id" :key="item.id"> |
|
|
|
|
<i :class="item.icon"></i> |
|
|
|
|
<span slot="title">{{ item.name }}</span> |
|
|
|
|
</el-menu-item> |
|
|
|
|
</template> |
|
|
|
|
</el-menu> |
|
|
|
|
</div> |
|
|
|
@ -88,9 +72,7 @@ export default { |
|
|
|
|
totals: 0, |
|
|
|
|
listData: [], |
|
|
|
|
loadIns: null, |
|
|
|
|
columnId: '', |
|
|
|
|
firstName: '', |
|
|
|
|
secondName: '' |
|
|
|
|
columnId: '' |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -99,6 +81,9 @@ export default { |
|
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
|
this.getData() |
|
|
|
|
},500) |
|
|
|
|
}, |
|
|
|
|
$route() { |
|
|
|
|
this.getData() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
@ -110,29 +95,25 @@ export default { |
|
|
|
|
"setColumnId" |
|
|
|
|
]), |
|
|
|
|
getData() { |
|
|
|
|
this.setColumnId(""); |
|
|
|
|
let data = { |
|
|
|
|
page: this.pageNo, |
|
|
|
|
size: this.pageSize |
|
|
|
|
} |
|
|
|
|
const parentId = this.$route.query.parentId |
|
|
|
|
this.setColumnId('') |
|
|
|
|
this.loadIns = Loading.service() |
|
|
|
|
this.$get(this.api.queryAllColumns,data).then(res => { |
|
|
|
|
this.menuList = res.columnTree |
|
|
|
|
this.$get(this.api.secondaryColumnsByFirst, { |
|
|
|
|
parentId |
|
|
|
|
}).then(res => { |
|
|
|
|
const { data } = res |
|
|
|
|
this.menuList = data |
|
|
|
|
// 从文章页返回的情况,需要回到之前进文章页的那个分类 |
|
|
|
|
if(this.historyId){ |
|
|
|
|
this.defaultIndex = this.historyId |
|
|
|
|
this.getContent(this.historyId) |
|
|
|
|
const historyId = this.historyId |
|
|
|
|
if(historyId && data.find(e => e.id === historyId)){ |
|
|
|
|
this.defaultIndex = historyId |
|
|
|
|
this.getContent(historyId) |
|
|
|
|
}else{ |
|
|
|
|
// 正常情况默认展示第一个分类下的文章列表 |
|
|
|
|
if(this.menuList[0].secondColumn.length){ |
|
|
|
|
this.getContent(this.menuList[0].secondColumn[0].id) |
|
|
|
|
this.defaultIndex = this.menuList[0].secondColumn[0].id |
|
|
|
|
}else{ |
|
|
|
|
this.getContent(this.menuList[0].id) |
|
|
|
|
this.defaultIndex = this.menuList[0].id |
|
|
|
|
} |
|
|
|
|
const id = data.length ? data[0].id : parentId |
|
|
|
|
this.getContent(id) |
|
|
|
|
this.defaultIndex = id |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
this.loadIns.close() |
|
|
|
|
}); |
|
|
|
@ -144,28 +125,11 @@ export default { |
|
|
|
|
getContent(index,indexPath){ |
|
|
|
|
if(indexPath) this.loadIns = Loading.service() |
|
|
|
|
this.columnId = index |
|
|
|
|
let data = { |
|
|
|
|
this.$get(`${this.api.queryArticleByCondition}/${this.pageNo}/${this.pageSize}`, { |
|
|
|
|
name: this.keyword, |
|
|
|
|
columnId: index, |
|
|
|
|
port: 0 |
|
|
|
|
} |
|
|
|
|
let list = this.menuList |
|
|
|
|
list.map(n => { |
|
|
|
|
if(n.secondColumn.length){ |
|
|
|
|
n.secondColumn.map(e => { |
|
|
|
|
if(e.id == index){ |
|
|
|
|
this.firstName = n.name |
|
|
|
|
this.secondName = e.name |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
if(n.id == index){ |
|
|
|
|
this.firstName = n.name |
|
|
|
|
this.secondName = '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
this.$get(`${this.api.queryArticleByCondition}/${this.pageNo}/${this.pageSize}`,data).then(res => { |
|
|
|
|
}).then(res => { |
|
|
|
|
this.listData = res.articleList |
|
|
|
|
this.totals = res.total |
|
|
|
|
this.listData.map(n => { |
|
|
|
@ -181,8 +145,10 @@ export default { |
|
|
|
|
this.getContent(this.columnId); |
|
|
|
|
}, |
|
|
|
|
toArticle(id){ |
|
|
|
|
this.setColumnId(this.columnId); |
|
|
|
|
this.$router.push(`/info/details?id=${id}&first=${this.firstName}&second=${this.secondName}`) |
|
|
|
|
const columnId = this.columnId |
|
|
|
|
const list = this.menuList |
|
|
|
|
this.setColumnId(columnId) |
|
|
|
|
this.$router.push(`/info/details?parentId=${this.$route.query.parentId}&id=${id}&first=${this.$route.query.name}&second=${list.length ? list.find(e => e.id === columnId).name : ''}`) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|