EasyUI+JavaWeb奖助学金管理系统[18]-奖助学金申请功能开发

简介: 本文目录1. 本章任务2. 数据库表结构分析3. 学生查看申请记录功能开发4. 学生发起申请功能开发5. 总结

1. 本章任务

本章需要开发的奖助学金申请功能,是整个系统的核心功能,用于实现学生角色发起奖助学金项目的申请。


整体的申请流程是学生申请–班主任审核–学院管理员审核–学校管理员审核,全部审核通过后即为申请成功。


如果某一流程审批被驳回,即为失败。


2. 数据库表结构分析

审批过程中相关数据使用flow表来记录,flow表结构如下:

CREATE TABLE `flow` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `studentId` int(11) DEFAULT NULL,
  `studentName` varchar(255) DEFAULT NULL,
  `projectId` int(11) DEFAULT NULL,
  `projectName` varchar(255) DEFAULT NULL,
  `content` varchar(255) DEFAULT NULL,
  `classUserId` int(11) DEFAULT NULL,
  `classAdvice` varchar(255) DEFAULT NULL,
  `collegeUserId` int(11) DEFAULT NULL,
  `collegeAdvice` varchar(255) DEFAULT NULL,
  `schoolUserId` int(11) DEFAULT NULL,
  `schoolAdvice` varchar(255) DEFAULT NULL,
  `currentUserId` int(11) DEFAULT NULL,
  `currentNode` varchar(255) DEFAULT NULL COMMENT 'class/college/shcool/success/fail',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

这个表结构很重要,我们来详细解释下。


id是记录的唯一编号,从1开始自动增长。

studentId/studentName是提交申请的学生编号、姓名

projectId/projectName是学生申请的奖助学金项目的编号、名称

content是学生填写的申请内容

classUserId/classAdvice是班主任编号、班主任审核意见

collegeUserId/collegeAdvice是学院管理员编号、学院管理员审核意见

schoolUserId/schoolAdvice是学校管理员编号、学校管理员审核意见

currentUserId是当前处理节点的用户id,例如待班主任申请的话,currentUserId即为班主任的id

currentNode是当前审核节点,class/college/shcool值表示班主任审核中/学院审核中/学校审核中,success表示全部审核通过,fail表示被驳回。

好的,知道了存储结构后,学生奖助学金申请的需求基本也就清楚了。


学生需要能够查看已申请的记录相关的信息,也可以发起新的项目申请。


3. 学生查看申请记录功能开发

页面上显示申请记录的表格:

    <table id="mainTable" title="已申请项目列表" class="easyui-datagrid" url="CoreServlet?method=getStudentApplyFlowPage"
     pagination="true" singleSelect="true" fitColumns="true">
      <thead>
        <tr>
          <th data-options="field:'id',width:50">申请序号</th>
          <th data-options="field:'studentName',width:50">申请人</th>
          <th data-options="field:'projectName',width:50">申请项目名称</th>
          <th data-options="field:'content',width:100">申请说明</th>
          <th data-options="field:'classAdvice',width:100">班主任审核意见</th>
          <th data-options="field:'collegeAdvice',width:100">学院审核意见</th>
          <th data-options="field:'schoolAdvice',width:100">学校审核意见</th>
          <th data-options="field:'currentNode',width:100" formatter="formatCurrentNode">进度</th>
        </tr>
      </thead>
    </table>
其中进度需要格式化:
      // 格式化
      function formatCurrentNode(val, row) {
        if (val == "class") {
          return "待班主任审核";
        } else if (val == "college") {
          return "待学院审核";
        } else if (val == "shcool") {
          return "待学校审核";
        } else if (val == "success") {
          return "通过";
        } else if (val == "fail") {
          return "驳回";
        }
        return "";
      }
然后编写后台分页方法getStudentApplyFlowPage,修改CoreServlet:
    // 获取学生申请流程列表
    else if (method.equals("getStudentApplyFlowPage")) {
      FlowDao flowDao = new FlowDao();
      total = flowDao.getCountByStudentId(loginUser.getId());
      result.setTotal(total);
      result.setRows(flowDao.getPageByStudentId(page, rows, loginUser.getId()));
    }
