EasyUI+JavaWeb奖助学金管理系统[18]-奖助学金申请功能开发
點此查看本系列文章目錄、源代碼、配套視頻教程
本文目錄
- 1. 本章任務(wù)
- 2. 數(shù)據(jù)庫表結(jié)構(gòu)分析
- 3. 學(xué)生查看申請記錄功能開發(fā)
- 4. 學(xué)生發(fā)起申請功能開發(fā)
- 5. 總結(jié)
1. 本章任務(wù)
本章需要開發(fā)的獎助學(xué)金申請功能,是整個系統(tǒng)的核心功能,用于實現(xiàn)學(xué)生角色發(fā)起獎助學(xué)金項目的申請。
整體的申請流程是學(xué)生申請–班主任審核–學(xué)院管理員審核–學(xué)校管理員審核,全部審核通過后即為申請成功。
如果某一流程審批被駁回,即為失敗。
2. 數(shù)據(jù)庫表結(jié)構(gòu)分析
審批過程中相關(guān)數(shù)據(jù)使用flow表來記錄,flow表結(jié)構(gòu)如下:
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;這個表結(jié)構(gòu)很重要,我們來詳細(xì)解釋下。
好的,知道了存儲結(jié)構(gòu)后,學(xué)生獎助學(xué)金申請的需求基本也就清楚了。
學(xué)生需要能夠查看已申請的記錄相關(guān)的信息,也可以發(fā)起新的項目申請。
3. 學(xué)生查看申請記錄功能開發(fā)
頁面上顯示申請記錄的表格:
<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">學(xué)院審核意見</th><th data-options="field:'schoolAdvice',width:100">學(xué)校審核意見</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 "待學(xué)院審核";} else if (val == "shcool") {return "待學(xué)校審核";} else if (val == "success") {return "通過";} else if (val == "fail") {return "駁回";}return "";}然后編寫后臺分頁方法getStudentApplyFlowPage,修改CoreServlet:
// 獲取學(xué)生申請流程列表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,增加分頁查詢方法:
/*** 獲取數(shù)量*/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;}注意學(xué)生只能查看自己的申請,所以查詢條件里面要限制studentId。
4. 學(xué)生發(fā)起申請功能開發(fā)
學(xué)生發(fā)起申請,也是通過彈窗的方式實現(xiàn),選擇要申請的項目,然后填寫申請理由,提交即可。
此處注意后臺需要補全flow表需要的參數(shù),例如班主任、學(xué)院管理員、學(xué)校管理員的id,就需要查詢出來之后填入flow表。
首先編輯下申請的彈窗:
<!-- 新增彈窗 --><div id="dialog-add" class="easyui-dialog" title="發(fā)起申請" 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>頁面初始化時,需要將申請項目下拉框數(shù)據(jù)填充:
// 初始化$(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");// 動態(tài)添加的選項var items = [{"value": "-1","text": "請選擇"}];$.each(data, function(i, v) { //遍歷返回值items.push({"value": v.id,"text": v.name});});// 加載數(shù)據(jù)$(id).combobox("loadData", items);// 設(shè)置默認(rèn)選中值$(id).combobox("setValue", "-1");}點擊提交后,將數(shù)據(jù)提交到后臺:
// 新增保存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);}},});}后臺需要查詢出關(guān)聯(lián)的數(shù)據(jù),然后新增一條flow記錄。
// 學(xué)生申請?zhí)峤?/span>else if (method.equals("applySubmit")) {// 獲取網(wǎng)頁提交的信息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,增加一些查詢方法:
/*** 獲取學(xué)生對應(yīng)的班主任*/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;}/*** 獲取學(xué)生對應(yīng)的學(xué)院管理員*/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;}/*** 獲取學(xué)校管理員*/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. 總結(jié)
學(xué)生可以從系統(tǒng)中提交獎助學(xué)金申請,然后隨時可以查詢審批進度,還是相當(dāng)管用的,這個系統(tǒng)具備了一定的社會價值。
穩(wěn)得很。
總結(jié)
以上是生活随笔為你收集整理的EasyUI+JavaWeb奖助学金管理系统[18]-奖助学金申请功能开发的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ListView适配器
- 下一篇: java信息管理系统总结_java实现科