Quellcode durchsuchen

GLY-4624 - 后台部分

Tony Kang vor 3 Monaten
Ursprung
Commit
1777a75f83

+ 1 - 0
lib/ztree/css/zTreeStyle.css

@@ -72,6 +72,7 @@ website:	http://code.google.com/p/jquerytree/
 
 .ztree li span.button.star {margin-right:2px; background-position:-126px -64px; vertical-align:top; *vertical-align:middle}
 .ztree li span.button.blue_core {margin-right:2px; background-position:-126px -16px; vertical-align:top; *vertical-align:middle}
+.ztree li span.button.right_arrow {margin-right:2px; background-position:-126px -48px; vertical-align:top; *vertical-align:middle}
 
 .ztree li span.button.ico_open{margin-right:2px; background-position:-110px -16px; vertical-align:top; *vertical-align:middle}
 .ztree li span.button.ico_close{margin-right:2px; background-position:-110px 0; vertical-align:top; *vertical-align:middle}

+ 7 - 0
web/maintain/report/html/rpt_tpl_dtl_info.html

@@ -104,5 +104,12 @@
             <!--
             -->
         </div>
+        <p>
+        <div class="form-group col-md-6">
+            <label>同类表 <input id="hasAssociationChk" type="checkbox" disabled></label>
+            <div class="ztree-warp">
+                <ul id="tpl_data_info_association" class="ztree"></ul>
+            </div>
+        </div>
     </div>
 </div>

+ 1 - 0
web/maintain/report/html/rpt_tpl_main.html

@@ -110,6 +110,7 @@
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/web/maintain/report/js/global.js"></script>
     <script src="/web/maintain/report/js/rpt_tpl_main.js"></script>
+    <script src="/web/maintain/report/js/rpt_tpl_association.js"></script>
     <script src="/web/maintain/report/js/rpt_tpl_cfg_helper.js"></script>
     <script src="/web/maintain/report/js/rpt_tpl_band.js"></script>
     <script src="/web/maintain/report/js/rpt_tpl_field_map.js"></script>

+ 40 - 0
web/maintain/report/js/cfg_const.js

@@ -601,6 +601,46 @@ let filterKeysSetting = {
     }
 };
 
