|
|
@@ -104,9 +104,11 @@ module.exports = app => {
|
|
|
|
|
|
const stages = await ctx.service.safeStage.getAllStages(ctx.tender.id, 'DESC');
|
|
|
const unCompleteCount = stages.filter(s => { return s.status !== auditConst.common.status.checked; }).length;
|
|
|
- if (unCompleteCount.length > 0) throw `最新一起未审批通过,请审批通过后再新增`;
|
|
|
+ if (unCompleteCount.length > 0) throw '最新一起未审批通过,请审批通过后再新增';
|
|
|
|
|
|
const newStage = await ctx.service.safeStage.add(ctx.tender.id, stage_code, stage_date);
|
|
|
+ const preStgId = stages.length > 0 ? stages[0].id : ''; // 这里排序是DESC,最前的那个是最后的期
|
|
|
+ await ctx.service.roleRptRel.createRoleRelationshipFromOtherBz(ctx.tender.id, '-150', newStage.id, preStgId);
|
|
|
if (!newStage) throw '新增期失败';
|
|
|
ctx.redirect(`/sp/${ctx.subProject.id}/safe/tender/${ctx.tender.id}/stage/${newStage.stage_order}/bills`);
|
|
|
} catch (err) {
|
|
|
@@ -314,7 +316,7 @@ module.exports = app => {
|
|
|
async uploadStageFile(ctx) {
|
|
|
let stream;
|
|
|
try {
|
|
|
- const parts = ctx.multipart({autoFields: true});
|
|
|
+ const parts = ctx.multipart({ autoFields: true });
|
|
|
|
|
|
let index = 0;
|
|
|
const create_time = Date.parse(new Date()) / 1000;
|
|
|
@@ -351,7 +353,7 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
const result = await ctx.service.safeStageFile.addFiles(ctx.safeStage, 'bills', uploadfiles, user);
|
|
|
- ctx.body = {err: 0, msg: '', data: result};
|
|
|
+ ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (error) {
|
|
|
ctx.log(error);
|
|
|
// 失败需要消耗掉stream 以防卡死
|
|
|
@@ -360,12 +362,12 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
async deleteStageFile(ctx) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data && !data.id) throw '缺少参数';
|
|
|
const result = await ctx.service.safeStageFile.delFiles(data.id);
|
|
|
ctx.body = { err: 0, msg: '', data: result };
|
|
|
- } catch(error) {
|
|
|
+ } catch (error) {
|
|
|
ctx.log(error);
|
|
|
ctx.ajaxErrorBody(error, '删除附件失败');
|
|
|
}
|
|
|
@@ -530,7 +532,7 @@ module.exports = app => {
|
|
|
tender.details = await ctx.service.paymentDetail.getAllDataByCondition({ where: { tender_id: tender.id, type: 1 } });
|
|
|
}
|
|
|
ctx.body = { err: 0, msg: '', data: { tenderList, folderList } };
|
|
|
- } catch(err) {
|
|
|
+ } catch (err) {
|
|
|
ctx.log(error);
|
|
|
ctx.ajaxErrorBody(err, '获取安全生产费旧数据失败');
|
|
|
}
|
|
|
@@ -540,8 +542,8 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.tid) throw '参数错误';
|
|
|
await ctx.service.safeStage.copyPaySafeData(data.tid);
|
|
|
- ctx.body = {err: 0, msg: '迁移旧数据成功', data: null };
|
|
|
- } catch(err) {
|
|
|
+ ctx.body = { err: 0, msg: '迁移旧数据成功', data: null };
|
|
|
+ } catch (err) {
|
|
|
ctx.log(err);
|
|
|
ctx.ajaxErrorBody(err, '迁移旧数据失败');
|
|
|
}
|