Browse Source

粘贴通用方法容错

zhongzewei 6 years ago
parent
commit
37669eca4a

+ 5 - 4
public/web/sheet/sheet_common.js

@@ -246,7 +246,6 @@ var sheetCommonObj = {
         }
         }
         return result;
         return result;
     },
     },
-    //todo
     analyzePasteData: function(setting, pastedInfo) {
     analyzePasteData: function(setting, pastedInfo) {
         var rst = [], propId = pastedInfo.cellRange.col, preStrIdx = 0, itemObj = {};//propId = 0 to proId = pastedInfo.cellRange.col, update by zhong
         var rst = [], propId = pastedInfo.cellRange.col, preStrIdx = 0, itemObj = {};//propId = 0 to proId = pastedInfo.cellRange.col, update by zhong
         for (var i = 0; i < pastedInfo.pasteData.text.length; i++) {
         for (var i = 0; i < pastedInfo.pasteData.text.length; i++) {
@@ -258,15 +257,17 @@ var sheetCommonObj = {
                     itemObj = {};
                     itemObj = {};
                 }
                 }
             } else if (pastedInfo.pasteData.text[i] === "\t" || pastedInfo.pasteData.text[i] === "\r") {
             } else if (pastedInfo.pasteData.text[i] === "\t" || pastedInfo.pasteData.text[i] === "\r") {
-                itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
+                if (setting.header[propId]) {
+                    itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
+                }
                 propId++;
                 propId++;
                 preStrIdx = i + 1;
                 preStrIdx = i + 1;
                 //if the last copied-cell were empty, should check whether the end of text
                 //if the last copied-cell were empty, should check whether the end of text
-                if (i == pastedInfo.pasteData.text.length - 1) {
+                if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
                     itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                     itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                     rst.push(itemObj);
                     rst.push(itemObj);
                 }
                 }
-            } else if (i == pastedInfo.pasteData.text.length - 1) {
+            } else if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
                 itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                 itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                 rst.push(itemObj);
                 rst.push(itemObj);
             }
             }

+ 1 - 1
web/building_saas/complementary_glj_lib/js/glj.js

@@ -83,7 +83,7 @@ let repositoryGljObj = {
         header:[
         header:[
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:160,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:160,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
-            {headerName:"规格型号",headerWidth:120,dataCode:"specs", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:120,dataCode:"specs", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"单位",headerWidth:45,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"单位",headerWidth:45,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"类型",headerWidth:90,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"类型",headerWidth:90,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},