浏览代码

协同设置,清空

MaiXinRong 9 月之前
父节点
当前提交
0da5dcbe37
共有 1 个文件被更改,包括 22 次插入1 次删除
  1. 22 1
      app/public/js/shenpi.js

+ 22 - 1
app/public/js/shenpi.js

@@ -1003,8 +1003,14 @@ $(document).ready(function () {
             SpreadJsObj.selChangedRefreshBackColor(this.sheet);
             this.spread.bind(spreadNS.Events.EditEnded, function(e, info) {
                 const node = SpreadJsObj.getSelectObject(info.sheet);
+                if (!node) return;
+
+                const refreshAuditId = [];
+                if (node.audit_id) refreshAuditId.push(node.audit_id);
                 const col = info.sheet.zh_setting.cols[info.col];
                 node[col.field] = info.editingText;
+                if (node.audit_id) refreshAuditId.push(node.audit_id);
+                self.refreshUnionCount(refreshAuditId);
             });
 
             $('#union').on('shown.bs.modal', function() {
@@ -1016,6 +1022,14 @@ $(document).ready(function () {
                     $('#union').modal('hide');
                 });
             });
+            $('body').on('click', '[name=clear-union]', function() {
+                const aid = parseInt(this.getAttribute('aid'));
+                for (const node of self.tree.nodes) {
+                    if (node.audit_id === aid) node.audit_id = 0;
+                }
+                SpreadJsObj.reloadColData(self.sheet, 2);
+                self.refreshUnionCount(aid);
+            });
         }
         _refreshUnionTree() {
             const ledgerAss = {};
@@ -1035,12 +1049,19 @@ $(document).ready(function () {
             const html = [];
             for (const auditor of auditors) {
                 auditor.lid = auditor.audit_ledger_id ? auditor.audit_ledger_id.split(',') : [];
-                html.push(`<tr><td>${auditor.name}</td><td>${auditor.company}</td><td>${auditor.lid.length}<button class="ml-2 btn btn-sm btn-outline-danger" jaid="${auditor.audit_id}">清空</button></td></tr>`);
+                html.push(`<tr><td>${auditor.name}</td><td>${auditor.company}</td><td><span aid="${auditor.audit_id}">${auditor.lid.length}</span><button class="ml-2 btn btn-sm btn-outline-danger" name="clear-union" aid="${auditor.audit_id}">清空</button></td></tr>`);
                 this.selectUnion.push({ value: auditor.audit_id, text: auditor.name });
             }
             $('#union_table').html(html.join(''));
             this._refreshUnionTree();
         }
+        refreshUnionCount(auditId) {
+            const auditIds = auditId instanceof Array ? auditId : [auditId];
+            for (const aid of auditIds) {
+                const unionNodes = this.tree.nodes.filter(x => { return x.audit_id === aid; });
+                $(`span[aid=${aid}]`).html(unionNodes.length);
+            }
+        }
         loadUnionData(sp_type, audit_order) {
             const data = { sp_type, audit_order };
             if (!this.loaded) data.ledger = 1;