|
@@ -19,6 +19,7 @@ const loadExcelType = {
|
|
|
};
|
|
|
const loadType = loadExcelType.display;
|
|
|
const auditConst = require('../const/audit').ledger;
|
|
|
+const permissionConst = require('../const/account_permission');
|
|
|
|
|
|
module.exports = app => {
|
|
|
class DealBillsController extends app.BaseController {
|
|
@@ -48,6 +49,24 @@ module.exports = app => {
|
|
|
ctx.body = responseData;
|
|
|
}
|
|
|
|
|
|
+ async checkPermisision(ctx) {
|
|
|
+ if (!ctx.tender.data) throw '标段数据错误';
|
|
|
+
|
|
|
+ const tender = ctx.tender.data;
|
|
|
+ const isUser = tender.user_id === this.ctx.session.sessionUser.accountId;
|
|
|
+ const auditors = await this.service.ledgerAudit.getAuditors(tender.id, tender.ledger_times);
|
|
|
+ const auditorsId = this.ctx.helper._.map(auditors, 'audit_id');
|
|
|
+ const isAuditor = auditorsId.indexOf(this.ctx.session.sessionUser.accountId) >= 0;
|
|
|
+ const upPermision = this.ctx.session.sessionUser.permission
|
|
|
+ ? this.ctx.session.sessionUser.permission.tender.indexOf('3') >= 0
|
|
|
+ : false;
|
|
|
+ if (((tender.ledger_status === auditConst.status.uncheck || tender.ledger_status === auditConst.status) && !isUser) ||
|
|
|
+ (tender.ledger_status === auditConst.status.checking && !isAuditor) ||
|
|
|
+ !(tender.ledger_status === auditConst.status.checked && isAuditor && upPermision)) {
|
|
|
+ throw '您无权进行该操作';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导入Excel数据
|
|
|
* @param ctx
|
|
@@ -56,6 +75,7 @@ module.exports = app => {
|
|
|
async loadExcel(ctx) {
|
|
|
let stream;
|
|
|
try {
|
|
|
+ await this.checkPermisision(ctx);
|
|
|
stream = await ctx.getFileStream();
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
@@ -165,10 +185,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async update(ctx) {
|
|
|
try {
|
|
|
- if (!ctx.tender.data) throw '标段数据错误';
|
|
|
- if (ctx.tender.data.user_id !== ctx.session.sessionUser.accountId ||
|
|
|
- (ctx.tender.ledger_status === auditConst.status.checking || ctx.tender.ledger_status === auditConst.status.checked))
|
|
|
- throw '您无权进行该操作';
|
|
|
+ await this.checkPermisision(ctx);
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const result = await ctx.service.dealBills.updateDatas(data);
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|