gaoluyang
2026-08-28 3f85e5410dda49e7e6a6292859649513f3644cb2
src/pages/works.vue
@@ -1,28 +1,5 @@
<template>
  <view class="content">
    <!-- OA办公模块 -->
    <view class="common-module oa-module"
          v-if="hasOaItems">
      <view class="module-header">
        <view class="module-title-container">
          <text class="module-title">OA办公</text>
        </view>
      </view>
      <view class="module-content">
        <up-grid :border="false"
                 col="4">
          <up-grid-item v-for="(item, index) in oaItems"
                        :key="index"
                        @click="handleCommonItemClick(item)">
            <view class="icon-container">
              <image :src="item.icon"
                     class="item-icon"></image>
            </view>
            <text class="item-label">{{item.label}}</text>
          </up-grid-item>
        </up-grid>
      </view>
    </view>
    <!-- 协同办公模块 -->
    <view class="common-module collaboration-module"
          v-if="hasCollaborationItems">
@@ -331,7 +308,6 @@
  import { userLoginFacotryList } from "@/api/login";
  import { getProductWorkOrderById } from "@/api/productionManagement/productionReporting";
  import DownloadProgressMask from "@/components/DownloadProgressMask.vue";
  import { OA_WORKBENCH_ITEMS } from "@/config/oaWorkbench.js";
  import modal from "@/plugins/modal";
  import useUserStore from "@/store/modules/user";
@@ -510,6 +486,21 @@
      icon: "/static/images/icon/hetongguanli.svg",
      label: "合同管理",
    },
    {
      icon: "/static/images/icon/hetongguanli.svg",
      label: "转正申请",
      path: "/pages/oa/HrManage/regular-apply/index",
    },
    {
      icon: "/static/images/icon/renyuanxinzi.svg",
      label: "调动申请",
      path: "/pages/oa/HrManage/transfer-apply/index",
    },
    {
      icon: "/static/images/icon/gongchuguanli.svg",
      label: "工作交接",
      path: "/pages/oa/HrManage/work-handover/index",
    },
  ]);
  const qualityItems = reactive([
    {
@@ -559,17 +550,22 @@
      label: "安全培训考核",
    },
  ]);
  // OA办公功能数据(纯前端配置,不参与后端权限过滤)
  const oaItems = reactive(
    OA_WORKBENCH_ITEMS.map(item => ({ ...item }))
  );
  // 协同办公功能数据
  const collaborationItems = reactive([
    {
      icon: "/static/images/icon/xietongshenpi.svg",
      label: "协同审批",
    },
    // {
    //   icon: "/static/images/icon/xietongshenpi.svg",
    //   label: "协同审批",
    // },
      {
         icon: "/static/images/icon/guizhangzhidu.svg",
         label: "审批管理",
         path: "/pages/oa/ApproveManage/approve-template/index",
      },
      {
         icon: "/static/images/icon/xietongshenpi.svg",
         label: "协同审批",
         path: "/pages/oa/ApproveManage/approve-list/index",
      },
    {
      icon: "/static/images/icon/huiyiguanli.svg",
      label: "会议管理",
@@ -593,6 +589,26 @@
    {
      icon: "/static/images/icon/kehubaifang.svg",
      label: "客户拜访",
    },
    {
      icon: "/static/images/icon/qingjiaguanli.svg",
      label: "请假申请",
      path: "/pages/oa/AttendManage/leave-apply/index",
    },
    {
      icon: "/static/images/icon/dakaqiandao.svg",
      label: "加班申请",
      path: "/pages/oa/AttendManage/overtime-apply/index",
    },
    {
      icon: "/static/images/icon/chuchaiguanli.svg",
      label: "差旅报销",
      path: "/pages/oa/ReimburseManage/travel-reimburse/index",
    },
    {
      icon: "/static/images/icon/baoxiaoguanli.svg",
      label: "费用报销",
      path: "/pages/oa/ReimburseManage/cost-reimburse/index",
    },
  ]);
@@ -640,6 +656,10 @@
    //    label: '设备台账',
    // },
    {
      icon: "/static/images/icon/saomashebei.svg",
      label: "扫码查设备",
    },
    {
      icon: "/static/images/icon/yunxingguanli.svg",
      label: "运行管理",
    },
@@ -656,6 +676,42 @@
      label: "设备巡检",
    },
  ]);
  // 扫码查设备:解析 deviceId 后跳转到设备信息页
  const getDeviceIdFromScan = scanResult => {
    if (!scanResult) return null;
    const match = scanResult.match(/deviceId=(\d+)/);
    if (match && match[1]) return match[1];
    if (/^\d+$/.test(scanResult.trim())) return scanResult.trim();
    try {
      const obj = JSON.parse(scanResult);
      if (obj.deviceId) return String(obj.deviceId);
    } catch (e) {
      // 忽略非 JSON 内容
    }
    return null;
  };
  const startScanDevice = () => {
    uni.scanCode({
      scanType: ["qrCode", "barCode"],
      success: res => {
        console.log("扫码结果:", res.result);
        const deviceId = getDeviceIdFromScan(res.result);
        if (!deviceId) {
          uni.showToast({ title: "未识别到设备ID", icon: "none" });
          return;
        }
        uni.navigateTo({
          url: `/pages/equipmentManagement/deviceInfo/index?deviceId=${deviceId}`,
        });
      },
      fail: err => {
        console.error("扫码失败:", err);
        uni.showToast({ title: "扫码失败,请重试", icon: "none" });
      },
    });
  };
  // 处理常用功能点击
  const handleCommonItemClick = item => {
@@ -922,6 +978,9 @@
        uni.navigateTo({
          url: "/pages/equipmentManagement/ledger/index",
        });
        break;
      case "扫码查设备":
        startScanDevice();
        break;
      case "运行管理":
        uni.navigateTo({
@@ -1242,7 +1301,7 @@
    // 收集所有有权限的菜单标题(根据 meta.title)
    const allowedMenuTitles = new Set();
    const alwaysShowTitles = new Set(["采购退货单", "供应商管理"]);
    const alwaysShowTitles = new Set(["采购退货单", "供应商管理", "扫码查设备"]);
    const collectMenuTitles = routes => {
      if (!Array.isArray(routes)) return;
      routes.forEach(route => {
@@ -1268,6 +1327,7 @@
    // 通用过滤函数
    const filterArray = (targetArray, specialMapping) => {
      const filtered = targetArray.filter(item => {
        if (alwaysShowTitles.has(item.label)) return true;
        let matched = allowedMenuTitles.has(item.label);
        if (specialMapping && !matched && specialMapping[item.label]) {
          matched = allowedMenuTitles.has(specialMapping[item.label]);
@@ -1303,7 +1363,6 @@
  const hasAfterSalesServiceItems = computed(
    () => afterSalesServiceItems.length > 0
  );
  const hasOaItems = computed(() => oaItems.length > 0);
  const hasCollaborationItems = computed(() => collaborationItems.length > 0);
  const hasSafetyItems = computed(() => safetyItems.length > 0);
  const hasQualityItems = computed(() => qualityItems.length > 0);