• 会议OA项目(三)---我的会议(会议排座、送审)


    目录

    前言

    一、需求分析

    二、准备工作

    三、编码

            1、后台编码

            2、前端编码

    四、效果展示


    前言

            上篇分享了会议OA项目的我的会议功能的查询取消会议。本篇文章将完善我的会议功能。

    我的会议功能有一个难点------会议排座。


    一、需求分析

            为什么会有会议排座功能?

    参会人员所坐的位置是有讲究的,并不是随便坐。

    请人吃饭,请客的人坐在主位;那么开会最重要的人,做决策的人就要坐在主位。 

     会议排座:

    一个会议,参会人数、怎么排座位都是有讲究的。

     如图:我可以这边坐四个、对面坐三个。也可以这一边没有一个人。

     领导突然要来听会议,是不是要把他加到会议中。

     

    所以,对于排座。点击排座,界面需要有参会人员、列席人员以及主持人。同时、可以增加座位。

    排座可以将位置进行拖动。

     

    在送审之前,我们要排好座位,没有排座如果坐错位置了,审批人就得罪人啦。

    所以没有排座 不能送审。

    二、准备工作

            我们需要对会议排座,且排座可以拖动。对应的功能我们是自己编写还是查找资料呢?

    为了提高开发效率,我选择的是找jQuery是否有对应的插件,将其进行修改,改为适合我们项目的需求。

     

    其中找到了jQuery的Portal 插件。但是与我们项目需求差距有点大。

    另一个,找到的资料更符合我们的项目。

     

     会发现,每一个“座位”太小了而且重叠了。如果有很多个人要开会,我们根本分不清。我们对它进行一系列的修改

     

     修改后就合适多了。将素材和我们的代码拼接使用。

    SQL语句分析:

    我们要查出对应的会议由哪些人参会。

    参会人员:参会者、列席者 、主持人

    find_in_set 与 in 的区别

     

     

     在mysql中in可以包括指定的数字,而find_in_set()用于特定的数据类型

     

    三、编码

            1、后台编码

            UserDao

    1. package com.zking.dao;
    2. import java.sql.SQLException;
    3. import java.util.List;
    4. import java.util.Map;
    5. import com.zking.entity.User;
    6. import com.zking.util.BaseDao;
    7. import com.zking.util.PageBean;
    8. import com.zking.util.StringUtils;
    9. public class UserDao extends BaseDao {
    10. public User login(User user) throws Exception {
    11. String sql = "select * from t_oa_user where loginName = '"
    12. +user.getLoginName()+"' and pwd = '"+user.getPwd()+"'";
    13. // 根据sql查询符合条件的用户,通常只会返回一条数据
    14. List users = super.executeQuery(sql, User.class, null);
    15. return users == null || users.size() == 0 ? null : users.get(0);
    16. // return super.executeQuery(sql, clz, pageBean);
    17. }
    18. // 查询用户信息及对应的角色,角色是通过case when得来的
    19. public List> list(User user,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
    20. String sql = "SELECT *\r\n" +
    21. ",(case rid \r\n" +
    22. "when 1 then '管理员' \r\n" +
    23. "when 2 then '发起者' \r\n" +
    24. "when 3 then '审批者' \r\n" +
    25. "when 4 then '参与者' \r\n" +
    26. "when 5 then '会议室管理员' \r\n" +
    27. "else '其他' end \r\n" +
    28. ") roleName \r\n" +
    29. "from \r\n" +
    30. "t_oa_user where 1 = 1 ";
    31. String name = user.getName();
    32. if(StringUtils.isNotBlank(name)) {
    33. sql += " and name like '%"+name+"%'";
    34. }
    35. // 当实体类的属性完全包含数据库查询出来的列段的时候使用
    36. // super.executeQuery(sql, User.class, pageBean)
    37. // 返回List>,对应的是链表查询,单个实体类对象不完全包含查询的列段
    38. return super.executeQuery(sql, pageBean);
    39. }
    40. // 查询所有用户用于绑定多功能下拉框
    41. public List> queryUserAll(User user,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
    42. String sql = "select id as value,name from t_oa_user";
    43. return super.executeQuery(sql, pageBean);
    44. }
    45. public int add(User user) throws Exception {
    46. String sql = "insert into t_oa_user(name,loginName,pwd) values(?,?,?)";
    47. return super.executeUpdate(sql, user, new String[] {"name","loginName","pwd"});
    48. }
    49. public int del(User user) throws Exception {
    50. String sql = "delete from t_oa_user where id = ?";
    51. return super.executeUpdate(sql, user, new String[] {"id"});
    52. }
    53. public int edit(User user) throws Exception {
    54. String sql = "update t_oa_user set name = ?,loginName = ? ,pwd = ? where id = ?";
    55. return super.executeUpdate(sql, user, new String[] {"name","loginName","pwd","id"});
    56. }
    57. public List queryUserByMeetingId(Long meetingId) throws Exception{
    58. String sql="select * from t_oa_user where FIND_IN_SET(id,"
    59. + "(select concat(canyuze,',',liexize,',',zhuchiren) uid "
    60. + "from t_oa_meeting_info where id="+meetingId+"))";
    61. return super.executeQuery(sql, User.class, null);
    62. }
    63. }

            UserAction

     

    1. package com.zking.web;
    2. import java.util.HashMap;
    3. import java.util.List;
    4. import java.util.Map;
    5. import javax.servlet.http.HttpServletRequest;
    6. import javax.servlet.http.HttpServletResponse;
    7. import com.zking.dao.UserDao;
    8. import com.zking.entity.User;
    9. import com.zking.framework.ActionSupport;
    10. import com.zking.framework.ModelDriver;
    11. import com.zking.util.BaseDao;
    12. import com.zking.util.CommonUtils;
    13. import com.zking.util.PageBean;
    14. import com.zking.util.R;
    15. import com.zking.util.ResponseUtil;
    16. public class UserAction extends ActionSupport implements ModelDriver {
    17. private User user = new User();
    18. private UserDao userDao = new UserDao();
    19. public String login(HttpServletRequest req, HttpServletResponse resp) {
    20. try {
    21. User u = userDao.login(user);
    22. // 通过账户名密码查到了用户记录
    23. if (u != null) {
    24. // ResponseUtil.writeJson(resp, new R()
    25. // .data("code", 200)
    26. // .data("msg", "成功"));
    27. ResponseUtil.writeJson(resp, R.ok(200, "登录成功"));
    28. req.getSession().setAttribute("user", u);
    29. } else {
    30. ResponseUtil.writeJson(resp, R.error(0, "用户名密码错误"));
    31. }
    32. } catch (Exception e) {
    33. e.printStackTrace();
    34. try {
    35. ResponseUtil.writeJson(resp, R.error(0, "用户名密码错误"));
    36. } catch (Exception e1) {
    37. e1.printStackTrace();
    38. }
    39. }
    40. return null;
    41. }
    42. // 用户查询
    43. public String list(HttpServletRequest req, HttpServletResponse resp) {
    44. try {
    45. PageBean pageBean = new PageBean();
    46. pageBean.setRequest(req);
    47. List> users = userDao.list(user, pageBean);
    48. // 注意:layui中的数据表格的格式
    49. ResponseUtil.writeJson(resp, R.ok(0, "用户数据查询成功" , pageBean.getTotal(), users));
    50. } catch (Exception e) {
    51. e.printStackTrace();
    52. try {
    53. ResponseUtil.writeJson(resp, R.error(0, "用户数据查询失败"));
    54. } catch (Exception e1) {
    55. e1.printStackTrace();
    56. }
    57. }
    58. return null;
    59. }
    60. // 查询所有用户用于绑定多功能下拉框
    61. public String queryUserAll(HttpServletRequest req, HttpServletResponse resp) {
    62. try {
    63. List> users = userDao.queryUserAll(user, null);
    64. // 注意:layui中的数据表格的格式
    65. ResponseUtil.writeJson(resp, R.ok(0, "多功能下拉框数据查询成功" , users));
    66. } catch (Exception e) {
    67. e.printStackTrace();
    68. try {
    69. ResponseUtil.writeJson(resp, R.error(0, "多功能下拉框数据查询失败"));
    70. } catch (Exception e1) {
    71. e1.printStackTrace();
    72. }
    73. }
    74. return null;
    75. }
    76. public String add(HttpServletRequest req, HttpServletResponse resp) {
    77. try {
    78. // rs是sql语句执行的影响行数
    79. int rs = userDao.add(user);
    80. if(rs > 0) {
    81. ResponseUtil.writeJson(resp, R.ok(200, "用户数据新增成功"));
    82. }else {
    83. ResponseUtil.writeJson(resp, R.error(0, "用户数据新增失败"));
    84. }
    85. } catch (Exception e) {
    86. e.printStackTrace();
    87. try {
    88. ResponseUtil.writeJson(resp, R.error(0, "用户数据新增失败"));
    89. } catch (Exception e1) {
    90. e1.printStackTrace();
    91. }
    92. }
    93. return null;
    94. }
    95. public String del(HttpServletRequest req, HttpServletResponse resp) {
    96. try {
    97. // rs是sql语句执行的影响行数
    98. int rs = userDao.del(user);
    99. if(rs > 0) {
    100. ResponseUtil.writeJson(resp, R.ok(200, "用户数据删除成功"));
    101. }else {
    102. ResponseUtil.writeJson(resp, R.error(0, "用户数据删除失败"));
    103. }
    104. } catch (Exception e) {
    105. e.printStackTrace();
    106. try {
    107. ResponseUtil.writeJson(resp, R.error(0, "用户数据删除失败"));
    108. } catch (Exception e1) {
    109. e1.printStackTrace();
    110. }
    111. }
    112. return null;
    113. }
    114. public String edit(HttpServletRequest req, HttpServletResponse resp) {
    115. try {
    116. // rs是sql语句执行的影响行数
    117. int rs = userDao.edit(user);
    118. if(rs > 0) {
    119. ResponseUtil.writeJson(resp, R.ok(200, "用户数据修改成功"));
    120. }else {
    121. ResponseUtil.writeJson(resp, R.error(0, "用户数据修改失败"));
    122. }
    123. } catch (Exception e) {
    124. e.printStackTrace();
    125. try {
    126. ResponseUtil.writeJson(resp, R.error(0, "用户数据修改失败"));
    127. } catch (Exception e1) {
    128. e1.printStackTrace();
    129. }
    130. }
    131. return null;
    132. }
    133. public String queryUserByMeetingId(HttpServletRequest req,HttpServletResponse resp) throws Exception{
    134. try {
    135. String meetingId = req.getParameter("meetingId");
    136. List users = userDao.queryUserByMeetingId(Long.valueOf(meetingId));
    137. CommonUtils.toJson(true, users, resp);
    138. } catch (Exception e) {
    139. CommonUtils.toJson(false,"获取参会人员信息失败", resp);
    140. e.printStackTrace();
    141. }
    142. return null;
    143. }
    144. @Override
    145. public User getModel() {
    146. return user;
    147. }
    148. }

            meetingInfoDao

    1. package com.zking.dao;
    2. import java.sql.SQLException;
    3. import java.util.List;
    4. import java.util.Map;
    5. import com.zking.entity.MeetingInfo;
    6. import com.zking.util.BaseDao;
    7. import com.zking.util.PageBean;
    8. import com.zking.util.StringUtils;
    9. public class MeetingInfoDao extends BaseDao{
    10. // 会议信息新增
    11. public int add(MeetingInfo t) throws Exception {
    12. String sql = "insert into t_oa_meeting_info"
    13. + "(title,content,canyuze,liexize,zhuchiren,location,startTime,endTime,remark) "
    14. + "values(?,?,?,?,?,?,?,?,?)";
    15. return super.executeUpdate(sql, t, new String[] {"title","content","canyuze","liexize","zhuchiren","location","startTime","endTime","remark"});
    16. }
    17. //我的会议、其他菜单会用到。
    18. private String getSQL() {
    19. return "SELECT a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,b.`name`,a.location\r\n" +
    20. ",DATE_FORMAT(a.startTime,'%Y-%m-%d %H:%i:%s') as startTime\r\n" +
    21. ",DATE_FORMAT(a.endTime,'%Y-%m-%d %H:%i:%s') as endTime\r\n" +
    22. ",a.state\r\n" +
    23. ",(case a.state\r\n" +
    24. "when 0 then '取消会议'\r\n" +
    25. "when 1 then '新建'\r\n" +
    26. "when 2 then '待审核'\r\n" +
    27. "when 3 then '驳回'\r\n" +
    28. "when 4 then '待开'\r\n" +
    29. "when 5 then '进行中'\r\n" +
    30. "when 6 then '开启投票'\r\n" +
    31. "else '结束会' end\r\n" +
    32. ") as meetingState\r\n" +
    33. ",a.seatPic,a.remark,a.auditor,c.`name` as auditorName\r\n" +
    34. "FROM t_oa_meeting_info a\r\n" +
    35. "inner join t_oa_user b on a.zhuchiren = b.id\r\n" +
    36. "left JOIN t_oa_user c on a.auditor = c.id where 1=1 ";
    37. }
    38. // 我的会议
    39. public List> myInfos(MeetingInfo info, PageBean pageBean) throws Exception {
    40. String sql = getSQL();
    41. String title = info.getTitle();
    42. if(StringUtils.isNotBlank(title)) {
    43. sql += " and title like '%"+title+"%'";
    44. }
    45. //根据当前登陆用户ID作为主持人字段的条件
    46. sql+=" and zhuchiren="+info.getZhuchiren();
    47. //按照会议ID降序排序
    48. // sql+=" order by a.id desc";
    49. System.out.println(sql);
    50. return super.executeQuery(sql, pageBean);
    51. }
    52. // 取消会议
    53. public int updateState(MeetingInfo info) throws Exception {
    54. String sql = "update t_oa_meeting_info set state = 0 where id = ?";
    55. return super.executeUpdate(sql, info,new String[] {"id"} );
    56. }
    57. // 根据会议ID更新会议的排座图片
    58. public int updateSeatPicById(MeetingInfo info) throws Exception {
    59. String sql="update t_oa_meeting_info set seatPic=? where id=?";
    60. return super.executeUpdate(sql, info, new String[] {"seatPic","id"});
    61. }
    62. // 根据会议ID更新会议的审批人(送审)
    63. public int updateAuditorById(MeetingInfo info) throws Exception {
    64. String sql="update t_oa_meeting_info set auditor=?,state=2 where id=?";
    65. return super.executeUpdate(sql, info, new String[] {"auditor","id"});
    66. }
    67. }

    meetingInfoAction

    1. package com.zking.web;
    2. import java.util.Date;
    3. import java.util.List;
    4. import java.util.Map;
    5. import java.util.UUID;
    6. import javax.servlet.http.HttpServletRequest;
    7. import javax.servlet.http.HttpServletResponse;
    8. import org.apache.commons.beanutils.ConvertUtils;
    9. import com.zking.dao.MeetingInfoDao;
    10. import com.zking.entity.MeetingInfo;
    11. import com.zking.framework.ActionSupport;
    12. import com.zking.framework.ModelDriver;
    13. import com.zking.util.Base64ImageUtils;
    14. import com.zking.util.MyDateConverter;
    15. import com.zking.util.PageBean;
    16. import com.zking.util.PropertiesUtil;
    17. import com.zking.util.R;
    18. import com.zking.util.ResponseUtil;
    19. public class MeetingInfoAction extends ActionSupport implements ModelDriver{
    20. private MeetingInfo info = new MeetingInfo();
    21. private MeetingInfoDao infoDao = new MeetingInfoDao();
    22. @Override
    23. public MeetingInfo getModel() {
    24. // 注册一个转换器
    25. ConvertUtils.register(new MyDateConverter(), Date.class);
    26. return info;
    27. }
    28. public String add(HttpServletRequest req, HttpServletResponse resp) {
    29. try {
    30. // rs是sql语句执行的影响行数
    31. int rs = infoDao.add(info);
    32. if(rs > 0) {
    33. ResponseUtil.writeJson(resp, R.ok(200, "会议信息数据新增成功"));
    34. }else {
    35. ResponseUtil.writeJson(resp, R.error(0, "会议信息数据新增失败"));
    36. }
    37. } catch (Exception e) {
    38. e.printStackTrace();
    39. try {
    40. ResponseUtil.writeJson(resp, R.error(0, "会议信息数据新增失败"));
    41. } catch (Exception e1) {
    42. e1.printStackTrace();
    43. }
    44. }
    45. return null;
    46. }
    47. // 我的会议
    48. public String myInfos(HttpServletRequest req, HttpServletResponse resp) {
    49. try {
    50. PageBean pageBean = new PageBean();
    51. pageBean.setRequest(req);
    52. List> list = infoDao.myInfos(info, pageBean);
    53. // 注意:layui中的数据表格的格式
    54. ResponseUtil.writeJson(resp, R.ok(0, "我的会议数据查询成功" , pageBean.getTotal(), list));
    55. } catch (Exception e) {
    56. e.printStackTrace();
    57. try {
    58. ResponseUtil.writeJson(resp, R.error(0, "我的会议数据查询失败"));
    59. } catch (Exception e1) {
    60. e1.printStackTrace();
    61. }
    62. }
    63. return null;
    64. }
    65. // 取消会议
    66. public String del(HttpServletRequest req, HttpServletResponse resp) {
    67. try {
    68. PageBean pageBean = new PageBean();
    69. pageBean.setRequest(req);
    70. int upd = infoDao.updateState(info);
    71. // 注意:layui中的数据表格的格式
    72. if(upd > 0) {
    73. ResponseUtil.writeJson(resp, R.ok(200, "会议取消成功"));
    74. }else {
    75. ResponseUtil.writeJson(resp, R.error(0, "会议取消失败"));
    76. }
    77. } catch (Exception e) {
    78. e.printStackTrace();
    79. try {
    80. ResponseUtil.writeJson(resp, R.error(0, "会议取消失败"));
    81. } catch (Exception e1) {
    82. e1.printStackTrace();
    83. }
    84. }
    85. return null;
    86. }
    87. // 根据会议id更新排座
    88. public String updateSeatPicById(HttpServletRequest req,
    89. HttpServletResponse resp) throws Exception{
    90. try {
    91. //1.将排座图片保存到指定的位置并得到图片路径
    92. //1) 定义会议图片的保存路径
    93. String serverPath=PropertiesUtil.getValue("serverPath");
    94. String dirPath=PropertiesUtil.getValue("dirPath");
    95. //2) 定义会议排座图片的名称(最终要保存到数据库表中),例如:/uploads/xxxxx.jpg
    96. String fileName=UUID.randomUUID().toString().replace("-", "")+".jpg";
    97. //3) 拼接成完整的路径
    98. String realPath=dirPath+fileName;
    99. //4) 将图片保存到指定位置
    100. Base64ImageUtils.GenerateImage(info.getSeatPic().replace("data:image/png;base64,",""), realPath);
    101. //2.根据会议ID修改会议图片信息
    102. info.setSeatPic(serverPath+fileName);
    103. infoDao.updateSeatPicById(info);
    104. ResponseUtil.writeJson(resp, R.ok(200, "更新会议的排座图片成功"));
    105. } catch (Exception e) {
    106. e.printStackTrace();
    107. try {
    108. ResponseUtil.writeJson(resp, R.error(0, "更新会议的排座图片失败"));
    109. } catch (Exception e1) {
    110. e1.printStackTrace();
    111. }
    112. }
    113. return null;
    114. }
    115. // 根据会议ID更新会议的审批人(送审)
    116. public String updateAuditorById(HttpServletRequest req, HttpServletResponse resp) {
    117. try {
    118. int rs = infoDao.updateAuditorById(info);
    119. if (rs > 0) {
    120. ResponseUtil.writeJson(resp, R.ok(200, "会议审批成功"));
    121. }else {
    122. ResponseUtil.writeJson(resp, R.error(0, "会议审批失败"));
    123. }
    124. } catch (Exception e) {
    125. e.printStackTrace();
    126. try {
    127. ResponseUtil.writeJson(resp, R.error(0, "会议审批失败"));
    128. } catch (Exception e1) {
    129. e1.printStackTrace();
    130. }
    131. }
    132. return null;
    133. }
    134. }

     

            2、前端编码

            seatPic.jsp

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    4. <html>
    5. <head>
    6. <base href="${pageContext.request.contextPath }/"/>
    7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    8. <link href="static/js/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    9. <script type="text/javascript" src="static/js/jquery-3.3.1.min.js">script>
    10. <script type="text/javascript" src="static/js/layui/layui.js">script>
    11. <script type="text/javascript" src="static/js/plugins/html2canvas/html2canvas.js">script>
    12. <title>会议座位安排title>
    13. head>
    14. <style type="text/css">
    15. * {
    16. padding: 0;
    17. margin: 0;
    18. }
    19. body{
    20. width: 100%;
    21. height: 100%;
    22. /* background: red; */
    23. }
    24. .tips {
    25. /* position: absolute; */
    26. background: pink;
    27. display: inline-block;
    28. height: 60px;
    29. /* width: 60px; */
    30. line-height: 60px;
    31. text-align: center;
    32. margin: 5px;
    33. padding: 0 10px;
    34. }
    35. .add {
    36. position: fixed;
    37. right: 10px;
    38. top: 10px;
    39. display:inline;
    40. }
    41. #tu {
    42. width: 100%;
    43. height: 100%;
    44. /* background: lightblue; */
    45. /*background: url('u=3318199716,2583790385&fm=26&gp=0.jpg');*/
    46. }
    47. .layui-input{
    48. height:30px;
    49. }
    50. style>
    51. <body id="screen_body">
    52. <div id="tu">div>
    53. <div class="add">
    54. <div style="display:inline-block;">
    55. <input id="dan_input" type="text" value="" class="layui-input">
    56. div>
    57. <div style="display:inline-block;">
    58. <button onclick="return addDanMu()" class="layui-btn layui-btn-sm">添加座位button><input id="jie_input" type="button" class="layui-btn layui-btn-sm" value='下载'>
    59. div>
    60. div>
    61. body>
    62. <script type="text/javascript">
    63. var $id = function(id) {
    64. return document.getElementById(id);
    65. }
    66. //会议排座拖拽
    67. var dragF = {
    68. locked: false,
    69. lastObj: undefined,
    70. drag: function(obj) {
    71. $id(obj).onmousedown = function(e) {
    72. var e = e ? e : window.event;
    73. if (!window.event) {
    74. e.preventDefault();
    75. } /* 阻止标注浏览器下拖动a,img的默认事件 */
    76. dragF.locked = true;
    77. $id(obj).style.position = "absolute";
    78. $id(obj).style.zIndex = "100";
    79. if (dragF.lastObj && dragF.lastObj != $id(obj)) { /* 多元素拖动需要恢复上次元素状态 */
    80. dragF.lastObj.style.zIndex = "1";
    81. }
    82. dragF.lastObj = $id(obj);
    83. var tempX = $id(obj).offsetLeft;
    84. var tempY = $id(obj).offsetTop;
    85. dragF.x = e.clientX;
    86. dragF.y = e.clientY;
    87. document.onmousemove = function(e) {
    88. var e = e ? e : window.event;
    89. if (dragF.locked == false) return false;
    90. $id(obj).style.left = tempX + e.clientX - dragF.x + "px";
    91. $id(obj).style.top = tempY + e.clientY - dragF.y + "px";
    92. if (window.event) {
    93. e.returnValue = false;
    94. } /* 阻止ie下a,img的默认事件 */
    95. }
    96. document.onmouseup = function() {
    97. dragF.locked = false;
    98. }
    99. }
    100. }
    101. }
    102. script>
    103. <script type="text/javascript">
    104. var layer;
    105. layui.use(['layer'],function(){
    106. layer=layui.layer;
    107. //初始化会议排座:根据会议ID获取参会的所有人员的名字(主持人+参会人+列席人)
    108. initMeetingUsers();
    109. //绘制会议排座图片
    110. $("#jie_input").on("click", function(event) {
    111. $('.add').hide();
    112. event.preventDefault();
    113. html2canvas(document.getElementById("screen_body")).then(function(canvas) {
    114. var dataUrl = canvas.toDataURL();
    115. console.log(dataUrl);
    116. var param = {};
    117. param['seatPic'] = dataUrl;
    118. param['id'] = '${param.id}';
    119. param['methodName']='updateSeatPicById';
    120. console.log(param);
    121. //此处需要完成会议排座图片上传操作
    122. $.post('${pageContext.request.contextPath }/info.action',param,function(rs){
    123. if(rs.success){
    124. //先得到当前iframe层的索引
    125. var index = parent.layer.getFrameIndex(window.name);
    126. //再执行关闭
    127. parent.layer.close(index);
    128. //调用父页面的刷新方法
    129. parent.query();
    130. }else{
    131. layer.msg(rs.msg,{icon:5},function(){});
    132. }
    133. },'json');
    134. });
    135. });
    136. });
    137. function initMeetingUsers(){
    138. $.getJSON('${pageContext.request.contextPath }/user.action',{
    139. 'methodName':'queryUserByMeetingId',
    140. 'meetingId':'${param.id}'
    141. },function(rs){
    142. console.log(rs);
    143. let data=rs.data;
    144. $.each(data,function(i,e){
    145. $('#dan_input').val(e.name);
    146. addDanMu();
    147. });
    148. });
    149. }
    150. //添加会议排座
    151. function addDanMu() {
    152. var dan = document.getElementById("dan_input").value;
    153. if (dan == "") {
    154. alert("请先输入座次~");
    155. return false;
    156. } else {
    157. document.getElementById("dan_input").value = ""; //清空 弹幕输入框
    158. // var br = document.createElement("BR"); //
    159. var node = document.createElement("DIV"); //
    160. var tipsArr = document.getElementsByClassName('tips');
    161. var i;
    162. // console.log(parseInt(tipsArr[tipsArr.length-1].id.substr(4))+1);
    163. if (tipsArr.length == 0) {
    164. i = 1
    165. } else {
    166. i = parseInt(tipsArr[tipsArr.length - 1].id.substr(4)) + 1;
    167. }
    168. // var aNode = document.createElement("P"); //

    169. node.setAttribute("class", "tips");
    170. node.setAttribute("id", "tips" + i);
    171. node.setAttribute("onmouseover", "dragF.drag('tips" + i + "');");
    172. var textnode = document.createTextNode(dan); // 创建个 文本节点, 将用户输入的弹幕,存入 创建的 元素节点

    173. // aNode.appendChild(textnode);
    174. node.appendChild(textnode);
    175. // document.body.appendChild(br);
    176. // document.body.appendChild(node);
    177. document.getElementById("tu").appendChild(node);
    178. return true;
    179. }
    180. }
    181. script>
    182. html>

            myMeeting.js

    1. let layer,table,$,form;
    2. var row;
    3. layui.use(['layer','table','jquery','form'],function(){
    4. layer=layui.layer,
    5. table=layui.table,
    6. form=layui.form,
    7. $=layui.jquery;
    8. initTable();
    9. //查询事件
    10. $('#btn_search').click(function(){
    11. query();
    12. });
    13. //初始化审批人
    14. initFormSelects();
    15. //送审
    16. $('#btn_auditor').click(function(){
    17. $.post('info.action',{
    18. 'methodName':'updateAuditorById',
    19. 'id':$('#meetingId').val(),
    20. 'auditor':$('#auditor').val()
    21. },function(rs){
    22. if(rs.success){
    23. //关闭对话框
    24. layer.closeAll();
    25. //刷新列表
    26. query();
    27. }else{
    28. layer.msg(rs.msg,{icon:5},function(){});
    29. }
    30. },'json');
    31. return false;
    32. });
    33. });
    34. //1.初始化数据表格
    35. function initTable(){
    36. table.render({ //执行渲染
    37. elem: '#tb', //指定原始表格元素选择器(推荐id选择器)
    38. height: 400, //自定义高度
    39. loading: false, //是否显示加载条(默认 true)
    40. cols: [[ //设置表头
    41. {field: 'id', title: '会议编号', width: 90},
    42. {field: 'title', title: '会议标题', width: 120},
    43. {field: 'location', title: '会议地点', width: 140},
    44. {field: 'startTime', title: '开始时间', width: 120},
    45. {field: 'endTime', title: '结束时间', width: 120},
    46. {field: 'meetingState', title: '会议状态', width: 120},
    47. {field: 'seatPic', title: '会议排座', width: 120,
    48. templet: function(d){
    49. if(d.seatPic==null || d.seatPic=="")
    50. return "尚未排座";
    51. else
    52. return "";
    53. }
    54. },
    55. {field: 'auditorName', title: '审批人', width: 120},
    56. {field: '', title: '操作', width: 200,toolbar:'#tbar'},
    57. ]]
    58. });
    59. }
    60. //2.点击查询
    61. function query(){
    62. table.reload('tb', {
    63. url: 'info.action', //请求地址
    64. method: 'POST', //请求方式,GET或者POST
    65. loading: true, //是否显示加载条(默认 true)
    66. page: true, //是否分页
    67. where: { //设定异步数据接口的额外参数,任意设
    68. 'methodName':'myInfos',
    69. 'zhuchiren':$('#zhuchiren').val(),
    70. 'title':$('#title').val(),
    71. },
    72. request: { //自定义分页请求参数名
    73. pageName: 'page', //页码的参数名称,默认:page
    74. limitName: 'rows' //每页数据量的参数名,默认:limit
    75. },
    76. done: function (res, curr, count) {
    77. console.log(res);
    78. }
    79. });
    80. //工具条事件
    81. table.on('tool(tb)', function(obj){ //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
    82. row = obj.data; //获得当前行数据
    83. var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
    84. var tr = obj.tr; //获得当前行 tr 的 DOM 对象(如果有的话)
    85. console.log(row);
    86. if(layEvent === 'seat'){ //会议排座
    87. open(row.id);
    88. } else if(layEvent === 'send'){ //送审
    89. if(row.seatPic==null || row.seatPic==""){
    90. layer.msg('先请完成会议排座,再进行送审操作!',function(){});
    91. return false;
    92. }
    93. //在打开送审页面之前,先完成会议ID的赋值操作
    94. $('#meetingId').val(row.id);
    95. openLayerAudit();
    96. } else if(layEvent==="back"){ //反馈详情
    97. openLayerFeedBack(row.id);
    98. } else {
    99. layer.confirm('确认取消会议吗?', {icon: 3, title:'提示'}, function(index){
    100. $.post('info.action',{
    101. 'methodName':'del',
    102. 'id':row.id
    103. },function(rs){
    104. if(rs.success){
    105. //调用查询方法刷新数据
    106. query();
    107. }else{
    108. layer.msg(rs.msg,function(){});
    109. }
    110. },'json');
    111. layer.close(index);
    112. });
    113. }
    114. });
    115. }
    116. //打开会议排座对话框
    117. function open(id){
    118. layer.open({
    119. type: 2,
    120. title: '会议排座',
    121. area: ['460px', '340px'], //宽高
    122. skin: 'layui-layer-rim', //样式类名
    123. content: 'jsp/meeting/seatPic.jsp?id='+id,
    124. });
    125. }
    126. //会议送审
    127. function openLayerAudit(){
    128. //每次打开都对送审人进行初始化默认值设置
    129. $('#auditor').val("");
    130. //必须重新渲染
    131. form.render('select');
    132. //弹出对话框
    133. layer.open({
    134. type: 1,
    135. title:'会议送审',
    136. area: ['426px', '140px'],
    137. skin: 'layui-layer-rim',
    138. content: $('#audit'),
    139. });
    140. }
    141. //初始化审批人
    142. function initFormSelects(){
    143. $.getJSON('user.action',{
    144. 'methodName':'queryUserAll'
    145. },function(rs){
    146. console.log(rs);
    147. let data=rs.data;
    148. $.each(data,function(i,e){
    149. $('#auditor').append(new Option(e.name,e.value));
    150. });
    151. //重新渲染
    152. form.render('select');
    153. });
    154. }

    四、效果展示

                    先发布一个新的会议

     

    直接点击送审

     

    排座

     

     

     

     重新送审

  • 相关阅读:
    小米面试题——不用加减乘除计算两数之和
    Java代码审计——URL 跳转漏洞
    vue3 传值
    Metabase学习教程:仪表盘-3
    记录一次通过openVPN访问域名无法访问的问题
    【Go语言入门教程】Go语言简介
    【技术实战】Linux中的命令行【实战篇】【一】
    Tomcat - mac - 启动/关闭
    Ribbon负载均衡 (源码分析)
    个人项目(玩具)列表(可能会更新)
  • 原文地址:https://blog.csdn.net/qq_62331938/article/details/125980657