Browse Source

台账修订,作废相关

MaiXinRong 5 years ago
parent
commit
fe73f1fe51

+ 1 - 5
app/controller/revise_controller.js

@@ -122,7 +122,7 @@ module.exports = app => {
                     throw '修订已审批通过,不可作废';
                 }
                 if (revise.valid) {
-                    const result = await ctx.service.ledgerRevise.cancelRevise(revise.id);
+                    const result = await ctx.service.ledgerRevise.cancelRevise(revise);
                 }
 
                 ctx.redirect('/tender/' + ctx.tender.id + '/revise/');
@@ -207,7 +207,6 @@ module.exports = app => {
             const [stdBills, stdChapters] = await this.ctx.service.valuation.getValuationStdList(ctx.tender.data.valuation);
             const curAuditor = await ctx.service.reviseAudit.getCurAuditor(revise.id, revise.times);
             const auditors = await ctx.service.reviseAudit.getAuditors(revise.id, revise.times);
-            console.log(auditors);
             const user = await ctx.service.projectAccount.getAccountInfoById(revise.uid);
             const auditHistory = [];
             if (revise.times > 1) {
@@ -215,7 +214,6 @@ module.exports = app => {
                     auditHistory.push(await ctx.service.reviseAudit.getAuditors(revise.id, i));
                 }
             }
-            console.log(auditHistory);
             return {
                 revise: revise, tender: ctx.tender.data,
                 reviseBills, revisePos, ledgerSpread, posSpread, tenderMenu, measureType,
@@ -493,7 +491,6 @@ module.exports = app => {
                 }
                 ctx.body = responseData;
             } catch (err) {
-                console.log(err);
                 this.log(err);
                 ctx.body = this.ajaxErrorBody(err, '数据错误');
             }
@@ -542,7 +539,6 @@ module.exports = app => {
         async removeAuditor(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);
-                console.log(data);
                 const id = data.auditorId instanceof Number ? data.auditorId : this.app._.toNumber(data.auditorId);
                 if (isNaN(id) || id <= 0) {
                     throw '参数错误';

+ 0 - 1
app/public/js/revise.js

@@ -684,7 +684,6 @@ $(document).ready(() => {
                     data.postData.push(sortData[iRow + row].id);
                 }
             }
-            console.log(data);
             if (data.postData.length > 0) {
                 postData(window.location.pathname + '/update', data, function (result) {
                     pos.removeDatas(result.pos);

+ 5 - 11
app/service/ledger_revise.js

@@ -45,18 +45,11 @@ module.exports = app => {
             const sql = 'SELECT lc.*, pa.name As user_name, pa.role As user_role, pa.company As user_company' +
                 '  FROM ' + this.tableName + ' As lc' +
                 '  INNER JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa ON lc.uid = pa.id' +
-                '  WHERE lc.tid = ?' +
+                '  WHERE lc.tid = ? And lc.valid' +
                 '  ORDER BY lc.in_time DESC' +
                 '  LIMIT 0, 1';
             const sqlParam = [tid];
             return await this.db.queryOne(sql, sqlParam);
-            // const revise = await this.db.select(this.tableName, {
-            //     where: {tid: tid},
-            //     orders: [['in_time', 'DESC']],
-            //     limit: 1,
-            //     offset: 0,
-            // });
-            // return revise.length > 0 ? revise[0] : null;
         }
 
         /**
@@ -159,11 +152,12 @@ module.exports = app => {
 
         /**
          * 作废修订
-         * @param id
+         * @param revise
          * @returns {Promise<void>}
          */
-        async cancelRevise(id) {
-            const result = await this.db.update(this.tableName, {id: id, valid: false});
+        async cancelRevise(revise) {
+            const [billsHis, posHis] = await this.ctx.service.reviseAudit.saveReviseHistoryFile(revise);
+            const result = await this.db.update(this.tableName, {id: revise.id, valid: false, bills_file: billsHis, pos_file: posHis});
             return result.affectedRows === 1;
         }
 

+ 2 - 2
app/service/revise_audit.js

@@ -179,7 +179,7 @@ module.exports = app => {
          * @returns {Promise<void>}
          * @private
          */
-        async saveLedgerHistoryFile(revise) {
+        async saveReviseHistoryFile(revise) {
             const timestamp = Date.parse(new Date());
 
             const billsHis = 'file/revise/bills' + timestamp + '.json';
@@ -205,7 +205,7 @@ module.exports = app => {
             if (!audit) throw '审核人信息错误';
 
             // 拷贝备份台账数据
-            const [billsHis, posHis] = await this.saveLedgerHistoryFile(revise);
+            const [billsHis, posHis] = await this.saveReviseHistoryFile(revise);
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, {id: audit.id, status: auditConst.status.checking, begin_time: new Date()});