|
@@ -13,6 +13,7 @@ class loadStageExcelTree {
|
|
|
this.ctx = ctx;
|
|
|
|
|
|
this.decimal = ctx.tender.info.decimal;
|
|
|
+ this.settleStatus === ctx.service.settle.settleStatus;
|
|
|
|
|
|
this.insertBills = [];
|
|
|
this.insertPos = [];
|
|
@@ -66,7 +67,7 @@ class loadStageExcelTree {
|
|
|
for (const p of node.pos) {
|
|
|
if (!p.contract_qty) continue;
|
|
|
const sp = sourcePos.find(x => { return x.name === p.name; });
|
|
|
- if (!sp) continue;
|
|
|
+ if (!sp || sp.settle_status === this.settleStatus.finish) continue;
|
|
|
|
|
|
contract_qty = this.ctx.helper.add(contract_qty, p.contract_qty);
|
|
|
let ssp = sourceStagePos.find(x => { return x.pid === sp.id; });
|
|
@@ -123,7 +124,7 @@ class loadStageExcelTree {
|
|
|
node.is_leaf = !node.children || node.children.length === 0 ? 1 : 0;
|
|
|
node.has_pos = node.pos && node.pos.length > 0;
|
|
|
const cur = this.findNode(node, parent);
|
|
|
- if (!cur) return;
|
|
|
+ if (!cur || cur.settle_status === this.settleStatus.finish) return;
|
|
|
|
|
|
if (cur) {
|
|
|
if (!node.b_code) this.loadDgn(node, cur);
|
|
@@ -226,18 +227,25 @@ module.exports = app => {
|
|
|
async reCalcStashData(stage, data) {
|
|
|
const decimal = this.ctx.tender.info.decimal;
|
|
|
const insertBillsData = [], insertPosData = [], insertChangeData = [];
|
|
|
+ const settleStatus = this.ctx.service.settle.settleStatus;
|
|
|
|
|
|
const bills = await this.ctx.service.ledger.getAllDataByCondition({ where: { tender_id: stage.tid, is_leaf: true } });
|
|
|
const extraData = await this.ctx.service.ledgerExtra.getData(stage.tid, ['id', 'is_tp']);
|
|
|
+ const settleStatusBills = stage.readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
|
|
|
this.ctx.helper.assignRelaData(bills, [
|
|
|
{ data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
|
|
|
+ { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
const pos = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: stage.tid } });
|
|
|
+ const settleStatusPos = stage.readySettle ? await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
|
|
|
+ this.ctx.helper.assignRelaData(pos, [
|
|
|
+ { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
|
|
|
+ ]);
|
|
|
|
|
|
const said = this.ctx.session.sessionUser.accountId;
|
|
|
for (const d of data) {
|
|
|
const b = bills.find(x => { return x.id === d.lid });
|
|
|
- if (!b) continue;
|
|
|
+ if (!b || b.settle_status === settleStatus.finish) continue;
|
|
|
|
|
|
const nbs = {
|
|
|
tid: stage.tid, sid: stage.id, said, lid: b.id, times: 1, order: 0,
|
|
@@ -247,7 +255,7 @@ module.exports = app => {
|
|
|
if (d.pos) {
|
|
|
for (const bp of d.pos) {
|
|
|
const p = pos.find(x => { return x.id === bp.pid});
|
|
|
- if (!p) continue;
|
|
|
+ if (!p || p.settle_status === settleStatus.finish) continue;
|
|
|
|
|
|
const nps = { tid: stage.tid, sid: stage.id, said, lid: b.id, pid: p.id, times: 1, order: 0 };
|
|
|
nps.contract_qty = this.ctx.helper.round(bp.contract_qty, decimal.qty);
|
|
@@ -366,19 +374,25 @@ module.exports = app => {
|
|
|
where: { tender_id: stage.tid},
|
|
|
});
|
|
|
const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
|
|
|
+ const settleStatusBills = stage.readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
|
|
|
this.ctx.helper.assignRelaData(ledgerData, [
|
|
|
{ data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
|
|
|
+ { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
|
|
|
]);
|
|
|
const posData = await this.ctx.service.pos.getAllDataByCondition({
|
|
|
columns: ['id', 'lid', 'name', 'porder'],
|
|
|
where: { tid: stage.tid },
|
|
|
});
|
|
|
+ const settleStatusPos = stage.readySettle ? await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
|
|
|
+ this.ctx.helper.assignRelaData(posData, [
|
|
|
+ { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
|
|
|
+ ]);
|
|
|
const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
|
|
|
const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
|
|
|
const stageBillsDgn = await this.ctx.service.stageBillsDgn.getAllDataByCondition({ where: { tid: stage.tid } });
|
|
|
|
|
|
const loadModal = new loadStageExcelTree(this.ctx);
|
|
|
- loadModal.load(cacheTree, {ledgerData, posData, stageBills, stagePos, stageBillsDgn, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });
|
|
|
+ loadModal.load(cacheTree, { ledgerData, posData, stageBills, stagePos, stageBillsDgn, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });
|
|
|
|
|
|
const conn = await this.db.beginTransaction();
|
|
|
try {
|