diff --git a/src/store/index.js b/src/store/index.js index de91a35..cab0bfe 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,6 +6,7 @@ export const useAdminStore = defineStore('admin', { adminData: null, // 用户信息 menuTree: [], // 菜单权限树 marketList: {}, // 市场列表 + flag: 0, //员工数据开关状态,0=不包含员工数据,1=包含员工数据 }), actions: { // 设置用户信息并同步到localStorage @@ -24,11 +25,18 @@ export const useAdminStore = defineStore('admin', { localStorage.setItem('marketList', JSON.stringify(list)) }, + // 设置员工数据开关状态(使用数字0和1) + setFlag(flag) { + this.flag = flag + localStorage.setItem('flag', JSON.stringify(flag)) + }, + // 从localStorage初始化数据 initFromLocalStorage() { const adminData = localStorage.getItem('adminData') const menuTree = localStorage.getItem('menuTree') const marketList = localStorage.getItem('marketList') + const flag = localStorage.getItem('flag') if (adminData) { this.adminData = JSON.parse(adminData) @@ -41,6 +49,10 @@ export const useAdminStore = defineStore('admin', { if (marketList) { this.marketList = JSON.parse(marketList) } + + if (flag) { + this.flag = JSON.parse(flag) + } }, // 清空状态并移除localStorage数据 @@ -48,9 +60,11 @@ export const useAdminStore = defineStore('admin', { this.adminData = null this.menuTree = [] this.marketList = {} + this.flag = 0 localStorage.removeItem('adminData') localStorage.removeItem('menuTree') localStorage.removeItem('marketList') + localStorage.removeItem('flag') // localStorage.removeItem('token') } } diff --git a/src/utils/menuUtils.js b/src/utils/menuUtils.js index b148ad5..10a20c0 100644 --- a/src/utils/menuUtils.js +++ b/src/utils/menuUtils.js @@ -62,7 +62,6 @@ export const getRoutePath = (menu) => { '退款管理': '/coinRefund', - // '金豆退款': '/beanRefund', '历史数据查询': '/history', '新版金币查询': '/history/newHistory', @@ -77,9 +76,6 @@ export const getRoutePath = (menu) => { '金币客户账户明细': '/usergold', '金豆客户账户明细': '/userbean', - // '用户管理': '/permissions/userPermission', - // '角色管理': '/permissions/rolePermission', - '收款明细': '/moneyManage/receiveDetail', '收款-地区客服':'/moneyManage/receiveDetail/receiveService', '收款-地区财务':'/moneyManage/receiveDetail/receiveArea', diff --git a/src/views/consume/bean/beanConsume.vue b/src/views/consume/bean/beanConsume.vue index ea2c360..df8141d 100644 --- a/src/views/consume/bean/beanConsume.vue +++ b/src/views/consume/bean/beanConsume.vue @@ -3,8 +3,8 @@ @@ -72,26 +72,26 @@ const navigateTo = (name) => { const initPermissions = () => { if (!menuTree.value || !menuTree.value.length) return; - hasAdd.value = hasMenuPermission(menuTree.value, permissionMapping.addBeanConsume); - hasLive.value = hasMenuPermission(menuTree.value, permissionMapping.beanZBDetail); - hasFan.value = hasMenuPermission(menuTree.value, permissionMapping.beanTFDetail); - hasArticleVideo.value = hasMenuPermission(menuTree.value, permissionMapping.beanSPWZDetail); + hasAdd.value = hasMenuPermission(menuTree.value, permissionMapping.add_gold_bean_consumption); + hasLive.value = hasMenuPermission(menuTree.value, permissionMapping.gold_bean_live_details); + hasFan.value = hasMenuPermission(menuTree.value, permissionMapping.gold_bean_fan_details); + hasArticleVideo.value = hasMenuPermission(menuTree.value, permissionMapping.gold_bean_video_details); }; // 默认跳转逻辑 const getDefaultAuditRoute = () => { initPermissions(); - if (hasAdd.value) return 'addBeanConsume'; + if (hasAdd.value) return 'add_gold_bean_consumption'; if (hasLive.value) return 'liveStream'; if (hasFan.value) return 'dieHardFan'; if (hasArticleVideo.value) return 'articleVideo'; - return 'addBeanConsume'; + return 'add_gold_bean_consumption'; }; // 监听路由变化更新标签状态 watch(() => route.name, (newName) => { initPermissions() - if (newName=== 'addBeanConsume' || newName === 'liveStream' || newName === 'dieHardFan' || newName === 'articleVideo') { + if (newName=== 'add_gold_bean_consumption' || newName === 'liveStream' || newName === 'dieHardFan' || newName === 'articleVideo') { activeTab.value = newName; } else if (newName === 'beanConsume') { // 每次访问 /beanConsume 都进行默认跳转 @@ -108,7 +108,7 @@ onMounted(() => { navigateTo(defaultRoute); } else { // 非父路由初始化当前标签状态 - if (route.name=== 'addBeanConsume' || route.name === 'liveStream' || route.name === 'dieHardFan' || route.name === 'articleVideo') { + if (route.name=== 'add_gold_bean_consumption' || route.name === 'liveStream' || route.name === 'dieHardFan' || route.name === 'articleVideo') { activeTab.value = route.name; } } diff --git a/src/views/consume/gold/addCoinConsume.vue b/src/views/consume/gold/addCoinConsume.vue index 4ff8467..e299370 100644 --- a/src/views/consume/gold/addCoinConsume.vue +++ b/src/views/consume/gold/addCoinConsume.vue @@ -8,6 +8,7 @@ import { useAdminStore } from "@/store/index.js"; import { storeToRefs } from "pinia"; import { WarnTriangleFilled } from "@element-plus/icons-vue"; import dayjs from "dayjs"; +import {hasMenuPermission, permissionMapping} from "@/utils/menuTreePermission.js"; const adminStore = useAdminStore(); const { adminData, menuTree } = storeToRefs(adminStore); @@ -213,8 +214,20 @@ const WriteCookiesTime = ref(null) const ReadCookies = ref(null) // 用来读的 cookie 的 value const ReadCookiesTime = ref(null) + +const addCoinConsumePermission = ref(false) // 新增金币消耗的权限状态 +// 初始化权限状态 +const initPermissions = async() => { + if (!menuTree.value || !menuTree.value.length) return; + addCoinConsumePermission.value = hasMenuPermission(menuTree.value, permissionMapping.add_gold_coin_consumption); + +}; // 这是添加消费信息的接口 const add = async function () { + if (!addCoinConsumePermission) { + ElMessage.error('暂无权限') + return + } try { // 验证输入数据 再验证一次 if (!validateInput()) { diff --git a/src/views/consume/gold/coinConsume.vue b/src/views/consume/gold/coinConsume.vue index dbbaa24..7187be0 100644 --- a/src/views/consume/gold/coinConsume.vue +++ b/src/views/consume/gold/coinConsume.vue @@ -52,8 +52,8 @@ const navigateTo = (name) => { // 初始化权限状态 const initPermissions = () => { if (!menuTree.value || !menuTree.value.length) return; - hasAdd.value = hasMenuPermission(menuTree.value, permissionMapping.addCoinConsume); - hasDetail.value = hasMenuPermission(menuTree.value, permissionMapping.coinConsumeDetail); + hasAdd.value = hasMenuPermission(menuTree.value, permissionMapping.add_gold_coin_consumption); + hasDetail.value = hasMenuPermission(menuTree.value, permissionMapping.gold_coin_consumption_details); }; // 默认跳转逻辑 diff --git a/src/views/consume/gold/coinConsumeDetail.vue b/src/views/consume/gold/coinConsumeDetail.vue index d8f01c5..46c33d5 100644 --- a/src/views/consume/gold/coinConsumeDetail.vue +++ b/src/views/consume/gold/coinConsumeDetail.vue @@ -5,6 +5,7 @@ import request from '@/util/http.js' import API from '@/util/http.js' import moment from 'moment' import { reverseMarketMapping } from "@/utils/marketMap.js"; +import {hasMenuPermission, permissionMapping} from "@/utils/menuTreePermission.js"; // 之后整理一下 /* @@ -141,6 +142,15 @@ const totalGoldSearch = ref({ goodsName: "" }) +const selectPermission = ref(false) +// 初始化权限状态 +const initPermissions = async() => { + if (!menuTree.value || !menuTree.value.length) return; + selectPermission.value = hasMenuPermission(menuTree.value, permissionMapping.gold_coin_consumption_details); + + +}; + /* ====================方法================================= */ @@ -161,6 +171,12 @@ const getAdminData = async function () { const ConsumeSelectBy = async function (val) { + + if (!hasrechargeWaitShow) { + ElMessage.error('暂无权限') + return + } + try { // 搜索参数页码赋值 diff --git a/src/views/history/history.vue b/src/views/history/history.vue index 291f562..6e5524f 100644 --- a/src/views/history/history.vue +++ b/src/views/history/history.vue @@ -28,8 +28,8 @@ const initPermissions = () => { if (!menuTree.value || !menuTree.value.length) return - hasNew.value = hasMenuPermission(menuTree.value, permissionMapping.newCoinSelect) - hasOld.value = hasMenuPermission(menuTree.value, permissionMapping.oldCoinSelect) + hasNew.value = hasMenuPermission(menuTree.value, permissionMapping.new_version_gold_query) + hasOld.value = hasMenuPermission(menuTree.value, permissionMapping.old_version_gold_query) } // 默认跳转逻辑 diff --git a/src/views/history/newHistory.vue b/src/views/history/newHistory.vue index a592369..a0626fa 100644 --- a/src/views/history/newHistory.vue +++ b/src/views/history/newHistory.vue @@ -51,11 +51,12 @@ import dayjs from 'dayjs' const adminStore = useAdminStore() const { adminData, menuTree } = storeToRefs(adminStore) import { permissionMapping, findMenuById } from "@/utils/menuTreePermission.js" + const defaultTime = [ new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59), ] - +const canLook = ref(findMenuById(menuTree.value, permissionMapping.new_version_gold_query)) const tableData = ref([]) const dateRange = ref([]) const searchObj = ref({ @@ -69,6 +70,10 @@ const pagination = ref({ }) //获取新表数据 const get = async function () { + if(!canLook.value){ + ElMessage.error('无此权限') + return + } try { if (searchObj.value.name || searchObj.value.jwcode) { const startTime = dateRange.value && dateRange.value[0] ? moment(dateRange.value[0]).format('YYYY-MM-DD HH:mm:ss') : "" diff --git a/src/views/history/oldHistory.vue b/src/views/history/oldHistory.vue index a0e0114..ed34232 100644 --- a/src/views/history/oldHistory.vue +++ b/src/views/history/oldHistory.vue @@ -52,7 +52,7 @@ const defaultTime = [ new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59), ] - +const canLook = ref(findMenuById(menuTree.value, permissionMapping.old_version_gold_query)) const tableData = ref([]) const dateRange = ref([]) const searchObj = ref({ @@ -67,6 +67,10 @@ const pagination = ref({ //获取旧表数据 const getOld = async function () { + if(!canLook.value){ + ElMessage.error('无此权限') + return + } try { if (searchObj.value.name || searchObj.value.jwcode) { const startTime = dateRange.value && dateRange.value[0] ? moment(dateRange.value[0]).format('YYYY-MM-DD HH:mm:ss') : "" diff --git a/src/views/home.vue b/src/views/home.vue index b692dfe..5910196 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -79,7 +79,7 @@ const menuList = ref([]) // 获取仓库实例 const adminStore = useAdminStore() // 解构状态(保持响应式) 获得 adminData(用户信息) 和 menuTree(菜单树) -const { adminData, menuTree } = storeToRefs(adminStore) +const { adminData, menuTree, flag } = storeToRefs(adminStore) // 筛选权限菜单 ,menuTree 是组件通信拿的 menuList.value = filterMenu(menuTree.value) @@ -156,6 +156,13 @@ function logout() { ElMessage.success('退出成功') } +// 切换员工数据开关状态 +const toggleFlag = () => { + const newFlag = flag.value === 1 ? 0 : 1 + adminStore.setFlag(newFlag) + ElMessage.success(newFlag === 1 ? '员工数据已隐藏' : '员工数据已显示') + console.log('flag',newFlag) +} @@ -243,6 +250,10 @@ function logout() {