Explorar el Código

GLY-4624 - 后台部分

Tony Kang hace 3 meses
padre
commit
37b9b751fe

+ 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 - 1
web/maintain/report/html/rpt_tpl_dtl_info.html

@@ -143,7 +143,6 @@
                 </div>
                 
             </div>
-
         </div>
         <div class="row p-3">
             <div class="input-group col-3">
@@ -220,6 +219,13 @@
                 </select>
             </div>
         </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("修改同类表请求失败!");
+        }
+      });
+    }
+  },
+};

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

@@ -237,6 +237,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);
         }
@@ -247,13 +251,9 @@ let zTreeOprObj = {
 
   addHoverDom: function (treeId, treeNode) {
     let me = zTreeOprObj,
-      sObj = $("#" + treeNode.tId + "_span");
-    if (
-      treeNode.editNameFlag ||
-      $("#addBtn_" + treeNode.tId).length > 0 ||
-      treeNode.nodeType === RT.NodeType.TEMPLATE
-    )
-      return;
+      sObj = $("#" + treeNode.tId + IDMark_Span);
+
+    if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0 || treeNode.nodeType === RT.NodeType.TEMPLATE) return;
     if (treeNode.level === 0) {
       let addStr =
         "<span class='button star' id='addBtn_" +
@@ -854,6 +854,8 @@ let zTreeOprObj = {
               }
             }
           }
+          // 同类表初始化
+          associationOprObj.iniAssociateNodes(allTopTplNodes);
         });
       },
       null,
@@ -1116,6 +1118,7 @@ let zTreeOprObj = {
         //显示报表模板
         me.chkAndRreshRefTpl(true);
       }
+      associationOprObj.refreshNodes(me.currentNode);
     }
   },
   isFlowTpl: function () {