Esempio n. 1
0
  /**
   * 获取子节点数据
   *
   * @param parentIds
   * @return
   */
  public String childNodeData(String parentIds) {
    String sql = null;
    List<Department> list = null;
    if (null != parentIds) {
      sql =
          " select ids, names, isparent, images from pt_department where parentDepartmentIds = ? order by orderIds asc ";
      list = Department.dao.find(sql, parentIds);

    } else {
      sql =
          " select ids, names, isparent, images from pt_department where parentDepartmentIds is null order by orderIds asc ";
      list = Department.dao.find(sql);
    }

    StringBuilder sb = new StringBuilder();
    sb.append("[");

    int size = list.size() - 1;
    for (Department dept : list) {
      sb.append(" { ");
      sb.append(" id : '").append(dept.getStr("ids")).append("', ");
      sb.append(" name : '").append(dept.getStr("names")).append("', ");
      sb.append(" isParent : true, ");
      sb.append(" font : {'font-weight':'bold'}, ");
      sb.append(" icon : '")
          .append("/jsFile/zTree/css/zTreeStyle/img/diy/")
          .append(dept.getStr("images"))
          .append("' ");
      sb.append(" }");
      if (list.indexOf(dept) < size) {
        sb.append(", ");
      }
    }

    sb.append("]");

    return sb.toString();
  }
Esempio n. 2
0
  /**
   * 保存
   *
   * @param pIds
   * @param names
   * @param orderIds
   * @return
   */
  @Before(Tx.class)
  public String save(String pIds, String names, int orderIds) {
    Department pDept = Department.dao.findById(pIds);
    pDept.set("isparent", "true").update();

    String images = "";
    if (orderIds < 2 || orderIds > 9) {
      orderIds = 2;
      images = "2.png";
    } else {
      images = orderIds + ".png";
    }

    Department dept = new Department();
    dept.set("isparent", "false");
    dept.set("parentdepartmentids", pIds);
    dept.set("orderids", orderIds);
    dept.set("names", names);
    dept.set("images", images);
    dept.save();

    return dept.getStr("ids");
  }