Browse Source

1. 台账审批,台账修订,备份数据
2. 计量台账,计量单元,部位名称改为名称

MaiXinRong 5 years ago
parent
commit
eae2f03bd7

+ 3 - 3
app/const/spread.js

@@ -140,7 +140,7 @@ const stageTz = {
     },
     pos: {
         cols: [
-            {title: '部位名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true},
             {title: '台账数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 60, formatter: '@', readOnly: true},
             {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
@@ -202,7 +202,7 @@ const stageCl = {
     },
     pos: {
         cols: [
-            {title: '部位名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@'},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@'},
             {title: '台账数量|施工图复核', colSpan: '4|1', rowSpan: '1|1', field: 'sgfh_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|设计错漏增减', colSpan: '1', rowSpan: '|1', field: 'sjcl_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|其他错漏增减', colSpan: '1', rowSpan: '|1', field: 'qtcl_qty', hAlign: 2, width: 60, type: 'Number'},
@@ -267,7 +267,7 @@ const stageNoCl = {
     },
     pos: {
         cols: [
-            {title: '部位名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@'},
+            {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@'},
             {title: '设计量', colSpan: '1', rowSpan: '2', field: 'sgfh_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},

+ 25 - 1
app/service/ledger_revise.js

@@ -131,6 +131,26 @@ module.exports = app => {
         }
 
         /**
+         * 备份
+         * @param {Object} revise - 修订
+         * @returns {Promise<void>}
+         * @private
+         */
+        async backupReviseHistoryFile(revise) {
+            const timestamp = (new Date()).getTime();
+
+            const billsHis = '/revise/bills' + timestamp + '.json';
+            const bills = await this.ctx.service.reviseBills.getData(revise.tid);
+            await this.ctx.helper.saveBufferFile(JSON.stringify(bills), this.ctx.app.filePath + billsHis);
+
+            const posHis = '/revise/pos' + timestamp + '.json';
+            const pos = await this.ctx.service.revisePos.getData(revise.tid);
+            await this.ctx.helper.saveBufferFile(JSON.stringify(pos), this.ctx.app.filePath + posHis);
+
+            return [billsHis, posHis];
+        }
+
+        /**
          * 新增修订
          * @param {Number}tid - 标段id
          * @param {Number}uid - 提交人id
@@ -170,7 +190,11 @@ module.exports = app => {
          * @returns {Promise<void>}
          */
         async cancelRevise(revise) {
-            const result = await this.db.update(this.tableName, {id: revise.id, valid: false, end_time: new Date()});
+            const [billsHis, posHis] = await this.backupReviseHistoryFile(revise);
+            const result = await this.db.update(this.tableName, {
+                id: revise.id, valid: false, end_time: new Date(),
+                bills_file: billsHis, pos_file: posHis,
+            });
             return result.affectedRows === 1;
         }
 

+ 8 - 2
app/service/revise_audit.js

@@ -184,11 +184,18 @@ module.exports = app => {
             if (!audit) throw '审核人信息错误';
             const time = new Date();
 
+            // 拷贝备份台账数据
+            const [billsHis, posHis] = await this.ctx.service.ledgerRevise.backupReviseHistoryFile(revise);
+
             const transaction = await this.db.beginTransaction();
             try {
-                await transaction.update(this.tableName, {id: audit.id, status: auditConst.status.checking, begin_time: time});
+                await transaction.update(this.tableName, {
+                    id: audit.id, status: auditConst.status.checking, begin_time: time,
+                    bills_file: revise.bills_file, pos_file: revise.pos_file,
+                });
                 const reviseData = {
                     id: revise.id, status: auditConst.status.checking,
+                    bills_file: billsHis, pos_file: posHis,
                 };
                 if (revise.times === 1) {
                     reviseData.begin_time = time;
@@ -257,7 +264,6 @@ module.exports = app => {
                 // 更新当前审核流程
                 await transaction.update(this.tableName, {
                     id: audit.id, status: checkType, opinion: opinion, end_time: time,
-                    bills_file: revise.bills_file, pos_file: revise.pos_file,
                 });
                 if (checkType === auditConst.status.checked) {
                     const nextAudit = await this.getDataByCondition({rid: revise.id, times: times, audit_order: audit.audit_order + 1});

+ 1 - 1
config/config.default.js

@@ -100,7 +100,7 @@ module.exports = appInfo => {
         app: true,
     };
 
-    config.filePath = '/etc/calc_file/';
+    config.filePath = '/etc/calc/files/';
 
     // 上传设置
     config.multipart = {

+ 1 - 1
config/config.qa.js

@@ -43,7 +43,7 @@ module.exports = appInfo => {
         version: '1.0.0',
     };
 
-    config.filePath = appInfo.baseDir + '/app/public/';
+    config.filePath = appInfo.baseDir + '/app/public/files';
 
     // session配置
     config.session = {

+ 0 - 3
test/app/service/ledger_audit.test.js

@@ -144,9 +144,6 @@ describe('test/app/service/ledger_audit.test.js', () => {
         const ctx = app.mockContext(mockData);
         yield ctx.service.ledgerAudit.check(ctx.tender.id, auditConst.ledger.status.checkNo, '审批不通过', ctx.tender.data.ledger_times);
 
-        const copyData = yield app.mysql.select(ctx.service.ledgerAudit.tableName + '_copy', {where: {tender_id: ctx.tender.id, times: ctx.tender.data.ledger_times}});
-        assert(copyData.length === 53);
-
         const auditors = yield ctx.service.ledgerAudit.getAuditors(ctx.tender.id, ctx.tender.data.ledger_times);
         assert(auditors);
         assert(auditors.length === 1);

+ 0 - 2
test/app/service/tender.test.js

@@ -110,8 +110,6 @@ describe('test/app/service/tender.test.js', () => {
         assert(count === 0);
         count = yield ctx.service.ledgerAudit.count({tender_id: testTenderId});
         assert(count === 0);
-        count = yield app.mysql.count(ctx.service.ledgerAudit.tableName + '_copy', {tender_id: testTenderId});
-        assert(count === 0);
         count = yield ctx.service.pos.count({tid: testTenderId});
         assert(count === 0);
         count = yield ctx.service.pay.count({tid: testTenderId});