laiguoran 4 éve
szülő
commit
6c14fe0476
1 módosított fájl, 28 hozzáadás és 1 törlés
  1. 28 1
      app/public/js/schedule_ledger.js

+ 28 - 1
app/public/js/schedule_ledger.js

@@ -145,6 +145,9 @@ $(function () {
                     if (select_msg.select_siblings) {
                         updateSiblingsSelect(info.sheet.zh_tree, select.ledger_pid, select.is_select, select_msg);
                     }
+                    if (select_msg.select_other_siblings) {
+                        updateOtherSiblingsSelect(info.sheet.zh_tree, select.ledger_pid, select.is_select, select_msg);
+                    }
                     if(select.is_select === 1) {
                         updateParentSelect(info.sheet.zh_tree, select.ledger_pid, select.is_select);
                     }
@@ -204,7 +207,6 @@ function updateChildrenSelect(datas, is_select) {
 }
 
 function updateSiblingsSelect(tree, pid, is_select, select_msg) {
-    console.log(tree);
     const parent = pid !== -1 ? _.find(tree.nodes, { 'ledger_id': pid }) : tree;
     if (parent) {
         for(const d of parent.children) {
@@ -217,6 +219,31 @@ function updateSiblingsSelect(tree, pid, is_select, select_msg) {
     }
 }
 
+function updateOtherSiblingsSelect(tree, pid, is_select, select_msg) {
+    if(pid === -1) {
+        return;
+    }
+    const parent = _.find(tree.nodes, { 'ledger_id': pid });
+    if (parent) {
+        const grandparent = parent.ledger_pid === -1 ? tree : _.find(tree.nodes, { 'ledger_id': parent.ledger_pid });
+        if (grandparent) {
+            for (const d of grandparent.children) {
+                if (d.ledger_id !== pid) {
+                    if(d.children && d.children.length > 0) {
+                        for (const dd of d.children) {
+                            dd.is_select = is_select;
+                            if (select_msg.select_children || is_select === 0) {
+                                updateChildrenSelect(dd.children, is_select);
+                            }
+                            selects.push(dd);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
 function updateParentSelect(tree, pid, is_select) {
     if (pid !== -1) {
         const parent = _.find(tree.nodes, { 'ledger_id': pid });