| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 | 
							- 'use strict';
 
- /**
 
-  *
 
-  *
 
-  * @author Mai
 
-  * @date
 
-  * @version
 
-  */
 
- module.exports = options => {
 
-     /**
 
-      * 标段校验 中间件
 
-      * 1. 读取标段数据(包括属性)
 
-      * 2. 检验用户是否可见标段(不校验具体权限)
 
-      *
 
-      * @param {function} next - 中间件继续执行的方法
 
-      * @return {void}
 
-      */
 
-     return function* budgetCheck(next) {
 
-         try {
 
-             // 读取标段数据
 
-             const id = parseInt(this.params.id);
 
-             if (!id) throw '参数错误';
 
-             this.budget = yield this.service.budget.getCurBudget(id);
 
-             if (!this.budget) throw '项目不存在';
 
-             if (this.session.sessionUser.is_admin) {
 
-                 this.budget.readOnly = false;
 
-             } else {
 
-                 const bp = yield this.service.budgetPermission.getBudgetUserPermission(id);
 
-                 if (!bp) throw '您无权查看该项目';
 
-                 this.budget.readOnly = bp.permission.indexOf(this.service.budgetPermission.PermissionConst.edit.value) < 0;
 
-             }
 
-             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);
 
-             }
 
-         }
 
-     };
 
- };
 
 
  |