Prechádzať zdrojové kódy

fix: 导入清单示例提示无有效数据

vian 5 rokov pred
rodič
commit
056a5b9460

+ 4 - 4
web/building_saas/main/js/views/importBills.js

@@ -24,7 +24,7 @@ const importBills = (function () {
     }
 
     function _deNR(data) {
-        return _isDef(data) ? data.toString().replace(/\r\r/g, '\r') : data;
+        return _isDef(data) ? data.toString().replace(/[\r\n]/g, '') : data;
     }
     //find 返回最后匹配
     function findLast(datas, func) {
@@ -72,7 +72,7 @@ const importBills = (function () {
             //表格中顶层节点
             if (isGCLHead(dataTable[row])) {
                 let rootRow = dataTable[row + 2];
-                let name = rootRow[0].value ? _deESC(rootRow[0].value) : '';
+                let name = rootRow[0].value ? _deNR(rootRow[0].value) : '';
                 let existsRoot = findLast(rst, x => x.name === name && x.depth === 0);
                 if (!existsRoot) {
                     let root = {
@@ -94,7 +94,7 @@ const importBills = (function () {
                 continue;
             }
             let code = dataTable[row][colMapping.code] ? dataTable[row][colMapping.code].value : null,
-                name = dataTable[row][colMapping.name] ? _deESC(dataTable[row][colMapping.name].value) : null,
+                name = dataTable[row][colMapping.name] ? _deNR(dataTable[row][colMapping.name].value) : null,
                 unit = dataTable[row][colMapping.unit] ? dataTable[row][colMapping.unit].value : null,
                 quantity = dataTable[row][colMapping.quantity] ? dataTable[row][colMapping.quantity].value : null;
             if (!code && !name || /合计/.test(code)) {   //过滤掉同时没有编号和名称的、过滤合计行
@@ -175,7 +175,7 @@ const importBills = (function () {
         let curRoot = null;
         for (let row = 0; row < rowCount; row++) {
             let code = dataTable[row][colMapping.code] && dataTable[row][colMapping.code].value ? String(dataTable[row][colMapping.code].value).trim() : null,
-                name = dataTable[row][colMapping.name] ? _deESC(dataTable[row][colMapping.name].value) : null,
+                name = dataTable[row][colMapping.name] ? _deNR(dataTable[row][colMapping.name].value) : null,
                 unit = dataTable[row][colMapping.unit] ? dataTable[row][colMapping.unit].value : null,
                 quantity = dataTable[row][colMapping.quantity] ? dataTable[row][colMapping.quantity].value : null;
             if (!code) {    //没有编号的数据,名称必须为:清单 第xx章,认为新的表根节点