瀏覽代碼

1. 台账审批流程,排序问题
2. 签约清单,统一报错信息,未知错误,均提示“导入的Excel的数据类型有误”

MaiXinRong 6 年之前
父節點
當前提交
ab61a12f50
共有 3 個文件被更改,包括 10 次插入10 次删除
  1. 8 8
      app/controller/deal_bills_controller.js
  2. 1 1
      app/public/js/global.js
  3. 1 1
      app/service/ledger_audit.js

+ 8 - 8
app/controller/deal_bills_controller.js

@@ -11,6 +11,7 @@
 const fs = require('fs');
 const path = require('path');
 const excel = require('node-xlsx');
+const sendToWormhole = require('stream-wormhole');
 
 module.exports = app => {
     class DealBillsController extends app.BaseController {
@@ -43,11 +44,6 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async loadExcel(ctx) {
-            const responseData = {
-                err: 0,
-                msg: '',
-                data: [],
-            };
             let stream;
             try {
                 stream = await ctx.getFileStream();
@@ -66,7 +62,8 @@ module.exports = app => {
                     throw '导入数据失败';
                 }
 
-                responseData.data = await this.ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
+                const dealBills = await this.ctx.service.dealBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
+                ctx.body = {err: 0, msg: '', data: dealBills};
             } catch (err) {
                 this.log(err);
                 // 失败需要消耗掉stream 以防卡死
@@ -74,9 +71,12 @@ module.exports = app => {
                     await sendToWormhole(stream);
                 }
                 this.setMessage(err.toString(), this.messageType.ERROR);
+                if (err.stack) {
+                    ctx.body = {err: 1, msg: '导入的Excel的数据类型有误', data: null};
+                } else {
+                    ctx.body = {err: 1, msg: err.toString(), data: null};
+                }
             }
-
-            ctx.body = responseData;
         }
 
         /**

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

@@ -216,7 +216,7 @@ const postDataWithFile = function (url, formData, successCallback, errorCallBack
                     successCallback(result.data);
                 }
             } else {
-                toast('error: ' + result.message, 'error', 'exclamation-circle');
+                toast('error: ' + result.msg, 'error', 'exclamation-circle');
                 if (errorCallBack) {
                     errorCallBack();
                 }

+ 1 - 1
app/service/ledger_audit.js

@@ -51,7 +51,7 @@ module.exports = app => {
             const sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
                 'FROM ?? AS la, ?? AS pa ' +
                 'WHERE la.`tender_id` = ? and la.`times` = ?' +
-                '    and la.`audit_id` = pa.`id` order by la.`order`';
+                '    and la.`audit_id` = pa.`id` order by la.`audit_order`';
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, times];
             return await this.db.query(sql, sqlParam);
         }