|
|
@@ -21,10 +21,11 @@ const billsUtils = require('../lib/bills_utils');
|
|
|
|
|
|
class BaseBillsSerivce extends TreeService {
|
|
|
|
|
|
- constructor (ctx, setting, relaPosName, relaAncGclName, relaExtraName, relaPosDetailName) {
|
|
|
+ constructor (ctx, setting, relaPosName, relaAncGclName, relaAncGclDetailName, relaExtraName, relaPosDetailName) {
|
|
|
super(ctx, setting);
|
|
|
this.relaPosService = relaPosName;
|
|
|
this.relaAncGclService = relaAncGclName;
|
|
|
+ this.relaAncGclDetailService = relaAncGclDetailName;
|
|
|
this.relaExtraService = relaExtraName;
|
|
|
this.relaPosDetailService = relaPosDetailName;
|
|
|
}
|
|
|
@@ -50,6 +51,13 @@ class BaseBillsSerivce extends TreeService {
|
|
|
return this._ancGclName ? this.ctx.service[this._ancGclName] : undefined;
|
|
|
}
|
|
|
|
|
|
+ set relaAncGclDetailService(ancGclDetailName) {
|
|
|
+ this._ancGclDetailName = ancGclDetailName;
|
|
|
+ }
|
|
|
+ get relaAncGclDetailService() {
|
|
|
+ return this._ancGclDetailName ? this.ctx.service[this._ancGclDetailName] : undefined;
|
|
|
+ }
|
|
|
+
|
|
|
set relaExtraService(extraName) {
|
|
|
this._extraName = extraName
|
|
|
}
|
|
|
@@ -657,12 +665,13 @@ class BaseBillsSerivce extends TreeService {
|
|
|
if (pd[0].ledger_pid !== pasteData[0][0].ledger_pid) throw '复制数据错误:仅可操作同层节点';
|
|
|
}
|
|
|
const userId = this.ctx.session.sessionUser.accountId;
|
|
|
+ const qtyDecimal = this.ctx.tender.info.decimal.qty;
|
|
|
this.newBills = false;
|
|
|
const selectData = await this.getDataByKid(tid, sid);
|
|
|
if (!selectData) throw '粘贴数据错误';
|
|
|
const newParentPath = selectData.full_path.replace(selectData.ledger_id, '');
|
|
|
|
|
|
- const pasteBillsData = [], pastePosData = [], pasteAncGclData = [], pasteBillsExtraData = [], pastePosDetailData = [], leafBillsId = [];
|
|
|
+ const pasteBillsData = [], pastePosData = [], pasteAncGclData = [], pasteAncGclDetailData = [], pasteBillsExtraData = [], pastePosDetailData = [], leafBillsId = [];
|
|
|
const tpDecimal = this.ctx.tender.info.decimal.tp;
|
|
|
let maxId = await this._getMaxLid(this.ctx.tender.id);
|
|
|
const calcTemplate = await this.ctx.service.calcTmpl.getAllTemplateDetail(this.ctx.session.sessionProject.id, 'posCalc');
|
|
|
@@ -794,6 +803,40 @@ class BaseBillsSerivce extends TreeService {
|
|
|
newBills.qtcl_qty = this.ctx.helper.add(newBills.qtcl_qty, newPos.qtcl_qty);
|
|
|
newBills.ex_qty1 = this.ctx.helper.add(newBills.ex_qty1, newPos.ex_qty1);
|
|
|
if (defaultData) this.ctx.helper._.assignIn(newPos, defaultData);
|
|
|
+
|
|
|
+ for (const ag of pos.ancGcl) {
|
|
|
+ const nig = {
|
|
|
+ id: this.uuid.v4(), tid: this.ctx.tender.id,
|
|
|
+ add_user_id: userId, update_user_id: userId,
|
|
|
+ lid: newPos.lid, pid: newPos.id, g_order: ag.g_order,
|
|
|
+ is_aux: ag.is_aux || 0, name: ag.name || '', unit: ag.unit || '',
|
|
|
+ drawing_code: ag.drawing_code || '', memo: ag.memo || '',
|
|
|
+ quantity: ag.quantity || 0, expr: ag.expr || '', calc_template: ag.calc_template || ''
|
|
|
+ };
|
|
|
+ pasteAncGclData.push(nig);
|
|
|
+ if (!ag.calc_template) continue;
|
|
|
+
|
|
|
+ let sumQty = 0;
|
|
|
+ for (const cd of ag.calcDetail) {
|
|
|
+ const newDetail = {
|
|
|
+ id: this.uuid.v4(), tid: this.ctx.tender.id, lid: newPos.lid, pid: newPos.id, ag_id: nig.id,
|
|
|
+ create_user_id: userId, update_user_id: userId,
|
|
|
+ agd_order: cd.agd_order,
|
|
|
+ str1 : cd.str1 || '', str2 : cd.str1 || '', str3 : cd.str1 || '', str4 : cd.str1 || '',
|
|
|
+ num_a : cd.num_a || 0, num_b : cd.num_b || 0, num_c : cd.num_c || 0, num_d : cd.num_d || 0,
|
|
|
+ num_e : cd.num_e || 0, num_f : cd.num_f || 0, num_g : cd.num_g || 0, num_h : cd.num_h || 0,
|
|
|
+ num_i : cd.num_i || 0, num_j : cd.num_j || 0, num_k : cd.num_k || 0, num_l : cd.num_l || 0,
|
|
|
+ num_m : cd.num_m || 0, num_n : cd.num_n || 0, num_o : cd.num_o || 0, num_p : cd.num_p || 0,
|
|
|
+ num_q : cd.num_q || 0, num_r : cd.num_r || 0, num_s : cd.num_s || 0, num_t : cd.num_t || 0,
|
|
|
+ num_u : cd.num_u || 0,
|
|
|
+ qty: cd.qty || 0, expr: cd.expr || 0, spec: cd.spec || ''
|
|
|
+ };
|
|
|
+ sumQty = this.ctx.helper.add(sumQty, newDetail.qty);
|
|
|
+ pasteAncGclDetailData.push(newDetail);
|
|
|
+ }
|
|
|
+ nig.quantity = this.ctx.helper.round(sumQty, qtyDecimal);
|
|
|
+ }
|
|
|
+
|
|
|
pastePosData.push(newPos);
|
|
|
}
|
|
|
} else {
|
|
|
@@ -811,19 +854,19 @@ class BaseBillsSerivce extends TreeService {
|
|
|
newBills.deal_tp = this.ctx.helper.mul(newBills.deal_qty, newBills.unit_price, tpDecimal);
|
|
|
newBills.ex_tp1 = this.ctx.helper.mul(newBills.ex_qty1, newBills.unit_price, tpDecimal);
|
|
|
if (defaultData) this.ctx.helper._.assignIn(newBills, defaultData);
|
|
|
- if (d.ancGcl && d.ancGcl.length > 0) {
|
|
|
- for (const gcl of d.ancGcl) {
|
|
|
- const newAncGcl = {
|
|
|
- id: this.uuid.v4(), tid: tid, lid: newBills.id,
|
|
|
- add_user_id: userId, update_user_id: userId,
|
|
|
- name: gcl.name, unit: gcl.unit, g_order: gcl.g_order, is_aux: gcl.is_aux,
|
|
|
- quantity: gcl.quantity, expr: gcl.expr,
|
|
|
- drawing_code: gcl.drawing_code, memo: gcl.memo,
|
|
|
- };
|
|
|
- if (defaultData) this.ctx.helper._.assignIn(newAncGcl, defaultData);
|
|
|
- pasteAncGclData.push(newAncGcl);
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (d.ancGcl && d.ancGcl.length > 0) {
|
|
|
+ // for (const gcl of d.ancGcl) {
|
|
|
+ // const newAncGcl = {
|
|
|
+ // id: this.uuid.v4(), tid: tid, lid: newBills.id,
|
|
|
+ // add_user_id: userId, update_user_id: userId,
|
|
|
+ // name: gcl.name, unit: gcl.unit, g_order: gcl.g_order, is_aux: gcl.is_aux,
|
|
|
+ // quantity: gcl.quantity, expr: gcl.expr,
|
|
|
+ // drawing_code: gcl.drawing_code, memo: gcl.memo,
|
|
|
+ // };
|
|
|
+ // if (defaultData) this.ctx.helper._.assignIn(newAncGcl, defaultData);
|
|
|
+ // pasteAncGclData.push(newAncGcl);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
pbd.push(newBills);
|
|
|
}
|
|
|
for (const d of pbd) {
|
|
|
@@ -852,6 +895,7 @@ class BaseBillsSerivce extends TreeService {
|
|
|
await this.transaction.insert(this.relaPosService.tableName, pastePosData);
|
|
|
}
|
|
|
if (pasteAncGclData.length > 0 && this.relaAncGclService) await this.transaction.insert(this.relaAncGclService.tableName, pasteAncGclData);
|
|
|
+ if (pasteAncGclDetailData.length > 0 && this.relaAncGclDetailService) await this.transaction.insert(this.relaAncGclDetailService.tableName, pasteAncGclDetailData);
|
|
|
if (pasteBillsExtraData.length > 0 && this.relaExtraService) await this.transaction.insert(this.relaExtraService.tableName, pasteBillsExtraData);
|
|
|
if (pastePosDetailData.length > 0 && this.relaPosDetailService) await this.transaction.insert(this.relaPosDetailService.tableName, pastePosDetailData);
|
|
|
await this.transaction.commit();
|
|
|
@@ -863,6 +907,7 @@ class BaseBillsSerivce extends TreeService {
|
|
|
// 查询应返回的结果
|
|
|
const updateData = await this.getNextsData(selectData.tender_id, selectData.ledger_pid, selectData.order + pasteData.length);
|
|
|
const ancGcl = this.relaAncGclService ? { add: pasteAncGclData } : undefined;
|
|
|
+ const ancGclDetail = this.relaAncGclDetailSerivce ? { add: pasteAncGclDetailData } : undefined;
|
|
|
const posCalcDetail = this.relaPosDetailService ? { add: pastePosDetailData } : undefined;
|
|
|
if (pasteBillsExtraData.length > 0) {
|
|
|
for (const be of pasteBillsExtraData) {
|
|
|
@@ -872,7 +917,7 @@ class BaseBillsSerivce extends TreeService {
|
|
|
}
|
|
|
return {
|
|
|
ledger: { create: pasteBillsData, update: updateData },
|
|
|
- pos: pastePosData, ancGcl, posCalcDetail,
|
|
|
+ pos: pastePosData, ancGcl, ancGclDetail, posCalcDetail,
|
|
|
};
|
|
|
}
|
|
|
|