目录
一、我的会议 SQL编写
--- 分析:会议没有审批也要查询出来,那么会议信息表就作为主表,用户表作为从表;用会议信息表左外连接用户表
1、时间字段要格式化,否则页面会显示一串数字
 2、会议状态是数字,前端要显示会议状态描述
  
状态:0取消会议 1新建 2待审核 3驳回 4待开 5进行中 6开启投票 7结束会议,默认值为1
查询sql语句如下:
SELECT a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,
b.name zhuchirenname ,
a.location,
DATE_FORMAT(a.startTime,'%Y-%m-%d %H-%m-%s') startTime,
DATE_FORMAT(a.endTime,'%Y-%m-%d %H-%m-%s') endTime,
a.state,
(
	case a.state
	when 0 then'取消会议'
	when 1 then'新建'
	when 2 then'待审核'
	when 3 then'驳回'
	when 4 then'待开'
	when 5 then'进行中'
	when 6 then'开启投票'
	when 7 then'结束会议'
	else '其他' end
) meetingstate,
a.seatPic,a.remark,a.auditor,
c.name auditorname from t_oa_meeting_info a
inner join t_oa_user b on a.zhuchiren =b.id
left join t_oa_user c on a.auditor = c.id
SQL运行结果如下:

 
二、我的会议后台
MeetingInfoDao:
package com.zking.dao;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import com.zking.entity.MeetingInfo;
import com.zking.util.BaseDao;
import com.zking.util.PageBean;
import com.zking.util.StringUtils;
public class MeetingInfoDao extends BaseDao<MeetingInfo>{
	
	
	//会议信息新增
	public int add(MeetingInfo t) throws Exception {
		String sql="insert into t_oa_meeting_info"
				+"(title,content,canyuze,liexize,zhuchiren,location,startTime,endTime,remark) values (?,?,?,?,?,?,?,?,?)";
		return super.executeUpdate(sql, t, new String[] {"title","content","canyuze","liexize","zhuchiren","location","startTime","endTime","remark"});
	}
	
//	我的会议SQL,后续其他菜单也会使用
	private String getSQL() {
		return "SELECT a.id,a.title,a.content,a.canyuze,a.liexize,a.zhuchiren,\r\n" + 
				"b.name zhuchirenname ,\r\n" + 
				"a.location,\r\n" + 
				"DATE_FORMAT(a.startTime,'%Y-%m-%d %H-%m-%s') startTime,\r\n" + 
				"DATE_FORMAT(a.endTime,'%Y-%m-%d %H-%m-%s') endTime,\r\n" + 
				"a.state,\r\n" + 
				"(\r\n" + 
				"	case a.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" + 
				"	when 7 then'结束会议'\r\n" + 
				"	else '其他' end\r\n" + 
				") meetingstate,\r\n" + 
				"a.seatPic,a.remark,a.auditor,\r\n" + 
				"c.name auditorname from t_oa_meeting_info a\r\n" + 
				"inner join t_oa_user b on a.zhuchiren =b.id\r\n" + 
				"left join t_oa_user c on a.auditor = c.id and 1=1 ";
	}
	
//	我的会议
		public List<Map<String, Object>> myInfos(MeetingInfo info, PageBean pageBean)
				throws SQLException, InstantiationException, IllegalAccessException {
			String sql=getSQL();
			String title = info.getTitle();
			if(StringUtils.isNotBlank(title)) {
				sql+=" and title like '%"+title+"%'";
			}
		sql+=" and zhuchiren ="+info.getZhuchiren();
		return super.executeQuery(sql, pageBean);
		}
	
}
MeetingInfoDaoTest :
package com.zking.dao;
import static org.junit.Assert.*;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.zking.entity.MeetingInfo;
import com.zking.util.PageBean;
public class MeetingInfoDaoTest {
	private MeetingInfoDao infoDao=new MeetingInfoDao();
	@Before
	public void setUp() throws Exception {
	}
	@After
	public void tearDown() throws Exception {
	}
	@Test
	public void testMyInfos() {
		MeetingInfo info=new MeetingInfo();
		PageBean pageBean=new PageBean();
		//pageBean.setPagination(false);
		try {
			List<Map<String, Object>> myInfos = infoDao.myInfos(info, pageBean);
		for (Map<String, Object> map : myInfos) {
			System.out.println(map);
		}
		System.out.println(pageBean);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
打印结果:

MeetingInfoAction :
package com.zking.web;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.ConvertUtils;
import com.zking.dao.MeetingInfoDao;
import com.zking.entity.MeetingInfo;
import com.zking.framework.ActionSupport;
import com.zking.framework.ModelDriver;
import com.zking.util.MyDateConverter;
import com.zking.util.PageBean;
import com.zking.util.R;
import com.zking.util.ResponseUtil;
public class MeetingInfoAction extends ActionSupport implements ModelDriver<MeetingInfo>{
	private MeetingInfo info=new MeetingInfo();
	private MeetingInfoDao infoDao=new MeetingInfoDao();
	@Override
	public MeetingInfo getModel() {
		//注册一个转接器
		ConvertUtils.register(new MyDateConverter(), Date.class);
		return info;
	}
	//	增加会议
	public String add(HttpServletRequest req, HttpServletResponse resp) {
		try {
//			rs是sql语句执行的影响行数
			int rs = infoDao.add(info);
			if(rs>0) {
				ResponseUtil.writeJson(resp, R.ok(200, "会议信息增加成功"));
			}else {
				ResponseUtil.writeJson(resp, R.error(0, "会议信息增加失败"));
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				ResponseUtil.writeJson(resp, R.error(0, "会议信息查询失败"));
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return null;
	}
//	我的会议
	public String myInfos(HttpServletRequest req, HttpServletResponse resp) {
		try {
			PageBean pageBean=new PageBean();
			pageBean.setRequest(req);
			List<Map<String, Object>> infos = infoDao.myInfos(info, pageBean);
//		注意:layui中的数据表格的格式
			ResponseUtil.writeJson(resp, R.ok(0, "我的会议数据查询成功",pageBean.getTotal(),infos));
		} catch (Exception e) {
			e.printStackTrace();
			try {
				ResponseUtil.writeJson(resp, R.error(0, "我的会议数据查询失败"));
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return null;
	}
	
}
三、我的会议前端
myMeeting.js:
let layer,$,table;
var row;
layui.use(['jquery', 'layer', 'table'], function(){
	layer = layui.layer
	,$ = layui.jquery
	,table = layui.table;
	//初始化数据表格
	initTable();
	//绑定查询按钮的点击事件
	$('#btn_search').click(function(){
		query();
	});
});
//1.初始化数据表格
function initTable(){
	table.render({           //执行渲染
        elem: '#tb',         //指定原始表格元素选择器(推荐id选择器)
//        url: 'user.action?methodName=list',     //请求地址
        height:500,         //自定义高度
        loading: false,      //是否显示加载条(默认 true)
        cols: [[             //设置表头
            {field: 'id', title: '会议编号', width: 120},
            {field: 'title', title: '会议标题', width: 120},
            {field: 'location', title: '会议地点', width: 140},
            {field: 'startTime', title: '开始时间', width: 120},
            {field: 'endTime', title: '结束时间', width: 120},
            {field: 'meetingstate', title: '会议状态', width: 140},
            {field: 'seatPic', title: '会议排座', width: 120},
            {field: 'name', title: '审批人', width: 120},
            {field: 'auditor', title: '操作', width: 220,toolbar:'#tbar'},
        ]]
    });
	
	//在页面中的<table>中必须配置lay-filter="tb_goods"属性才能触发属性!!!
	table.on('tool(tb)', function (obj) {
		row = obj.data;
		if (obj.event == "seat") {
			layer.msg("排座");
		}else if(obj.event == "send"){
			layer.msg("送审");
		}
		else if(obj.event == "del"){
			layer.confirm('确认删除吗?', {icon: 3, title:'提示'}, function(index){
				  $.post($("#ctx").val()+'/user.action',{
					  'methodName':'del',
					  'id':row.id
				  },function(rs){
					  if(rs.success){
		        		   //调用查询方法刷新数据
		        		   query();
		        	   }else{
		        		   layer.msg(rs.msg,function(){});
		        	   }
				  },'json');
				  layer.close(index);
				});
			layer.msg("取消会议");
		}
		else if(obj.event == "back"){
			layer.msg("反馈详情");
		}else{
		}
	});
	
}
//2.点击查询
function query(){
	table.reload('tb', {
        url: 'info.action',     //请求地址
        method: 'POST',                    //请求方式,GET或者POST
        loading: true,                     //是否显示加载条(默认 true)
        page: true,                        //是否分页
        where: {                           //设定异步数据接口的额外参数,任意设
        	'methodName':'myInfos',
        	'title':$('#title').val(),
        	'zhuchiren':$("#zhuchiren").val()
        },  
        request: {                         //自定义分页请求参数名
            pageName: 'page', //页码的参数名称,默认:page
            limitName: 'rows' //每页数据量的参数名,默认:limit
        }
   });
}运行效果:

进官网文档:
找到表格:

 
 
myMeeting.js:
//1.初始化数据表格
function initTable(){
	table.render({           //执行渲染
        elem: '#tb',         //指定原始表格元素选择器(推荐id选择器)
//        url: 'user.action?methodName=list',     //请求地址
        height:500,         //自定义高度
        loading: false,      //是否显示加载条(默认 true)
        cols: [[             //设置表头
            {field: 'id', title: '会议编号', width: 120},
            {field: 'title', title: '会议标题', width: 120},
            {field: 'location', title: '会议地点', width: 140},
            {field: 'startTime', title: '开始时间', width: 120},
            {field: 'endTime', title: '结束时间', width: 120},
            {field: 'meetingstate', title: '会议状态', width: 140},
            {field: 'seatPic', title: '会议排座', width: 120,templet: function(d){
                console.log(d.LAY_INDEX); //得到序号。一般不常用
                console.log(d.LAY_COL); //得到当前列表头配置信息(layui 2.6.8 新增)。一般不常用
                
                //得到当前行数据,并拼接成自定义模板
                return 'ID:'+ d.id +',标题:<span style="color: #c00;">'+ d.title +'</span>'}},
            {field: 'name', title: '审批人', width: 120},
            {field: 'auditor', title: '操作', width: 220,toolbar:'#tbar'},
        ]]
    }); 运行效果 :
{field: 'seatPic', title: '会议排座', width: 120,templet: function(d){
                console.log(d.LAY_INDEX); //得到序号。一般不常用
                console.log(d.LAY_COL); //得到当前列表头配置信息(layui 2.6.8 新增)。一般不常用
                
                //得到当前行数据,并拼接成自定义模板
                return '<img src="'+d.seatPic+'">'}
            }, 解决方案:
解决方案:
1、数据库中的数据不能带项目名
2、项目发布访问去掉项目名
3、项目中图片映射不能带项目名

 
 
即可。









