讲解思路
- 我的审批查询功能
- 手写签批插件及工具类介绍
- 手写签批插件集成
- 手写签批功能实现
会议查询
MeetingInfoDao.java
// 我的审批 public List<Map<String,Object>> myAudit(MeetingInfo info,PageBean pageBean) throws Exception{ String sql=this.getSQL(); String title = info.getTitle(); //按照会议标题模糊查询 if(!StringUtils.isNotBlank(title)) sql+=" and title like '%"+title+"%'"; //根据当前登陆用户ID作为审批人字段的条件 sql+=" and auditor="+info.getAuditor(); //查询会议状态为待审核的会议信息 sql+=" and state=2"; //按照会议ID降序排序 sql+=" order by a.id desc"; System.out.println(sql); return super.executeQuery(sql, pageBean); }
MeetingInfoAction.java
// 我的审批 public String myAudit(HttpServletRequest req, HttpServletResponse resp) { try { PageBean pageBean = new PageBean(); pageBean.setRequest(req); List<Map<String, Object>> infos = meetingInfoDao.myAudit(info, pageBean); ResponseUtil.writeJson(resp, R.ok(0, "我的审批查询成功!!!", pageBean.getTotal(), infos)); } catch (Exception e) { e.printStackTrace(); try { ResponseUtil.writeJson(resp, R.error(0, "我的审批查询失败")); } catch (Exception e1) { e1.printStackTrace(); } } return null; }
myAudit.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@include file="/common/head.jsp"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="${pageContext.request.contextPath }/static/js/meeting/myAudit.js"></script> </head> <style> body{ margin:15px; } .layui-table-cell {height: inherit;} .layui-layer-page .layui-layer-content { overflow: visible !important;} </style> <body> <!-- 搜索栏 --> <div class="layui-form-item" style="margin:15px 0px;"> <div class="layui-inline"> <label class="layui-form-label">会议标题</label> <div class="layui-input-inline"> <input type="hidden" id="auditor" value="${user.id }"/> <input type="text" id="title" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-inline"> <button id="btn_search" type="button" class="layui-btn"><i class="layui-icon layui-icon-search"></i> 查询</button> </div> </div> <!-- 数据表格 --> <table id="tb" lay-filter="tb" class="layui-table" style="margin-top:-15px"></table> <script type="text/html" id="tbar"> <a class="layui-btn layui-btn-xs" lay-event="edit">审批</a> </script> </body> </html>
myAudit.js
let layer,table,$,form; var row; layui.use(['layer','table','jquery','form'],function(){ layer=layui.layer, table=layui.table, form=layui.form, $=layui.jquery; initTable(); //查询事件 $('#btn_search').click(function(){ query(); }); }); //初始化数据表格(我的审批) function initTable(){ table.render({ //执行渲染 elem: '#tb', //指定原始表格元素选择器(推荐id选择器) height: 400, //自定义高度 loading: false, //是否显示加载条(默认 true) cols: [[ //设置表头 {field: 'id', title: '会议编号', width: 90}, {field: 'title', title: '会议标题', width: 120}, {field: 'location', title: '会议地点', width: 140}, {field: 'startTime', title: '开始时间', width: 120}, {field: 'endTime', title: '结束时间', width: 120}, {field: 'meetingState', title: '会议状态', width: 120}, {field: 'seatPic', title: '会议排座', width: 120, templet: function(d){ if(d.seatPic==null || d.seatPic=="") return "尚未排座"; else return "<img width='120px' src='"+d.seatPic+"'/>"; } }, {field: '', title: '操作', width: 200,toolbar:'#tbar'}, ]] }); } //点击查询 function query(){ table.reload('tb', { url: $("#ctx").val()+'/info.action', //请求地址 method: 'POST', //请求方式,GET或者POST loading: true, //是否显示加载条(默认 true) page: true, //是否分页 where: { //设定异步数据接口的额外参数,任意设 'methodName':'myAudit', 'auditor':$('#auditor').val(), 'title':$('#title').val(), }, request: { //自定义分页请求参数名 pageName: 'page', //页码的参数名称,默认:page limitName: 'rows' //每页数据量的参数名,默认:limit }, done: function (res, curr, count) { console.log(res); } }); //工具条事件 table.on('tool(tb)', function(obj){ //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值" row = obj.data; //获得当前行数据 var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值) var tr = obj.tr; //获得当前行 tr 的 DOM 对象(如果有的话) console.log(row); if(layEvent === 'edit'){ //审批 } else { } }); }
会议签字
讲解思路
- 手写签批功能实现
- SQL语句批处理
目标:能够在文件夹中看到签字图片,并且文字居中
会议审批
MeetingAudit.java
package com.zking.oa.model; import java.util.Date; import org.lisen.mvc.util.AutoIncrement; import org.lisen.mvc.util.Key; import org.lisen.mvc.util.Table; @Table("t_oa_meeting_audit") public class MeetingAudit { @AutoIncrement @Key private Integer id; private Integer meetingId; private String auditor; private String sign; private Date createdate; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getMeetingId() { return meetingId; } public void setMeetingId(Integer meetingId) { this.meetingId = meetingId; } public String getAuditor() { return auditor; } public void setAuditor(String auditor) { this.auditor = auditor; } public String getSign() { return sign; } public void setSign(String sign) { this.sign = sign; } public Date getCreatedate() { return createdate; } public void setCreatedate(Date createdate) { this.createdate = createdate; } public MeetingAudit() { // TODO Auto-generated constructor stub } public MeetingAudit(Integer id, Integer meetingId, String auditor, String sign, Date createdate) { this.id = id; this.meetingId = meetingId; this.auditor = auditor; this.sign = sign; this.createdate = createdate; } @Override public String toString() { return "MeetingAudit [id=" + id + ", meetingId=" + meetingId + ", auditor=" + auditor + ", sign=" + sign + ", createdate=" + createdate + "]"; } }
MeetingAuditDao.java
package com.zking.dao; import com.zking.entity.MeetingAudit; import com.zking.util.BaseDao; import com.zking.util.StringUtils; public class MeetingAuditDao extends BaseDao<MeetingAudit> { /** * 新增会议审批记录 * @param audit */ public void add(MeetingAudit audit) { //1.新增会议审批记录 String sql="insert into t_oa_meeting_audit(meetingId,auditor,sign)" + " values("+audit.getMeetingId()+","+audit.getAuditor()+",'"+audit.getSign()+"')"; //2.根据会议ID更新会议的状态(3=驳回,4=待开) int state=StringUtils.isBlank(audit.getSign())?3:4; String sql1="update t_oa_meeting_info set state="+state+" where id="+audit.getMeetingId(); //如何一次执行两条SQL,使用数据库事务? super.executeUpdateBatch(new String[] {sql,sql1}); } }