Bladeren bron

修复合同测试bug

ellisran 10 maanden geleden
bovenliggende
commit
d05d975a2c
2 gewijzigde bestanden met toevoegingen van 7 en 6 verwijderingen
  1. 6 5
      app/service/contract.js
  2. 1 1
      app/service/contract_tree.js

+ 6 - 5
app/service/contract.js

@@ -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 };
         }
 
         /**

+ 1 - 1
app/service/contract_tree.js

@@ -305,7 +305,7 @@ module.exports = app => {
                 const maxOrder = await this.ctx.service.contract.getMaxOrder(options, select[this.setting.kid], transaction);
                 const newDatas = [];
                 const maxId = await this._getMaxLid(options);
-                for (let i = 1; i < count + 1; i++) {
+                for (let i = 0; i < count; i++) {
                     const newData = [];
                     if (this.setting.uuid) newData.id = this.uuid.v4();
                     newData[this.setting.kid] = maxId + i;