| | |
| | | <!-- </view>--> |
| | | <!-- </view>--> |
| | | <!-- 营销管理模块 --> |
| | | <view class="common-module marketing-module" v-if="hasMarketingItems"> |
| | | <view class="common-module marketing-module" |
| | | v-if="hasMarketingItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">营销管理</text> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- <!– 采购管理模块 –>--> |
| | | <view class="common-module purchase-module" v-if="hasPurchaseItems"> |
| | | <view class="common-module purchase-module" |
| | | v-if="hasPurchaseItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">采购管理</text> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- <!– 协同办公模块 –> --> |
| | | <view class="common-module collaboration-module" v-if="hasCollaborationItems"> |
| | | <view class="common-module collaboration-module" |
| | | v-if="hasCollaborationItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">协同办公</text> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- 安全生产模块 --> |
| | | <view class="common-module collaboration-module" v-if="hasSafetyItems"> |
| | | <view class="common-module collaboration-module" |
| | | v-if="hasSafetyItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">安全生产</text> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- 人力资源模块 --> |
| | | <view class="common-module collaboration-module" v-if="hasHumanResourcesItems"> |
| | | <view class="common-module collaboration-module" |
| | | v-if="hasHumanResourcesItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">人力资源</text> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- 生产管控模块 --> |
| | | <view class="common-module equipment-module" v-if="hasProductionItems"> |
| | | <view class="common-module equipment-module" |
| | | v-if="hasProductionItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">生产管控</text> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- 设备管理模块 --> |
| | | <view class="common-module equipment-module" v-if="hasEquipmentItems"> |
| | | <view class="common-module equipment-module" |
| | | v-if="hasEquipmentItems"> |
| | | <view class="module-header"> |
| | | <view class="module-title-container"> |
| | | <text class="module-title">设备管理</text> |
| | |
| | | const safetyItems = reactive([ |
| | | { |
| | | icon: "/static/images/icon/caigoutaizhang@2x.png", |
| | | label: "规程资质", |
| | | label: "规程与资质", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/caigoutaizhang@2x.png", |
| | |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/caigoutaizhang@2x.png", |
| | | label: "危险作业", |
| | | label: "危险作业审批", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/guzhangfenxi@2x.png", |
| | | label: "隐患排查", |
| | | label: "隐患排查上报", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/guzhangfenxi@2x.png", |
| | | label: "危险物料", |
| | | label: "危险物料管控", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/guzhangfenxi@2x.png", |
| | | label: "应急预案", |
| | | label: "应急预案查阅", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/guzhangfenxi@2x.png", |
| | | label: "事故上报", |
| | | label: "事故上报记录", |
| | | }, |
| | | { |
| | | icon: "/static/images/icon/guzhangfenxi@2x.png", |
| | | label: "安全培训", |
| | | label: "安全培训考核", |
| | | }, |
| | | ]); |
| | | // 协同办公功能数据 |
| | |
| | | url: "/pages/equipmentManagement/verification/index", |
| | | }); |
| | | break; |
| | | case "规程资质": |
| | | case "规程与资质": |
| | | uni.navigateTo({ |
| | | url: "/pages/safeProduction/safeQualifications/index", |
| | | }); |
| | |
| | | url: "/pages/safeProduction/hazardSourceLedger/index", |
| | | }); |
| | | break; |
| | | case "危险作业": |
| | | case "危险作业审批": |
| | | uni.navigateTo({ |
| | | url: "/pages/cooperativeOffice/collaborativeApproval/index8", |
| | | }); |
| | | break; |
| | | case "隐患排查": |
| | | case "隐患排查上报": |
| | | uni.navigateTo({ |
| | | url: "/pages/safeProduction/dangerInvestigation/index", |
| | | }); |
| | | break; |
| | | case "危险物料": |
| | | case "危险物料管控": |
| | | uni.navigateTo({ |
| | | url: "/pages/safeProduction/hazardousMaterialsControl/index", |
| | | }); |
| | | break; |
| | | case "应急预案": |
| | | case "应急预案查阅": |
| | | uni.navigateTo({ |
| | | url: "/pages/safeProduction/emergencyPlanReview/index", |
| | | }); |
| | | break; |
| | | case "事故上报": |
| | | case "事故上报记录": |
| | | uni.navigateTo({ |
| | | url: "/pages/safeProduction/accidentReportingRecord/index", |
| | | }); |
| | | break; |
| | | case "安全培训": |
| | | case "安全培训考核": |
| | | uni.navigateTo({ |
| | | url: "/pages/safeProduction/safetyTrainingAssessment/index", |
| | | }); |
| | | break; |
| | | case "打卡签到": |
| | | uni.navigateTo({ |
| | | url: "/pages/attendance/checkin", |
| | | url: "/pages/humanResources/attendance/checkin", |
| | | }); |
| | | break; |
| | | case "人员薪资": |
| | | uni.navigateTo({ |
| | | url: "/pages/humanResources/monthlyStatistics/index", |
| | | }); |
| | | break; |
| | | default: |
| | |
| | | }; |
| | | function loginSuccess(result) { |
| | | // 获取路由权限 |
| | | userStore.getRouters().then(() => { |
| | | console.log("路由权限获取成功"); |
| | | // 过滤菜单项 |
| | | filterMenuItemsByRoutes(); |
| | | }).catch(error => { |
| | | console.error("获取路由权限失败:", error); |
| | | }); |
| | | userStore |
| | | .getRouters() |
| | | .then(() => { |
| | | console.log("路由权限获取成功"); |
| | | // 过滤菜单项 |
| | | filterMenuItemsByRoutes(); |
| | | }) |
| | | .catch(error => { |
| | | console.error("获取路由权限失败:", error); |
| | | }); |
| | | uni.reLaunch({ |
| | | url: "/pages/index", |
| | | }); |
| | |
| | | // 根据路由权限过滤菜单项 |
| | | const filterMenuItemsByRoutes = () => { |
| | | const routers = userStore.routers || []; |
| | | |
| | | |
| | | // 如果没有路由权限数据,不进行过滤(显示所有菜单) |
| | | if (!routers || routers.length === 0) { |
| | | console.log("暂无路由权限数据,显示所有菜单"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 收集所有有权限的菜单标题(根据 meta.title) |
| | | const allowedMenuTitles = new Set(); |
| | | const collectMenuTitles = (routes) => { |
| | | const collectMenuTitles = routes => { |
| | | if (!Array.isArray(routes)) return; |
| | | routes.forEach(route => { |
| | | // 收集当前路由的标题 |
| | |
| | | collectMenuTitles(routers); |
| | | |
| | | console.log("允许的菜单标题:", Array.from(allowedMenuTitles)); |
| | | console.log("过滤前 - 营销管理:", marketingItems.length, "采购管理:", purchaseItems.length, "协同办公:", collaborationItems.length); |
| | | console.log("过滤前 - 安全生产:", safetyItems.length, "人力资源:", humanResourcesItems.length, "生产管控:", productionItems.length, "设备管理:", equipmentItems.length); |
| | | console.log( |
| | | "过滤前 - 营销管理:", |
| | | marketingItems.length, |
| | | "采购管理:", |
| | | purchaseItems.length, |
| | | "协同办公:", |
| | | collaborationItems.length |
| | | ); |
| | | console.log( |
| | | "过滤前 - 安全生产:", |
| | | safetyItems.length, |
| | | "人力资源:", |
| | | humanResourcesItems.length, |
| | | "生产管控:", |
| | | productionItems.length, |
| | | "设备管理:", |
| | | equipmentItems.length |
| | | ); |
| | | |
| | | // 过滤营销管理菜单 |
| | | const originalMarketing = [ |
| | |
| | | } |
| | | return matched; |
| | | }); |
| | | collaborationItems.splice(0, collaborationItems.length, ...filteredCollaboration); |
| | | collaborationItems.splice( |
| | | 0, |
| | | collaborationItems.length, |
| | | ...filteredCollaboration |
| | | ); |
| | | |
| | | // 过滤采购管理菜单 |
| | | const originalPurchase = [ |
| | |
| | | { icon: "/static/images/icon/laipiaotaizhang@2x.png", label: "来票台账" }, |
| | | { icon: "/static/images/icon/fukuanjingji@2x.png", label: "付款登记" }, |
| | | { icon: "/static/images/icon/fukuanliushui@2x.png", label: "付款流水" }, |
| | | { icon: "/static/images/icon/gongyingshangwanglai@2x.png", label: "供应商往来" }, |
| | | { |
| | | icon: "/static/images/icon/gongyingshangwanglai@2x.png", |
| | | label: "供应商往来", |
| | | }, |
| | | ]; |
| | | const filteredPurchase = originalPurchase.filter(item => { |
| | | return allowedMenuTitles.has(item.label); |
| | |
| | | |
| | | // 过滤安全生产菜单 |
| | | const originalSafety = [ |
| | | { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "规程资质" }, |
| | | { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "规程与资质" }, |
| | | { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "危险源台账" }, |
| | | { icon: "/static/images/icon/caigoutaizhang@2x.png", label: "危险作业" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "隐患排查" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "危险物料" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "应急预案" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "事故上报" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "安全培训" }, |
| | | { |
| | | icon: "/static/images/icon/caigoutaizhang@2x.png", |
| | | label: "危险作业审批", |
| | | }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "隐患排查上报" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "危险物料管控" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "应急预案查阅" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "事故上报记录" }, |
| | | { icon: "/static/images/icon/guzhangfenxi@2x.png", label: "安全培训考核" }, |
| | | ]; |
| | | const filteredSafety = originalSafety.filter(item => { |
| | | return allowedMenuTitles.has(item.label); |
| | |
| | | const filteredHumanResources = originalHumanResources.filter(item => { |
| | | return allowedMenuTitles.has(item.label); |
| | | }); |
| | | humanResourcesItems.splice(0, humanResourcesItems.length, ...filteredHumanResources); |
| | | humanResourcesItems.splice( |
| | | 0, |
| | | humanResourcesItems.length, |
| | | ...filteredHumanResources |
| | | ); |
| | | |
| | | // 过滤生产管控菜单 |
| | | const originalProduction = [ |
| | | { icon: "/static/images/icon/shengchanbaogong@2x.png", label: "生产报工", bgColor: "#673AB7" }, |
| | | { |
| | | icon: "/static/images/icon/shengchanbaogong@2x.png", |
| | | label: "生产报工", |
| | | bgColor: "#673AB7", |
| | | }, |
| | | ]; |
| | | const filteredProduction = originalProduction.filter(item => { |
| | | return allowedMenuTitles.has(item.label); |
| | |
| | | }); |
| | | equipmentItems.splice(0, equipmentItems.length, ...filteredEquipment); |
| | | |
| | | console.log("过滤后 - 营销管理:", marketingItems.length, "采购管理:", purchaseItems.length, "协同办公:", collaborationItems.length); |
| | | console.log("过滤后 - 安全生产:", safetyItems.length, "人力资源:", humanResourcesItems.length, "生产管控:", productionItems.length, "设备管理:", equipmentItems.length); |
| | | console.log("生产管控菜单项:", productionItems.map(item => item.label)); |
| | | console.log( |
| | | "过滤后 - 营销管理:", |
| | | marketingItems.length, |
| | | "采购管理:", |
| | | purchaseItems.length, |
| | | "协同办公:", |
| | | collaborationItems.length |
| | | ); |
| | | console.log( |
| | | "过滤后 - 安全生产:", |
| | | safetyItems.length, |
| | | "人力资源:", |
| | | humanResourcesItems.length, |
| | | "生产管控:", |
| | | productionItems.length, |
| | | "设备管理:", |
| | | equipmentItems.length |
| | | ); |
| | | console.log( |
| | | "生产管控菜单项:", |
| | | productionItems.map(item => item.label) |
| | | ); |
| | | }; |
| | | |
| | | // 检查模块是否有菜单项需要显示 |
| | |
| | | onMounted(() => { |
| | | // 每次进入首页都强制刷新用户信息和路由权限,不做本地缓存判断 |
| | | userStore.getInfo().then(() => { |
| | | userStore.getRouters().then(() => { |
| | | filterMenuItemsByRoutes(); |
| | | }).catch(error => { |
| | | console.error("获取路由权限失败:", error); |
| | | }); |
| | | userStore |
| | | .getRouters() |
| | | .then(() => { |
| | | filterMenuItemsByRoutes(); |
| | | }) |
| | | .catch(error => { |
| | | console.error("获取路由权限失败:", error); |
| | | }); |
| | | }); |
| | | getUserLoginFacotryList(); |
| | | // 启动通知状态定时器 |