浏览代码

导入增加空白格去除

laiguoran 2 年之前
父节点
当前提交
4a31351a07
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 2 1
      app/public/js/material.js
  2. 1 1
      app/public/js/material_checklist.js

+ 2 - 1
app/public/js/material.js

@@ -1589,6 +1589,7 @@ $(document).ready(() => {
                     if (/(xls|xlsx|XLS|XLSX)$/.test(ext)) {
                         const workbook = XLSX.read(data, {type: 'binary'}); // 以二进制流方式读取得到整份excel表格对象
                         const jsonData = transExcel(XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]], { defval: null }));
+                        console.log(jsonData);
                         if (!(jsonData[0] && jsonData[0].code !== undefined && jsonData[0].code !== null && jsonData[0].unit !== undefined && jsonData[0].name !== undefined &&
                             jsonData[0].spec !== undefined && jsonData[0].msg_tp !== undefined && jsonData[0].msg_times !== undefined)) {
                             throw 'excel必须按指定格式内容上传';
@@ -1934,7 +1935,7 @@ $(document).ready(() => {
             zhKeys.forEach(zhKey => {
                 const enKey = mapInfo[zhKey];
 
-                enObj[enKey] = zhObj[zhKey];
+                enObj[enKey] = zhObj[zhKey] && _.isString(zhObj[zhKey]) ? _.trim(zhObj[zhKey]) : zhObj[zhKey];
             });
 
             return enObj

+ 1 - 1
app/public/js/material_checklist.js

@@ -1429,7 +1429,7 @@ $(document).ready(() => {
             zhKeys.forEach(zhKey => {
                 const enKey = mapInfo[zhKey];
 
-                enObj[enKey] = zhObj[zhKey];
+                enObj[enKey] = zhObj[zhKey] && _.isString(zhObj[zhKey]) ? _.trim(zhObj[zhKey]) : zhObj[zhKey];
             });
 
             return enObj