|
@@ -208,12 +208,84 @@ module.exports = app => {
|
|
|
} else if (data.bills) {
|
|
|
responseData.data.curStageData = await ctx.service.stageBills.updateStageData(data.bills);
|
|
|
}
|
|
|
+ await this.ctx.service.stage.updateCheckDetailFlag(ctx.stage.id, true);
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 查询可用变更令 (Ajax-Post)
|
|
|
+ * @param ctx
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async searchValidChange(ctx) {
|
|
|
+ try {
|
|
|
+ // if (ctx.stage.readOnly) {
|
|
|
+ // throw '您无权调用变更令';
|
|
|
+ // }
|
|
|
+
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (!data.bills && !data.pos) {
|
|
|
+ throw '数据错误';
|
|
|
+ }
|
|
|
+ const bills = data.bills ? data.bills : await ctx.service.ledger.getDataById(data.pos.lid);
|
|
|
+ const pos = data.pos;
|
|
|
+ const changes = await ctx.service.change.getValidChanges(ctx.tender.id, bills);
|
|
|
+ const useChanges = await ctx.service.stageChange.getLastestStageData(ctx.tender.id, ctx.stage.id, bills.id, pos ? pos.id : -1);
|
|
|
+ ctx.body = {err: 0, msg: '', data: {changes, useChanges}};
|
|
|
+ } catch(err) {
|
|
|
+ this.log(err);
|
|
|
+ ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 调用变更令 (Ajax-Post)
|
|
|
+ * @param ctx
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async useChange(ctx) {
|
|
|
+ try {
|
|
|
+ if (ctx.stage.readOnly) {
|
|
|
+ throw '您无权使用变更令';
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (!data.target || (!data.target.bills && !data.target.pos) || !data.change) {
|
|
|
+ throw '调用变更令数据错误'
|
|
|
+ }
|
|
|
+ let result;
|
|
|
+ if (data.target.bills) {
|
|
|
+ result = await ctx.service.stageChange.billsChange(data.target.bills, data.change);
|
|
|
+ } else {
|
|
|
+ result = await ctx.service.stageChange.posChange(data.target.pos, data.change);
|
|
|
+ }
|
|
|
+ await this.ctx.service.stage.updateCheckDetailFlag(ctx.stage.id, true);
|
|
|
+ ctx.body = {err: 0, msg: '', data: result};
|
|
|
+ } catch(err) {
|
|
|
+ this.log(err);
|
|
|
+ ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查询变更令 明细数据(包括附件、变更清单、累计使用情况、本期使用情况) (Ajax-Post)
|
|
|
+ * @param ctx
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async changeDetail(ctx) {
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (!data.cid) {
|
|
|
+ throw '查询数据错误';
|
|
|
+ }
|
|
|
+ const detailData = await this._getChangeDetailData(ctx.tender.id, ctx.stage.id, data.cid);
|
|
|
+ ctx.body = {err: 0, msg: '', data: detailData};
|
|
|
+ } catch(err) {
|
|
|
+ this.log(err);
|
|
|
+ ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 中间计量 (Get)
|
|
@@ -398,6 +470,36 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 中间计量 -- 完成中间计量(Post)
|
|
|
+ * @param ctx
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async doneDetail(ctx) {
|
|
|
+ try {
|
|
|
+ await ctx.service.stage.updateCheckDetailFlag(ctx.stage.id, false);
|
|
|
+ ctx.stage.check_detail = false;
|
|
|
+ ctx.redirect(ctx.request.header.referer);
|
|
|
+ } catch (err) {
|
|
|
+ ctx.redirect(ctx.request.header.referer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 中间计量 -- 解锁编辑(Post)
|
|
|
+ * @param ctx
|
|
|
+ * @returns {Promise<void>}
|
|
|
+ */
|
|
|
+ async unlockDetail(ctx) {
|
|
|
+ try {
|
|
|
+ await ctx.service.stage.updateCheckDetailFlag(ctx.stage.id, true);
|
|
|
+ ctx.stage.check_detail = true;
|
|
|
+ ctx.redirect(ctx.request.header.referer);
|
|
|
+ } catch (err) {
|
|
|
+ ctx.redirect(ctx.request.header.referer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 合同支付 (Get)
|
|
|
* @param ctx
|
|
|
* @returns {Promise<void>}
|
|
@@ -592,77 +694,6 @@ module.exports = app => {
|
|
|
ctx.redirect('/tender/' + ctx.tender.id + '/measure/stage');
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 查询可用变更令 (Ajax-Post)
|
|
|
- * @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async searchValidChange(ctx) {
|
|
|
- try {
|
|
|
- // if (ctx.stage.readOnly) {
|
|
|
- // throw '您无权调用变更令';
|
|
|
- // }
|
|
|
-
|
|
|
- const data = JSON.parse(ctx.request.body.data);
|
|
|
- if (!data.bills && !data.pos) {
|
|
|
- throw '数据错误';
|
|
|
- }
|
|
|
- const bills = data.bills ? data.bills : await ctx.service.ledger.getDataById(data.pos.lid);
|
|
|
- const pos = data.pos;
|
|
|
- const changes = await ctx.service.change.getValidChanges(ctx.tender.id, bills);
|
|
|
- const useChanges = await ctx.service.stageChange.getLastestStageData(ctx.tender.id, ctx.stage.id, bills.id, pos ? pos.id : -1);
|
|
|
- ctx.body = {err: 0, msg: '', data: {changes, useChanges}};
|
|
|
- } catch(err) {
|
|
|
- this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 调用变更令 (Ajax-Post)
|
|
|
- * @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async useChange(ctx) {
|
|
|
- try {
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '您无权使用变更令';
|
|
|
- }
|
|
|
-
|
|
|
- const data = JSON.parse(ctx.request.body.data);
|
|
|
- if (!data.target || (!data.target.bills && !data.target.pos) || !data.change) {
|
|
|
- throw '调用变更令数据错误'
|
|
|
- }
|
|
|
- let result;
|
|
|
- if (data.target.bills) {
|
|
|
- result = await ctx.service.stageChange.billsChange(data.target.bills, data.change);
|
|
|
- } else {
|
|
|
- result = await ctx.service.stageChange.posChange(data.target.pos, data.change);
|
|
|
- }
|
|
|
- ctx.body = {err: 0, msg: '', data: result};
|
|
|
- } catch(err) {
|
|
|
- this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 查询变更令 明细数据(包括附件、变更清单、累计使用情况、本期使用情况) (Ajax-Post)
|
|
|
- * @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async changeDetail(ctx) {
|
|
|
- try {
|
|
|
- const data = JSON.parse(ctx.request.body.data);
|
|
|
- if (!data.cid) {
|
|
|
- throw '查询数据错误';
|
|
|
- }
|
|
|
- const detailData = await this._getChangeDetailData(ctx.tender.id, ctx.stage.id, data.cid);
|
|
|
- ctx.body = {err: 0, msg: '', data: detailData};
|
|
|
- } catch(err) {
|
|
|
- this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
// 审批相关
|
|
|
/**
|
|
@@ -743,6 +774,9 @@ module.exports = app => {
|
|
|
if (ctx.stage.status === auditConst.status.checking || ctx.stage.status === auditConst.status.checked) {
|
|
|
throw '该期数据当前无法上报';
|
|
|
}
|
|
|
+ if (ctx.stage.check_detail) {
|
|
|
+ throw '上报前,需要完成中间计量。';
|
|
|
+ }
|
|
|
|
|
|
await ctx.service.stageAudit.start(ctx.stage.id, ctx.stage.times);
|
|
|
|
|
@@ -773,6 +807,9 @@ module.exports = app => {
|
|
|
if (!data.checkType || isNaN(data.checkType)) {
|
|
|
throw '提交数据错误';
|
|
|
}
|
|
|
+ if (data.checkType === auditConst.status.checked && ctx.stage.check_detail) {
|
|
|
+ throw '审批通过前,需要完成中间计量。';
|
|
|
+ }
|
|
|
if (data.checkType === auditConst.status.checkNo) {
|
|
|
if (!data.checkType || isNaN(data.checkType)) {
|
|
|
throw '提交数据错误';
|
|
@@ -841,7 +878,7 @@ module.exports = app => {
|
|
|
renderData.dealBills = await ctx.service.dealBills.getAllDataByCondition({ where: {tender_id: this.ctx.tender.id} });
|
|
|
|
|
|
renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.stage.gather);
|
|
|
- await this.layout('stage/gather.ejs', renderData);
|
|
|
+ await this.layout('stage/gather.ejs', renderData, 'stage/gather_modal.ejs');
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.redirect('/tender/' + ctx.tender.id + '/measure/stage/' + ctx.params.order);
|