This commit is contained in:
clay
2022-01-16 21:14:30 +08:00
parent 8e9cf7b833
commit b7897ba20e
18 changed files with 799 additions and 269 deletions

View File

@@ -4,10 +4,10 @@
<el-col :span="24">
<!--首页图片-->
<div class="top">
<span v-if="bgImage != ''">
<span v-if="bgImage != null">
<img :src="bgImage" alt="">
</span>
<span v-else>
<span v-if="bgImage == null">
<img src="@/assets/school_profile/bj123.png" alt="">
</span>
</div>
@@ -18,7 +18,7 @@
<el-col :xs="2" :sm="2" :md="1.5" :lg="2" :xl="4">
<div class="grid-content"></div>
</el-col>
<el-col v-show="width>=992" :md="6" :lg="6" :xl="4">
<el-col v-show="width" :md="6" :lg="6" :xl="4">
<div class="left_lab" ref="lab">
<div class="lab">
<div v-for="(nav,index) in navList" class="lab_div">
@@ -59,23 +59,25 @@
<Introduction :value="contextData" v-if="type == 1"/>
<List :value="contextData" v-if="type == 2"/>
<DireData :value="contextData" v-if="type == 3"/>
<Details :value="detailsData" v-if="type == null"/>
</el-col>
</el-row>
</el-col>
<el-col :xs="2" :sm="2" :md="1.5" :lg="2" :xl="4">
<div class="grid-content"></div>
</el-col>
</el-row>
</div>
</template>
<script>
import {getNode,crumbs} from "@/api";
import {getNode, crumbs, article} from "@/api";
import Introduction from './components/Introduction.vue'
import List from './components/list.vue'
import DireData from './components/dire_data.vue'
import Details from './components/details.vue'
import {handleTree} from "@/utils/ebts";
export default {
@@ -84,73 +86,150 @@ export default {
Introduction,
List,
DireData,
Details
},
data() {
return {
width: document.documentElement.clientWidth,
width: document.documentElement.clientWidth > 992,
secondId: null,
navId: null,
navList: [],
showIndex: 0,
contextData: {},
type: 2,
bgImage:"",
crumbs:{},
bgImage: null, crumbs: {
"two": {
"title": "学院领导",
},
"one": {
"title": "学院概况",
}
},
detailsData: {}
}
},
watch: {
$route(to, from) {
this.getNav()
console.log("触发了 $route")
let arcId = this.$route.params && this.$route.query.id
console.log(arcId)
if (arcId != undefined) {
this.getContext(arcId)
}
let id = this.$route.params && this.$route.params.secondId
this.navId = this.$route.params && this.$route.params.navId;
try {
this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem'
} catch (e) {
}
if (this.secondId == id) {
for (let i = 0; i < this.navList.length; i++) {
if (this.navId == this.navList[i].encodeId) {
this.showIndex = i
this.getContent(this.navList[i])
}
}
} else {
this.getNav()
}
}
},
created() {
this.getNav()
crumbs(this.navId).then(res=>{
crumbs(this.secondId).then(res => {
this.crumbs = res.data
})
},
methods: {
getContext(arcId) {
article(arcId).then(res => {
console.log(res);
this.detailsData = res.data.data
this.type = null
})
},
getNav() {
console.log("触发了 getNav")
this.secondId = this.$route.params && this.$route.params.secondId;
this.navId = this.$route.params && this.$route.params.navId;
this.navList = []
getNode({id: this.navId}).then(res => {
getNode({id: this.secondId}).then(res => {
this.navList = res.data
try {
this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem'
}catch (e) {
setTimeout(() => {
this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem'
}, 100);
} catch (e) {
console.log(e)
}
this.getContent(this.navList[0])
for (let i = 0; i < this.navList.length; i++) {
if (this.navId == this.navList[i].encodeId) {
this.showIndex = i
}
}
let arcId = this.$route.params && this.$route.query.id
if (arcId != undefined) {
this.getContext(arcId)
} else {
if (this.navId == undefined) {
this.getContent(this.navList[0])
} else {
this.getContent(this.navList[this.showIndex])
}
}
})
},
getContent(menu) {
this.type = menu.type
this.contextData = null
this.bgImage = menu.link
getNode({id: menu.encodeId}).then(res => {
if (this.type == 2){
let data = null
if (this.type == 2) {
data = {
id: menu.encodeId,
pageNum: 1,
pageSize: 4
}
} else {
data = {
id: menu.encodeId,
}
}
getNode(data).then(res => {
if (this.type == 2) {
this.contextData = {
data:res.rows,
total:res.total
data: res.rows,
total: res.total,
pageNum: data.pageNum,
navId: this.navId,
secondId: this.secondId,
}
}else if (this.type == 1){
} else if (this.type == 1) {
this.contextData = res.data
}else if (this.type == 3){
this.contextData = handleTree(res.data, "id", "pid",null,null)
} else if (this.type == 3) {
this.contextData = handleTree(res.data, "id", "pid", null, null)
}
})
},
navClick(nav, index) {
if (index != this.showIndex) {
this.showIndex = index
this.type = nav.type
this.getContent(nav)
}
//if (index != this.showIndex) {
this.showIndex = index
this.type = nav.type
this.$router.push("/pc/" + this.secondId + "/" + nav.encodeId);
//this.getContent(nav)
//}
}
},
}
</script>
<style scoped lang="scss">
.top {
img {
width: 100%;
}
}
.left_lab {
margin-left: 4rem;