| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | 
							- 'use strict';
 
- /**
 
-  *
 
-  *
 
-  * @author Mai
 
-  * @date
 
-  * @version
 
-  */
 
- const auditConst = require('../const/audit').revise;
 
- module.exports = options => {
 
-     /**
 
-      * 标段校验 中间件
 
-      * 1. 读取标段数据(包括属性)
 
-      * 2. 检验用户是否可见标段(不校验具体权限)
 
-      *
 
-      * @param {function} next - 中间件继续执行的方法
 
-      * @return {void}
 
-      */
 
-     return function* reviseCheck(next) {
 
-         try {
 
-             // 获取revise
 
-             const revise = this.params.rid
 
-                 ? yield this.service.ledgerRevise.getRevise(this.tender.id, this.params.rid)
 
-                 : yield this.service.ledgerRevise.getLastestRevise(this.tender.id);
 
-             if (!revise) throw '台账修订数据有误';
 
-             // 修订前后,历史台账
 
-             revise.preHis = revise.pre_his_id ? yield this.service.ledgerHistory.getDataById(revise.pre_his_id) : null;
 
-             revise.curHis = revise.his_id ? yield this.service.ledgerHistory.getDataById(revise.his_id) : null;
 
-             revise.reviseUsers = [revise.uid];
 
-             if (revise.status !== auditConst.status.uncheck) {
 
-                 const times = revise.status === auditConst.status.checkNo ? revise.times - 1 : revise.times;
 
-                 const auditors = yield this.service.reviseAudit.getAuditors(revise.id, times);
 
-                 const auditorsId = this.helper._.map(auditors, 'audit_id');
 
-                 revise.reviseUsers.push(...auditorsId);
 
-             }
 
-             revise.readOnly = revise.uid !== this.session.sessionUser.accountId ||
 
-                 revise.status === auditConst.status.checking || revise.status === auditConst.status.checked;
 
-             revise.priceCount = yield this.service.revisePrice.count({ rid: revise.id });
 
-             this.revise = revise;
 
-             yield next;
 
-         } catch (err) {
 
-             // 输出错误到日志
 
-             if (err.stack) {
 
-                 this.logger.error(err);
 
-             } else {
 
-                 this.getLogger('fail').info(JSON.stringify({
 
-                     error: err,
 
-                     project: this.session.sessionProject,
 
-                     user: this.session.sessionUser,
 
-                     body: this.session.body,
 
-                 }));
 
-             }
 
-             // 重定向值标段管理
 
-             if (this.helper.isAjax(this.request)) {
 
-                 if (err.stack) {
 
-                     this.body = {err: 4, msg: '标段数据未知错误', data: null};
 
-                 } else {
 
-                     this.body = {err: 3, msg: err.toString(), data: null};
 
-                 }
 
-             } else {
 
-                 if (this.helper.isWap(this.request)) {
 
-                     this.redirect('/wap/list');
 
-                 } else {
 
-                     err === '您无权查看该内容' ? this.redirect(this.request.headers.referer) : this.redirect('/list');
 
-                 }
 
-             }
 
-         }
 
-     };
 
- };
 
 
  |