|
@@ -37,6 +37,7 @@ module.exports = app => {
|
|
|
ctx.showProject = true;
|
|
|
ctx.showTender = true;
|
|
|
ctx.showTitle = true;
|
|
|
+ ctx.reUploadPermission = false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1197,6 +1198,32 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 检测当前期当用用户是否在审核列表中,如果是的话运行再次上传附件
|
|
|
+ * @param {Object} ctx 上下文
|
|
|
+ */
|
|
|
+ _checkStageCanModifyRe(ctx) {
|
|
|
+ // 检查登录用户,是否可操作
|
|
|
+ if (ctx.stage.readOnly) {
|
|
|
+ if (ctx.stage.status === auditConst.status.checked) {
|
|
|
+ // 当前期状态为完成,且提交人是审核列表中的则可再次上传
|
|
|
+ console.log('当前期审核通过!');
|
|
|
+ if (ctx.stage.auditors.findIndex(auditor => auditor.aid === ctx.session.sessionUser.accountId) !== -1) {
|
|
|
+ console.log('当前用户拥有上传权限!');
|
|
|
+ // 再次上传的图片要给个标识,方便给前端进行编辑操作
|
|
|
+ ctx.reUploadPermission = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ throw '该计量期当前您无权操作';
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw '该计量期当前您无权操作';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ctx.stage.revising) {
|
|
|
+ throw '台账修订中,请勿修改提交期数据';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 上传附件
|
|
|
* @param {Object} ctx - egg全局变量
|
|
|
* @return {void}
|
|
@@ -1209,7 +1236,7 @@ module.exports = app => {
|
|
|
};
|
|
|
let stream;
|
|
|
try {
|
|
|
- this._checkStageCanModify(ctx);
|
|
|
+ this._checkStageCanModifyRe(ctx);
|
|
|
|
|
|
const parts = ctx.multipart({ autoFields: true });
|
|
|
const files = [];
|
|
@@ -1245,6 +1272,10 @@ module.exports = app => {
|
|
|
filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
|
|
|
filepath: path.join(dirName, fileName),
|
|
|
};
|
|
|
+ if (ctx.reUploadPermission) {
|
|
|
+ console.log('111111111111111');
|
|
|
+ fileData.re_upload = 1;
|
|
|
+ }
|
|
|
const result = await ctx.service.stageAtt.save(parts.field, fileData, ctx.session.sessionUser.accountId);
|
|
|
if (!result) {
|
|
|
throw '导入数据库保存失败';
|
|
@@ -1254,6 +1285,7 @@ module.exports = app => {
|
|
|
files.length !== 0 ? files.unshift(attData) : files.push(attData);
|
|
|
++index;
|
|
|
}
|
|
|
+ console.log('files:', files);
|
|
|
responseData.data = files;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
@@ -1344,7 +1376,7 @@ module.exports = app => {
|
|
|
data: '',
|
|
|
};
|
|
|
try {
|
|
|
- this._checkStageCanModify(ctx);
|
|
|
+ this._checkStageCanModifyRe(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const fileInfo = await ctx.service.stageAtt.getDataById(data.id);
|