|
@@ -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;
|