|
@@ -32,7 +32,7 @@ module.exports = app => {
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} auditorId - 审核人id
|
|
* @param {Number} auditorId - 审核人id
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async getAuditor(materialId, auditorId, times = 1) {
|
|
async getAuditor(materialId, auditorId, times = 1) {
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
@@ -48,7 +48,7 @@ module.exports = app => {
|
|
*
|
|
*
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async getAuditors(materialId, times = 1) {
|
|
async getAuditors(materialId, times = 1) {
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
|
|
@@ -70,7 +70,7 @@ module.exports = app => {
|
|
*
|
|
*
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async getCurAuditor(materialId, times = 1) {
|
|
async getCurAuditor(materialId, times = 1) {
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
@@ -86,7 +86,7 @@ module.exports = app => {
|
|
*
|
|
*
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<number>}
|
|
|
|
|
|
+ * @return {Promise<number>}
|
|
*/
|
|
*/
|
|
async getNewOrder(materialId, times = 1) {
|
|
async getNewOrder(materialId, times = 1) {
|
|
const sql = 'SELECT Max(??) As max_order FROM ?? Where `mid` = ? and `times` = ?';
|
|
const sql = 'SELECT Max(??) As max_order FROM ?? Where `mid` = ? and `times` = ?';
|
|
@@ -123,7 +123,7 @@ module.exports = app => {
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} auditorId - 审核人id
|
|
* @param {Number} auditorId - 审核人id
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
* @private
|
|
* @private
|
|
*/
|
|
*/
|
|
async _syncOrderByDelete(transaction, materialId, order, times) {
|
|
async _syncOrderByDelete(transaction, materialId, order, times) {
|
|
@@ -406,17 +406,54 @@ module.exports = app => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async _checkNoPre(materialId, checkData, times) {
|
|
|
|
+ const time = new Date();
|
|
|
|
+ // 整理当前流程审核人状态更新
|
|
|
|
+ const audit = await this.getDataByCondition({ mid: materialId, times, status: auditConst.status.checking });
|
|
|
|
+ console.log('audit', audit);
|
|
|
|
+ if (!audit || audit.order <= 1) {
|
|
|
|
+ throw '审核数据错误';
|
|
|
|
+ }
|
|
|
|
+ // 添加重新审批后,不能用order-1,取groupby值里的上一个才对
|
|
|
|
+ const auditors2 = await this.getAuditGroupByList(materialId, times);
|
|
|
|
+ const auditorIndex = await auditors2.findIndex(function(item) {
|
|
|
|
+ return item.aid === audit.aid;
|
|
|
|
+ });
|
|
|
|
+ const preAuditor = auditors2[auditorIndex - 1];
|
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
|
|
|
|
+ const newAuditors = [];
|
|
|
|
+ newAuditors.push({
|
|
|
|
+ tid: audit.tid, mid: audit.mid, aid: preAuditor.aid,
|
|
|
|
+ times: audit.times, order: audit.order + 1, status: auditConst.status.checking,
|
|
|
|
+ begin_time: time,
|
|
|
|
+ });
|
|
|
|
+ newAuditors.push({
|
|
|
|
+ tid: audit.tid, mid: audit.mid, aid: audit.aid,
|
|
|
|
+ times: audit.times, order: audit.order + 2, status: auditConst.status.uncheck,
|
|
|
|
+ });
|
|
|
|
+ await transaction.insert(this.tableName, newAuditors);
|
|
|
|
+ await transaction.commit();
|
|
|
|
+ } catch (error) {
|
|
|
|
+ await transaction.rollback();
|
|
|
|
+ throw error;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 审批
|
|
* 审批
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {auditConst.status.checked|auditConst.status.checkNo} checkType - 审批结果
|
|
* @param {auditConst.status.checked|auditConst.status.checkNo} checkType - 审批结果
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<void>}
|
|
|
|
|
|
+ * @return {Promise<void>}
|
|
*/
|
|
*/
|
|
async check(materialId, checkData, times = 1) {
|
|
async check(materialId, checkData, times = 1) {
|
|
- if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo) {
|
|
|
|
|
|
+ if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo && checkData.checkType !== auditConst.status.checkNoPre) {
|
|
throw '提交数据错误';
|
|
throw '提交数据错误';
|
|
}
|
|
}
|
|
|
|
+ console.log('checkData:', checkData);
|
|
|
|
+ console.log('times', times);
|
|
switch (checkData.checkType) {
|
|
switch (checkData.checkType) {
|
|
case auditConst.status.checked:
|
|
case auditConst.status.checked:
|
|
await this._checked(materialId, checkData, times);
|
|
await this._checked(materialId, checkData, times);
|
|
@@ -424,6 +461,9 @@ module.exports = app => {
|
|
case auditConst.status.checkNo:
|
|
case auditConst.status.checkNo:
|
|
await this._checkNo(materialId, checkData, times);
|
|
await this._checkNo(materialId, checkData, times);
|
|
break;
|
|
break;
|
|
|
|
+ case auditConst.status.checkNoPre:
|
|
|
|
+ await this._checkNoPre(materialId, checkData, times);
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
throw '无效审批操作';
|
|
throw '无效审批操作';
|
|
}
|
|
}
|
|
@@ -433,7 +473,7 @@ module.exports = app => {
|
|
* 审批
|
|
* 审批
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} materialId - 材料调差期id
|
|
* @param {Number} times - 第几次审批
|
|
* @param {Number} times - 第几次审批
|
|
- * @returns {Promise<void>}
|
|
|
|
|
|
+ * @return {Promise<void>}
|
|
*/
|
|
*/
|
|
async checkAgain(materialId, times = 1) {
|
|
async checkAgain(materialId, times = 1) {
|
|
const time = new Date();
|
|
const time = new Date();
|
|
@@ -494,7 +534,7 @@ module.exports = app => {
|
|
* 获取审核人需要审核的期列表
|
|
* 获取审核人需要审核的期列表
|
|
*
|
|
*
|
|
* @param auditorId
|
|
* @param auditorId
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async getAuditMaterial(auditorId) {
|
|
async getAuditMaterial(auditorId) {
|
|
const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`mid`,' +
|
|
const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`mid`,' +
|
|
@@ -512,7 +552,7 @@ module.exports = app => {
|
|
* @param {Number} pid - 查询标段
|
|
* @param {Number} pid - 查询标段
|
|
* @param {Number} uid - 查询人
|
|
* @param {Number} uid - 查询人
|
|
* @param {Date} time - 查询时间
|
|
* @param {Date} time - 查询时间
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async getNoticeMaterial(pid, uid, time) {
|
|
async getNoticeMaterial(pid, uid, time) {
|
|
const sql = 'SELECT * FROM (SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
|
|
const sql = 'SELECT * FROM (SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
|
|
@@ -535,7 +575,7 @@ module.exports = app => {
|
|
* 获取审核人流程列表
|
|
* 获取审核人流程列表
|
|
*
|
|
*
|
|
* @param auditorId
|
|
* @param auditorId
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async getAuditGroupByList(materialId, times) {
|
|
async getAuditGroupByList(materialId, times) {
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`mid`, la.`aid`, la.`order` ' +
|
|
const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`mid`, la.`aid`, la.`order` ' +
|
|
@@ -551,7 +591,7 @@ module.exports = app => {
|
|
* @param transaction - 新增一期的事务
|
|
* @param transaction - 新增一期的事务
|
|
* @param {Object} preMaterial - 上一期
|
|
* @param {Object} preMaterial - 上一期
|
|
* @param {Object} newaMaterial - 最新一期
|
|
* @param {Object} newaMaterial - 最新一期
|
|
- * @returns {Promise<*>}
|
|
|
|
|
|
+ * @return {Promise<*>}
|
|
*/
|
|
*/
|
|
async copyPreMaterialAuditors(transaction, preMaterial, newMaterial) {
|
|
async copyPreMaterialAuditors(transaction, preMaterial, newMaterial) {
|
|
const auditors = await this.getAuditGroupByList(preMaterial.id, preMaterial.times);
|
|
const auditors = await this.getAuditGroupByList(preMaterial.id, preMaterial.times);
|