修改UserDao,增加分页查询方法:
  /**
   * 获取数量
   */
  public int getCountByStudentId(String studentId) throws Exception {
    Connection conn = ConnectionUtils.getConnection();
    String sql = "select count(id) from flow where studentId=?";
    QueryRunner runner = new QueryRunner();
    Object[] params = { studentId };
    Number number = (Number) runner.query(conn, sql, new ScalarHandler(), params);
    int value = number.intValue();
    ConnectionUtils.releaseConnection(conn);
    return value;
  }
  /**
   * 分页查询
   */
  public List<Flow> getPageByStudentId(int page, int rows, String studentId) throws Exception {
    Connection conn = ConnectionUtils.getConnection();
    String sql = "select * from flow where studentId=? limit ?,?";
    QueryRunner runner = new QueryRunner();
    Object[] params = { studentId, (page - 1) * rows, rows };
    List<Flow> flows = runner.query(conn, sql, new BeanListHandler<Flow>(Flow.class), params);
    ConnectionUtils.releaseConnection(conn);
    return flows;
  }
注意学生只能查看自己的申请,所以查询条件里面要限制studentId。
4. 学生发起申请功能开发
学生发起申请,也是通过弹窗的方式实现,选择要申请的项目,然后填写申请理由,提交即可。
此处注意后台需要补全flow表需要的参数,例如班主任、学院管理员、学校管理员的id,就需要查询出来之后填入flow表。
首先编辑下申请的弹窗:
    <!-- 新增弹窗 -->
    <div id="dialog-add" class="easyui-dialog" title="发起申请" data-options="iconCls:'icon-ok',closed:'true'" style="width: 600px; height: 400px; padding: 10px">
      <table>
        <tr>
          <td>申请项目:</td>
          <td>
            <select id="add-projectId" class="easyui-combobox" style="width: 200px;">
            </select>
          </td>
        </tr>
        <tr>
          <td>申请说明:</td>
          <td><input id="add-content" class="easyui-textbox" style="width: 200px"></td>
        </tr>
        <tr>
          <td></td>
          <td><a id="btn" onclick="btnAddSubmit()" href="#" class="easyui-linkbutton">提交申请</a></td>
        </tr>
      </table>
    </div>
页面初始化时,需要将申请项目下拉框数据填充:
      // 初始化
      $(function() {
        loadProjects();
      });
      // 加载项目列表
      function loadProjects() {
        $.ajax({
          url: "CoreServlet?method=getProjectList",
          type: "post",
          dataType: "json",
          data: null,
          success: function(res) {
            console.log(res);
            if (res.code == 0) {
              // 为指定下拉框增加选项
              addItemsForSelect("#add-projectId", res.data);
            } else { //提示错误信息
              alert(res.msg);
            }
          },
        });
      }
      // 为下拉框增加选项
      function addItemsForSelect(id, data) {
        // 清空选项
        $(id).combobox("clear");
        // 动态添加的选项
        var items = [{
          "value": "-1",
          "text": "请选择"
        }];
        $.each(data, function(i, v) { //遍历返回值
          items.push({
            "value": v.id,
            "text": v.name
          });
        });
        // 加载数据
        $(id).combobox("loadData", items);
        // 设置默认选中值
        $(id).combobox("setValue", "-1");
      }
点击提交后,将数据提交到后台:
      // 新增保存
      function btnAddSubmit() {
        var param = {
          projectId: $("#add-projectId").combobox("getValue"),
          projectName: $("#add-projectId").combobox("getText"),
          content: $("#add-content").val(),
        }
        $.ajax({
          url: "CoreServlet?method=applySubmit",
          type: "post",
          dataType: "json",
          data: param,
          success: function(res) {
            console.log(res);
            if (res.code == 0) { //成功则刷新表格
              $('#mainTable').datagrid('reload');
              $('#dialog-add').dialog('close');
            } else { //提示错误信息
              alert(res.msg);
            }
          },
        });
      }
