zhangwencui
4 天以前 61a2db936dcbc3d5aebe8ff850bcaab76e3b3785
合并恢复
已修改7个文件
247 ■■■■ 文件已修改
src/config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/directive/permission/hasPermi.ts 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/directive/permission/hasRole.ts 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/manifest.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/works.vue 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/permission.ts 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/config.js
@@ -1,7 +1,7 @@
// 应用全局配置
const config = {
  baseUrl: "https://122701huey826.vicp.fun",
  fileUrl: "http://122701huey826.vicp.fun",
  baseUrl: "http://1.15.17.182:9048",
  fileUrl: "http://1.15.17.182:9049",
  // 应用信息
  appInfo: {
    // 应用名称
src/directive/permission/hasPermi.ts
@@ -1,7 +1,30 @@
/**
* v-hasPermi 操作权限处理
* Copyright (c) 2019 ruoyi
*/
import useUserStore from '@/store/modules/user'
import type { Directive } from "vue";
const vHasPermi: Directive = {
  mounted() {}
};
  mounted(el, binding, vnode) {
    const { value } = binding
    const all_permission = "*:*:*";
    const permissions = useUserStore().permissions
export default vHasPermi;
    if (value && value instanceof Array && value.length > 0) {
      const permissionFlag = value
      const hasPermissions = permissions.some(permission => {
        return all_permission === permission || permissionFlag.includes(permission)
      })
      if (!hasPermissions) {
        el.parentNode && el.parentNode.removeChild(el)
      }
    } else {
      throw new Error(`请设置操作权限标签值`)
    }
  }
}
export default vHasPermi
src/directive/permission/hasRole.ts
@@ -1,7 +1,30 @@
import type { Directive } from "vue";
/**
* v-hasRole 角色权限处理
* Copyright (c) 2019 ruoyi
*/
import useUserStore from '@/store/modules/user'
import type { Directive } from "vue";
const vHasRole: Directive = {
  mounted() {}
};
  mounted(el, binding, vnode) {
    const { value } = binding
    const super_admin = "admin";
    const roles = useUserStore().roles
    if (value && value instanceof Array && value.length > 0) {
      const roleFlag = value
      const hasRole = roles.some(role => {
        return super_admin === role || roleFlag.includes(role)
      })
      if (!hasRole) {
        el.parentNode && el.parentNode.removeChild(el)
      }
    } else {
      throw new Error(`请设置角色权限标签值`)
    }
  }
}
export default vHasRole;
src/manifest.json
@@ -1,6 +1,6 @@
{
    "name" : "中兴实强",
    "appid" : "__UNI__1F2DCE1",
    "name" : "信息管理Pro-OA",
    "appid" : "__UNI__751174B",
    "description" : "",
    "versionName" : "1.1.5",
    "versionCode" : 100,
src/pages/index.vue
@@ -230,21 +230,21 @@
    icon: "/static/images/icon/shengchanbaogong.svg",
    action: "scan",
  },
  // {
  //   label: "设备巡检",
  //   icon: "/static/images/icon/xunjianshangchuan.svg",
  //   route: "/pages/inspectionUpload/index",
  // },
  // {
  //   label: "设备保养",
  //   icon: "/static/images/icon/shebeibaoyang.svg",
  //   route: "/pages/equipmentManagement/upkeep/index",
  // },
  // {
  //   label: "设备报修",
  //   icon: "/static/images/icon/shebeibaoxiu.svg",
  //   route: "/pages/equipmentManagement/repair/index",
  // },
  {
    label: "设备巡检",
    icon: "/static/images/icon/xunjianshangchuan.svg",
    route: "/pages/inspectionUpload/index",
  },
  {
    label: "设备保养",
    icon: "/static/images/icon/shebeibaoyang.svg",
    route: "/pages/equipmentManagement/upkeep/index",
  },
  {
    label: "设备报修",
    icon: "/static/images/icon/shebeibaoxiu.svg",
    route: "/pages/equipmentManagement/repair/index",
  },
];
const quickTools = ref([...quickToolSource]);
const allowedMenuTitles = ref(new Set());
src/pages/works.vue
@@ -1,5 +1,28 @@
<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">
@@ -208,27 +231,28 @@
      </view>
    </view>
    <!-- 售后服务模块 -->
<!--    <view class="common-module after-sales-module"-->
<!--          v-if="hasAfterSalesServiceItems">-->
<!--      <view class="module-header">-->
<!--        <view class="module-title-container">-->
<!--          <text class="module-title">售后服务</text>-->
<!--        </view>-->
<!--      </view>-->
<!--      <view class="module-content">-->
<!--        <up-grid :border="false"-->
<!--                 col="4">-->
<!--          <up-grid-item v-for="(item, index) in afterSalesServiceItems"-->
<!--                        :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 after-sales-module"
          v-if="hasAfterSalesServiceItems">
      <view class="module-header">
        <view class="module-title-container">
          <text class="module-title">售后服务</text>
        </view>
      </view>
      <view class="module-content">
        <up-grid :border="false"
                 col="4">
          <up-grid-item v-for="(item, index) in afterSalesServiceItems"
                        :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="hasQualityItems">
@@ -276,28 +300,28 @@
      </view>
    </view>
    <!-- 安全生产模块 -->
<!--    <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="module-content">-->
<!--        <up-grid :border="false"-->
<!--                 col="4">-->
<!--          <up-grid-item v-for="(item, index) in safetyItems"-->
<!--                        :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="hasSafetyItems">
      <view class="module-header">
        <view class="module-title-container">
          <text class="module-title">安全生产</text>
        </view>
      </view>
      <view class="module-content">
        <up-grid :border="false"
                 col="4">
          <up-grid-item v-for="(item, index) in safetyItems"
                        :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>
    <DownloadProgressMask />
  </view>
</template>
@@ -535,6 +559,11 @@
      label: "安全培训考核",
    },
  ]);
  // OA办公功能数据(纯前端配置,不参与后端权限过滤)
  const oaItems = reactive(
    OA_WORKBENCH_ITEMS.map(item => ({ ...item }))
  );
  // 协同办公功能数据
  const collaborationItems = reactive([
    {
src/utils/permission.ts
@@ -1,10 +1,28 @@
import useUserStore from '@/store/modules/user'
/**
 * 字符权限校验
 * @param {Array} value 校验值
 * @returns {Boolean}
 */
export function checkPermi(value:Array<string>) {
  if (value && value instanceof Array && value.length > 0) {
    const permissions:Array<string> = useUserStore().permissions
    const permissionDatas = value
    const all_permission = "*:*:*"
    const hasPermission = permissions.some(permission => {
      return all_permission === permission || permissionDatas.includes(permission)
    })
    if (!hasPermission) {
      return false
    }
  return true
  } else {
    console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
    return false
  }
}
/**
@@ -13,5 +31,21 @@
 * @returns {Boolean}
 */
export function checkRole(value:Array<string>) {
  if (value && value instanceof Array && value.length > 0) {
    const roles:Array<string> = useUserStore().roles
    const permissionRoles = value
    const super_admin = "admin"
    const hasRole = roles.some(role => {
      return super_admin === role || permissionRoles.includes(role)
    })
    if (!hasRole) {
      return false
    }
  return true
  } else {
    console.error(`need roles! Like checkRole="['admin','editor']"`)
    return false
  }
}