Browse Source

报表数据,变更方案相关

MaiXinRong 3 years ago
parent
commit
3b6538f059

+ 0 - 1
app/lib/sum_load.js

@@ -396,7 +396,6 @@ class gatherStageGclTree extends loadGclBaseTree {
                 }
             }
         }
-        console.log(result.update.length);
         for (const i of this.items) {
             result.errors.push({ b_code: i.b_code, name: i.name, unit: i.unit, qty: i.contract_qty, type: 'miss' });
             if (i.change_detail && i.change_detail.length > 0) {

+ 2 - 3
app/service/change_apply_list.js

@@ -206,9 +206,8 @@ module.exports = app => {
         async getChangeBills(tid, onlyChecked) {
             const sql = 'SELECT cb.*' +
                 '  FROM ' + this.tableName + ' cb' +
-                '  LEFT JOIN ' + this.ctx.service.change.tableName + ' c ON cb.caid = c.id' +
-                '  WHERE c.tid = ? ' + (onlyChecked ? `and c.status = ${audit.changeApply.status.checked}` : '') +
-                '  ORDER BY cb.cid, cb.code';
+                '  LEFT JOIN ' + this.ctx.service.changeApply.tableName + ' c ON cb.caid = c.id' +
+                '  WHERE c.tid = ? ' + (onlyChecked ? `and c.status = ${audit.changeApply.status.checked}` : '');
             const param = [tid];
             const result = await this.db.query(sql, param);
             return result;

+ 16 - 0
app/service/change_plan_list.js

@@ -225,6 +225,22 @@ module.exports = app => {
             if (updateArray.length > 0) await transaction.updateRows(this.tableName, updateArray);
             await this.calcCamountSum(transaction);
         }
+
+        /**
+         * 报表用
+         * Tony Kang
+         * @param {tid} tid - 标段id
+         * @return {void}
+         */
+        async getChangeBills(tid, onlyChecked) {
+            const sql = 'SELECT cb.*' +
+                '  FROM ' + this.tableName + ' cb' +
+                '  LEFT JOIN ' + this.ctx.service.changePlan.tableName + ' c ON cb.cpid = c.id' +
+                '  WHERE c.tid = ? ' + (onlyChecked ? `and c.status = ${audit.changeApply.status.checked}` : '');
+            const param = [tid];
+            const result = await this.db.query(sql, param);
+            return result;
+        }
     }
 
     return ChangePlanList;

+ 9 - 8
app/service/report_memory.js

@@ -842,23 +842,23 @@ module.exports = app => {
 
         async _generateChangeApply(tid) {
             if (!!this.changeApplyData) return;
-            this.changeApplyData = {};
+            const helper = this.ctx.helper;
             const where = { tid };
             if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
-            const data = await this.ctx.service.changeApply.getAllDataByCondition({ where });
+            const apply = await this.ctx.service.changeApply.getAllDataByCondition({ where });
             const bills = await this.ctx.service.changeApplyList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
             bills.sort(function(a, b ) {
-                const aCIndex = data.findIndex(function (c) {
+                const aCIndex = apply.findIndex(function (c) {
                     return c.cid === a.cid;
                 });
-                const bCIndex = data.findIndex(function (c) {
+                const bCIndex = apply.findIndex(function (c) {
                     return c.cid === b.cid;
                 });
                 return aCIndex === bCIndex
-                    ? ctx.helper.compareCode(a.code, b.code)
+                    ? helper.compareCode(a.code, b.code)
                     : aCIndex - bCIndex;
             });
-            this.changeApplyData = { data, bills };
+            this.changeApplyData = { data: apply, bills };
         }
 
         async _generateChangeApplyAudit() {
@@ -903,6 +903,7 @@ module.exports = app => {
 
         async _generateChangePlan(tid) {
             if (!!this.changePlanData) return;
+            const helper = this.ctx.helper;
             this.changePlanData = {};
             const where = { tid };
             if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
@@ -916,7 +917,7 @@ module.exports = app => {
                     return c.cid === b.cid;
                 });
                 return aCIndex === bCIndex
-                    ? ctx.helper.compareCode(a.code, b.code)
+                    ? helper.compareCode(a.code, b.code)
                     : aCIndex - bCIndex;
             });
             this.changePlanData = { data, bills };
@@ -927,7 +928,7 @@ module.exports = app => {
 
             this.changePlanData.audit = [];
             for (const c of this.changePlanData.data) {
-                const changeAudit = await this.ctx.service.changePlanAudit.getAllDataByCondition({ where: { caid: c.id, times: c.times }});
+                const changeAudit = await this.ctx.service.changePlanAudit.getAllDataByCondition({ where: { cpid: c.id, times: c.times }});
                 const changeAuditFilter = this.ctx.helper.filterLastestData(changeAudit, ['aid']);
                 this.changePlanData.audit.push(...changeAuditFilter);
             }

+ 1 - 1
app/view/report/index.ejs

@@ -33,8 +33,8 @@
                         <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change_project');">变更立项</a>
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change_apply');">变更申请</a>
-                            <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change');">变更令</a>
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change_plan');">变更方案</a>
+                            <a class="dropdown-item" href="javascript: void(0)" onclick="rptChangeRela.showChangeRela('change');">变更令</a>
                         </div>
                     </div>
                 </div>