MaiXinRong 4 mesi fa
parent
commit
0d0f53c8ab
2 ha cambiato i file con 81 aggiunte e 31 eliminazioni
  1. 41 1
      app/public/js/shares/tree_ass.js
  2. 40 30
      app/view/shares/tree_ass_modal.ejs

+ 41 - 1
app/public/js/shares/tree_ass.js

@@ -12,7 +12,7 @@ const TreeAss = (function() {
     const refreshAssTable = function() {
         const html = [];
         for (const ass of assData) {
-            html.push('<tr>', `<td>${ass.name}</td>`, `<td>${ass.company}</td>`, `<td class="text-center">${ass.ass_id.length}</td>`, '</tr>');
+            html.push('<tr>', `<td class="text-center"><input type="checkbox" ass-id="${ass.user_id}"></td>`, `<td>${ass.name}</td>`, `<td>${ass.company}</td>`, `<td class="text-center">${ass.ass_id.length}</td>`, '</tr>');
         }
         $('#ass-table').html(html.join(''));
     };
@@ -88,6 +88,46 @@ const TreeAss = (function() {
                 refreshAssTable();
                 refreshAssSelect();
             });
+            $('#del-ass-user').click(function() {
+                const select = $('input[ass-id]:checked');
+                if (select.length === 0) {
+                    toastr.warning('请先选择需要移除的协同人');
+                    return;
+                }
+                for (const s of select) {
+                    const userId = parseInt(s.getAttribute('ass-id'))
+                    const index = assData.findIndex(x => { return x.user_id === userId; });
+                    if (index >= 0) assData.splice(index, 1);
+                    assTree.nodes.forEach(x => {
+                        if (x.ass_user === userId) delete x.ass_user;
+                    });
+                }
+                refreshAssTable();
+                refreshAssSelect();
+                SpreadJsObj.reloadColData(assSheet, 2);
+            });
+            $('a[name=tae-showLevel]').click(function () {
+                const tag = $(this).attr('tag');
+                const tree = assSheet.zh_tree;
+                if (!tree) return;
+                setTimeout(() => {
+                    showWaitingView();
+                    switch (tag) {
+                        case "1":
+                        case "2":
+                        case "3":
+                        case "4":
+                            tree.expandByLevel(parseInt(tag));
+                            SpreadJsObj.refreshTreeRowVisible(assSheet);
+                            break;
+                        case "last":
+                            tree.expandByCustom(() => { return true; });
+                            SpreadJsObj.refreshTreeRowVisible(assSheet);
+                            break;
+                    }
+                    closeWaitingView();
+                }, 100);
+            });
         }
     };
     const resetAssData = function() {

+ 40 - 30
app/view/shares/tree_ass_modal.ejs

@@ -5,41 +5,41 @@
                 <h5 class="modal-title">协同配置</h5>
             </div>
             <div class="modal-body">
-                <div class="mb-2">
-                    <div class="dropdown d-inline-block" data-code="ass-user">
-                        <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="ass-user_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                            添加协同人
-                        </button>
-                        <div class="dropdown-menu dropdown-menu-left" aria-labelledby="ass-user_dropdownMenuButton" style="width:220px" id="ass-user_dropdownMenu">
-                            <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search" placeholder="姓名/手机 检索" autocomplete="off" data-code="ass-user"></div>
-                            <dl class="list-unstyled book-list">
-                                <% accountGroup.forEach((group, idx) => { %>
-                                <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>" data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
-                                <div class="dd-content" data-toggleid="<%- idx %>">
-                                    <% group.groupList.forEach(item => { %>
-                                    <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
-                                        <p class="mb-0 d-flex"><span class="text-primary"><%- item.name %></span><span
-                                                    class="ml-auto"><%- item.mobile %></span></p>
-                                        <span class="text-muted"><%- item.role %></span>
-                                    </dd>
-                                    <% });%>
-                                </div>
-                                <% }) %>
-                            </dl>
-                        </div>
-                    </div>
-                    <div class="d-inline-block">
-                        <button class="btn btn-outline-danger btn-sm" id="del-ass-user">
-                            移除协同人
-                        </button>
-                    </div>
-                </div>
                 <div class="row">
                     <div class="col-6">
+                        <div class="mb-2">
+                            <div class="dropdown d-inline-block" data-code="ass-user">
+                                <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="ass-user_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                    添加协同人
+                                </button>
+                                <div class="dropdown-menu dropdown-menu-left" aria-labelledby="ass-user_dropdownMenuButton" style="width:220px" id="ass-user_dropdownMenu">
+                                    <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search" placeholder="姓名/手机 检索" autocomplete="off" data-code="ass-user"></div>
+                                    <dl class="list-unstyled book-list">
+                                        <% accountGroup.forEach((group, idx) => { %>
+                                        <dt><a href="javascript: void(0);" class="acc-btn" data-groupid="<%- idx %>" data-type="hide"><i class="fa fa-plus-square"></i></a> <%- group.groupName %></dt>
+                                        <div class="dd-content" data-toggleid="<%- idx %>">
+                                            <% group.groupList.forEach(item => { %>
+                                            <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
+                                                <p class="mb-0 d-flex"><span class="text-primary"><%- item.name %></span><span
+                                                            class="ml-auto"><%- item.mobile %></span></p>
+                                                <span class="text-muted"><%- item.role %></span>
+                                            </dd>
+                                            <% });%>
+                                        </div>
+                                        <% }) %>
+                                    </dl>
+                                </div>
+                            </div>
+                            <div class="d-inline-block">
+                                <button class="btn btn-outline-danger btn-sm" id="del-ass-user">
+                                    移除协同人
+                                </button>
+                            </div>
+                        </div>
                         <div class="modal-height-500" style="overflow: auto;">
                             <table class="table table-hover table-bordered">
                                 <thead class="text-center" >
-                                <tr><th>姓名</th><th>单位</th><th>协同处理</th></tr>
+                                <tr><th>选择</th><th>姓名</th><th>单位</th><th>协同处理</th></tr>
                                 </thead>
                                 <tbody id="ass-table">
                                 </tbody>
@@ -47,6 +47,16 @@
                         </div>
                     </div>
                     <div class="col-6">
+                        <div class="btn-group mb-2">
+                            <button type="button" class="btn btn-sm  text-primary dropdown-toggle" data-toggle="dropdown" id="tree-ass-expand" aria-expanded="false">显示层级</button>
+                            <div class="dropdown-menu" aria-labelledby="tree-ass-expand" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 21px, 0px); top: 0px; left: 0px; will-change: transform;">
+                                <a class="dropdown-item" name="tae-showLevel" tag="1" href="javascript: void(0);">第一层</a>
+                                <a class="dropdown-item" name="tae-showLevel" tag="2" href="javascript: void(0);">第二层</a>
+                                <a class="dropdown-item" name="tae-showLevel" tag="3" href="javascript: void(0);">第三层</a>
+                                <a class="dropdown-item" name="tae-showLevel" tag="4" href="javascript: void(0);">第四层</a>
+                                <a class="dropdown-item" name="tae-showLevel" tag="last" href="javascript: void(0);">最底层</a>
+                            </div>
+                        </div>
                         <div class="modal-height-500" id="tree-ass-spread">
                         </div>
                     </div>