Quellcode durchsuchen

1. 汇总表问题
2. 获取章级编号问题

MaiXinRong vor 5 Jahren
Ursprung
Commit
b93ac25fe0

+ 4 - 3
app/extend/helper.js

@@ -427,9 +427,10 @@ module.exports = {
     getChapterCode(code, symbol = '-') {
         if (!code || code === '') return '';
         const codePath = code.split(symbol);
-        const reg = /[0-9]{3,4}$/;
-        const result = codePath[0].match(reg);
-        if (result) {
+        const reg = /^[^0-9]*[0-9]{3,4}$/;
+        if (reg.test(codePath[0])) {
+            const numReg = /[0-9]{3,4}$/;
+            const result = codePath[0].match(numReg);
             const num = parseInt(result[0]);
             return this.mul(this.div(num, 100, 0), 100) + '';
         } else {

+ 1 - 1
app/service/rpt_gather_memory.js

@@ -258,7 +258,7 @@ module.exports = app => {
                 if (hasPre) {
                     const preStage = stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
                     this.ctx.helper.assignRelaData(billsData, [
-                        {data: preStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'lid'}
+                        {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
                     ]);
                 }
             }

+ 1 - 1
test/app/extend/helper.test.js

@@ -147,7 +147,7 @@ describe('test/app/extend/helper.test.js', () => {
     it('test getChapterCode', function () {
         const ctx = app.mockContext();
         const testData = ['A101-1-a', 'A201B102-1', '新增203-1', '新增1001-1'];
-        const targetData = ['100', '100', '200', '1000'];
+        const targetData = ['100', '10000', '200', '1000'];
         for (const i in testData) {
             assert(ctx.helper.getChapterCode(testData[i]) === targetData[i]);
         }

+ 18 - 6
test/app/service/rpt_gather_memory.test.js

@@ -30,17 +30,24 @@ describe('test/app/service/rpt_gather_memory.test.js', () => {
     });
     // 台账数据
     it('test getGatherStageBills - month', function* () {
-        const ctx = app.mockContext(mockData);
+        const ctx = app.mockContext();
+        const postData = {
+            account: 'zengpeiwen',
+            project: 'P1201',
+            project_password: '123456',
+        };
+        ctx.session = {};
+        const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
 
         // const select = {
         //     tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
         //     type: 'month',
         //     month: '2020-01',
         // };
-        const select = {
-            tenders: [{tid: 2256}, {tid: 2257}],
-            type: 'ledger',
-        };
+        // const select = {
+        //     tenders: [{tid: 2256}, {tid: 2257}],
+        //     type: 'ledger',
+        // };
         // const define = {
         //     enable: true,
         //     setting: JSON.stringify({
@@ -51,11 +58,16 @@ describe('test/app/service/rpt_gather_memory.test.js', () => {
         //         ]
         //     })
         // };
+        const select = {
+            tenders: [{tid: 2659}],
+            type: 'final',
+        };
         const define = {
             enable: true,
             setting: JSON.stringify({
                 title: '请选择汇总的标段',
-                type: 'ledger',
+                type: 'final',
+                hasPre: true
             })
         };