MaiXinRong 3 years ago
parent
commit
7184c68147
1 changed files with 3 additions and 1 deletions
  1. 3 1
      app/service/stage_change.js

+ 3 - 1
app/service/stage_change.js

@@ -337,6 +337,8 @@ module.exports = app => {
             const data = await this.getAllDataByCondition({ where: { sid, cid } });
             const _ = this.ctx.helper._;
             const filter = this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
+            if (filter.length === 0) return filter;
+
             const bills = await this.ctx.service.ledger.getAllDataByCondition({
                 where: { id: _.uniq(_.map(filter, 'lid')) }
             });
@@ -350,7 +352,7 @@ module.exports = app => {
                     ...x,
                     ledger_id: b.ledger_id, l_code: b.b_code, l_name: b.name, l_unit: b.unit, l_up: b.unit_price,
                     l_deal_qty: b.deal_qty, l_deal_tp: b.deal_tp, l_qty: b.quantity, l_tp: b.total_price, l_drawing_code: b.drawing_code,
-                    p_name: p.name, p_drawing_code: p.drawing_code, p_qty: p.quantity,
+                    p_name: p ? p.name || '', p_drawing_code: p ? p.drawing_code : '', p_qty: p ? p.quantity : '',
                 };
             });
         }