xujunjie 1 ano atrás
pai
commit
1bc185e600
5 arquivos alterados com 211 adições e 207 exclusões
  1. 2 2
      src/controllers/constant.js
  2. 1 1
      src/controllers/resize.js
  3. 1 0
      src/controllers/sheetBar.js
  4. 27 29
      src/core.js
  5. 180 175
      src/global/setdata.js

+ 2 - 2
src/controllers/constant.js

@@ -1531,8 +1531,8 @@ function customCellRightClickConfig() {
 		deleteRow: true, // delete the selected row
 		deleteColumn: true, // delete the selected column
 		deleteCell: true, // delete cell
-		hideRow: true, // hide the selected row and display the selected row
-		hideColumn: true, // hide the selected column and display the selected column
+		hideRow: false, // hide the selected row and display the selected row
+		hideColumn: false, // hide the selected column and display the selected column
 		rowHeight: true, // row height
 		columnWidth: true, // column width
 		clear: true, // clear content

+ 1 - 1
src/controllers/resize.js

@@ -29,7 +29,7 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
     else {
         $("#" + Store.container).find(".luckysheet-wa-editor").show();
         // Store.toolbarHeight = 72;
-        Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor').offsetHeight;
+        Store.toolbarHeight = document.querySelector('#' + Store.container +' .luckysheet-wa-editor')?.offsetHeight || 72;
     }
 
     // if (!luckysheetConfigsetting.showsheetbar) {

+ 1 - 0
src/controllers/sheetBar.js

@@ -801,6 +801,7 @@ export function initialSheetBar() {
 			}
 
 			if (f['hide'] == 1) {
+				// break;
 				icon = '<i class="fa fa-low-vision" aria-hidden="true"></i>';
 				style += 'color:#BBBBBB;';
 			}

+ 27 - 29
src/core.js

@@ -299,21 +299,6 @@ function numberToExcelColumn(num) {
 }
 
 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,
-  // };
   console.log("--------------permissions----------", permissions);
   let colhidden = {};
   let rowhidden = {};
@@ -331,23 +316,27 @@ function initSheet(sheet, authority, permissions) {
       canEditRangeList = [
         {
           hintText: "",
-          sqref: "$C$19:$C$20",
+          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: "$C$47:$C$52",
-        },
-        {
-          hintText: "",
-          sqref: "$C$56:$C$56",
-        },
-        {
-          hintText: "",
-          sqref: "$C$57:$C$57",
-        },
-        {
-          hintText: "",
-          sqref: "$C$86:$C$87",
+          sqref: "$B$104:$B$118",
         },
       ];
       // 隐藏PSR表
@@ -429,11 +418,20 @@ function initSheet(sheet, authority, permissions) {
         });
       }
     } 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",
+      });
     }
 
     // 设置保护区域,lucksheet不能直接设置不允许编辑的区域

+ 180 - 175
src/global/setdata.js

