Ver Fonte

添加系统账号统计接口

lianghongjie há 1 ano atrás
pai
commit
37393f7105
2 ficheiros alterados com 12 adições e 1 exclusões
  1. 4 1
      src/modules/count/control.ts
  2. 8 0
      src/utils/validate.ts

+ 4 - 1
src/modules/count/control.ts

@@ -1,4 +1,5 @@
 import { Dict_Apis } from "@/dict/apis";
+import { hasUserRole } from "@/utils/validate";
 import { reactive } from "vue";
 
 export class MapCountCtrl {
@@ -30,7 +31,9 @@ export class MapCountCtrl {
   });
 
   init(id: string) {
-    fetch(`${Dict_Apis.promotion}/count/${id}`).then((res) => {
+    fetch(
+      `${Dict_Apis.promotion}${hasUserRole("system") ? "/sys" : ""}/count/${id}`
+    ).then((res) => {
       res.json().then((ret) => {
         if (ret.errorNo === 200) {
           this._originData.areas = ret.result.areas || [];

+ 8 - 0
src/utils/validate.ts

@@ -0,0 +1,8 @@
+export function hasUserRole(roleType: string) {
+  try {
+    let userInfo = JSON.parse(localStorage.getItem("userInfo") || `{}`);
+    return userInfo.roles.includes(roleType);
+  } catch (error) {
+    return false;
+  }
+}