Pārlūkot izejas kodu

导入签约清单,过滤清单编号后的空格

maixinrong 5 gadi atpakaļ
vecāks
revīzija
1b22507656
1 mainītis faili ar 35 papildinājumiem un 28 dzēšanām
  1. 35 28
      app/service/deal_bills.js

+ 35 - 28
app/service/deal_bills.js

@@ -55,21 +55,25 @@ module.exports = app => {
                             iUp = -1;
                             iQty = -1;
                         }
-                    } else if (this.ctx.helper.validBillsCode(row[iCode])) {
-                        const data = {
-                            deal_id: bills.length + 1,
-                            tender_id: tenderId,
-                            code: row[iCode],
-                            name: row[iName],
-                            unit: row[iUnit],
-                            unit_price: row[iUp],
-                            quantity: row[iQty],
-                        };
-                        if ((data.unit_price && !this._.isNumber(data.unit_price)) || (data.quantity && !this._.isNumber(data.quantity))) {
-                            throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                    } else {
+                        const code = this.ctx.helper._.trimEnd(row[iCode]);
+                        console.log(code);
+                        if (this.ctx.helper.validBillsCode(code)) {
+                            const data = {
+                                deal_id: bills.length + 1,
+                                tender_id: tenderId,
+                                code: code,
+                                name: row[iName],
+                                unit: row[iUnit],
+                                unit_price: row[iUp],
+                                quantity: row[iQty],
+                            };
+                            if ((data.unit_price && !this._.isNumber(data.unit_price)) || (data.quantity && !this._.isNumber(data.quantity))) {
+                                throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                            }
+                            bills.push(data);
                         }
-                        bills.push(data);
-                    }
+                    } 
                 }
                 if (!bCheckCol) {
                     throw '导入的Excel表头定义有误,请下载示例检查';
@@ -144,21 +148,24 @@ module.exports = app => {
                         iQty = -1;
                         iTp = -1;
                     }
-                } else if (this.ctx.helper.validBillsCode(row[iCode])) {
-                    const data = {
-                        deal_id: bills.length + 1,
-                        tender_id: tenderId,
-                        code: this.ctx.helper.replaceReturn(row[iCode]),
-                        name: this.ctx.helper.replaceReturn(row[iName]),
-                        unit: this.ctx.helper.replaceReturn(row[iUnit]),
-                        unit_price: (row[iUp] === undefined || row[iUp] === null) ? 0 : this._.toNumber(row[iUp]),
-                        quantity: (row[iQty] === undefined || row[iQty] === null) ? 0 : this._.toNumber(row[iQty]),
-                        total_price: (row[iTp] === undefined || row[iTp] === null) ? 0 : this._.toNumber(row[iTp]),
-                    };
-                    if (this._.isNaN(data.unit_price) || this._.isNaN(data.quantity) || this._.isNaN(data.total_price)) {
-                        throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                } else {
+                    const code = this.ctx.helper.replaceReturn(this.ctx.helper._.trimEnd(row[iCode]));
+                    if (this.ctx.helper.validBillsCode(code)) {
+                        const data = {
+                            deal_id: bills.length + 1,
+                            tender_id: tenderId,
+                            code: code,
+                            name: this.ctx.helper.replaceReturn(row[iName]),
+                            unit: this.ctx.helper.replaceReturn(row[iUnit]),
+                            unit_price: (row[iUp] === undefined || row[iUp] === null) ? 0 : this._.toNumber(row[iUp]),
+                            quantity: (row[iQty] === undefined || row[iQty] === null) ? 0 : this._.toNumber(row[iQty]),
+                            total_price: (row[iTp] === undefined || row[iTp] === null) ? 0 : this._.toNumber(row[iTp]),
+                        };
+                        if (this._.isNaN(data.unit_price) || this._.isNaN(data.quantity) || this._.isNaN(data.total_price)) {
+                            throw '导入的Excel的数据类型有误,请检查第' + (iRow + 1) + '行';
+                        }
+                        bills.push(data);
                     }
-                    bills.push(data);
                 }
             }
             if (!bCheckCol) {