后台需要查询出关联的数据,然后新增一条flow记录。
    // 学生申请提交
    else if (method.equals("applySubmit")) {
      // 获取网页提交的信息
      String projectId = request.getParameter("projectId");
      String projectName = request.getParameter("projectName");
      String content = request.getParameter("content");
      // 获取管理员
      UserDao userDao = new UserDao();
      User classMaster = userDao.getClassMaster(loginUser);
      User collegeMaster = userDao.getCollegeMaster(loginUser);
      User schoolMaster = userDao.getSchoolMaster();
      // 新增
      FlowDao flowDao = new FlowDao();
      Flow flow = new Flow();
      flow.setStudentId(loginUser.getId());
      flow.setStudentName(loginUser.getUserName());
      flow.setProjectId(projectId);
      flow.setProjectName(projectName);
      flow.setContent(content);
      flow.setClassUserId(classMaster.getId());
      flow.setClassAdvice("");
      flow.setCollegeUserId(collegeMaster.getId());
      flow.setCollegeAdvice("");
      flow.setSchoolUserId(schoolMaster.getId());
      flow.setSchoolAdvice("");
      flow.setCurrentUserId(classMaster.getId());
      flow.setCurrentNode("class");
      flowDao.insert(flow);
      result.setCode(0);
      result.setMsg("操作成功");
    }
最后修改UserDao,增加一些查询方法:
  /**
   * 获取学生对应的班主任
   */
  public User getClassMaster(User student) throws Exception {
    Connection conn = ConnectionUtils.getConnection();
    String sql = "select * from user where role=? and departId=?";
    Object[] params = { "classmaster", student.getDepartId() };
    QueryRunner runner = new QueryRunner();
    User user = (User) runner.query(conn, sql, new BeanHandler<User>(User.class), params);
    ConnectionUtils.releaseConnection(conn);
    return user;
  }
  /**
   * 获取学生对应的学院管理员
   */
  public User getCollegeMaster(User student) throws Exception {
    Connection conn = ConnectionUtils.getConnection();
    String sql = "select u.* from user u where u.role=? and u.departId =(select d.parentId from depart d where d.id=?)";
    Object[] params = { "collegemaster", student.getDepartId() };
    QueryRunner runner = new QueryRunner();
    User user = (User) runner.query(conn, sql, new BeanHandler<User>(User.class), params);
    ConnectionUtils.releaseConnection(conn);
    return user;
  }
  /**
   * 获取学校管理员
   */
  public User getSchoolMaster() throws Exception {
    Connection conn = ConnectionUtils.getConnection();
    String sql = "select u.* from user u where u.role=?";
    Object[] params = { "schoolmaster" };
    QueryRunner runner = new QueryRunner();
    User user = (User) runner.query(conn, sql, new BeanHandler<User>(User.class), params);
    ConnectionUtils.releaseConnection(conn);
    return user;
  }

5. 总结

学生可以从系统中提交奖助学金申请,然后随时可以查询审批进度,还是相当管用的,这个系统具备了一定的社会价值。

稳得很。

相关文章
|
4天前
基于EasyUI的后台管理系统页面原型_示例图_下载地址
基于EasyUI的后台管理系统页面原型_示例图_下载地址
5 0
|
8月前
|
数据库
22EasyUI 数据网格- 添加查询功能
22EasyUI 数据网格- 添加查询功能
23 0
|
11月前
|
数据可视化 安全 Java
【项目源码】基于spring boot+mybatis+easyui开发的质量溯源系统
粮油溯源系统是从种植到加工、包装、库存、物流、销售、售出、异常反馈的全流程可视化质量溯源系统。技术架构:spring boot+mybatis+easyui+mysql
【项目源码】基于spring boot+mybatis+easyui开发的质量溯源系统
|
安全 数据安全/隐私保护
EasyUI+JavaWeb奖助学金管理系统[20]-项目总结与展望
本文目录 1. 总结 1.1 管理员新增奖助学金项目 1.2 学生发起申请 1.3 班主任审批 1.4 学院管理员审批 1.5 学校管理员审批 1.6 学生查看申请结果 2. 展望
153 0
EasyUI+JavaWeb奖助学金管理系统[20]-项目总结与展望
|
前端开发
EasyUI+JavaWeb奖助学金管理系统[19]-奖助学金审批功能开发
本文目录 1. 本章任务 2. 查看当前待审批的申请 3. 审批功能的开发 4. 总结
180 0

热门文章

最新文章