| 对比新文件 | 
|  |  |  | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | import { mapState } from 'vuex' | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: 'BasePage', | 
|---|
|  |  |  | data () { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | // 瓒呯骇绠$悊鍛樿鑹瞔ode | 
|---|
|  |  |  | adminCode: 'admin' | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | computed: { | 
|---|
|  |  |  | ...mapState(['userInfo','tableHeightNew']), | 
|---|
|  |  |  | // 鏄惁涓鸿秴绾х鐞嗗憳 | 
|---|
|  |  |  | isAdmin () { | 
|---|
|  |  |  | return this.userInfo.roles.findIndex(code => code === this.adminCode) > -1 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 鍒ゆ柇鏄惁涓篋EBUG妯″紡 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | isDebug () { | 
|---|
|  |  |  | return process.env.VUE_APP_DEBUG === 'on' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 鏄惁鍖呭惈鎸囧畾瑙掕壊 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param roles 鐩爣瑙掕壊鏁扮粍 | 
|---|
|  |  |  | * @returns {boolean} | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 鏄惁鍖呭惈鎸囧畾鏉冮檺 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param permissions 鐩爣鏉冮檺鏁扮粍 | 
|---|
|  |  |  | * @returns {boolean} | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 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> | 
|---|