12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- module.exports = options => {
- /**
- * 期校验 中间件
- * 1. 读取期数据
- * 2. 检验用户是否参与期(不校验具体权限)
- *
- * 写入ctx.phasePay数据
- * 其中:
- * phasePay.user: 创建人
- * phasePay.auditors: 审批人列表(退回原报时,加载上一流程)
- * phasePay.curAuditors: 当前审批人(未上报为空,审批通过 or 退回原报时,为空)
- *
- * phasePay.readOnly: 登录人,是否可操作
- * phasePay.curTimes: 当前登录人,操作、查阅数据times
- * phasePay.curOrder: 当前登录人,操作、查阅数据order
- *
- * 该方法为通用方法,如需phasePay其他数据,请在controller中查询
- *
- * @param {function} next - 中间件继续执行的方法
- * @return {void}
- */
- return function* phasePayCheck(next) {
- try {
- // 读取标段数据
- const phaseOrder = parseInt(this.params.order);
- if (phaseOrder <= 0) throw '您访问的合同支付不存在';
- const phasePay = yield this.service.phasePay.getPhasePayByOrder(this.tender.id, phaseOrder);
- if (!phasePay) throw '合同支付数据错误';
- // 读取原报、审核人数据
- yield this.service.phasePay.doCheckPhase(phasePay);
- phasePay.latestOrder = yield this.service.phasePay.count({ tid: this.tender.id });
- phasePay.isLatest = phasePay.latestOrder === phasePay.phase_order;
- yield this.service.phasePay.checkShenpi(phasePay);
- this.phasePay = phasePay;
- yield next;
- } catch (err) {
- this.log(err);
- if (this.helper.isAjax(this.request)) {
- this.ajaxErrorBody(err, '读取合同支付错误');
- } else {
- this.postError(err, '读取合同支付错误');
- this.redirect(this.request.headers.referer);
- }
- }
- };
- };
|