Bladeren bron

fix: 导入信息价excel报错问题

vian 3 maanden geleden
bovenliggende
commit
4850af4660
1 gewijzigde bestanden met toevoegingen van 11 en 9 verwijderingen
  1. 11 9
      modules/price_info_lib/facade/index.js

+ 11 - 9
modules/price_info_lib/facade/index.js

@@ -174,25 +174,27 @@ async function importExcelData(libID, sheetData) {
     let curClassName;
     let curClassID;
     for (let row = 1; row < sheetData.length; row++) {
-        const areaName = sheetData[row][colMap.area] || '';
-        const className = sheetData[row][colMap.class] || '';
-        const code = sheetData[row][colMap.code] ? sheetData[row][colMap.code].trim() : '';
-        const name = sheetData[row][colMap.name] ? sheetData[row][colMap.name].trim() : '';
-        const specs = sheetData[row][colMap.specs] ? sheetData[row][colMap.specs].trim() : '';
-        const unit = sheetData[row][colMap.unit] ? sheetData[row][colMap.unit].trim() : '';
-        const noTaxPrice = sheetData[row][colMap.noTaxPrice] ? sheetData[row][colMap.noTaxPrice].trim() : '';
-        const taxPrice = sheetData[row][colMap.taxPrice] ? sheetData[row][colMap.taxPrice].trim() : '';
+        const areaName = sheetData[row][colMap.area] ? String(sheetData[row][colMap.area]).trim() : '';
+        const className = sheetData[row][colMap.class] ? String(sheetData[row][colMap.class]).trim() : '';
+        const code = sheetData[row][colMap.code] ? String(sheetData[row][colMap.code]).trim() : '';
+        const name = sheetData[row][colMap.name] ? String(sheetData[row][colMap.name]).trim() : '';
+        const specs = sheetData[row][colMap.specs] ? String(sheetData[row][colMap.specs]).trim() : '';
+        const unit = sheetData[row][colMap.unit] ? String(sheetData[row][colMap.unit]).trim() : '';
+        const noTaxPrice = sheetData[row][colMap.noTaxPrice] ? String(sheetData[row][colMap.noTaxPrice]).trim() : '';
+        const taxPrice = sheetData[row][colMap.taxPrice] ? String(sheetData[row][colMap.taxPrice]).trim() : '';
         if (!className && !code && !name && !specs && !noTaxPrice && !taxPrice) { // 认为是空数据
             continue;
         }
+        let areaChange = false;
         if (areaName && areaName !== curAreaName) {
             curAreaName = areaName;
+            areaChange = true;
         }
         const areaID = areaMap[curAreaName];
         if (!areaID) {
             continue;
         }
-        if (className && className !== curClassName) {
+        if ((className && className !== curClassName) || areaChange) {
             curClassName = className;
             const classItem = {
                 libID,