|
@@ -253,13 +253,27 @@ module.exports = app => {
|
|
|
*/
|
|
|
async getAuditChange(uid) {
|
|
|
const sql = 'SELECT ca.`uid`, ca.`times`, ca.`usite`, ca.`usort`, ca.`tid`, ca.`cid`, ca.`sin_time`, ' +
|
|
|
- ' c.`code` As `ccode`, c.`name` As `cname`,' +
|
|
|
+ ' c.`code` As `ccode`, c.`name` As `cname`, c.`status` As `cstatus`, ' +
|
|
|
' t.`name`, t.`type`, t.`user_id` ' +
|
|
|
' FROM ?? AS ca, ?? AS c, ?? As t ' +
|
|
|
- ' WHERE ca.`uid` = ? and ca.`status` = ? and ca.`status` = c.`status`' +
|
|
|
+ ' WHERE ca.`uid` = ? and ca.`status` = ? and c.`status` != ?' +
|
|
|
' and ca.`cid` = c.`cid` and ca.`tid` = t.`id`';
|
|
|
- const sqlParam = [this.tableName, this.ctx.service.change.tableName, this.ctx.service.tender.tableName, uid, 2];
|
|
|
- return await this.db.query(sql, sqlParam);
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.change.tableName, this.ctx.service.tender.tableName, uid, 2, audit.flow.status.uncheck];
|
|
|
+ const changes = await this.db.query(sql, sqlParam);
|
|
|
+ for (const c of changes) {
|
|
|
+ if (c.cstatus === audit.flow.status.back) {
|
|
|
+ const preSql = 'SELECT pa.`id`, pa.`account`, pa.`account_group`, pa.`name`, pa.`company`, pa.`role`, pa.`telephone` FROM ?? As ca, ?? As pa ' +
|
|
|
+ ' WHERE ca.cid = ? and ca.times = ? and ca.status = ? and ca.uid = pa.id';
|
|
|
+ const preSqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, c.cid, c.times - 1, c.cstatus];
|
|
|
+ c.pre = await this.db.queryOne(preSql, preSqlParam);
|
|
|
+ } else {
|
|
|
+ const preSql = 'SELECT pa.`id`, pa.`account`, pa.`account_group`, pa.`name`, pa.`company`, pa.`role`, pa.`telephone` FROM ?? As ca, ?? As pa ' +
|
|
|
+ ' WHERE ca.cid = ? and ca.times = ? and ca.usort = ? and ca.uid = pa.id';
|
|
|
+ const preSqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, c.cid, c.times, c.usort - 1];
|
|
|
+ c.pre = await this.db.queryOne(preSql, preSqlParam);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return changes;
|
|
|
}
|
|
|
}
|
|
|
|