Преглед на файлове

修复查看权限在编辑情况下不生效的问题

xujunjie преди 1 година
родител
ревизия
933c1ab99c
променени са 1 файла, в които са добавени 121 реда и са изтрити 120 реда
  1. 121 120
      src/core.js

+ 121 - 120
src/core.js

@@ -180,8 +180,8 @@ luckysheet.create = function(setting) {
   } else {
     $.post(loadurl, { gridKey: server.gridKey }, function(d) {
       let data = new Function("return " + d)();
-      console.log('====================================================')
-      console.log(data)
+      console.log("====================================================");
+      console.log(data);
       data.forEach((sheet) => {
         initSheet(sheet, authority, setting.permissions);
       });
@@ -308,134 +308,135 @@ function initSheet(sheet, authority, permissions) {
     delete sheet.config.authority;
   }
   sheet.config = sheet.config || {};
-  // 处于审批时  所有人都无法修改
-  if (authority) {
-    sheet.config.authority = authority;
-  } else {
-    let canEditRangeList = [];
-
-    if (sheet.name == "PSR") {
-      canEditRangeList = [
-        {
-          hintText: "",
-          sqref: "$C$1:$C$999",
-        },
-        // {
-        //   hintText: "",
-        //   sqref: "$C$47:$C$52",
-        // },
-        // {
-        //   hintText: "",
-        //   sqref: "$C$55:$C$55",
-        // },
-        // {
-        //   hintText: "",
-        //   sqref: "$C$57:$C$57",
-        // },
-        // {
-        //   hintText: "",
-        //   sqref: "$C$86:$C$87",
-        // },
-        {
-          hintText: "",
-          sqref: "$B$104:$B$118",
-        },
-      ];
-      // 隐藏PSR表
-      if (!permissions["func-psr-01"]) {
-        sheet.hide = 1;
-        sheet.status = 0;
-      }
-      // 隐藏项目经理预算
-      if (!permissions["func-psr-02"]) {
-        for (let i = 77; i <= 88; i++) {
-          rowhidden[i] = 0;
-        }
-      }
-      // 最下方预算
-      if (!permissions["func-psr-03"]) {
-        for (let i = 101; i <= 117; i++) {
-          rowhidden[i] = 0;
-        }
-      }
-      // 更新时间权限
-      if (permissions["func-psr-04"]) {
-        canEditRangeList.push({
-          hintText: "",
-          sqref: "$B$2:$B$2",
-        });
-      }
-      // 预算列权限
-      if (permissions["func-psr-05"]) {
-        canEditRangeList.push({
-          hintText: "",
-          sqref: "$G$6:$G$89",
-        });
-      }
-    } else if (sheet.name == "现金流") {
-      if (!permissions["func-actual-01"]) {
-        sheet.hide = 1;
-        sheet.status = 0;
-      }
-      // 预计回款权限
-      if (permissions["func-actual-02"]) {
-        canEditRangeList.push({
-          hintText: "",
-          sqref: "$A$3:$CF$3",
-        });
-      }
-      // 实际回款权限
-      if (permissions["func-actual-03"]) {
-        canEditRangeList.push({
-          hintText: "",
-          sqref: "$A$4:$CF$4",
-        });
-      }
-      // 日期列已发生:成本会计;
-      if (permissions["func-actual-04"]) {
-        //获取当前表单日期 44675
-        const days = sheet.celldata.find((item) => item.r == 1 && item.c == 3)
-          ?.v.v;
-        //获取跟当前日期匹配的 col
-        const colNum = getColSign(sheet.celldata, days);
-        //转化成 ABC
-        const colSign = numberToExcelColumn(colNum);
-        canEditRangeList.push({
-          hintText: "",
-          sqref: `$M$7:$${colSign}$248`,
-        });
+ 
+  let canEditRangeList = [];
+
+  if (sheet.name == "PSR") {
+    canEditRangeList = [
+      {
+        hintText: "",
+        sqref: "$C$1:$C$999",
+      },
+      // {
+      //   hintText: "",
+      //   sqref: "$C$47:$C$52",
+      // },
+      // {
+      //   hintText: "",
+      //   sqref: "$C$55:$C$55",
+      // },
+      // {
+      //   hintText: "",
+      //   sqref: "$C$57:$C$57",
+      // },
+      // {
+      //   hintText: "",
+      //   sqref: "$C$86:$C$87",
+      // },
+      {
+        hintText: "",
+        sqref: "$B$104:$B$118",
+      },
+    ];
+    // 隐藏PSR表
+    if (!permissions["func-psr-01"]) {
+      sheet.hide = 1;
+      sheet.status = 0;
+    }
+    // 隐藏项目经理预算
+    if (!permissions["func-psr-02"]) {
+      for (let i = 77; i <= 88; i++) {
+        rowhidden[i] = 0;
       }
-      // 日期列未发生:采购经理;
-      if (permissions["func-actual-05"]) {
-        //获取当前表单日期 44675
-        const days = sheet.celldata.find((item) => item.r == 1 && item.c == 3)
-          ?.v.v;
-        //获取跟当前日期匹配的 col 的后一列
-        const colNum = getColSign(sheet.celldata, days) + 1;
-        //转化成 ABC  不包括当前列
-        const colSign = numberToExcelColumn(colNum);
-        canEditRangeList.push({
-          hintText: "",
-          sqref: `$${colSign}$7:$CF$248`,
-        });
+    }
+    // 最下方预算
+    if (!permissions["func-psr-03"]) {
+      for (let i = 101; i <= 117; i++) {
+        rowhidden[i] = 0;
       }
-    } else if (sheet.name == "清单") {
+    }
+    // 更新时间权限
+    if (permissions["func-psr-04"]) {
       canEditRangeList.push({
         hintText: "",
-        sqref: "$A$1:$Q$999",
+        sqref: "$B$2:$B$2",
       });
-      // 清单预算列显示
-      if (!permissions["func-list-01"]) {
-        colhidden[8] = 0;
-        colhidden[9] = 0;
-      }
-    } else {
+    }
+    // 预算列权限
+    if (permissions["func-psr-05"]) {
       canEditRangeList.push({
         hintText: "",
-        sqref: "$A$1:$Q$999",
+        sqref: "$G$6:$G$89",
       });
     }
+  } else if (sheet.name == "现金流") {
+    if (!permissions["func-actual-01"]) {
+      sheet.hide = 1;
+      sheet.status = 0;
+    }
+    // 预计回款权限
+    if (permissions["func-actual-02"]) {
+      canEditRangeList.push({
+        hintText: "",
+        sqref: "$A$3:$CF$3",
+      });
+    }
+    // 实际回款权限
+    if (permissions["func-actual-03"]) {
+      canEditRangeList.push({
+        hintText: "",
+        sqref: "$A$4:$CF$4",
+      });
+    }
+    // 日期列已发生:成本会计;
+    if (permissions["func-actual-04"]) {
+      //获取当前表单日期 44675
+      const days = sheet.celldata.find((item) => item.r == 1 && item.c == 3)?.v
+        .v;
+      //获取跟当前日期匹配的 col
+      const colNum = getColSign(sheet.celldata, days);
+      //转化成 ABC
+      const colSign = numberToExcelColumn(colNum);
+      canEditRangeList.push({
+        hintText: "",
+        sqref: `$M$7:$${colSign}$248`,
+      });
+    }
+    // 日期列未发生:采购经理;
+    if (permissions["func-actual-05"]) {
+      //获取当前表单日期 44675
+      const days = sheet.celldata.find((item) => item.r == 1 && item.c == 3)?.v
+        .v;
+      //获取跟当前日期匹配的 col 的后一列
+      const colNum = getColSign(sheet.celldata, days) + 1;
+      //转化成 ABC  不包括当前列
+      const colSign = numberToExcelColumn(colNum);
+      canEditRangeList.push({
+        hintText: "",
+        sqref: `$${colSign}$7:$CF$248`,
+      });
+    }
+  } else if (sheet.name == "清单") {
+    canEditRangeList.push({
+      hintText: "",
+      sqref: "$A$1:$Q$999",
+    });
+    // 清单预算列显示
+    if (!permissions["func-list-01"]) {
+      colhidden[8] = 0;
+      colhidden[9] = 0;
+    }
+  } else {
+    canEditRangeList.push({
+      hintText: "",
+      sqref: "$A$1:$Q$999",
+    });
+  }
 
+  // 处于审批时  所有人都无法修改
+  if (authority) {
+    sheet.config.authority = authority;
+  } else {
     // 设置保护区域,lucksheet不能直接设置不允许编辑的区域
     // 只能禁止整体编辑,设置例外区域
     sheet.config.authority = {