|
@@ -175,7 +175,7 @@ module.exports = app => {
|
|
*/
|
|
*/
|
|
async getAuditors(vid, times = 1) {
|
|
async getAuditors(vid, times = 1) {
|
|
const sql =
|
|
const sql =
|
|
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`create_time`, la.`end_time`, g.`sort` ' +
|
|
|
|
|
|
+ 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`type`, la.`order`, la.`status`, la.`opinion`, la.`create_time`, la.`end_time`, g.`sort` ' +
|
|
'FROM ?? AS la, ?? AS pa, (SELECT t1.`audit_id`,(@i:=@i+1) as `sort` FROM (SELECT t.`audit_id`, t.`order` FROM (select `audit_id`, `order` from ?? WHERE `vid` = ? AND `times` = ? ORDER BY `order` LIMIT 200) t GROUP BY t.`audit_id` ORDER BY t.`order`) t1, (select @i:=0) as it) as g ' +
|
|
'FROM ?? AS la, ?? AS pa, (SELECT t1.`audit_id`,(@i:=@i+1) as `sort` FROM (SELECT t.`audit_id`, t.`order` FROM (select `audit_id`, `order` from ?? WHERE `vid` = ? AND `times` = ? ORDER BY `order` LIMIT 200) t GROUP BY t.`audit_id` ORDER BY t.`order`) t1, (select @i:=0) as it) as g ' +
|
|
'WHERE la.`vid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`order`';
|
|
'WHERE la.`vid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`order`';
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, vid, times, vid, times];
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, vid, times, vid, times];
|
|
@@ -530,6 +530,65 @@ module.exports = app => {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 重新审批
|
|
|
|
+ * @param { string } cid - 查询的清单
|
|
|
|
+ * @return {Promise<*>} - 可用的变更令列表
|
|
|
|
+ */
|
|
|
|
+ async checkAgain(advance) {
|
|
|
|
+ const accountId = this.ctx.session.sessionUser.accountId;
|
|
|
|
+ // 初始化事务
|
|
|
|
+ const time = new Date();
|
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
|
+ let result = false;
|
|
|
|
+ try {
|
|
|
|
+ const maxOrder = advance.auditors[advance.auditors.length - 1].order;
|
|
|
|
+ const audits = advance.auditors.filter(x => { return x.order === maxOrder; });
|
|
|
|
+ if (!audits || audits.length === 0 || maxOrder < 1) throw '审核数据错误';
|
|
|
|
+ const selfAudit = audits.find(x => { return x.audit_id === accountId; });
|
|
|
|
+ if (!selfAudit) throw '当前标段您无权审批';
|
|
|
|
+ // 当前审批人2次添加至流程中
|
|
|
|
+ const checkAgainAuditors = [];
|
|
|
|
+ audits.forEach(x => {
|
|
|
|
+ checkAgainAuditors.push({
|
|
|
|
+ tid: advance.tid, vid: advance.id, audit_id: x.audit_id, type: x.type,
|
|
|
|
+ times: x.times, order: maxOrder + 1,
|
|
|
|
+ status: auditConst.status.checkAgain,
|
|
|
|
+ create_time: time, end_time: time, opinion: '',
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ const checkingAuditors = [];
|
|
|
|
+ audits.forEach(x => {
|
|
|
|
+ checkingAuditors.push({
|
|
|
|
+ tid: advance.tid, vid: advance.id, audit_id: x.audit_id, type: x.type,
|
|
|
|
+ times: x.times, order: maxOrder + 2,
|
|
|
|
+ status: auditConst.status.checking,
|
|
|
|
+ create_time: time,
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ await transaction.insert(this.tableName, checkAgainAuditors);
|
|
|
|
+ const checkingAuditors_result = await transaction.insert(this.tableName, checkingAuditors);
|
|
|
|
+ // 获取刚批量添加的所有list
|
|
|
|
+ // for (let j = 0; j < checkingAuditors.length; j++) {
|
|
|
|
+ // checkingAuditors[j].id = checkingAuditors_result.insertId + j;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // 设置审批中
|
|
|
|
+ await transaction.update(this.ctx.service.advance.tableName, {
|
|
|
|
+ id: advance.id,
|
|
|
|
+ status: auditConst.status.checking,
|
|
|
|
+ end_time: null,
|
|
|
|
+ });
|
|
|
|
+ await transaction.commit();
|
|
|
|
+ result = true;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error);
|
|
|
|
+ await transaction.rollback();
|
|
|
|
+ result = false;
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 用于添加推送所需的content内容
|
|
* 用于添加推送所需的content内容
|
|
* @param {Number} pid 项目id
|
|
* @param {Number} pid 项目id
|
|
* @param {Number} tid 台账id
|
|
* @param {Number} tid 台账id
|