浏览代码

bug提交

laiguoran 4 年之前
父节点
当前提交
6ee5257ebf
共有 2 个文件被更改,包括 43 次插入6 次删除
  1. 31 2
      app/public/js/schedule_ledger.js
  2. 12 4
      app/view/schedule/ledger.ejs

+ 31 - 2
app/public/js/schedule_ledger.js

@@ -67,6 +67,13 @@ $(function () {
     }, null, true);
 
     const ledgerSpreadObj = {
+        getselectButton: function() {
+            return {
+                select_siblings: $('#select_siblings').is(':checked'),
+                select_other_siblings: $('#select_other_siblings').is(':checked'),
+                select_children: $('#select_children').is(':checked'),
+            }
+        },
         refreshTree: function (sheet, data) {
             SpreadJsObj.massOperationSheet(sheet, function () {
                 const tree = sheet.zh_tree;
@@ -131,8 +138,16 @@ $(function () {
                     select.is_select = info.sheet.getValue(info.row, info.col) ? 1 : 0;
                     selects.splice(0, selects.length);
                     selects.push(select);
-                    updateChildrenSelect(select.children, select.is_select);
-                    updateParentSelect(info.sheet.zh_tree, select.ledger_pid, select.is_select);
+                    const select_msg = ledgerSpreadObj.getselectButton();
+                    if (select_msg.select_children || select.is_select === 0) {
+                        updateChildrenSelect(select.children, select.is_select);
+                    }
+                    if (select_msg.select_siblings) {
+                        updateSiblingsSelect(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);
+                    }
                     // console.log(selects);
                     const refreshNode = ledgerTree.loadPostData({update: selects});
                     ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
@@ -188,6 +203,20 @@ 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) {
+            d.is_select = is_select;
+            if (select_msg.select_children || is_select === 0) {
+                updateChildrenSelect(d.children, is_select);
+            }
+            selects.push(d);
+        }
+    }
+}
+
 function updateParentSelect(tree, pid, is_select) {
     if (pid !== -1) {
         const parent = _.find(tree.nodes, { 'ledger_id': pid });

+ 12 - 4
app/view/schedule/ledger.ejs

@@ -7,16 +7,24 @@
                 <div class="d-inline-block">
                     <a class="btn btn-sm btn-light">
                         <div class="custom-control custom-checkbox">
-                            <input type="checkbox" class="custom-control-input" id="save_siblings">
-                            <label class="custom-control-label text-primary" for="save_siblings">自动选择同级项</label>
+                            <input type="checkbox" class="custom-control-input" id="select_siblings" checked>
+                            <label class="custom-control-label text-primary" for="select_siblings">自动选择同级项</label>
                         </div>
                     </a>
                 </div>
                 <div class="d-inline-block">
                     <a class="btn btn-sm btn-light">
                         <div class="custom-control custom-checkbox">
-                            <input type="checkbox" class="custom-control-input" id="save_other_siblings">
-                            <label class="custom-control-label text-primary" for="save_other_siblings">跨级选择同级项</label>
+                            <input type="checkbox" class="custom-control-input" id="select_other_siblings">
+                            <label class="custom-control-label text-primary" for="select_other_siblings">跨级选择同级项</label>
+                        </div>
+                    </a>
+                </div>
+                <div class="d-inline-block">
+                    <a class="btn btn-sm btn-light">
+                        <div class="custom-control custom-checkbox">
+                            <input type="checkbox" class="custom-control-input" id="select_children" checked>
+                            <label class="custom-control-label text-primary" for="select_children">自动选择子项</label>
                         </div>
                     </a>
                 </div>