目录
1.左侧导航
2.导入数据表及无限级分类
1) 数据导入(此步骤在第一次文章已完成) 2) 无限级分类:父亲找儿子的过程,将对应的儿子放在父亲下面,形成树结构。(递归算法)
3.实现左侧菜单后台代码接口
4.前端左侧菜单绑定
5.Tab选项卡
Tab广泛应用于Web页面,因此我们也对其进行了良好的支持(简约风格、卡片风格、响应式Tab以及带删除的Tab等等)。Layui内置多种Tab风格,支持删除选项卡、并提供响应式支持。
Tab分类
参考地址:http://layui.org.cn/doc/element/tab.html
1)Tab简约风格
2)Tab卡片风格
3)响应式Tab 当容器的宽度不足以显示全部的选项时,即会自动出现展开图标。
4)带删除的Tab
与默认相比没有什么特别的结构,就是多了个属性 lay-allowClose="true"
5)动态Tab
1)根据模块名称判断是否已经存在tab选项卡 $(".layui-tab-title li[lay-id='" + name + "']").length > 0
2)切换到指定选项卡 element.tabChange('tabs', name);
3)动态添加选项卡
// 新增一个Tab项 element.tabAdd('tabs', { title : name, content : tabContent, id : name }) // 切换刷新 element.tabChange('tabs', name);
注:tabs为tab选项卡的lay-filter=""
附录一:什么是lay-filter事件过滤器。你可能会在很多地方看到他,他一般是用于监听特定的自定义事件。你可以把它看作是一个ID选择器
附录二:iframe
注:在index.jsp首页页面中请将更改成:不然会导致使用iframe动态打开页面的高度无法100%填充父容器;
附录三:如何隐藏tab第一个选项卡的删除图标
一.会议发布
二.动态选项卡&左侧菜单
三.效果展示
左侧菜单
动态选项卡
会议发布界面
初始化会议发布页面
addMeeting.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
Insert title here
<%@include file="/common/head.jsp" %>
addMeeting.js
会议发布功能实现
IMeetingInfoDao.java
package com.zking.oa.dao;
import java.util.List;
import java.util.Map;
import org.lisen.mvc.util.PageBean;
import com.zking.oa.model.MeetingMember;
import com.zking.oa.model.Meetinginfo;
import com.zking.oa.model.User;
public interface IMeetinginfoDao {
List listMeetingMember();
/**
* 增加
* @param meetinginfo
*/
void addMeetinginfo(Meetinginfo meetinginfo);
/**
* 获取我的会议信息
* @param meetingInfo
* @param pageBean
* @return
*/
List
MeetingInfoDao.java
package com.zking.oa.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.lisen.mvc.util.DbTemplate;
import org.lisen.mvc.util.PageBean;
import com.mysql.cj.util.StringUtils;
import com.zking.oa.model.MeetingMember;
import com.zking.oa.model.Meetinginfo;
import com.zking.oa.model.User;
import com.zking.oa.util.BaseDao;
import com.zking.oa.util.CommonUtils;
@SuppressWarnings("unchecked")
public class MeetinginfoDao extends BaseDao implements IMeetinginfoDao {
@Override
public List listMeetingMember(){
String sql="select name,id from t_oa_user";
return DbTemplate.query(sql, MeetingMember.class);
}
@Override
public void addMeetinginfo(Meetinginfo meetinginfo) {
DbTemplate.save(meetinginfo);
}
/**
* 封装sql:作为我的会议、我的审批、会议通知、代开会议、
* 历史会议级所有会议的基础SQL语句
* @return
*/
private String getSql() {
return "SELECT \r\n" +
"m.id,m.title,m.content,m.canyuze,m.zhuchiren,m.liexize,u.name\r\n" +
",m.location,\r\n" +
"DATE_FORMAT(m.startTime,'%Y-%m-%d %H:%i:%s') as startTime,\r\n" +
"DATE_FORMAT(m.endTime,'%Y-%m-%d %H:%i:%s') as endTime,\r\n" +
"(case m.state\r\n" +
" when 0 then '取消会议'\r\n" +
" when 1 then '新建'\r\n" +
" when 2 then '待审核'\r\n" +
" when 3 then '驳回'\r\n" +
" when 4 then '待开'\r\n" +
" when 5 then '进行中'\r\n" +
" when 6 then '开启投票'\r\n" +
" ELSE '结束会议' end\r\n" +
") as meetingState,m.state,m.seatPic,m.remark,m.auditor,\r\n" +
"u2.name as auditName\r\n" +
"from \r\n" +
"t_oa_meeting_info m inner join t_oa_user u\r\n" +
"on m.zhuchiren=u.id\r\n" +
"LEFT JOIN t_oa_user u2\r\n" +
"on u2.id=m.auditor where 1=1 ";
}
@Override
public List
MeetingInfoAction.java
package com.zking.oa.action;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;
import org.lisen.mvc.framework.AbstractDispatchAction;
import org.lisen.mvc.framework.ModelDrive;
import org.lisen.mvc.util.PageBean;
import com.zking.oa.dao.MeetinginfoDao;
import com.zking.oa.model.MeetingMember;
import com.zking.oa.model.Meetinginfo;
import com.zking.oa.model.User;
import com.zking.oa.service.IMeetinginfoService;
import com.zking.oa.service.MeetinginfoService;
import com.zking.oa.util.Base64ImageUtils;
import com.zking.oa.util.CommonUtil;
public class MeetinginfoAction extends AbstractDispatchAction implements ModelDrive{
private Meetinginfo meetinginfo = new Meetinginfo();
private IMeetinginfoService service = new MeetinginfoService();
@Override
public Object getModel() {
//日期转换器
DateConverter converter = new DateConverter();
converter.setPattern("yyyy-MM-dd HH:mm:ss");
ConvertUtils.register(converter, Date.class);
return meetinginfo;
}
public void listMeetingMember(HttpServletRequest req,HttpServletResponse resp) {
try {
List list = service.listMeetingMember();
CommonUtil.sendResponse(0, "成功", list,resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "获取会议参与人员失败", resp);
}
}
public void addMeetinginfo(HttpServletRequest req,HttpServletResponse resp) {
try {
service.addMeetinginfo(meetinginfo);
CommonUtil.sendResponse(0, "会议发布成功", resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "会议发布失败", resp);
}
}
/**
* 获取以当前用户为主持人的会议信息,即我的会议功能
* @param req
* @param resp
*/
public void listMeetingInfo(HttpServletRequest req, HttpServletResponse resp) {
try {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
//从session中获取当前用户放入条件
User user = (User)req.getSession().getAttribute("user");
meetinginfo.setZhuchiren(user.getId().toString());
List> list = service.listMeetingInfo(meetinginfo, pageBean);
CommonUtil.sendResponse(0, "会议信息查询成功", pageBean.getTotal(), list, resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "会议信息查询失败",resp);
}
}
/**
* 查询与当前登录用户相关的状态为待开的会议信息
* @return
*/
public void listRelatedMeetingInfoByUserId(HttpServletRequest req, HttpServletResponse resp) {
MeetinginfoDao ma=new MeetinginfoDao();
try {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
//从session中获取当前用户,并且只查询待审记录
User user = (User)req.getSession().getAttribute("user");
List list = ma.listRelatedMeetingInfoByUserId(user.getId(),meetinginfo.getTitle(),4, pageBean);
CommonUtil.sendResponse(0, "会议信息查询成功", pageBean.getTotal(), list, resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "会议信息查询失败",resp);
}
}
/**
* 历史会议
* @return
*/
public void listRelatedMeetingInfoNotify(HttpServletRequest req, HttpServletResponse resp) {
MeetinginfoDao ma=new MeetinginfoDao();
try {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
//从session中获取当前用户,并且只查询待审记录
User user = (User)req.getSession().getAttribute("user");
List list = ma.listRelatedMeetingInfoByUserId2(user.getId(),meetinginfo.getTitle(),7, pageBean);
CommonUtil.sendResponse(0, "历史会议查询成功", pageBean.getTotal(), list, resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "历史会议查询失败",resp);
}
}
/**
* 通过会议的Id获取与本次会议相关的参与人员信息
* @param req
* @param resp
*/
public void listMeetingMemberById(HttpServletRequest req, HttpServletResponse resp) {
try {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
List list = service.listMeetingMembersById(meetinginfo.getId().intValue());
CommonUtil.sendResponse(0, "会议信息查询成功", pageBean.getTotal(), list, resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "会议信息查询失败",resp);
}
}
/**
* 保存排座图片到服务器的指定目录,并更新相关会议信息的排座图片字段
* @param req
* @param resp
*/
public void addArrangeSeat(HttpServletRequest req, HttpServletResponse resp) {
try {
String fName = UUID.randomUUID().toString().replace("-", "").concat(".jpg");
String path = "D:\\temp\\images\\seatPic\\uploads\\" + fName;
String base64Image = meetinginfo.getSeatPic().replace("data:image/png;base64,", "");
//生成图片
Base64ImageUtils.GenerateImage(base64Image, path);
//更新会议信息表中的排座信息,需要设置tomcat的设置增加一个扩展web模块
meetinginfo.setSeatPic("/uploads/"+fName);
service.updateSeatPicById(meetinginfo);
CommonUtil.sendResponse(0, "排座成功", resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "排座失败", resp);
}
}
/**
* 我的审核,会议的审核人员是当前登录的用户,且会议的状态为待审
* @param req
* @param resp
*/
public void listMyAuditMeetingInfo(HttpServletRequest req, HttpServletResponse resp) {
try {
PageBean pageBean = new PageBean();
pageBean.setRequest(req);
//从session中获取当前用户,并且只查询待审记录
User user = (User)req.getSession().getAttribute("user");
meetinginfo.setAuditor(user.getId().toString());
meetinginfo.setState(2);
List> list = service.listMeetingInfo(meetinginfo, pageBean);
CommonUtil.sendResponse(0, "会议信息查询成功", pageBean.getTotal(), list, resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "会议信息查询失败",resp);
}
}
/**
* 会议送审,能够送审的前提是该会议已经排座,否则不能送审,此外
* 对于审核通过,结束,取消,进行中等状态的会议不能执行送审
* @param rep
* @param resp
*/
public void sendAudit(HttpServletRequest rep, HttpServletResponse resp) {
try {
service.sendAudit(meetinginfo);
CommonUtil.sendResponse(0, "送审成功", resp);
} catch (Exception e) {
e.printStackTrace();
CommonUtil.sendResponse(-1, "送审失败", resp);
}
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@include file="/common/head.jsp" %>