MaiXinRong 3 vuotta sitten
vanhempi
commit
bb8b08eabe
2 muutettua tiedostoa jossa 10 lisäystä ja 5 poistoa
  1. 3 2
      app/lib/sum_load.js
  2. 7 3
      app/public/js/shares/tender_select.js

+ 3 - 2
app/lib/sum_load.js

@@ -125,7 +125,8 @@ class loadLedgerGclTree extends loadGclBaseTree {
     }
 
     getUpdateData() {
-        const update = [{id: this.parent.id, ledger_id: this.parent.ledger_id, is_leaf: 0}];
+        const update = [];
+        if (this.items.length > 0) update.push({id: this.parent.id, ledger_id: this.parent.ledger_id, is_leaf: 0});
         const create = [];
         for (const i of this.items) {
             create.push({
@@ -190,7 +191,7 @@ class updateReviseGclTree extends loadGclBaseTree {
     getUpdateData() {
         const result = {update: [], errors: [], create: []};
         if (this.baseNodes.length === 0) {
-            result.update = [{id: this.parent.id, ledger_id: this.parent.ledger_id, is_leaf: 0}];
+            if (this.items.length > 0) result.update.push({id: this.parent.id, ledger_id: this.parent.ledger_id, is_leaf: 0});
         } else {
             for (const bn of this.baseNodes) {
                 if (bn.children && bn.children.length > 0) continue;

+ 7 - 3
app/public/js/shares/tender_select.js

@@ -175,10 +175,14 @@ const TenderSelect = function (setting) {
 
             $('#tender-select-ok').click(() => {
                 const updateData = {lid: tsObj.select.id, type: tsObj.setting.type, tenders: tsObj.trArray};
-                postData(window.location.pathname + '/sumLoad', updateData, result => {
-                    tsObj.setting.afterLoad(result);
+                if (updateData.tenders.length > 0) {
+                    postData(window.location.pathname + '/sumLoad', updateData, result => {
+                        tsObj.setting.afterLoad(result);
+                        $('#tender-select').modal('hide');
+                    });
+                } else {
                     $('#tender-select').modal('hide');
-                });
+                }
             });
 
             this.loadHistory();