lrf402788946 пре 4 година
родитељ
комит
84ce25f363
1 измењених фајлова са 11 додато и 8 уклоњено
  1. 11 8
      app/service/order/transport.js

+ 11 - 8
app/service/order/transport.js

@@ -167,7 +167,7 @@ class TransportService extends CrudService {
     let data = {};
     if (type === 'car') data = await this.carCalculate(query);
     else data = await this.calculate(query);
-    const res = await this.export({ data, ...query });
+    const res = await this.export({ data, ...query, type });
     return res;
   }
 
@@ -175,7 +175,7 @@ class TransportService extends CrudService {
    * 核算整理数据导出
    * @param {Object} Object { data } data:数据
    */
-  async export({ data, car_no }) {
+  async export({ data, car_no, type }) {
     // console.log(data);
     // 获取车牌号
     const car = await this.ctx.model.Car.findById(car_no);
@@ -193,7 +193,7 @@ class TransportService extends CrudService {
     arr.push(...countArr);
     // 各部分
     // 收入部分 前4个(A-D), 运输支出部分中间4个(E-H),日常维护部分最后4个(I-L)
-    let excelData = this.getExcelData(data);
+    let excelData = this.getExcelData(data, type);
     excelData = excelData.map(i => {
       const obj = { content: i };
       return obj;
@@ -214,8 +214,9 @@ class TransportService extends CrudService {
   /**
    * 整理收入/支出数据
    * @param {Object} data 核算结果集
+   * @param {String} type 类型,car/once once没有I-L
    */
-  getExcelData(data) {
+  getExcelData(data, type) {
     const inBill = _.get(data, 'inBill', []);
     const outBill = _.get(data, 'outBill', []);
     const daily = _.get(data, 'daily', []);
@@ -229,11 +230,13 @@ class TransportService extends CrudService {
       F7: '支出项目',
       G7: '支出金额',
       H7: '运输支出备注',
-      I7: '维护项目',
-      J7: '维护金额',
-      K7: '维护日期',
-      L7: '维护备注',
     };
+    if (type === 'car') {
+      lineSeven.I7 = '维护项目';
+      lineSeven.J7 = '维护金额';
+      lineSeven.K7 = '维护日期';
+      lineSeven.L7 = '维护备注';
+    }
     // 默认第八行开始=>标题1-4行,合计5-6行,7行上面
     const num = 8;
     const arr = [];