<script>
|
import { mapState } from 'vuex'
|
export default {
|
name: 'BasePage',
|
data () {
|
return {
|
tableHeightNew: 300,
|
// 超级管理员角色code
|
adminCode: 'admin'
|
}
|
},
|
computed: {
|
...mapState(['userInfo']),
|
// 是否为超级管理员
|
isAdmin () {
|
return this.userInfo.roles.findIndex(code => code === this.adminCode) > -1
|
}
|
},
|
created() {
|
this.computeTableHeight()
|
},
|
mounted () {
|
this.computeTableHeight()
|
window.addEventListener('resize', this.computeTableHeight)
|
},
|
activated() {
|
this.computeTableHeight()
|
},
|
methods: {
|
computeTableHeight () {
|
this.$nextTick(() => {
|
// const height = window.innerHeight
|
const height = document.getElementsByClassName('el-container') && document.getElementsByClassName('el-container')[0]?document.getElementsByClassName('el-container')[0].clientHeight:0
|
// alert(height)
|
const height1 = (document.getElementsByClassName('table-search-form') && document.getElementsByClassName('table-search-form')[0]? document.getElementsByClassName('table-search-form')[0].clientHeight:0)
|
const height2 = document.getElementsByClassName('toolbar') && document.getElementsByClassName('toolbar')[0]?document.getElementsByClassName('toolbar')[0].clientHeight:0
|
const height3 = document.getElementsByClassName('main-header') && document.getElementsByClassName('main-header')[0]?document.getElementsByClassName('main-header')[0].clientHeight:0
|
const height4 = document.getElementsByClassName('table-pagination') && document.getElementsByClassName('table-pagination')[0]? document.getElementsByClassName('table-pagination')[0].clientHeight:0
|
const height5 = document.getElementsByTagName('thead') && document.getElementsByTagName('thead')[0]? document.getElementsByTagName('thead')[0].clientHeight:0
|
const height6 = document.getElementsByClassName('doumee-filter') && document.getElementsByClassName('doumee-filter')[0]? document.getElementsByClassName('doumee-filter')[0].clientHeight:0
|
const height7 =( document.getElementsByClassName('pt16') && document.getElementsByClassName('pt16')[0]? 1+document.getElementsByClassName('pt16')[0].clientHeight:0)
|
const height8 = document.getElementsByClassName('df_sb') && document.getElementsByClassName('df_sb')[0]? document.getElementsByClassName('df_sb')[0].clientHeight:0
|
const height9 = document.getElementsByClassName('static_wrap') && document.getElementsByClassName('static_wrap')[0]? document.getElementsByClassName('df_sb')[0].clientHeight:0
|
const height10 = document.getElementsByClassName('query_btns') && document.getElementsByClassName('query_btns')[0]? document.getElementsByClassName('query_btns')[0].clientHeight:0
|
// this.tableHeightNew = height-height4-height3-height2-height1-height5-height6-height7-height8-height9 -height10// 打印高度
|
|
if(document.getElementsByClassName('main_app') && document.getElementsByClassName('main_app')[0]){
|
this.tableHeightNew = height- height5-height6-height2-height7-height4-height8-height9-height10// 打印高度
|
}else{
|
this.tableHeightNew = height-height4-height3-height2-height1-height5
|
}
|
console.log(this.tableHeightNew)
|
})
|
},
|
// 是否包含指定角色
|
containRoles (roles) {
|
if (roles == null) {
|
return true
|
}
|
if (this.userInfo == null) {
|
return false
|
}
|
if (this.userInfo.roles == null || this.userInfo.roles.length === 0) {
|
return false
|
}
|
for (const code of roles) {
|
if (this.userInfo.roles.findIndex(r => r === code) > -1) {
|
return true
|
}
|
}
|
return false
|
},
|
// 是否包含指定权限
|
containPermissions (permissions) {
|
if (permissions == null) {
|
return true
|
}
|
if (this.userInfo == null) {
|
return false
|
}
|
if (this.userInfo.permissions == null || this.userInfo.permissions.length === 0) {
|
return false
|
}
|
for (const code of permissions) {
|
if (this.userInfo.permissions.findIndex(p => p === code) > -1) {
|
return true
|
}
|
}
|
return false
|
}
|
}
|
}
|
</script>
|