{"hidden":false,"children":[{"configs":{"serverScript":"var result = {},\n  records = {},\n  record, nodes, rs, meta;\n\nrs = app.run('select * from WB_DEPT order by ORDER_INDEX');\nmeta = rs.getMetaData();\nwhile (rs.next()) {\n  record = Wb.getRecord(rs, meta);\n  Wb.apply(record, {\n    text: record.DEPT_NAME,\n    iconCls: 'db_field_icon'\n  });\n  nodes = records[record.PARENT_DEPT];\n  if (nodes) {\n    nodes.push(record);\n  } else {\n    nodes = [record];\n    records[record.PARENT_DEPT] = nodes;\n  }\n}\n\nfunction createNodes(items, parentDept) {\n  items.children = records[parentDept] || [];\n  if (items.children.length)\n    items.expanded = true;\n  Wb.each(items.children, function(item) {\n    createNodes(item, item.DEPT_ID);\n  });\n}\ncreateNodes(result, '-1');\napp.send(result);","itemId":"module"},"expanded":false,"children":[],"type":"module"}],"roles":{"demo":1},"title":"查询","iconCls":"","inframe":false,"pageLink":""}