6 files modified
1 files added
| New file |
| | |
| | | import http from '@/http/api.js' |
| | | |
| | | //保存 |
| | | export const getFuncList = (type, roleName) => { |
| | | return http.request({ |
| | | url: 'blade-doorplateAddress/doorplateAddress/getFuncList', |
| | | method: 'GET', |
| | | params: { |
| | | type, |
| | | roleName |
| | | } |
| | | }) |
| | | } |
| | |
| | | |
| | | export const getDetail = (params) => { |
| | | return http.request({ |
| | | url: '/api/blade-system/role/detail', |
| | | url: '/blade-system/role/detail', |
| | | method: 'GET', |
| | | params |
| | | }) |
| | |
| | | <view class="main-select" @click="selectBoxShow = !selectBoxShow"> |
| | | <u-icon name="map" color="#fff"></u-icon> |
| | | <view> |
| | | 当前场所:暂无绑定场所信息 |
| | | 当前场所:{{curSelectSite.name?curSelectSite.name:'暂无绑定场所信息'}} |
| | | </view> |
| | | |
| | | <u-picker title="场所" :show="selectBoxShow" ref="uPicker" :columns="columns" @confirm="confirm" |
| | | @change="changeHandler"></u-picker> |
| | | <u-picker title="场所" :show="selectBoxShow" keyName="name" ref="uPicker" :columns="siteColumns" |
| | | @confirm="confirm" @change="changeHandler"></u-picker> |
| | | </view> |
| | | |
| | | <view class="main-btn"> |
| | |
| | | import curMenu from "@/components/curMenu/index.vue"; |
| | | import menuList from "@/components/menuList/index.vue"; |
| | | import gridMenu from "@/components/gridMenu/index.vue"; |
| | | import { |
| | | getFuncList |
| | | } from "@/api/doorplateAddress/doorplateAddress"; |
| | | |
| | | export default { |
| | | components: { |
| | |
| | | data() { |
| | | return { |
| | | menuList: [], |
| | | selectRole: {}, |
| | | selectBoxShow: false, |
| | | columns: [ |
| | | ['中国', '美国'] |
| | | ], |
| | | siteColumns: [], |
| | | curSelectSite: {}, |
| | | columnData: [], |
| | | btnList: [{ |
| | | imgUrl: '/static/img/sys.png', |
| | |
| | | }, |
| | | |
| | | onShow() { |
| | | this.menuList = uni.getStorageSync("menu") |
| | | this.getMenuList() |
| | | uni.hideTabBar() |
| | | this.init() |
| | | }, |
| | | |
| | | computed: { |
| | |
| | | }, |
| | | |
| | | methods: { |
| | | //初始化 |
| | | init() { |
| | | this.curSelectSite = {} |
| | | this.menuList = uni.getStorageSync("menu") |
| | | this.selectRole = uni.getStorageSync("activeRole") |
| | | this.getMenuList() |
| | | this.getSiteList() |
| | | uni.hideTabBar() |
| | | }, |
| | | //获取场所列表 |
| | | async getSiteList() { |
| | | console.log(this.selectRole) |
| | | let type = null |
| | | let roleName = this.selectRole.roleName |
| | | console.log("roleName", roleName) |
| | | if (roleName == '网格员' || roleName == '系统管理员') { |
| | | type = 1 |
| | | } else if (roleName == '场所负责人') { |
| | | type = 2 |
| | | } else if (roleName == '居民') { |
| | | type = 3 |
| | | } |
| | | |
| | | const res = await getFuncList(type, roleName) |
| | | console.log(res, "-----------") |
| | | let data = res.data |
| | | this.siteColumns = [] |
| | | |
| | | this.buildSiteColumn(data, 0) |
| | | console.log(this.siteColumns) |
| | | |
| | | }, |
| | | |
| | | buildSiteColumn(dataList, index) { |
| | | if (dataList.length > 0) { |
| | | this.siteColumns[index] = dataList |
| | | if (dataList[0].children && dataList[0].children.length > 0) { |
| | | this.buildSiteColumn(dataList[0].children, index + 1) |
| | | } |
| | | } |
| | | }, |
| | | |
| | | //获取首页菜单 |
| | | getMenuList() { |
| | | console.log("当前角色菜单", this.menuList) |
| | |
| | | // 回调参数为包含columnIndex、value、values |
| | | confirm(e) { |
| | | console.log('confirm', e) |
| | | this.curSelectSite = e.value[e.value.length - 1] |
| | | this.selectBoxShow = false |
| | | } |
| | | } |
| | |
| | | isLogin: lifeData.isLogin ? lifeData.isLogin : false, |
| | | // 如果version无需保存到本地永久存储,无需lifeData.version方式 |
| | | version: '1.0.0', |
| | | activeRoleId: "", |
| | | activeRole: {}, |
| | | // tabBarList: [], |
| | | adCodeBase: {}, |
| | | // tabbarIndex: uni.getStorageSync("tabbarIndex") || 0, |
| | |
| | | // // console.log(uni.getStorageSync('tabBarList')) |
| | | // }, |
| | | //设置当前激活的角色 |
| | | setActiveRoleId(state, roleId) { |
| | | state.activeRoleId = roleId |
| | | uni.setStorageSync('activeRoleId', roleId) |
| | | setActiveRole(state, role) { |
| | | state.activeRole = role |
| | | uni.setStorageSync('activeRole', role) |
| | | }, |
| | | |
| | | SET_MENU(state, menuList) { |
| | |
| | | <template> |
| | | <view class="role-container"> |
| | | <view @click="activeRole(item)" v-for="(item, index) in roleData" :key="index" :class="item.active?'active':''"> |
| | | <view @click="enableRole(item)" v-for="(item, index) in roleData" :key="index" :class="item.active?'active':''"> |
| | | <view class="l"> |
| | | <u-icon :name="item.iconName"></u-icon> |
| | | <view class="role-name"> |
| | |
| | | methods: { |
| | | |
| | | //启用角色 |
| | | activeRole(item) { |
| | | enableRole(item) { |
| | | this.roleData.forEach(role => { |
| | | if (role.id == item.id) { |
| | | role.active = true |
| | |
| | | } |
| | | }, |
| | | created() { |
| | | this.selectRole = uni.getStorageSync("activeRole") |
| | | this.getUserRole() |
| | | }, |
| | | |
| | |
| | | id: e.id, |
| | | iconName: 'account-fill', |
| | | roleName: e.roleName, |
| | | active: e.id == this.activeRoleId ? true : false |
| | | active: e.id == this.selectRole.id ? true : false |
| | | }) |
| | | }) |
| | | |
| | | this.selectRole = this.roleData.filter(e => e.id == this.activeRoleId)[0] |
| | | this.loading = !this.loading |
| | | |
| | | }, |
| | |
| | | const that = this |
| | | |
| | | //保存当前激活的角色 |
| | | store.commit("setActiveRoleId", this.selectRole.id) |
| | | store.commit("setActiveRole", this.selectRole) |
| | | |
| | | //获取角色菜单 |
| | | const res = await dynamicMenu(this.selectRole.id) |
| | | console.log(res, "*/*/*/*/*/*") |
| | | //把菜单存入store中 |
| | | let data = res.data |
| | | const appMenu = data.filter(e => e.name == 'app')[0].children |
| | | console.log("菜单:", appMenu) |
| | | store.commit("SET_MENU", appMenu) |
| | | |
| | | |
| | | |
| | | uni.showToast({ |
| | |
| | | import store from "@/store/index.js" |
| | | import { |
| | | dynamicMenu |
| | | dynamicMenu, |
| | | getDetail |
| | | } from "@/api/system/role.js" |
| | | import { |
| | | logAdd |
| | |
| | | const install = (Vue, vm) => { |
| | | |
| | | // 登录操作 1 |
| | | const login = (userInfo) => { |
| | | const login = async (userInfo) => { |
| | | |
| | | vm.$u.vuex('userInfo', userInfo) |
| | | vm.$u.vuex('accessToken', userInfo.access_token) |
| | | vm.$u.vuex('isLogin', true) |
| | | |
| | | let activeRoleId = userInfo.role_id.split(",")[0] |
| | | console.log("当前激活角色的id:", activeRoleId) |
| | | |
| | | //添加当前激活的roleId(默认取第一个) |
| | | vm.$u.vuex('activeRoleId', activeRoleId) |
| | | const resDetail = await getDetail({ |
| | | id: activeRoleId |
| | | }) |
| | | console.log("当前激活角色的id:", resDetail.data) |
| | | //添加当前激活的角色(默认取第一个) |
| | | store.commit('setActiveRole', resDetail.data) |
| | | |
| | | //获取角色菜单 |
| | | dynamicMenu(activeRoleId).then(res => { |
| | | let data = res.data |
| | | let appMenu = data.filter(e => e.name == 'app')[0].children |
| | | console.log("当前角色菜单:", appMenu) |
| | | store.commit('SET_MENU', appMenu) |
| | | const { |
| | | data |
| | | } = await dynamicMenu(activeRoleId) |
| | | |
| | | //跳转到首页 |
| | | uni.switchTab({ |
| | | url: '/pages/home/index' |
| | | }) |
| | | let appMenu = data.filter(e => e.name == 'app')[0].children |
| | | console.log("当前角色菜单:", appMenu) |
| | | store.commit('SET_MENU', appMenu) |
| | | |
| | | //跳转到首页 |
| | | uni.switchTab({ |
| | | url: '/pages/home/index' |
| | | }) |
| | | } |
| | | |