|
@@ -65,10 +65,6 @@ module.exports = app => {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
- _stageReadOnly(stage) {
|
|
|
- return stage.status === auditConst.status.checked;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取SpreadSetting
|
|
|
* @private
|
|
@@ -101,7 +97,7 @@ module.exports = app => {
|
|
|
removeFieldCols(ledger, spreadConst.filterCols.stageDgnCols);
|
|
|
}
|
|
|
const pos = JSON.parse(JSON.stringify(stageSetting.pos));
|
|
|
- if (this.ctx.stage.readOnly) {
|
|
|
+ if (this.ctx.stage.readOnly || this.ctx.stage.revising) {
|
|
|
ledger.readOnly = true;
|
|
|
pos.readOnly = true;
|
|
|
}
|
|
@@ -130,6 +126,16 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ _checkStageCanModify(ctx) {
|
|
|
+ // 检查登录用户,是否可操作
|
|
|
+ if (ctx.stage.readOnly) {
|
|
|
+ throw '该计量期当前您无权操作';
|
|
|
+ }
|
|
|
+ if (ctx.stage.revising) {
|
|
|
+ throw '台账修订中,请勿修改提交期数据';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 期计量页面 (Get)
|
|
|
* @param {Object} ctx - egg全局变量
|
|
@@ -235,10 +241,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async updateStageData(ctx) {
|
|
|
try {
|
|
|
- // 检查登录用户,是否可操作
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const responseData = { err: 0, msg: '', data: {}, };
|
|
@@ -266,10 +269,6 @@ module.exports = app => {
|
|
|
*/
|
|
|
async searchValidChange(ctx) {
|
|
|
try {
|
|
|
- // if (ctx.stage.readOnly) {
|
|
|
- // throw '您无权调用变更令';
|
|
|
- // }
|
|
|
-
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.bills && !data.pos) {
|
|
|
throw '数据错误';
|
|
@@ -291,9 +290,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async useChange(ctx) {
|
|
|
try {
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '您无权使用变更令';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.target || (!data.target.bills && !data.target.pos) || !data.change) {
|
|
@@ -357,10 +354,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async buildDetailData (ctx) {
|
|
|
try {
|
|
|
- // 检查登录用户,是否可操作
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
await ctx.service.stage.buildDetailData(ctx.tender.id, ctx.stage.order, data);
|
|
@@ -425,10 +419,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async setAdvancedConfig(ctx) {
|
|
|
try {
|
|
|
- // 检查登录用户,是否可操作
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
await ctx.service.stage.update(data, { id: ctx.stage.id });
|
|
@@ -448,10 +439,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async saveDetailData(ctx) {
|
|
|
try {
|
|
|
- // 检查登录用户,是否可操作
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const responseData = { err: 0, msg: '', data: {}, };
|
|
@@ -475,9 +463,8 @@ module.exports = app => {
|
|
|
*/
|
|
|
async addCalcImage(ctx) {
|
|
|
try {
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
const stream = await ctx.getFileStream();
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
@@ -498,10 +485,8 @@ module.exports = app => {
|
|
|
*/
|
|
|
async mergeCalcImage(ctx) {
|
|
|
try {
|
|
|
- // 检查登录用户,是否可操作
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
|
|
|
if (data.updateType === 'update') {
|
|
@@ -538,6 +523,8 @@ module.exports = app => {
|
|
|
*/
|
|
|
async doneDetail(ctx) {
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
await ctx.service.stage.updateCheckDetailFlag(ctx.stage.id, false);
|
|
|
ctx.stage.check_detail = false;
|
|
|
ctx.body = {err: 0, msg: '', data: false}
|
|
@@ -609,10 +596,7 @@ module.exports = app => {
|
|
|
|| data.minus !== undefined || data.is_yf !== undefined || data.dl_type !== undefined
|
|
|
}
|
|
|
try {
|
|
|
- // 检查登录用户,是否可操作
|
|
|
- if (ctx.stage.readOnly) {
|
|
|
- throw '该计量期当前您无权操作';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const responseData = { err: 0, msg: '', data: {}, };
|
|
@@ -787,11 +771,13 @@ module.exports = app => {
|
|
|
*/
|
|
|
async addAudit(ctx) {
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const id = this.app._.toInteger(data.auditorId);
|
|
|
if (isNaN(id) || id <= 0) {
|
|
|
throw '参数错误';
|
|
|
}
|
|
|
+
|
|
|
// 检查权限等
|
|
|
if (ctx.stage.user_id !== ctx.session.sessionUser.accountId) {
|
|
|
throw '您无权添加审核人';
|
|
@@ -826,6 +812,7 @@ module.exports = app => {
|
|
|
*/
|
|
|
async deleteAudit(ctx) {
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const id = data.auditorId instanceof Number ? data.auditorId : this.app._.toNumber(data.auditorId);
|
|
|
if (isNaN(id) || id <= 0) {
|
|
@@ -850,10 +837,8 @@ module.exports = app => {
|
|
|
*/
|
|
|
async startAudit(ctx) {
|
|
|
try {
|
|
|
- // 检查权限等
|
|
|
- if (!ctx.stage) {
|
|
|
- throw '数据错误';
|
|
|
- }
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
if (ctx.stage.user_id !== ctx.session.sessionUser.accountId) {
|
|
|
throw '您无权上报该期数据';
|
|
|
}
|
|
@@ -880,6 +865,8 @@ module.exports = app => {
|
|
|
*/
|
|
|
async checkAudit(ctx) {
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
if (!this.ctx.stage || (this.ctx.stage.status !== auditConst.status.checking && this.ctx.stage.status !== auditConst.status.checkNoPre)) {
|
|
|
throw '当前期数据有误';
|
|
|
}
|
|
@@ -912,7 +899,6 @@ module.exports = app => {
|
|
|
ctx.redirect(ctx.request.header.referer);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 重新审批
|
|
|
* @param ctx
|
|
@@ -920,6 +906,8 @@ module.exports = app => {
|
|
|
*/
|
|
|
async checkAuditAgain(ctx) {
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
if (ctx.stage.auditors[ctx.stage.auditors.length - 1].aid === ctx.session.sessionUser.accountId && ctx.stage.status === auditConst.status.checked && ctx.stage.order === ctx.stage.highOrder) {
|
|
|
await ctx.service.stageAudit.checkAgain(ctx.stage.id, ctx.stage.times);
|
|
|
console.log('success');
|
|
@@ -1092,6 +1080,8 @@ module.exports = app => {
|
|
|
};
|
|
|
let stream;
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
const parts = ctx.multipart({ autoFields: true });
|
|
|
const files = [];
|
|
|
let index = 0;
|
|
@@ -1200,6 +1190,8 @@ module.exports = app => {
|
|
|
data: '',
|
|
|
};
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const fileInfo = await ctx.service.stageAtt.getDataById(data.id);
|
|
|
if (fileInfo !== undefined && fileInfo !== '') {
|
|
@@ -1238,6 +1230,8 @@ module.exports = app => {
|
|
|
};
|
|
|
let stream;
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
stream = await ctx.getFileStream({ requireFile: false });
|
|
|
let fileData = {};
|
|
|
if (stream.filename !== undefined) {
|
|
@@ -1291,6 +1285,8 @@ module.exports = app => {
|
|
|
};
|
|
|
let stream;
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
const parts = ctx.multipart({ autoFields: true });
|
|
|
const files = [];
|
|
|
let index = 0;
|
|
@@ -1396,6 +1392,8 @@ module.exports = app => {
|
|
|
data: '',
|
|
|
};
|
|
|
try {
|
|
|
+ this._checkStageCanModify(ctx);
|
|
|
+
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const payInfo = await ctx.service.stagePay.getDataById(data.id);
|
|
|
if (payInfo !== undefined) {
|