Переглянути джерело

修复调差往期值读取bug

laiguoran 3 роки тому
батько
коміт
139b49249e

+ 11 - 2
app/controller/material_controller.js

@@ -496,7 +496,7 @@ module.exports = app => {
                     const materialListData = await ctx.service.materialList.getMaterialData(ctx.tender.id, lastMaterial.id);
                     const hadBillsList = [];
                     for (const ml of materialListData) {
-                        const hb = _.find(hadBillsList, { gcl_id: ml.gcl_id, mb_id: ml.mb_id });
+                        const hb = _.find(hadBillsList, {gcl_id: ml.gcl_id, mb_id: ml.mb_id});
                         if (!hb) {
                             hadBillsList.push({
                                 gcl_id: ml.gcl_id,
@@ -509,9 +509,18 @@ module.exports = app => {
                     }
                     // 批量插入并修改is_new值
                     await ctx.service.materialListGcl.setData(lastMaterial.id, hadBillsList);
+                    // responseData.data.gclList = hadBillsList;
+                }
+                // } else {
+                // 判断是否是最新期,不是则获取的gclList是由materialList拼接而成,
+                if (lastMaterial.id === ctx.material.id) {
+                    const hadBillsList = await ctx.service.materialListGcl.getAllDataByCondition({ where: { tid: ctx.tender.id } });
                     responseData.data.gclList = hadBillsList;
                 } else {
-                    const hadBillsList = await ctx.service.materialListGcl.getAllDataByCondition({ where: { tid: ctx.tender.id } });
+                    const materialList = await this.ctx.service.materialList.getAllDataByCondition({ where: { mid: ctx.material.id, is_self: 0 } });
+                    const hadBillsList = ctx.app._.unionWith(materialList, function(item1, item2) {
+                        return item1.gcl_id === item2.gcl_id && item1.mb_id === item2.mb_id;
+                    });
                     responseData.data.gclList = hadBillsList;
                 }
                 ctx.body = responseData;

+ 1 - 1
app/service/material_list_gcl.js

@@ -80,7 +80,7 @@ module.exports = app => {
             if (order >= 1) {
                 // 获取上一期的list值
                 const materialInfo = await this.ctx.service.material.getDataByCondition({ tid, order });
-                const materialList = await this.ctx.service.materialList.getAllDataByCondition({ where: { mid: materialInfo.id } });
+                const materialList = await this.ctx.service.materialList.getAllDataByCondition({ where: { mid: materialInfo.id, is_self: 0 } });
                 const lastMaterialGclList = this._.unionWith(materialList, function(item1, item2) {
                     return item1.gcl_id === item2.gcl_id && item1.mb_id === item2.mb_id;
                 });