|
@@ -295,7 +295,7 @@ module.exports = app => {
|
|
|
if (postData.changestatus !== undefined && parseInt(postData.changestatus) === 1) {
|
|
|
change_status = true;
|
|
|
// 更新原报人审批状态
|
|
|
- await this.transaction.update(this.ctx.service.changeAudit.tableName, { id: lastUser.id, status: 3, sin_time: new Date() });
|
|
|
+ await this.transaction.update(this.ctx.service.changeAudit.tableName, { id: lastUser.id, status: audit.flow.auditStatus.checked, sin_time: new Date() });
|
|
|
}
|
|
|
// 再插入postData里的变更审批人和清单
|
|
|
if (postData.changeaudit !== undefined && postData.changeaudit !== '') {
|
|
@@ -305,7 +305,7 @@ module.exports = app => {
|
|
|
let uSort = parseInt(lastUser.usort) + 1;
|
|
|
for (const [index, ca] of changeAudit.entries()) {
|
|
|
const auditInfo = ca.split('/%/');
|
|
|
- const uStatus = change_status && index === 0 ? 2 : 1;
|
|
|
+ const uStatus = change_status && index === 0 ? audit.flow.auditStatus.checking : audit.flow.auditStatus.uncheck;
|
|
|
const sin_time = change_status && index === 0 ? new Date() : null;
|
|
|
const caArray = {
|
|
|
tid: tenderId,
|
|
@@ -397,7 +397,7 @@ module.exports = app => {
|
|
|
},
|
|
|
};
|
|
|
if (change_status) {
|
|
|
- cArray.status = 2;
|
|
|
+ cArray.status = audit.flow.status.checking;
|
|
|
cArray.cin_time = Date.parse(new Date()) / 1000;
|
|
|
}
|
|
|
await this.transaction.update(this.tableName, cArray, options);
|
|
@@ -425,12 +425,12 @@ module.exports = app => {
|
|
|
const audit_update = {
|
|
|
id: postData.audit_id,
|
|
|
sdesc: postData.sdesc,
|
|
|
- status: 3,
|
|
|
+ status: audit.flow.auditStatus.checked,
|
|
|
sin_time: new Date(),
|
|
|
};
|
|
|
const change_update = {
|
|
|
w_code: postData.w_code,
|
|
|
- status: 2,
|
|
|
+ status: audit.flow.status.checking,
|
|
|
cin_time: Date.parse(new Date()) / 1000,
|
|
|
};
|
|
|
await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
|
|
@@ -458,7 +458,7 @@ module.exports = app => {
|
|
|
}
|
|
|
if (postData.audit_next_id === undefined) {
|
|
|
// 变更令审批完成
|
|
|
- change_update.status = 3;
|
|
|
+ change_update.status = audit.flow.status.checked;
|
|
|
change_update.p_code = postData.p_code;
|
|
|
change_update.sin_time = Date.parse(new Date()) / 1000;
|
|
|
change_update.total_price = total_price;
|
|
@@ -477,7 +477,7 @@ module.exports = app => {
|
|
|
// 设置下一个审批人为审批状态
|
|
|
const nextAudit_update = {
|
|
|
id: postData.audit_next_id,
|
|
|
- status: 2,
|
|
|
+ status: audit.flow.auditStatus.checking,
|
|
|
};
|
|
|
await this.transaction.update(this.ctx.service.changeAudit.tableName, nextAudit_update);
|
|
|
|
|
@@ -563,7 +563,7 @@ module.exports = app => {
|
|
|
const audit_update = {
|
|
|
id: postData.audit_id,
|
|
|
sdesc: postData.sdesc,
|
|
|
- status: 5,
|
|
|
+ status: audit.flow.auditStatus.back,
|
|
|
sin_time: new Date(),
|
|
|
};
|
|
|
await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
|
|
@@ -585,7 +585,7 @@ module.exports = app => {
|
|
|
times: newTimes,
|
|
|
usite: al.usite,
|
|
|
usort,
|
|
|
- status: al.usite !== 0 ? 1 : 2,
|
|
|
+ status: al.usite !== 0 ? audit.flow.auditStatus.uncheck : audit.flow.auditStatus.checking,
|
|
|
};
|
|
|
insert_audit_array.push(insert_audit);
|
|
|
usort++;
|
|
@@ -594,7 +594,7 @@ module.exports = app => {
|
|
|
// 设置变更令退回
|
|
|
const change_update = {
|
|
|
w_code: postData.w_code,
|
|
|
- status: 5,
|
|
|
+ status: audit.flow.status.back,
|
|
|
times: newTimes,
|
|
|
cin_time: Date.parse(new Date()) / 1000,
|
|
|
};
|
|
@@ -640,7 +640,7 @@ module.exports = app => {
|
|
|
const audit_update = {
|
|
|
id: postData.audit_id,
|
|
|
sdesc: postData.sdesc,
|
|
|
- status: 6,
|
|
|
+ status: audit.flow.auditStatus.backnew,
|
|
|
sin_time: new Date(),
|
|
|
};
|
|
|
await this.transaction.update(this.ctx.service.changeAudit.tableName, audit_update);
|
|
@@ -666,7 +666,7 @@ module.exports = app => {
|
|
|
times: lastauditInfo.times,
|
|
|
usite: lastauditInfo.usite,
|
|
|
usort,
|
|
|
- status: 2,
|
|
|
+ status: audit.flow.auditStatus.checking,
|
|
|
};
|
|
|
await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit1);
|
|
|
usort++;
|
|
@@ -681,7 +681,7 @@ module.exports = app => {
|
|
|
times: auditInfo.times,
|
|
|
usite: auditInfo.usite,
|
|
|
usort,
|
|
|
- status: 1,
|
|
|
+ status: audit.flow.auditStatus.uncheck,
|
|
|
};
|
|
|
await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit2);
|
|
|
|
|
@@ -709,7 +709,7 @@ module.exports = app => {
|
|
|
// 设置变更令退回
|
|
|
const change_update = {
|
|
|
w_code: postData.w_code,
|
|
|
- status: 6,
|
|
|
+ status: audit.flow.status.backnew,
|
|
|
cin_time: Date.parse(new Date()) / 1000,
|
|
|
};
|
|
|
const options = {
|
|
@@ -858,6 +858,102 @@ module.exports = app => {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新审批变更令
|
|
|
+ * @param { string } cid - 查询的清单
|
|
|
+ * @return {Promise<*>} - 可用的变更令列表
|
|
|
+ */
|
|
|
+ async checkAgain(cid) {
|
|
|
+ // 初始化事务
|
|
|
+ this.transaction = await this.db.beginTransaction();
|
|
|
+ let result = false;
|
|
|
+ try {
|
|
|
+ const changeInfo = await this.getDataByCondition({ cid });
|
|
|
+
|
|
|
+ // 获取终审
|
|
|
+ const auditInfo = (await this.ctx.service.changeAudit.getAllDataByCondition({ where: { cid }, orders: [['usort', 'desc']], limit: 1, offset: 0 }))[0];
|
|
|
+ let usort = auditInfo.usort + 1;
|
|
|
+
|
|
|
+ // 新增2个审批状态到审批列表中
|
|
|
+ const insert_audit1 = {
|
|
|
+ tid: auditInfo.tid,
|
|
|
+ cid: auditInfo.cid,
|
|
|
+ uid: auditInfo.uid,
|
|
|
+ name: auditInfo.name,
|
|
|
+ jobs: auditInfo.jobs,
|
|
|
+ company: auditInfo.company,
|
|
|
+ times: auditInfo.times,
|
|
|
+ usite: auditInfo.usite,
|
|
|
+ usort,
|
|
|
+ sin_time: new Date(),
|
|
|
+ status: audit.flow.auditStatus.checkAgain,
|
|
|
+ };
|
|
|
+ await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit1);
|
|
|
+ usort++;
|
|
|
+ // 新增2个审批人到审批列表中
|
|
|
+ const insert_audit2 = {
|
|
|
+ tid: auditInfo.tid,
|
|
|
+ cid: auditInfo.cid,
|
|
|
+ uid: auditInfo.uid,
|
|
|
+ name: auditInfo.name,
|
|
|
+ jobs: auditInfo.jobs,
|
|
|
+ company: auditInfo.company,
|
|
|
+ times: auditInfo.times,
|
|
|
+ usite: auditInfo.usite,
|
|
|
+ usort,
|
|
|
+ status: audit.flow.auditStatus.checking,
|
|
|
+ };
|
|
|
+ await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit2);
|
|
|
+
|
|
|
+ // 审批列表数据也要回退
|
|
|
+ let total_price = 0;
|
|
|
+ const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
|
|
|
+ for (const cl of changeList) {
|
|
|
+ const audit_amount = cl.audit_amount.split(',');
|
|
|
+ audit_amount.splice(-1, 1);
|
|
|
+ const list_update = {
|
|
|
+ id: cl.id,
|
|
|
+ audit_amount: audit_amount.join(','),
|
|
|
+ samount: '',
|
|
|
+ };
|
|
|
+ total_price += this.ctx.helper.accMul(cl.unit_price, cl.camount);
|
|
|
+ await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置变更令审批中
|
|
|
+ const change_update = {
|
|
|
+ p_code: null,
|
|
|
+ status: audit.flow.status.checking,
|
|
|
+ cin_time: Date.parse(new Date()) / 1000,
|
|
|
+ sin_time: null,
|
|
|
+ total_price,
|
|
|
+ };
|
|
|
+ const options = {
|
|
|
+ where: {
|
|
|
+ cid: changeInfo.cid,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ await this.transaction.update(this.tableName, change_update, options);
|
|
|
+ await this.transaction.commit();
|
|
|
+ result = true;
|
|
|
+
|
|
|
+ // 添加短信通知-需要审批提醒功能
|
|
|
+ const smsUser = await this.ctx.service.projectAccount.getDataById(auditInfo.uid);
|
|
|
+ if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
+ const smsType = JSON.parse(smsUser.sms_type);
|
|
|
+ if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.approval.toString()) !== -1) {
|
|
|
+ const sms = new SMS(this.ctx);
|
|
|
+ const content = '【纵横计量支付】' + changeInfo.code + '变更需要您审批。';
|
|
|
+ sms.send(smsUser.auth_mobile, content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ await this.transaction.rollback();
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
return Change;
|
|
|
};
|