• 会议OA项目之待开会议&&所有会议功能


    目录

    一、SQL语句的编写

            1.1 待开会议的SQL

            1.2 所有会议的SQL

    二、前端页面

    三、需要封装的Js代码

    四、后台代码的编写

            4.1 待开会议后台

            4.2 所有会议后台

    五、测试查询


    一、SQL语句的编写

            1.1 待开会议的SQL

                    首先我们先来分析待开会议需要的SQL语句,分析得到的SQL代码如下:

    1. -- 待开会议与我的会议区别就是需要匹配三个数据库列段
    2. select CONCAT(
    3. canyuze,',',liexize,',',zhuchiren),a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,
    4. b.`name` zhuchirenname,
    5. a.location,
    6. DATE_FORMAT(a.startTime,'%y-%m-%d %h-%M-%s') startTime,
    7. DATE_FORMAT(a.endTime,'%y-%m-%d %h-%M-%s') endTime,
    8. a.state,
    9. (
    10. case a.state
    11. when 0 then '取消会议'
    12. when 1 then '新建'
    13. when 2 then '待审核'
    14. when 3 then '驳回'
    15. when 4 then '待开'
    16. when 5 then '进行中'
    17. when 6 then '开启投票'
    18. when 7 then '结束会议'
    19. else '其它' end
    20. ) meetingstate,
    21. a.seatPic,a.remark,a.auditor,
    22. c.`name` auditorname from t_oa_meeting_info a
    23. inner join t_oa_user b on a.zhuchiren = b.id
    24. left join t_oa_user c on a.auditor = c.id where 1=1
    25. and state = 4 and FIND_IN_SET(1,CONCAT(
    26. canyuze,',',liexize,',',zhuchiren))

            1.2 所有会议的SQL

                    然后我们分析所有会议的SQL语句和待开会议极为相似,就是多了一个审批者的数据库字段;所以我们就copy一份上面分析的来的SQL代码,修改一下就好啦。

    就是要注意:要用IF NULL判断,不然就会因为有为空的审批人而丢失数据!

    1. -- 所有会议
    2. select a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,
    3. b.`name` zhuchirenname,
    4. a.location,
    5. DATE_FORMAT(a.startTime,'%y-%m-%d %h-%M-%s') startTime,
    6. DATE_FORMAT(a.endTime,'%y-%m-%d %h-%M-%s') endTime,
    7. a.state,
    8. (
    9. case a.state
    10. when 0 then '取消会议'
    11. when 1 then '新建'
    12. when 2 then '待审核'
    13. when 3 then '驳回'
    14. when 4 then '待开'
    15. when 5 then '进行中'
    16. when 6 then '开启投票'
    17. when 7 then '结束会议'
    18. else '其它' end
    19. ) meetingstate,
    20. a.seatPic,a.remark,a.auditor,
    21. c.`name` auditorname from t_oa_meeting_info a
    22. inner join t_oa_user b on a.zhuchiren = b.id
    23. left join t_oa_user c on a.auditor = c.id where 1=1
    24. and FIND_IN_SET(1,CONCAT(
    25. a.canyuze,',',a.liexize,',',a.zhuchiren,',',IFNULL(a.auditor,-1)))

    二、前端页面

    2.1待开会议 meetingWaiting.jsp

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. <%@include file="/common/header.jsp"%>
    4. html>
    5. <html>
    6. <head>
    7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    8. <script type="text/javascript" src="static/js/meeting/meetingWaiting.js">script>
    9. head>
    10. <style>
    11. body{
    12. margin:15px;
    13. }
    14. .layui-table-cell {height: inherit;}
    15. .layui-layer-page .layui-layer-content { overflow: visible !important;}
    16. style>
    17. <body>
    18. <div class="layui-form-item">
    19. <div class="layui-inline">
    20. <label class="layui-form-label">会议标题:label>
    21. <div class="layui-input-inline">
    22. <input type="hidden" id="userid" value="${sessionScope.user.id }"/>
    23. <input type="text" id="title" autocomplete="off"
    24. class="layui-input">
    25. div>
    26. div>
    27. <div class="layui-inline">
    28. <button id="btn_meeting_search" class="layui-btn layui-btn-normal">
    29. <i class="layui-icon">i> 查询
    30. button>
    31. div>
    32. div>
    33. <table style="margin-top: -15px;" id="tb_meeting" lay-filter="tb_meeting">table>
    34. body>
    35. html>

    2.2所有会议  meetingAll.jsp

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. <%@include file="/common/header.jsp"%>
    4. html>
    5. <html>
    6. <head>
    7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    8. <script type="text/javascript" src="static/js/meeting/meetingAll.js">script>
    9. head>
    10. <style>
    11. body{
    12. margin:15px;
    13. }
    14. .layui-table-cell {height: inherit;}
    15. .layui-layer-page .layui-layer-content { overflow: visible !important;}
    16. style>
    17. <body>
    18. <div class="layui-form-item">
    19. <div class="layui-inline">
    20. <label class="layui-form-label">会议标题:label>
    21. <div class="layui-input-inline">
    22. <input type="hidden" id="userid" value="${sessionScope.user.id }"/>
    23. <input type="text" id="title" autocomplete="off"
    24. class="layui-input">
    25. div>
    26. div>
    27. <div class="layui-inline">
    28. <button id="btn_meeting_search" class="layui-btn layui-btn-normal">
    29. <i class="layui-icon">i> 查询
    30. button>
    31. div>
    32. div>
    33. <table style="margin-top: -15px;" id="tb_meeting" lay-filter="tb_meeting">table>
    34. body>
    35. html>

    三、需要封装的Js代码

    3.1待开会议 meetingWaiting.js

    1. let layer,form,table,$;
    2. var row;
    3. layui.use(['layer','form','table'],function(){
    4. layer=layui.layer,form=layui.form,table=layui.table,$=layui.jquery;
    5. //初始化会议列表
    6. initMeeting();
    7. //绑定查询按钮的点击事件
    8. $('#btn_meeting_search').click(function(){
    9. query();
    10. });
    11. });
    12. //1.初始化会议列表
    13. function initMeeting(){
    14. table.render({ //执行渲染
    15. elem: '#tb_meeting', //指定原始表格元素选择器(推荐id选择器)
    16. height: 400, //自定义高度
    17. loading: false, //是否显示加载条(默认 true)
    18. cols: [[ //设置表头
    19. {field: 'title', title: '会议标题', width: 180},
    20. {field: 'location', title: '会议地点', width: 120},
    21. {field: 'startTime', title: '开始时间', width: 180},
    22. {field: 'endTime', title: '结束时间', width: 180},
    23. {field: 'meetingstate', title: '会议状态', width: 90},
    24. {field: 'zhuchirenname', title: '主持人', width: 120},
    25. //{field: '', title: '操作', width: 260, toolbar: '#tbMeeting'}
    26. ]]
    27. });
    28. }
    29. //2.待开会议
    30. function query(){
    31. table.reload('tb_meeting', {
    32. url: 'info.action', //请求地址
    33. method: 'POST', //请求方式,GET或者POST
    34. loading: true, //是否显示加载条(默认 true)
    35. page: true, //是否分页
    36. where: { //设定异步数据接口的额外参数,任意设
    37. 'methodName':'queryMeetingInfoByState',
    38. 'title':$('#title').val(),
    39. 'zhuchiren':$('#userid').val(),
    40. 'state':4
    41. },
    42. request: { //自定义分页请求参数名
    43. pageName: 'page', //页码的参数名称,默认:page
    44. limitName: 'rows' //每页数据量的参数名,默认:limit
    45. },
    46. done: function (res, curr, count) {
    47. //查询完成的回调函数
    48. }
    49. });
    50. }

    3.2所有会议 meetingAll.js

    1. let layer,form,table,$;
    2. var row;
    3. layui.use(['layer','form','table'],function(){
    4. layer=layui.layer,form=layui.form,table=layui.table,$=layui.jquery;
    5. //初始化会议列表
    6. initMeeting();
    7. //绑定查询按钮的点击事件
    8. $('#btn_meeting_search').click(function(){
    9. query();
    10. });
    11. });
    12. //1.初始化会议列表
    13. function initMeeting(){
    14. table.render({ //执行渲染
    15. elem: '#tb_meeting', //指定原始表格元素选择器(推荐id选择器)
    16. height: 400, //自定义高度
    17. loading: false, //是否显示加载条(默认 true)
    18. cols: [[ //设置表头
    19. {field: 'title', title: '会议标题', width: 180},
    20. {field: 'location', title: '会议地点', width: 120},
    21. {field: 'startTime', title: '开始时间', width: 180},
    22. {field: 'endTime', title: '结束时间', width: 180},
    23. {field: 'meetingstate', title: '会议状态', width: 90},
    24. {field: 'zhuchirenname', title: '主持人', width: 120},
    25. //{field: '', title: '操作', width: 260, toolbar: '#tbMeeting'}
    26. ]]
    27. });
    28. }
    29. //2.查询所有会议
    30. function query(){
    31. table.reload('tb_meeting', {
    32. url: 'info.action', //请求地址
    33. method: 'POST', //请求方式,GET或者POST
    34. loading: true, //是否显示加载条(默认 true)
    35. page: true, //是否分页
    36. where: { //设定异步数据接口的额外参数,任意设
    37. 'methodName':'allInfos',
    38. 'title':$('#title').val(),
    39. 'zhuchiren':$('#userid').val()
    40. },
    41. request: { //自定义分页请求参数名
    42. pageName: 'page', //页码的参数名称,默认:page
    43. limitName: 'rows' //每页数据量的参数名,默认:limit
    44. },
    45. done: function (res, curr, count) {
    46. //查询完成的回调函数
    47. }
    48. });
    49. }

    四、后台代码的编写

            4.1 待开会议后台

                    我们编写Dao方法:

    1. //待开会议
    2. public List> queryMeetingInfoByState(MeetingInfo mi, PageBean pageBean) throws Exception {
    3. String sql = "select CONCAT(\r\n" +
    4. " canyuze,',',liexize,',',zhuchiren),a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,\r\n" +
    5. " b.`name` zhuchirenname,\r\n" +
    6. " a.location,\r\n" +
    7. " DATE_FORMAT(a.startTime,'%y-%m-%d %h-%M-%s') startTime,\r\n" +
    8. " DATE_FORMAT(a.endTime,'%y-%m-%d %h-%M-%s') endTime,\r\n" +
    9. " a.state,\r\n" +
    10. " (\r\n" +
    11. " case a.state\r\n" +
    12. " when 0 then '取消会议'\r\n" +
    13. " when 1 then '新建'\r\n" +
    14. " when 2 then '待审核'\r\n" +
    15. " when 3 then '驳回'\r\n" +
    16. " when 4 then '待开'\r\n" +
    17. " when 5 then '进行中'\r\n" +
    18. " when 6 then '开启投票'\r\n" +
    19. " when 7 then '结束会议'\r\n" +
    20. " else '其它' end \r\n" +
    21. " ) meetingstate,\r\n" +
    22. " a.seatPic,a.remark,a.auditor,\r\n" +
    23. " c.`name` auditorname from t_oa_meeting_info a\r\n" +
    24. " inner join t_oa_user b on a.zhuchiren = b.id\r\n" +
    25. " left join t_oa_user c on a.auditor = c.id where 1=1\r\n" +
    26. " and state = 4 and FIND_IN_SET("+mi.getZhuchiren()+",CONCAT(\r\n" +
    27. " canyuze,',',liexize,',',zhuchiren))";
    28. return super.executeQuery(sql, pageBean);
    29. }

    再就是Action层: 

    1. //待开会议
    2. public String queryMeetingInfoByState(HttpServletRequest req, HttpServletResponse resp) {
    3. try {
    4. PageBean pageBean = new PageBean();
    5. //初始化
    6. pageBean.setRequest(req);
    7. List> list = mid.queryMeetingInfoByState(mi, pageBean);
    8. ResponseUtil.writeJson(resp, R.ok(0, "待开会议数据查询成功" ,pageBean.getTotal() ,list));
    9. } catch (Exception e) {
    10. e.printStackTrace();
    11. try {
    12. ResponseUtil.writeJson(resp, R.ok(0, "待开会议数据查询失败"));
    13. } catch (Exception e1) {
    14. e1.printStackTrace();
    15. }
    16. }
    17. return null;
    18. }

            4.2 所有会议后台

               然后就是所有会议查询的后台代码了,这个和上面的待开会议的后台代码是一样步骤的:

               依然是先写Dao方法:

    1. //所有会议
    2. public List> allInfos(MeetingInfo mi, PageBean pageBean) throws Exception {
    3. String sql = "select a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,\r\n" +
    4. " b.`name` zhuchirenname,\r\n" +
    5. " a.location,\r\n" +
    6. " DATE_FORMAT(a.startTime,'%y-%m-%d %h-%M-%s') startTime,\r\n" +
    7. " DATE_FORMAT(a.endTime,'%y-%m-%d %h-%M-%s') endTime,\r\n" +
    8. " a.state,\r\n" +
    9. " (\r\n" +
    10. " case a.state\r\n" +
    11. " when 0 then '取消会议'\r\n" +
    12. " when 1 then '新建'\r\n" +
    13. " when 2 then '待审核'\r\n" +
    14. " when 3 then '驳回'\r\n" +
    15. " when 4 then '待开'\r\n" +
    16. " when 5 then '进行中'\r\n" +
    17. " when 6 then '开启投票'\r\n" +
    18. " when 7 then '结束会议'\r\n" +
    19. " else '其它' end \r\n" +
    20. " ) meetingstate,\r\n" +
    21. " a.seatPic,a.remark,a.auditor,\r\n" +
    22. " c.`name` auditorname from t_oa_meeting_info a\r\n" +
    23. " inner join t_oa_user b on a.zhuchiren = b.id\r\n" +
    24. " left join t_oa_user c on a.auditor = c.id where 1=1\r\n" +
    25. " and FIND_IN_SET("+mi.getZhuchiren()+",CONCAT(\r\n" +
    26. " a.canyuze,',',a.liexize,',',a.zhuchiren,',',IFNULL(a.auditor,-1)))";
    27. return super.executeQuery(sql, pageBean);
    28. }

    然后就是Action层: 

    1. //所有会议
    2. public String allInfos(HttpServletRequest req, HttpServletResponse resp) {
    3. try {
    4. PageBean pageBean = new PageBean();
    5. //初始化
    6. pageBean.setRequest(req);
    7. List> list = mid.allInfos(mi, pageBean);
    8. ResponseUtil.writeJson(resp, R.ok(0, "所有会议数据查询成功" ,pageBean.getTotal() ,list));
    9. } catch (Exception e) {
    10. e.printStackTrace();
    11. try {
    12. ResponseUtil.writeJson(resp, R.ok(0, "所有会议数据查询失败"));
    13. } catch (Exception e1) {
    14. e1.printStackTrace();
    15. }
    16. }
    17. return null;
    18. }

     五、测试查询

    5.1 测试

    上面的代码全部编写好了后,我们就可以来测试一下了!

    待开会议:

    所有会议: 

    所有会议也全部都查询出来啦~


    OK,以上就是Leaf今天带来的关于会议OA项目的几个功能代码分享,喜欢的可以关注一起学习噢,有不理解的地方也可以私信来问我一起学习噢,我们下次见!!!

  • 相关阅读:
    2022年高教社杯国赛C题 | 古代玻璃制品的成分分析与鉴别(Matlab实现)
    vivado流程导航器详细介绍【全网最详细】
    Linux shell之重定向
    TG Pro 2.66(硬件温度监测)
    LNMP搭建
    CSRF漏洞
    2023黑龙江八一农垦大学计算机考研信息汇总
    高软核心问题
    java图形验证码到底是怎么生成的?
    QML的Popup遇到的坑
  • 原文地址:https://blog.csdn.net/qq_63492318/article/details/126056083