| | |
| | | |
| | | // 请求相关 |
| | | import { reqAll, reqGet, reqPost } from '../utils/index.js'; |
| | | |
| | | const findNodeByNme = (arr) => { |
| | | for (let i = 0; i < arr.length; i++) { |
| | | let node = arr[i]; |
| | | if (node.name === '汽车日发运计划管理') return node; |
| | | if (node.children && node.children.length > 0) { |
| | | // 如果当前节点有子节点,则递归查找子节点 |
| | | let foundNode = findNodeByNme(node.children); |
| | | if (foundNode) return foundNode; |
| | | } |
| | | } |
| | | // 没有找到目标节点,返回 null |
| | | return null; |
| | | } |
| | | const store = new Vuex.Store({ |
| | | state: { |
| | | shenqingMenu: uni.getStorageSync('shenqingMenu') || false, //申请菜单 |
| | | rijihuaMenu: uni.getStorageSync('rijihuaMenu') || false, //日计划菜单 |
| | | permissions: uni.getStorageSync('permissions') || [] //权限信息 |
| | | }, |
| | | mutations: { |
| | | ISHAS_SHENQING: (state, data) => { |
| | |
| | | state.shenqingMenu = false |
| | | uni.setStorageSync('shenqingMenu',state.shenqingMenu) |
| | | } |
| | | |
| | | |
| | | }, |
| | | |
| | | ISHAS_RIJIHUA: (state, data) => { |
| | | console.log(data,'data-----',state) |
| | | let labelArry = [] |
| | | let newObj = data.filter(e => e.label == '地销计量') |
| | | newObj && newObj.forEach(e => { |
| | | if(e.children.length > 0) { |
| | | e.children.forEach(item => { |
| | | labelArry.push(item.label) |
| | | }) |
| | | }else{ |
| | | state.rijihuaMenu = false |
| | | uni.setStorageSync('rijihuaMenu',state.rijihuaMenu) |
| | | } |
| | | }) |
| | | // let newObj = data.filter(e => e.label == '汽车日发运计划管理') |
| | | let newObj = findNodeByNme(data) //找 汽车日发运计划管理 |
| | | if(newObj && newObj.label) { |
| | | labelArry.push(newObj.label) |
| | | } |
| | | if(labelArry.indexOf('汽车日发运计划管理') > -1) { |
| | | state.rijihuaMenu = true |
| | | uni.setStorageSync('rijihuaMenu',state.rijihuaMenu) |
| | |
| | | state.rijihuaMenu = false |
| | | uni.setStorageSync('rijihuaMenu',state.rijihuaMenu) |
| | | } |
| | | }, |
| | | SET_PERMISSIONS: (state,permissions) => { |
| | | let list = {} |
| | | for(let i=0;i<permissions.length;i++) { |
| | | list[permissions[i]] = true |
| | | } |
| | | state.permissions = list |
| | | console.log(list,'list======----') |
| | | uni.setStorageSync('permissions', list); |
| | | } |
| | | }, |
| | | actions: { |
| | |
| | | commit('ISHAS_RIJIHUA',response.data) |
| | | }) |
| | | } |
| | | }, |
| | | getters: { |
| | | permissions:state => state.permissions |
| | | } |
| | | }) |
| | | |
| | | export default store |
| | | export default store |