+// 同类表
+const associationSetting = {
+    view: {
+        expandSpeed: "",
+        selectedMulti: false
+    },
+    check: {
+        enable: true
+    },
+    edit: {
+        enable: true,
+        showRemoveBtn: true,
+        showRenameBtn: false,
+        removeTitle: "移除同类表",
+        drag: {
+            isCopy: false,
+            isMove: false,
+        }
+    },
+    data: {
+        keep: {
+            parent: true,
+            leaf: true
+        },
+        key: {
+            children: "items",
+            name: "name",
+            title: "refId"
+        },
+        simpleData: {
+            enable: true,
+            rootPId: -1
+        }
+    },
+    callback: {
+        onCheck: associationOprObj.onCheck,
+    }
+    //
+};
+
 const engineering = {
     // 建筑工程
     ARCHITECTURE: 1,

+ 110 - 0
web/maintain/report/js/rpt_tpl_association.js

@@ -0,0 +1,110 @@
+const associationOprObj = {
+    treeObj: null,
+    iniAssociateNodes: function(allTopTplNodes) {
+      // 同类表初始化
+      const me = associationOprObj;
+      zTreeHelper.createTreeDirectly(
+        allTopTplNodes,
+        associationSetting,
+        "tpl_data_info_association",
+        associationOprObj
+      );
+      me.treeObj.expandAll(true);
+      const topNodes = me.treeObj.getNodes();
+      const private_setup_checked = function (itemNode) {
+        if (itemNode.nodeType === RT.NodeType.NODE) {
+          me.treeObj.setChkDisabled(itemNode, true);
+        } else if (itemNode.nodeType === RT.NodeType.TEMPLATE) {
+          me.treeObj.checkNode(itemNode, false); // 在初始化时,默认是不选;只有用户选择了具体的某一个表时,才会更新选择
+        }
+        if (itemNode.items && itemNode.items.length > 0) {
+          for (let subItem of itemNode.items) {
+            private_setup_checked(subItem);
+          }
+        }
+      };
+      for (let node of topNodes) {
+        me.treeObj.setChkDisabled(node, true);
+        if (node.items && node.items.length > 0) {
+          for (let item of node.items) {
+            me.treeObj.setChkDisabled(item, true);
+            private_setup_checked(item);
+          }
+        }
+      }
+    },
+    refreshNodes: function (refNode) {
+      const me = this;
+      // 不管三七二十一,先把所有节点的check给清除
+      const setUnCheck = (itemNode) => {
+        me.treeObj.checkNode(itemNode, false);
+        if (itemNode.items && itemNode.items.length > 0) {
+          for (let subItem of itemNode.items) {
+            setUnCheck(subItem);
+          }
+        }
+      };
+      const topNodes = me.treeObj.getNodes();
+      topNodes.forEach(node => {
+        setUnCheck(node);
+      });
+      const checkRefTpl = (itemNodes, associateRefIds) => {
+        for (const itemNode of itemNodes) {
+          if (itemNode.nodeType === RT.NodeType.TEMPLATE) {
+            if (associateRefIds.includes(itemNode.refId)) {
+              me.treeObj.checkNode(itemNode, true);
+            }
+          } else {
+            if (itemNode.items && itemNode.items.length > 0) {
+              checkRefTpl(itemNode.items, associateRefIds);
+            }
+          }
+        }
+      };
+      $("#hasAssociationChk").get(0).checked = false;
+      if (refNode && refNode.nodeType === RT.NodeType.TEMPLATE) {
+        if (refNode.associateRefIds && refNode.associateRefIds.length > 0) {
+          $("#hasAssociationChk").get(0).checked = true;
+          checkRefTpl(topNodes, refNode.associateRefIds);
+        }
+      }
+    },
+    getCheckedRefIds: function() {
+      const me = associationOprObj;
+      const rst = [];
+      const getCheckedId = (itemNodes) => {
+        for (const itemNode of itemNodes) {
+          if (itemNode.nodeType === RT.NodeType.TEMPLATE && itemNode.checked) {
+            rst.push(itemNode.refId);
+          }
+          if (itemNode.items && itemNode.items.length > 0) {
+            getCheckedId(itemNode.items);
+          }
+        }
+      };
+      if (me.treeObj) {
+        const topNodes = me.treeObj.getNodes();
+        getCheckedId(topNodes);
+      }
+      return rst;
+    },
+    onCheck: function(event, treeId, treeNode) {
+      const me = associationOprObj;
+      if (zTreeOprObj.currentNode) {
+        // 不考虑细节交互了,直接从头到尾扫一遍,重新整理associateRefIds信息,最后更新
+        zTreeOprObj.currentNode.associateRefIds = me.getCheckedRefIds();
+        if (zTreeOprObj.currentNode.associateRefIds.length > 0) {
+          $("#hasAssociationChk").get(0).checked = true;
+        } else {
+          $("#hasAssociationChk").get(0).checked = false;
+        }
+        const topPNode = zTreeOprObj.getParentNodeByNodeLevel(zTreeOprObj.currentNode, NODE_LEVEL_COMPILATION_NEW);
+        const newTopNode = zTreeOprObj.buildRootNodeDoc(topPNode);
+        zTreeOprObj.updateTreeRootNode(newTopNode, true, function (rst) {
+          if (!rst) {
+            alert("修改同类表请求失败!");
+          }
+        });
+      }
+    },
+  };

+ 7 - 0
web/maintain/report/js/rpt_tpl_main.js

@@ -214,6 +214,10 @@ let zTreeOprObj = {
                     if (item.hasOwnProperty('flags')) {
                         ir.flags = item.flags;
                     }
+                    // 同类表(associateRefIds)处理
+                    if (item.hasOwnProperty('associateRefIds')) {
+                        ir.associateRefIds = item.associateRefIds;
+                    }
                     ir.items = me.private_build_items(item.items);
                     itemRst.push(ir);
                 }
@@ -710,6 +714,8 @@ let zTreeOprObj = {
                         }
                     }
                 }
+                // 同类表初始化
+                associationOprObj.iniAssociateNodes(allTopTplNodes);
             });
         }, null, null);
     },
@@ -927,6 +933,7 @@ let zTreeOprObj = {
                 //显示报表模板
                 me.chkAndRreshRefTpl(true);
             }
+            associationOprObj.refreshNodes(me.currentNode);
         }
     },
     isFlowTpl: function () {