|
@@ -42,10 +42,10 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 获取通用的renderData(用于layout, Menu, subMenu部分)
|
|
|
* @param ctx
|
|
|
- * @returns {{tender, tenderMenu, auditConst}}
|
|
|
+ * @return {{tender, tenderMenu, auditConst}}
|
|
|
* @private
|
|
|
*/
|
|
|
- async _getDefaultRenderData (ctx) {
|
|
|
+ async _getDefaultRenderData(ctx) {
|
|
|
const data = {
|
|
|
tender: ctx.tender.data,
|
|
|
tenderMenu: JSON.parse(JSON.stringify(this.menu.stageMenu)),
|
|
@@ -74,12 +74,12 @@ module.exports = app => {
|
|
|
_getSpreadSetting() {
|
|
|
const _ = this.app._;
|
|
|
function removeFieldCols(setting, cols) {
|
|
|
- _.remove(setting.cols, function (c) {
|
|
|
+ _.remove(setting.cols, function(c) {
|
|
|
return cols.indexOf(c.field) > -1;
|
|
|
});
|
|
|
}
|
|
|
function setColFormat(cols, field, formatter) {
|
|
|
- const filterCols = cols.filter(function (c) {
|
|
|
+ const filterCols = cols.filter(function(c) {
|
|
|
return c.field.search(field) !== -1;
|
|
|
});
|
|
|
for (const col of filterCols) {
|
|
@@ -88,7 +88,8 @@ module.exports = app => {
|
|
|
}
|
|
|
// const tpFormatter = this.ctx.helper.getNumberFormatter(this.ctx.tender.info.decimal.tp);
|
|
|
// const upFormatter = this.ctx.helper.getNumberFormatter(2);
|
|
|
- const tender = this.ctx.tender, stage = this.ctx.stage;
|
|
|
+ const tender = this.ctx.tender,
|
|
|
+ stage = this.ctx.stage;
|
|
|
const stageSetting = tender.data.measure_type === measureType.tz.value
|
|
|
? spreadConst.stageTz
|
|
|
: (tender.info.display.ledger.clQty ? spreadConst.stageCl : spreadConst.stageNoCl);
|
|
@@ -110,10 +111,10 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 获取审批界面所需的 原报、审批人数据等
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
* @private
|
|
|
*/
|
|
|
- async _getStageAuditViewData (ctx) {
|
|
|
+ async _getStageAuditViewData(ctx) {
|
|
|
const times = ctx.stage.status === auditConst.status.checkNo ? ctx.stage.times - 1 : ctx.stage.times;
|
|
|
ctx.stage.user = await ctx.service.projectAccount.getAccountInfoById(ctx.stage.user_id);
|
|
|
ctx.stage.auditHistory = [];
|
|
@@ -142,7 +143,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 期计量页面 (Get)
|
|
|
* @param {Object} ctx - egg全局变量
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async index(ctx) {
|
|
|
try {
|
|
@@ -198,8 +199,8 @@ module.exports = app => {
|
|
|
const first = groupData[gd][0];
|
|
|
for (let i = 1, iLen = groupData[gd].length; i < iLen; i++) {
|
|
|
const check = groupData[gd][i];
|
|
|
- if (this.ctx.helper._.isMatch({field: check[field], sid: check.sid, order: check.order, times: check.times},
|
|
|
- {field: first[field], sid: first.sid, order: first.order, times: first.times})) {
|
|
|
+ if (this.ctx.helper._.isMatch({ field: check[field], sid: check.sid, order: check.order, times: check.times },
|
|
|
+ { field: first[field], sid: first.sid, order: first.order, times: first.times })) {
|
|
|
surplus.push(groupData[gd][i].id);
|
|
|
}
|
|
|
}
|
|
@@ -212,10 +213,11 @@ module.exports = app => {
|
|
|
const ledgerData = await ctx.service.ledger.getData(ctx.tender.id);
|
|
|
const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
|
|
|
for (const d of dgnData) {
|
|
|
- const l = ctx.app._.find(ledgerData, {id: d.id});
|
|
|
+ const l = ctx.app._.find(ledgerData, { id: d.id });
|
|
|
ctx.app._.assignIn(l, d);
|
|
|
}
|
|
|
- let curStageData, preStageData;
|
|
|
+ let curStageData,
|
|
|
+ preStageData;
|
|
|
// 当前操作人查看最新数据,其他人查看历史数据
|
|
|
if (ctx.stage.readOnly) {
|
|
|
curStageData = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
@@ -229,21 +231,22 @@ module.exports = app => {
|
|
|
// 查询截止上期数据
|
|
|
if (ctx.stage.order > 1) {
|
|
|
preStageData = await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
|
|
|
- //renderData.preStageData = await ctx.service.stageBills.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
|
|
|
+ // renderData.preStageData = await ctx.service.stageBills.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
|
|
|
} else {
|
|
|
preStageData = [];
|
|
|
}
|
|
|
this.ctx.helper.assignRelaData(ledgerData, [
|
|
|
- {data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid',},
|
|
|
- {data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'used'], prefix: 'pre_', relaId: 'lid',}
|
|
|
+ { data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid' },
|
|
|
+ { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'used'], prefix: 'pre_', relaId: 'lid' },
|
|
|
]);
|
|
|
return ledgerData;
|
|
|
}
|
|
|
async _getStagePosData(ctx) {
|
|
|
- let curStageData, preStageData;
|
|
|
- const posData = await ctx.service.pos.getPosDataWithAddStageOrder({tid: ctx.tender.id});
|
|
|
+ let curStageData,
|
|
|
+ preStageData;
|
|
|
+ const posData = await ctx.service.pos.getPosDataWithAddStageOrder({ tid: ctx.tender.id });
|
|
|
// 根据当前人,或指定对象查询数据
|
|
|
- //console.time('cur');
|
|
|
+ // console.time('cur');
|
|
|
if (ctx.stage.readOnly) {
|
|
|
curStageData = await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id,
|
|
|
ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
@@ -255,38 +258,38 @@ module.exports = app => {
|
|
|
await ctx.service.stagePos.deleteById(surplus);
|
|
|
}
|
|
|
}
|
|
|
- //console.timeEnd('cur');
|
|
|
+ // console.timeEnd('cur');
|
|
|
// 查询截止上期数据
|
|
|
- //console.time('pre');
|
|
|
+ // console.time('pre');
|
|
|
if (ctx.stage.order > 1) {
|
|
|
preStageData = await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
|
|
|
- //responseData.data.preStageData = await ctx.service.stagePos.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
|
|
|
+ // responseData.data.preStageData = await ctx.service.stagePos.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
|
|
|
} else {
|
|
|
preStageData = [];
|
|
|
}
|
|
|
- //console.timeEnd('pre');
|
|
|
- //console.time('assign');
|
|
|
- //console.log('cur: ' + curStageData.length);
|
|
|
- //console.log('pre: ' + preStageData.length);
|
|
|
+ // console.timeEnd('pre');
|
|
|
+ // console.time('assign');
|
|
|
+ // console.log('cur: ' + curStageData.length);
|
|
|
+ // console.log('pre: ' + preStageData.length);
|
|
|
this.ctx.helper.assignRelaData(posData, [
|
|
|
- {data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'postil'], prefix: '', relaId: 'pid'},
|
|
|
- {data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
|
|
|
+ { data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'postil'], prefix: '', relaId: 'pid' },
|
|
|
+ { data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
|
|
|
]);
|
|
|
return posData;
|
|
|
}
|
|
|
async _getStageDetailData(ctx) {
|
|
|
if (ctx.stage.readOnly) {
|
|
|
return await ctx.service.stageDetail.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
|
- } else {
|
|
|
- return await ctx.service.stageDetail.getLastestStageData(ctx.tender.id, ctx.stage.id);
|
|
|
}
|
|
|
+ return await ctx.service.stageDetail.getLastestStageData(ctx.tender.id, ctx.stage.id);
|
|
|
+
|
|
|
}
|
|
|
async _getStageChangeData(ctx) {
|
|
|
if (ctx.stage.readOnly) {
|
|
|
return await ctx.service.stageChange.getAuditorAllStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
|
- } else {
|
|
|
- return await ctx.service.stageChange.getLastestAllStageData(ctx.tender.id, ctx.stage.id);
|
|
|
}
|
|
|
+ return await ctx.service.stageChange.getLastestAllStageData(ctx.tender.id, ctx.stage.id);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
async getStageData(ctx) {
|
|
@@ -310,7 +313,7 @@ module.exports = app => {
|
|
|
break;
|
|
|
case 'dealBills':
|
|
|
responseData.data.dealBills = await ctx.service.dealBills.getAllDataByCondition({
|
|
|
- where: {tender_id: this.ctx.tender.id}
|
|
|
+ where: { tender_id: this.ctx.tender.id },
|
|
|
});
|
|
|
break;
|
|
|
}
|
|
@@ -319,7 +322,7 @@ module.exports = app => {
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -328,7 +331,7 @@ module.exports = app => {
|
|
|
const ledgerData = await this._getStageLedgerData(ctx);
|
|
|
const posData = await this._getStagePosData(ctx);
|
|
|
const data = ctx.helper.checkBillsWithPos(ledgerData, posData, ['contract_qty', 'qc_qty']);
|
|
|
- ctx.body = { err: 0, msg: '', data: data };
|
|
|
+ ctx.body = { err: 0, msg: '', data };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.body = this.ajaxErrorBody(err, '检查数据错误');
|
|
@@ -338,18 +341,19 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 获取期数据(截止上期 & 本期) (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async getStagePosData(ctx) {
|
|
|
try {
|
|
|
const condition = JSON.parse(ctx.request.body.data) || {};
|
|
|
condition.tid = ctx.tender.id;
|
|
|
- const responseData = {err: 0, msg: '', data: {}};
|
|
|
+ const responseData = { err: 0, msg: '', data: {} };
|
|
|
|
|
|
- let curStageData, preStageData;
|
|
|
+ let curStageData,
|
|
|
+ preStageData;
|
|
|
responseData.data = await ctx.service.pos.getPosDataWithAddStageOrder(condition);
|
|
|
// 根据当前人,或指定对象查询数据
|
|
|
- //console.time('cur');
|
|
|
+ // console.time('cur');
|
|
|
const curWhere = JSON.parse(ctx.request.body.data);
|
|
|
if (ctx.stage.readOnly) {
|
|
|
curStageData = await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id,
|
|
@@ -357,42 +361,42 @@ module.exports = app => {
|
|
|
} else {
|
|
|
curStageData = await ctx.service.stagePos.getLastestStageData2(ctx.tender.id, ctx.stage.id, curWhere);
|
|
|
}
|
|
|
- //console.timeEnd('cur');
|
|
|
+ // console.timeEnd('cur');
|
|
|
// 查询截止上期数据
|
|
|
- //console.time('pre');
|
|
|
+ // console.time('pre');
|
|
|
if (ctx.stage.order > 1) {
|
|
|
preStageData = await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1);
|
|
|
- //responseData.data.preStageData = await ctx.service.stagePos.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
|
|
|
+ // responseData.data.preStageData = await ctx.service.stagePos.getEndStageData(ctx.tender.id, ctx.stage.order - 1);
|
|
|
} else {
|
|
|
preStageData = [];
|
|
|
}
|
|
|
- //console.timeEnd('pre');
|
|
|
- //console.time('assign');
|
|
|
- //console.log('cur: ' + curStageData.length);
|
|
|
- //console.log('pre: ' + preStageData.length);
|
|
|
+ // console.timeEnd('pre');
|
|
|
+ // console.time('assign');
|
|
|
+ // console.log('cur: ' + curStageData.length);
|
|
|
+ // console.log('pre: ' + preStageData.length);
|
|
|
this.ctx.helper.assignRelaData(responseData.data, [
|
|
|
- {data: curStageData, fields: ['contract_qty', 'qc_qty', 'postil'], prefix: '', relaId: 'pid'},
|
|
|
- {data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
|
|
|
+ { data: curStageData, fields: ['contract_qty', 'qc_qty', 'postil'], prefix: '', relaId: 'pid' },
|
|
|
+ { data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
|
|
|
]);
|
|
|
- //console.timeEnd('assign');
|
|
|
+ // console.timeEnd('assign');
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存数据 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async updateStageData(ctx) {
|
|
|
try {
|
|
|
this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
- const responseData = { err: 0, msg: '', data: {}, };
|
|
|
+ const responseData = { err: 0, msg: '', data: {} };
|
|
|
if (data.pos) {
|
|
|
responseData.data = await ctx.service.stagePos.updateStageData(data.pos);
|
|
|
} else if (data.bills) {
|
|
@@ -416,13 +420,13 @@ module.exports = app => {
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 查询可用变更令 (Ajax-Post)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async searchValidChange(ctx) {
|
|
|
try {
|
|
@@ -434,16 +438,16 @@ module.exports = app => {
|
|
|
const pos = data.pos;
|
|
|
const changes = await ctx.service.change.getValidChanges(ctx.tender.id, bills);
|
|
|
const useChanges = await ctx.service.stageChange.getLastestStageData(ctx.tender.id, ctx.stage.id, bills.id, pos ? pos.id : -1);
|
|
|
- ctx.body = {err: 0, msg: '', data: {changes, useChanges}};
|
|
|
- } catch(err) {
|
|
|
+ ctx.body = { err: 0, msg: '', data: { changes, useChanges } };
|
|
|
+ } catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 调用变更令 (Ajax-Post)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async useChange(ctx) {
|
|
|
try {
|
|
@@ -451,12 +455,12 @@ module.exports = app => {
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
if (!data.target || (!data.target.bills && !data.target.pos) || !data.change) {
|
|
|
- throw '调用变更令数据错误'
|
|
|
+ throw '调用变更令数据错误';
|
|
|
}
|
|
|
let result;
|
|
|
if (data.target.pos) {
|
|
|
result = await ctx.service.stageChange.posChange(data.target.pos, data.change);
|
|
|
- result.change = { target: {lid: data.target.pos.lid, pid: data.target.pos.id } };
|
|
|
+ result.change = { target: { lid: data.target.pos.lid, pid: data.target.pos.id } };
|
|
|
result.change.data = await ctx.service.stageChange.getLastestStageData(ctx.tender.id,
|
|
|
ctx.stage.id, data.target.pos.lid, data.target.pos.id);
|
|
|
} else {
|
|
@@ -467,16 +471,16 @@ module.exports = app => {
|
|
|
}
|
|
|
await ctx.service.stage.updateCheckCalcFlag(ctx.stage, true);
|
|
|
await ctx.service.stage.updateCacheTime(ctx.stage.id);
|
|
|
- ctx.body = {err: 0, msg: '', data: result};
|
|
|
- } catch(err) {
|
|
|
+ ctx.body = { err: 0, msg: '', data: result };
|
|
|
+ } catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 查询变更令 明细数据(包括附件、变更清单、累计使用情况、本期使用情况) (Ajax-Post)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async changeDetail(ctx) {
|
|
|
try {
|
|
@@ -485,17 +489,17 @@ module.exports = app => {
|
|
|
throw '查询数据错误';
|
|
|
}
|
|
|
const detailData = await this._getChangeDetailData(ctx.tender.id, ctx.stage.id, data.cid);
|
|
|
- ctx.body = {err: 0, msg: '', data: detailData};
|
|
|
- } catch(err) {
|
|
|
+ ctx.body = { err: 0, msg: '', data: detailData };
|
|
|
+ } catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 中间计量 (Get)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async detail(ctx) {
|
|
|
try {
|
|
@@ -513,9 +517,9 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 设置中间计量生成规则,并生成中间计量数据 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
- async buildDetailData (ctx) {
|
|
|
+ async buildDetailData(ctx) {
|
|
|
try {
|
|
|
this._checkStageCanModify(ctx);
|
|
|
|
|
@@ -523,17 +527,17 @@ module.exports = app => {
|
|
|
await ctx.service.stage.buildDetailData(ctx.tender.id, ctx.stage.order, data);
|
|
|
await ctx.service.stage.updateCacheTime(ctx.stage.id);
|
|
|
|
|
|
- ctx.body = {err: 0, msg: '', data: null};
|
|
|
+ ctx.body = { err: 0, msg: '', data: null };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加载数据 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async loadDetailRelaData(ctx) {
|
|
|
try {
|
|
@@ -541,28 +545,28 @@ module.exports = app => {
|
|
|
// 加载台账数据
|
|
|
if (data.loadType === 'ledger') {
|
|
|
const ledgerData = await ctx.service.ledger.getData(ctx.tender.id);
|
|
|
- ctx.body = {err: 0, msg: '', data: ledgerData };
|
|
|
+ ctx.body = { err: 0, msg: '', data: ledgerData };
|
|
|
} else if (data.loadType === 'all') {
|
|
|
const result = {};
|
|
|
result.ledger = await ctx.service.ledger.getData(ctx.tender.id);
|
|
|
- result.pos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
|
|
|
+ result.pos = await ctx.service.pos.getPosData({ tid: ctx.tender.id });
|
|
|
if (ctx.stage.readOnly) {
|
|
|
const curStage = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
|
this.ctx.helper.assignRelaData(result.ledger, [
|
|
|
- {data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid'}
|
|
|
+ { data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
const curPosStage = await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
|
|
|
this.ctx.helper.assignRelaData(result.pos, [
|
|
|
- {data: curPosStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid'}
|
|
|
+ { data: curPosStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid' },
|
|
|
]);
|
|
|
} else {
|
|
|
const curStage = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, ctx.stage.id);
|
|
|
this.ctx.helper.assignRelaData(result.ledger, [
|
|
|
- {data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid'}
|
|
|
+ { data: curStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
const curPosStage = await ctx.service.stagePos.getLastestStageData2(ctx.tender.id, ctx.stage.id);
|
|
|
this.ctx.helper.assignRelaData(result.pos, [
|
|
|
- {data: curPosStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid'}
|
|
|
+ { data: curPosStage, fields: ['contract_qty', 'qc_qty'], prefix: '', relaId: 'pid' },
|
|
|
]);
|
|
|
}
|
|
|
result.stageDetail = await this._getStageDetailData(ctx);
|
|
@@ -578,7 +582,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 中间计量,生成规则,高级设置 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async setAdvancedConfig(ctx) {
|
|
|
try {
|
|
@@ -588,24 +592,24 @@ module.exports = app => {
|
|
|
await ctx.service.stage.update(data, { id: ctx.stage.id });
|
|
|
await ctx.service.stage.updateCacheTime(ctx.stage.id);
|
|
|
|
|
|
- ctx.body = {err: 0, msg: '', data: this.ctx.stage};
|
|
|
+ ctx.body = { err: 0, msg: '', data: this.ctx.stage };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 中间计量,编辑中间计量数据(Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async saveDetailData(ctx) {
|
|
|
try {
|
|
|
this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
- const responseData = { err: 0, msg: '', data: {}, };
|
|
|
+ const responseData = { err: 0, msg: '', data: {} };
|
|
|
if (data instanceof Array) {
|
|
|
responseData.data = await ctx.service.stageDetail.saveDetailDatas(data);
|
|
|
} else {
|
|
@@ -615,14 +619,14 @@ module.exports = app => {
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 中间计量,添加草图,上传图片 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async addCalcImage(ctx) {
|
|
|
try {
|
|
@@ -633,17 +637,17 @@ module.exports = app => {
|
|
|
const fileInfo = path.parse(stream.filename);
|
|
|
const fileName = path.join('public/upload', this.ctx.tender.id.toString(), 'im', 'calcImg_' + create_time + fileInfo.ext);
|
|
|
await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, 'app', fileName));
|
|
|
- ctx.body = {err: 0, msg: '', data: fileName};
|
|
|
- } catch(err) {
|
|
|
+ ctx.body = { err: 0, msg: '', data: fileName };
|
|
|
+ } catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 中间计量,设置草图 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async mergeCalcImage(ctx) {
|
|
|
try {
|
|
@@ -665,16 +669,17 @@ module.exports = app => {
|
|
|
} else if (data.updateType === 'clear') {
|
|
|
data.calc_img = null;
|
|
|
data.calc_img_org = null;
|
|
|
+ data.calc_img_remark = null;
|
|
|
delete data.updateType;
|
|
|
}
|
|
|
await this.ctx.service.stageDetail.saveDetailData(data);
|
|
|
const imData = await ctx.service.stageDetail.getLastestImStageData(this.ctx.tender.id, this.ctx.stage.id, data.lid, data.uuid);
|
|
|
await ctx.service.stage.updateCacheTime(ctx.stage.id);
|
|
|
- const responseData = {err: 0, msg: '', data: imData};
|
|
|
+ const responseData = { err: 0, msg: '', data: imData };
|
|
|
ctx.body = responseData;
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -683,14 +688,14 @@ module.exports = app => {
|
|
|
check_calc: false,
|
|
|
contract_tp: payCalculator.cur.contract_tp, qc_tp: payCalculator.cur.qc_tp,
|
|
|
yf_tp: payCalculator.yf.tp,
|
|
|
- sf_tp: payCalculator.sf.tp
|
|
|
- }, {id: ctx.stage.id});
|
|
|
+ sf_tp: payCalculator.sf.tp,
|
|
|
+ }, { id: ctx.stage.id });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 合同支付 (Get)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async pay(ctx) {
|
|
|
try {
|
|
@@ -716,7 +721,7 @@ module.exports = app => {
|
|
|
renderData.pre = await ctx.service.stageBillsFinal.getSumTotalPrice(ctx.stage.tid, ctx.stage.order - 1);
|
|
|
renderData.pre.gather_tp = ctx.helper.add(renderData.pre.contract_tp, renderData.pre.qc_tp);
|
|
|
} else {
|
|
|
- renderData.pre = {contract_tp: null, qc_tp: null, gather_tp: null};
|
|
|
+ renderData.pre = { contract_tp: null, qc_tp: null, gather_tp: null };
|
|
|
}
|
|
|
|
|
|
// 用户有无权限上传和删除附件
|
|
@@ -740,19 +745,19 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 合同支付 - 编辑合同支付项 (Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async savePayData(ctx) {
|
|
|
function checkCalcField(data) {
|
|
|
return data.sexpr !== undefined || data.sprice !== undefined
|
|
|
|| data.rexpr !== undefined || data.rprice !== undefined
|
|
|
- || data.minus !== undefined || data.is_yf !== undefined || data.dl_type !== undefined
|
|
|
+ || data.minus !== undefined || data.is_yf !== undefined || data.dl_type !== undefined;
|
|
|
}
|
|
|
try {
|
|
|
this._checkStageCanModify(ctx);
|
|
|
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
- const responseData = { err: 0, msg: '', data: {}, };
|
|
|
+ const responseData = { err: 0, msg: '', data: {} };
|
|
|
const payCalculator = new PayCalculator(ctx, ctx.stage, ctx.tender.info);
|
|
|
switch (data.type) {
|
|
|
case 'add':
|
|
@@ -792,16 +797,16 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
ctx.body = responseData;
|
|
|
- } catch(err) {
|
|
|
+ } catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 合同支付 - 章节明细 (Ajax-Post)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async chapterDetail(ctx) {
|
|
|
const _ = this.app._;
|
|
@@ -837,28 +842,28 @@ module.exports = app => {
|
|
|
assignStageData(cd, await ctx.service.stageBills.getSumTotalPriceGcl(ctx.stage));
|
|
|
break;
|
|
|
case 21:
|
|
|
- const sum = _.find(calcDetail, {cType: 11});
|
|
|
- const chapters = _.filter(calcDetail, {cType: 1});
|
|
|
+ const sum = _.find(calcDetail, { cType: 11 });
|
|
|
+ const chapters = _.filter(calcDetail, { cType: 1 });
|
|
|
for (const f of fields) {
|
|
|
- cd[f] = ctx.helper.sub(sum[f], this.ctx.helper.sum(_.map(chapters, f)));//_.sumBy(chapters, f));
|
|
|
+ cd[f] = ctx.helper.sub(sum[f], this.ctx.helper.sum(_.map(chapters, f)));// _.sumBy(chapters, f));
|
|
|
}
|
|
|
break;
|
|
|
case 31:
|
|
|
assignStageData(cd, await ctx.service.stageBills.getSumTotalPriceNotGcl(ctx.stage));
|
|
|
break;
|
|
|
case 41:
|
|
|
- const sum1 = _.find(calcDetail, {cType: 11});
|
|
|
- const sum2 = _.find(calcDetail, {cType: 31});
|
|
|
+ const sum1 = _.find(calcDetail, { cType: 11 });
|
|
|
+ const sum2 = _.find(calcDetail, { cType: 31 });
|
|
|
for (const f of fields) {
|
|
|
cd[f] = ctx.helper.add(sum1.value, sum2.value);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- ctx.body = {err: 0, msg: '', data: {detail: chapterDetail, decimal: ctx.tender.info.decimal}};
|
|
|
+ ctx.body = { err: 0, msg: '', data: { detail: chapterDetail, decimal: ctx.tender.info.decimal } };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -868,13 +873,13 @@ module.exports = app => {
|
|
|
* @param tid
|
|
|
* @param sid
|
|
|
* @param cid
|
|
|
- * @returns {Promise<{}>}
|
|
|
+ * @return {Promise<{}>}
|
|
|
* @private
|
|
|
*/
|
|
|
async _getChangeDetailData(tid, sid, cid) {
|
|
|
const data = {};
|
|
|
data.attachments = await this.ctx.service.changeAtt.getChangeAttachment(cid);
|
|
|
- data.bills = await this.ctx.service.changeAuditList.getAllDataByCondition({where: {cid: cid}});
|
|
|
+ data.bills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid } });
|
|
|
data.addUsedBills = await this.ctx.service.stageChange.getUsedData(tid, cid);
|
|
|
data.curUsedBills = await this.ctx.service.stageChange.getStageUsedData(sid, cid);
|
|
|
return data;
|
|
@@ -882,7 +887,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 获取变更数据 Post(Ajax)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async getChangeData(ctx) {
|
|
|
try {
|
|
@@ -895,16 +900,16 @@ module.exports = app => {
|
|
|
const change = data.changes[0];
|
|
|
change.detail = await this._getChangeDetailData(ctx.tender.id, ctx.stage.id, change.cid);
|
|
|
}
|
|
|
- ctx.body = {err: 0, msg: '', data: data};
|
|
|
+ ctx.body = { err: 0, msg: '', data };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 变更令 (Get)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async change(ctx) {
|
|
|
try {
|
|
@@ -923,7 +928,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 添加审批人
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async addAudit(ctx) {
|
|
|
try {
|
|
@@ -944,7 +949,7 @@ module.exports = app => {
|
|
|
|
|
|
ctx.stage.auditorList = await ctx.service.stageAudit.getAuditors(ctx.stage.id, ctx.stage.times);
|
|
|
// 检查审核人是否已存在
|
|
|
- const exist = this.app._.find(ctx.stage.auditorList, {aid: id});
|
|
|
+ const exist = this.app._.find(ctx.stage.auditorList, { aid: id });
|
|
|
if (exist) {
|
|
|
throw '该审核人已存在,请勿重复添加';
|
|
|
}
|
|
@@ -955,16 +960,16 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
const audit = await ctx.service.stageAudit.getAuditor(ctx.stage.id, id, ctx.stage.times);
|
|
|
- ctx.body = {err: 0, msg: '', data: audit};
|
|
|
+ ctx.body = { err: 0, msg: '', data: audit };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 移除审批人
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async deleteAudit(ctx) {
|
|
|
try {
|
|
@@ -981,15 +986,15 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
const auditors = await ctx.service.stageAudit.getAuditors(ctx.stage.id, ctx.stage.times);
|
|
|
- ctx.body = {err: 0, msg: '', data: auditors};
|
|
|
+ ctx.body = { err: 0, msg: '', data: auditors };
|
|
|
} catch (err) {
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 上报
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async startAudit(ctx) {
|
|
|
try {
|
|
@@ -1004,7 +1009,7 @@ module.exports = app => {
|
|
|
|
|
|
await ctx.service.stageAudit.start(ctx.stage.id, ctx.stage.times);
|
|
|
|
|
|
- ctx.body = {err: 0, msg: '', data: []};
|
|
|
+ ctx.body = { err: 0, msg: '', data: [] };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.body = this.ajaxErrorBody(err, '上报失败');
|
|
@@ -1013,7 +1018,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 审批
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async checkAudit(ctx) {
|
|
|
try {
|
|
@@ -1026,7 +1031,7 @@ module.exports = app => {
|
|
|
throw '您无权进行该操作';
|
|
|
}
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
- //data.checkType = parseInt(data.checkType);
|
|
|
+ // data.checkType = parseInt(data.checkType);
|
|
|
// const data = {
|
|
|
// checkType: parseInt(ctx.request.body.checkType),
|
|
|
// opinion: ctx.request.body.opinion,
|
|
@@ -1042,9 +1047,9 @@ module.exports = app => {
|
|
|
|
|
|
await ctx.service.stageAudit.check(ctx.stage.id, data, ctx.stage.times);
|
|
|
|
|
|
- ctx.body = {err: 0, msg: '', data: []};//ctx.redirect(ctx.request.header.referer);
|
|
|
+ ctx.body = { err: 0, msg: '', data: [] };// ctx.redirect(ctx.request.header.referer);
|
|
|
} catch (err) {
|
|
|
- //console.log(err);
|
|
|
+ // console.log(err);
|
|
|
this.log(err);
|
|
|
ctx.body = this.ajaxErrorBody(err, '提交失败');
|
|
|
// ctx.session.postError = err.toString();
|
|
@@ -1054,7 +1059,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 重新审批
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async checkAuditAgain(ctx) {
|
|
|
try {
|
|
@@ -1083,24 +1088,24 @@ module.exports = app => {
|
|
|
_getGatherSpreadSetting() {
|
|
|
const _ = this.app._;
|
|
|
function removeFieldCols(setting, cols) {
|
|
|
- _.remove(setting.cols, function (c) {
|
|
|
+ _.remove(setting.cols, function(c) {
|
|
|
return cols.indexOf(c.field) > -1;
|
|
|
});
|
|
|
}
|
|
|
function setColFormat(cols, field, formatter) {
|
|
|
- const filterCols = cols.filter(function (c) {
|
|
|
+ const filterCols = cols.filter(function(c) {
|
|
|
return c.field.search(field) !== -1;
|
|
|
});
|
|
|
for (const col of filterCols) {
|
|
|
col.formatter = formatter;
|
|
|
}
|
|
|
}
|
|
|
- //const tpFormatter = this.ctx.helper.getNumberFormatter(this.ctx.tender.info.decimal.tp);
|
|
|
- //const upFormatter = this.ctx.helper.getNumberFormatter(2);
|
|
|
+ // const tpFormatter = this.ctx.helper.getNumberFormatter(this.ctx.tender.info.decimal.tp);
|
|
|
+ // const upFormatter = this.ctx.helper.getNumberFormatter(2);
|
|
|
const gcl = JSON.parse(JSON.stringify(spreadConst.stageGather.gcl));
|
|
|
- //setColFormat(gcl.cols, 'unit_price', upFormatter);
|
|
|
- //setColFormat(gcl.cols, 'total_price', tpFormatter);
|
|
|
- //setColFormat(gcl.cols, 'tp', tpFormatter);
|
|
|
+ // setColFormat(gcl.cols, 'unit_price', upFormatter);
|
|
|
+ // setColFormat(gcl.cols, 'total_price', tpFormatter);
|
|
|
+ // setColFormat(gcl.cols, 'tp', tpFormatter);
|
|
|
|
|
|
const leafXmj = JSON.parse(JSON.stringify(spreadConst.stageGather.leafXmj));
|
|
|
const tender = this.ctx.tender;
|
|
@@ -1112,7 +1117,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 清单汇总 页面 (Get)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async gather(ctx) {
|
|
|
try {
|
|
@@ -1131,7 +1136,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 审核比较 页面 (Get)
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async compare(ctx) {
|
|
|
try {
|
|
@@ -1157,23 +1162,23 @@ module.exports = app => {
|
|
|
const data = JSON.parse(ctx.request.body.data);
|
|
|
const result = {
|
|
|
main: null,
|
|
|
- roles: []
|
|
|
+ roles: [],
|
|
|
};
|
|
|
if (data.main) {
|
|
|
result.main = {};
|
|
|
result.main.ledger = await ctx.service.ledger.getData(ctx.tender.id);
|
|
|
- result.main.pos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
|
|
|
+ result.main.pos = await ctx.service.pos.getPosData({ tid: ctx.tender.id });
|
|
|
}
|
|
|
for (const order of data.roles) {
|
|
|
- const data = { order: order, bills: [], pos: [] };
|
|
|
+ const data = { order, bills: [], pos: [] };
|
|
|
data.bills = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, order);
|
|
|
data.pos = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, order);
|
|
|
result.roles.push(data);
|
|
|
}
|
|
|
- ctx.body = {err: 0, msg: '', data: result};
|
|
|
+ ctx.body = { err: 0, msg: '', data: result };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
- ctx.body = {err: 1, msg: err.toString(), data: null};
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1205,8 +1210,8 @@ module.exports = app => {
|
|
|
// await ctx.service.externalData.saveExValue(ctx.tender.id, -1,
|
|
|
// externalDataConst.FuLong.exType, externalDataConst.FuLong.exFields.wbsCode, wbsCodeHis);
|
|
|
// }
|
|
|
- ctx.body = {err: 0, msg: '', data: result};
|
|
|
- } catch(err) {
|
|
|
+ ctx.body = { err: 0, msg: '', data: result };
|
|
|
+ } catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.body = this.ajaxErrorBody(err, '加载合同支付数据错误');
|
|
|
}
|
|
@@ -1602,7 +1607,7 @@ module.exports = app => {
|
|
|
/**
|
|
|
* 删除本次审批 - 期审批管理页面
|
|
|
* @param ctx
|
|
|
- * @returns {Promise<void>}
|
|
|
+ * @return {Promise<void>}
|
|
|
*/
|
|
|
async managerAuditDelete(ctx) {
|
|
|
try {
|