|
@@ -38,12 +38,12 @@ module.exports = app => {
|
|
|
|
|
|
async add(options, node, data) {
|
|
|
if (!options[this.setting.type] || !node || !data) throw '参数有误';
|
|
|
- let insertData = [];
|
|
|
+ const insertId = this.uuid.v4();
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
const maxId = await this.ctx.service.contractTree._getMaxLid(options);
|
|
|
- insertData = {
|
|
|
- id: this.uuid.v4(),
|
|
|
+ const insertData = {
|
|
|
+ id: insertId,
|
|
|
spid: options.spid || null,
|
|
|
tid: options.tid || null,
|
|
|
contract_type: options[this.setting.type],
|
|
@@ -54,7 +54,7 @@ module.exports = app => {
|
|
|
is_leaf: 1,
|
|
|
c_code: data.code,
|
|
|
name: data.name,
|
|
|
- total_price: data.total_price,
|
|
|
+ total_price: data.total_price ? parseFloat(data.total_price) : 0,
|
|
|
party_b: data.party_b,
|
|
|
remark: data.remark,
|
|
|
create_time: new Date(),
|
|
@@ -75,12 +75,13 @@ module.exports = app => {
|
|
|
await transaction.rollback();
|
|
|
throw err;
|
|
|
}
|
|
|
+ const createData = await this.ctx.service.contract.getDataById(insertId);
|
|
|
const updateData = await this.ctx.service.contractTree.getNextsData(options, !node.c_code ? node.contract_id : node[this.setting.pid], node[this.setting.order] + 1);
|
|
|
if (!node.c_code) {
|
|
|
const parent = await this.ctx.service.contractTree.getDataById(node.id);
|
|
|
updateData.push(parent);
|
|
|
}
|
|
|
- return { create: insertData, update: updateData };
|
|
|
+ return { create: createData, update: updateData };
|
|
|
}
|
|
|
|
|
|
/**
|