@@ -7,214 +7,219 @@ import Store from '../store/index'
 
 //Set cell value
 function setcellvalue(r, c, d, v) {
-    if(d == null){
-        d = Store.flowdata;
-    }
-    // 若采用深拷贝,初始化时的单元格属性丢失
-    // let cell = $.extend(true, {}, d[r][c]);
-    let cell = d[r][c];
-
-    let vupdate;
-
-    if(getObjType(v) == "object"){
-        if(cell == null){
-            cell = v;
+    try{
+        if(d == null){
+            d = Store.flowdata;
         }
-        else{
-            if(v.f != null){
-                cell.f = v.f;
-            }else if(cell.hasOwnProperty('f')){
-                delete cell.f;
+        // 若采用深拷贝,初始化时的单元格属性丢失
+        // let cell = $.extend(true, {}, d[r][c]);
+        let cell = d[r][c];
+    
+        let vupdate;
+    
+        if(getObjType(v) == "object"){
+            if(cell == null){
+                cell = v;
             }
-
-            if(v.spl != null){
-                cell.spl = v.spl;
+            else{
+                if(v.f != null){
+                    cell.f = v.f;
+                }else if(cell.hasOwnProperty('f')){
+                    delete cell.f;
+                }
+    
+                if(v.spl != null){
+                    cell.spl = v.spl;
+                }
+    
+                if(v.ct != null){
+                    cell.ct = v.ct;
+                }
             }
-
-            if(v.ct != null){
-                cell.ct = v.ct;
+    
+    
+            if(getObjType(v.v) == "object"){
+                vupdate = v.v.v;
+            }
+            else{
+                vupdate = v.v;
             }
-        }
-
-
-        if(getObjType(v.v) == "object"){
-            vupdate = v.v.v;
         }
         else{
-            vupdate = v.v;
+            vupdate = v;
         }
-    }
-    else{
-        vupdate = v;
-    }
-
-    if(isRealNull(vupdate)){
-        if(getObjType(cell) == "object"){
-            delete cell.m;
-            delete cell.v;
+    
+        if(isRealNull(vupdate)){
+            if(getObjType(cell) == "object"){
+                delete cell.m;
+                delete cell.v;
+            }
+            else{
+                cell = null;
+            }
+    
+            d[r][c] = cell;
+    
+            return;
         }
-        else{
-            cell = null;
+    
+        // 1.为null
+        // 2.数据透视表的数据,flowdata的每个数据可能为字符串,结果就是cell == v == 一个字符串或者数字数据
+        if(isRealNull(cell) || (getObjType(cell) === 'string' || getObjType(cell) === 'number') && cell === v){
+            cell = {};
         }
-
-        d[r][c] = cell;
-
-        return;
-    }
-
-    // 1.为null
-    // 2.数据透视表的数据,flowdata的每个数据可能为字符串,结果就是cell == v == 一个字符串或者数字数据
-    if(isRealNull(cell) || (getObjType(cell) === 'string' || getObjType(cell) === 'number') && cell === v){
-        cell = {};
-    }
-
-    let vupdateStr = vupdate.toString();
-
-    if(vupdateStr.substr(0, 1) == "'"){
-        cell.m = vupdateStr.substr(1);
-        cell.ct = { "fa": "@", "t": "s" };
-        cell.v = vupdateStr.substr(1);
-        cell.qp = 1;
-    }
-    else if(cell.qp == 1){
-        cell.m = vupdateStr;
-        cell.ct = { "fa": "@", "t": "s" };
-        cell.v = vupdateStr;
-    }
-    else if(vupdateStr.toUpperCase() === "TRUE"){
-        cell.m = "TRUE";
-        cell.ct = { "fa": "General", "t": "b" };
-        cell.v = true;
-    }
-    else if(vupdateStr.toUpperCase() === "FALSE"){
-        cell.m = "FALSE";
-        cell.ct = { "fa": "General", "t": "b" };
-        cell.v = false;
-    }
-    else if(vupdateStr.substr(-1) === "%" && isRealNum(vupdateStr.substring(0, vupdateStr.length-1))){
-            cell.ct = {fa: "0%", t: "n"};
-            cell.v = vupdateStr.substring(0, vupdateStr.length-1) / 100;
-            cell.m = vupdate;
-    }
-    else if(valueIsError(vupdate)){
-        cell.m = vupdateStr;
-        // cell.ct = { "fa": "General", "t": "e" };
-        if(cell.ct!=null){
-            cell.ct.t = "e";
+    
+        let vupdateStr = vupdate.toString();
+    
+        if(vupdateStr.substr(0, 1) == "'"){
+            cell.m = vupdateStr.substr(1);
+            cell.ct = { "fa": "@", "t": "s" };
+            cell.v = vupdateStr.substr(1);
+            cell.qp = 1;
         }
-        else{
-            cell.ct = { "fa": "General", "t": "e" };
+        else if(cell.qp == 1){
+            cell.m = vupdateStr;
+            cell.ct = { "fa": "@", "t": "s" };
+            cell.v = vupdateStr;
         }
-        cell.v = vupdate;
-    }
-    else{
-        if(cell.f != null && isRealNum(vupdate) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)){
-            cell.v = parseFloat(vupdate);
-            if(cell.ct==null){
-                cell.ct = { "fa": "General", "t": "n" };
-            }
-
-            if(cell.v == Infinity || cell.v == -Infinity){
-                cell.m = cell.v.toString();
+        else if(vupdateStr.toUpperCase() === "TRUE"){
+            cell.m = "TRUE";
+            cell.ct = { "fa": "General", "t": "b" };
+            cell.v = true;
+        }
+        else if(vupdateStr.toUpperCase() === "FALSE"){
+            cell.m = "FALSE";
+            cell.ct = { "fa": "General", "t": "b" };
+            cell.v = false;
+        }
+        else if(vupdateStr.substr(-1) === "%" && isRealNum(vupdateStr.substring(0, vupdateStr.length-1))){
+                cell.ct = {fa: "0%", t: "n"};
+                cell.v = vupdateStr.substring(0, vupdateStr.length-1) / 100;
+                cell.m = vupdate;
+        }
+        else if(valueIsError(vupdate)){
+            cell.m = vupdateStr;
+            // cell.ct = { "fa": "General", "t": "e" };
+            if(cell.ct!=null){
+                cell.ct.t = "e";
             }
             else{
-                if(cell.v.toString().indexOf("e") > -1){
-                    let len;
-                    if(cell.v.toString().split(".").length==1){
-                        len = 0;
-                    }
-                    else{
-                        len = cell.v.toString().split(".")[1].split("e")[0].length;
-                    }
-                    if(len > 5){
-                        len = 5;
-                    }
-
-                    cell.m = cell.v.toExponential(len).toString();
+                cell.ct = { "fa": "General", "t": "e" };
+            }
+            cell.v = vupdate;
+        }
+        else{
+            if(cell.f != null && isRealNum(vupdate) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)){
+                cell.v = parseFloat(vupdate);
+                if(cell.ct==null){
+                    cell.ct = { "fa": "General", "t": "n" };
+                }
+    
+                if(cell.v == Infinity || cell.v == -Infinity){
+                    cell.m = cell.v.toString();
                 }
                 else{
-                    let v_p = Math.round(cell.v * 1000000000) / 1000000000;
-                    if(cell.ct==null){
-                        let mask = genarate(v_p);
-                        cell.m = mask[0].toString();
+                    if(cell.v.toString().indexOf("e") > -1){
+                        let len;
+                        if(cell.v.toString().split(".").length==1){
+                            len = 0;
+                        }
+                        else{
+                            len = cell.v.toString().split(".")[1].split("e")[0].length;
+                        }
+                        if(len > 5){
+                            len = 5;
+                        }
+    
+                        cell.m = cell.v.toExponential(len).toString();
                     }
                     else{
-                        let mask = update(cell.ct.fa, v_p);
-                        cell.m = mask.toString();
+                        let v_p = Math.round(cell.v * 1000000000) / 1000000000;
+                        if(cell.ct==null){
+                            let mask = genarate(v_p);
+                            cell.m = mask[0].toString();
+                        }
+                        else{
+                            let mask = update(cell.ct.fa, v_p);
+                            cell.m = mask.toString();
+                        }
+    
+                        // cell.m = mask[0].toString();
                     }
-
-                    // cell.m = mask[0].toString();
                 }
             }
-        }
-        else if(cell.ct != null && cell.ct.fa == "@"){
-            cell.m = vupdateStr;
-            cell.v = vupdate;
-        }
-        else if(cell.ct != null && cell.ct.fa != null && cell.ct.fa != "General"){
-            if(isRealNum(vupdate)){
-                vupdate = parseFloat(vupdate);
-            }
-
-            let mask = update(cell.ct.fa, vupdate);
-
-            if(mask === vupdate){ //若原来单元格格式 应用不了 要更新的值,则获取更新值的 格式
-                mask = genarate(vupdate);
-
-                cell.m = mask[0].toString();
-                cell.ct = mask[1];
-                cell.v = mask[2];
-            }
-            else{
-                cell.m = mask.toString();
+            else if(cell.ct != null && cell.ct.fa == "@"){
+                cell.m = vupdateStr;
                 cell.v = vupdate;
             }
-        }
-        else{
-            if(isRealNum(vupdate) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)){
-
-                if(typeof vupdate === "string"){
-                    let flag = vupdate.split("").every(ele=>ele == "0" || ele == ".");
-                    if(flag){
-                        vupdate = parseFloat(vupdate);
-                    }
+            else if(cell.ct != null && cell.ct.fa != null && cell.ct.fa != "General"){
+                if(isRealNum(vupdate)){
+                    vupdate = parseFloat(vupdate);
                 }
-                cell.v = vupdate;   /* 备注:如果使用parseFloat,1.1111111111111111会转换为1.1111111111111112 ? */
-                cell.ct = { "fa": "General", "t": "n" };
-                if(cell.v == Infinity || cell.v == -Infinity){
-                    cell.m = cell.v.toString();
+    
+                let mask = update(cell.ct.fa, vupdate);
+    
+                if(mask === vupdate){ //若原来单元格格式 应用不了 要更新的值,则获取更新值的 格式
+                    mask = genarate(vupdate);
+    
+                    cell.m = mask[0].toString();
+                    cell.ct = mask[1];
+                    cell.v = mask[2];
                 }
                 else{
-                    let mask = genarate(cell.v);
-
-                    cell.m = mask[0].toString();
+                    cell.m = mask.toString();
+                    cell.v = vupdate;
                 }
             }
             else{
-                let mask = genarate(vupdate);
-
-                cell.m = mask[0].toString();
-                cell.ct = mask[1];
-                cell.v = mask[2];
+                if(isRealNum(vupdate) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(vupdate)){
+    
+                    if(typeof vupdate === "string"){
+                        let flag = vupdate.split("").every(ele=>ele == "0" || ele == ".");
+                        if(flag){
+                            vupdate = parseFloat(vupdate);
+                        }
+                    }
+                    cell.v = vupdate;   /* 备注:如果使用parseFloat,1.1111111111111111会转换为1.1111111111111112 ? */
+                    cell.ct = { "fa": "General", "t": "n" };
+                    if(cell.v == Infinity || cell.v == -Infinity){
+                        cell.m = cell.v.toString();
+                    }
+                    else{
+                        let mask = genarate(cell.v);
+    
+                        cell.m = mask[0].toString();
+                    }
+                }
+                else{
+                    let mask = genarate(vupdate);
+    
+                    cell.m = mask[0].toString();
+                    cell.ct = mask[1];
+                    cell.v = mask[2];
+                }
             }
         }
-    }
-
-    if(!server.allowUpdate && !luckysheetConfigsetting.pointEdit){
-        if(cell.ct != null && /^(w|W)((0?)|(0\.0+))$/.test(cell.ct.fa) == false && cell.ct.t == "n" && cell.v != null && parseInt(cell.v).toString().length > 4){
-            let autoFormatw = luckysheetConfigsetting.autoFormatw.toString().toUpperCase();
-            let accuracy = luckysheetConfigsetting.accuracy;
-
-            let sfmt = setAccuracy(autoFormatw, accuracy);
-
-            if(sfmt != "General") {
-                cell.ct.fa = sfmt;
-                cell.m = update(sfmt, cell.v);
+    
+        if(!server.allowUpdate && !luckysheetConfigsetting.pointEdit){
+            if(cell.ct != null && /^(w|W)((0?)|(0\.0+))$/.test(cell.ct.fa) == false && cell.ct.t == "n" && cell.v != null && parseInt(cell.v).toString().length > 4){
+                let autoFormatw = luckysheetConfigsetting.autoFormatw.toString().toUpperCase();
+                let accuracy = luckysheetConfigsetting.accuracy;
+    
+                let sfmt = setAccuracy(autoFormatw, accuracy);
+    
+                if(sfmt != "General") {
+                    cell.ct.fa = sfmt;
+                    cell.m = update(sfmt, cell.v);
+                }
             }
         }
+    
+        d[r][c] = cell;
+    } catch(err) {
+        console.error(err)
     }
-
-    d[r][c] = cell;
+    
 }
 
 //new runze 根据亿万格式autoFormatw和精确度accuracy 转换成 w/w0/w0.00 or 0/0.0格式