| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- const auditConst = require('../const/audit').ledger;
- const messageType = require('../const/message_type');
- module.exports = options => {
- /**
- * 标段校验 中间件
- * 1. 读取标段数据(包括属性)
- * 2. 检验用户是否可见标段(不校验具体权限)
- *
- * @param {function} next - 中间件继续执行的方法
- * @return {void}
- */
- return function* uncheckTenderCheck(next) {
- try {
- if (this.tender.data.ledger_status === auditConst.status.uncheck) {
- if (this.tender.data.user_id !== this.session.sessionUser.accountId && !this.session.sessionUser.is_admin && this.tender.advanceAuditorsId.indexOf(this.session.sessionUser.accountId) === -1 && !this.tender.isTourist && !this.tender.assLedger) {
- throw '您无权查看该项目';
- } else if (this.tender.advanceAuditorsId.indexOf(this.session.sessionUser.accountId) !== -1 && !this.session.sessionUser.is_admin && !this.tender.isTourist) {
- throw '您无权查看该内容';
- }
- }
- yield next;
- } catch (err) {
- // 输出错误到日志
- this.log(err);
- if (this.helper.isAjax(this.request)) {
- this.ajaxErrorBody(err, '查看标段数据错误');
- } else {
- this.postError(err, '查看标段数据错误');
- if (this.helper.isWap(this.request)) {
- this.redirect('/wap/subproj');
- } else {
- err === '您无权查看该内容' ? this.redirect(this.request.headers.referer) : this.redirect(`/sp/${this.subProject.id}/list`);
- }
- }
- }
- };
- };
|