|
@@ -1220,7 +1220,13 @@ module.exports = app => {
|
|
|
const sqlParam = [tender.id, stage.order, tender.id, audit.flow.status.checked];
|
|
|
const changes = await this.db.query(sql, sqlParam);
|
|
|
for (const c of changes) {
|
|
|
- const stageUsedData = await this.ctx.service.stageChange.getAllDataByCondition({ where: { sid: stage.id, cbid: c.cbid } });
|
|
|
+ let sSql = 'SELECT * FROM ' + this.ctx.service.stageChange.tableName + ' WHERE sid = ? and cbid = ?';
|
|
|
+ const sSqlParam = [stage.id, c.cbid];
|
|
|
+ if (stage.readOnly) {
|
|
|
+ sSql = sSql + ' and (stimes < ? or (stimes = ? and sorder <= ?))';
|
|
|
+ sSqlParam.push(stage.curTimes, stage.curTimes, stage.curOrder);
|
|
|
+ }
|
|
|
+ const stageUsedData = await this.db.query(sSql, sSqlParam);
|
|
|
const filter = this.ctx.helper.filterLastestData(stageUsedData, ['pid', 'lid'], 'stimes', 'sorder');
|
|
|
c.stage_used_amount = this.ctx.helper.sum(filter.map(x => { return x.qty }));
|
|
|
const aSql = 'SELECT ca.*, pa.name As u_name, pa.role As u_role ' +
|