|
@@ -178,31 +178,24 @@ luckysheet.create = function(setting) {
|
|
|
// luckysheetsizeauto();
|
|
|
initialWorkBook();
|
|
|
} else {
|
|
|
- $.get(authorityUrl, function(res) {
|
|
|
- let arr = res.data.filter(
|
|
|
- (item) => item.template?.template_id == templateId
|
|
|
- );
|
|
|
- console.log(arr);
|
|
|
-
|
|
|
- $.post(loadurl, { gridKey: server.gridKey }, function(d) {
|
|
|
- let data = new Function("return " + d)();
|
|
|
- data.forEach((sheet) => {
|
|
|
- initSheet(sheet, arr, authority);
|
|
|
- });
|
|
|
+ $.post(loadurl, { gridKey: server.gridKey }, function(d) {
|
|
|
+ let data = new Function("return " + d)();
|
|
|
+ data.forEach((sheet) => {
|
|
|
+ initSheet(sheet, authority, setting.permissions);
|
|
|
+ });
|
|
|
|
|
|
- console.log(data);
|
|
|
- Store.luckysheetfile = data;
|
|
|
+ console.log(data);
|
|
|
+ Store.luckysheetfile = data;
|
|
|
|
|
|
- sheetmanage.initialjfFile(menu, title);
|
|
|
- // luckysheetsizeauto();
|
|
|
- initialWorkBook();
|
|
|
+ sheetmanage.initialjfFile(menu, title);
|
|
|
+ // luckysheetsizeauto();
|
|
|
+ initialWorkBook();
|
|
|
|
|
|
- //需要更新数据给后台时,建立WebSocket连接
|
|
|
- if (server.allowUpdate) {
|
|
|
- server.getUser = setting.getUser;
|
|
|
- server.openWebSocket();
|
|
|
- }
|
|
|
- });
|
|
|
+ //需要更新数据给后台时,建立WebSocket连接
|
|
|
+ if (server.allowUpdate) {
|
|
|
+ server.getUser = setting.getUser;
|
|
|
+ server.openWebSocket();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
};
|
|
@@ -273,95 +266,126 @@ luckysheet.luckysheetextendData = luckysheetextendData;
|
|
|
|
|
|
export { luckysheet };
|
|
|
|
|
|
-function initSheet(sheet, cellAuthority, authority) {
|
|
|
- let allowRangeList = [],
|
|
|
- colhidden = {};
|
|
|
- let cache = {};
|
|
|
+// function initSheet(sheet, authority, permissions) {
|
|
|
+function initSheet(sheet, authority) {
|
|
|
+ let permissions = {
|
|
|
+ "func-psr-01": 1,
|
|
|
+ "func-psr-02": 0,
|
|
|
+ "func-psr-03": 0,
|
|
|
+ "func-psr-04": 0,
|
|
|
+ "func-psr-05": 0,
|
|
|
+ "func-psr-06": 0,
|
|
|
+ "func-actual-01": 1,
|
|
|
+ "func-actual-02": 0,
|
|
|
+ "func-actual-03": 0,
|
|
|
+ "func-actual-04": 0,
|
|
|
+ "func-actual-05": 0,
|
|
|
+ "func-list-01": 0,
|
|
|
+ };
|
|
|
+ let colhidden = {};
|
|
|
+ let rowhidden = {};
|
|
|
if (sheet.config) {
|
|
|
delete sheet.config.authority;
|
|
|
}
|
|
|
- sheet.celldata.forEach((item) => {
|
|
|
- if (!cache[item.c]) cache[item.c] = [];
|
|
|
- cache[item.c].push(item);
|
|
|
- });
|
|
|
- cellAuthority.forEach((item) => {
|
|
|
- // 将A B C D....转换为0 1 2 3...
|
|
|
- let col_idx = item.template.col_idx;
|
|
|
- let col = col_idx.charCodeAt(0) - 65;
|
|
|
- if (!item.can_read) {
|
|
|
- colhidden[col] = 0;
|
|
|
- }
|
|
|
- if (item.can_write) {
|
|
|
- // 区域保护
|
|
|
- allowRangeList.push({
|
|
|
- hintText: "",
|
|
|
- sqref: `$${col_idx}$0:$${col_idx}$99999`,
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- // let celldata = []
|
|
|
- // Object.values(cache).forEach(colItem => {
|
|
|
- // celldata = [...celldata,...colItem]
|
|
|
- // })
|
|
|
- // sheet.celldata = celldata
|
|
|
sheet.config = sheet.config || {};
|
|
|
// 处于审批时 所有人都无法修改
|
|
|
if (authority) {
|
|
|
sheet.config.authority = authority;
|
|
|
- } else if (cellAuthority.length > 0) {
|
|
|
- let newAuthority = {
|
|
|
- sheet: true,
|
|
|
- hintText: "没有编辑权限!",
|
|
|
- };
|
|
|
- if (allowRangeList.length > 0) {
|
|
|
- // 可编辑内容
|
|
|
- newAuthority.allowRangeList = allowRangeList;
|
|
|
- }
|
|
|
-
|
|
|
- sheet.config.authority = newAuthority;
|
|
|
} else {
|
|
|
- let lastCell = sheet.celldata[sheet.celldata.length - 1];
|
|
|
- if (lastCell) {
|
|
|
- let lastCol = String.fromCharCode(lastCell.c);
|
|
|
- // 第一列禁止编辑但是可以增加
|
|
|
- let canEditCell = sheet.celldata.filter((item) => {
|
|
|
- if (item.r == 0) {
|
|
|
- // 判断是否为空
|
|
|
- if ((item?.v?.v ?? "") === "" && !item?.v?.ct?.s) return true;
|
|
|
+ let canEditRangeList = [];
|
|
|
+
|
|
|
+ if (sheet.name == "PSR") {
|
|
|
+ canEditRangeList = [
|
|
|
+ {
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$C$19:$C$20",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$C$47:$C$52",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$C$56:$C$56",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$C$57:$C$57",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$C$86:$C$87",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ // 隐藏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;
|
|
|
}
|
|
|
- });
|
|
|
- let canEditRangeList = canEditCell.map((item) => {
|
|
|
- let col = String.fromCharCode(item.c + 65);
|
|
|
- return {
|
|
|
+ }
|
|
|
+ // 最下方预算
|
|
|
+ if (!permissions["func-psr-03"]) {
|
|
|
+ for (let i = 101; i <= 117; i++) {
|
|
|
+ rowhidden[i] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 更新时间权限
|
|
|
+ if (permissions["func-psr-04"]) {
|
|
|
+ canEditRangeList.push({
|
|
|
hintText: "",
|
|
|
- sqref: `$${col}$1:$${col}$1`,
|
|
|
- };
|
|
|
- });
|
|
|
- // 设置保护区域,lucksheet不能直接设置不允许编辑的区域
|
|
|
- // 只能禁止整体编辑,设置例外区域
|
|
|
- sheet.config.authority = {
|
|
|
- sheet: 1,
|
|
|
- hintText: "表头只能新增,禁止编辑!",
|
|
|
- // insertColumns: 0,
|
|
|
- allowRangeList: [
|
|
|
- // 第一行以外都能编辑
|
|
|
- {
|
|
|
- hintText: "",
|
|
|
- sqref: `$a$2:$z$99999`,
|
|
|
- },
|
|
|
-
|
|
|
- // 第一列未加载出来的row也允许编辑
|
|
|
- {
|
|
|
- hintText: "",
|
|
|
- sqref: `$${lastCol}$1:$${lastCol}$1`,
|
|
|
- },
|
|
|
- ...canEditRangeList,
|
|
|
- ],
|
|
|
- };
|
|
|
+ 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-psr-02"]) {
|
|
|
+ canEditRangeList.push({
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$A$3:$CF$3",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 实际回款权限
|
|
|
+ if (permissions["func-psr-03"]) {
|
|
|
+ canEditRangeList.push({
|
|
|
+ hintText: "",
|
|
|
+ sqref: "$A$4:$CF$4",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else if (sheet.name == "清单") {
|
|
|
+ // 隐藏项目经理预算
|
|
|
+ if (!permissions["func-list-01"]) {
|
|
|
+ colhidden[8] = 0;
|
|
|
+ colhidden[9] = 0;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ // 设置保护区域,lucksheet不能直接设置不允许编辑的区域
|
|
|
+ // 只能禁止整体编辑,设置例外区域
|
|
|
+ sheet.config.authority = {
|
|
|
+ sheet: 1,
|
|
|
+ hintText: "禁止编辑",
|
|
|
+ allowRangeList: canEditRangeList,
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
sheet.config.colhidden = colhidden;
|
|
|
+ sheet.config.rowhidden = rowhidden;
|
|
|
|
|
|
// 公式计算
|
|
|
let calcChain = [];
|