페이지 단추 권한 분석

2505 단어
import * as types from '../mutation-types'
const state = {
  btnCode: getBtnCode(),
}
const mutations = {
  getBtnObj(state, btnCodeObj) {
    //        --    
    state.btnCode = btnCodeObj;
  },
}
const getters = {
  btnCode: state => state.btnCode
}
const actions = {
  actionsBtnList({ commit }, btnlist) {
    commit('getBtnObj', setBtnList(btnlist))
  },
}
//   --  
function setBtnList(list) {
  //           --     
  let codeObj = {
    '100010': btnCode('100010', list), // xxx  code ;
  }
  sessionStorage.setItem('btnObj', JSON.stringify(codeObj));
  let btnCodeObj = JSON.parse(sessionStorage.getItem('btnObj')) || {}
  return btnCodeObj
}

function getBtnCode() {
  return sessionStorage.getItem('btnObj') ? JSON.parse(sessionStorage.getItem('btnObj')) : {}
}

function btnCode(code, list) {
  // console.log(list,'  list')
  return list.findIndex(e => {
    return e.buttonCode == code
  })
}

export default {
  state,
  mutations,
  getters,
  actions
}

 
전재 대상:https://www.cnblogs.com/lhl66/p/11098574.html

좋은 웹페이지 즐겨찾기