jeecg自定义datagrid封装列表分页数据显示自定义字段
生活随笔
收集整理的這篇文章主要介紹了
jeecg自定义datagrid封装列表分页数据显示自定义字段
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*** easyui AJAX請求數據* @param clockin* @param request* @param response* @param dataGrid*/@RequestMapping(params = "datagrid")public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {TSUser user = ResourceUtil.getSessionUser();List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();String workNum = "";if(StringUtils.isNotBlank(user.getEmp())) {//如果登錄者存在員工id 就只查詢自己的員工信息JformResumeInfoEntity jformResumeInfo = jformResumeInfoService.getEntity(JformResumeInfoEntity.class, user.getEmp());workNum = jformResumeInfo.getWorkNum();}/*** 早上gapTime = (case when datediff(MINUTE,CONVERT(VARCHAR(100),sj,23) + ' 08:00:00',sj) < -200 then '無'when datediff(MINUTE,CONVERT(VARCHAR(100),sj,23) + ' 08:00:00',sj) > -200 then '正常'when datediff(MINUTE,CONVERT(VARCHAR(100),sj,23) + ' 08:00:00',sj) <= 0 then '正常'when datediff(MINUTE,CONVERT(VARCHAR(100),sj,23) + ' 08:00:00',sj) > 0 then '遲到'else '其他' end )*/StringBuffer sql = new StringBuffer("select a.*,b.user_no as userNo,gapTime = (datediff(MINUTE,CONVERT(VARCHAR(100),sj,23) + ' 08:00:00',sj)) from kt_jl as a,dt_user as b WHERE a.user_serial = b.user_serial ");if(StringUtils.isNotBlank(workNum)) {sql.append(" and b.user_no = '" + workNum + "'");}else {String userNo = request.getParameter("userNo");if(StringUtils.isNotBlank(userNo)) {sql.append(" and b.user_no = '" + userNo + "'");}}String sj_begin = request.getParameter("sj_begin");if(StringUtils.isNotBlank(sj_begin)) {sql.append(" and sj >= '" + sj_begin + " 00:00:00'");}String sj_end = request.getParameter("sj_end");if(StringUtils.isNotBlank(sj_end)) {sql.append(" and sj <= '" + sj_end + " 23:59:59'");}if(StringUtils.isBlank(sj_end) && StringUtils.isBlank(sj_begin) ) {//默認當月String year = DateUtilsEx.getCurrYear();String month = DateUtilsEx.getCurrMothe();/*String lostDay = String.valueOf(DateUtilsEx.getMonthLastDay());//當月最后一天sql.append(" and sj BETWEEN '"+year+"-"+month+"-01 00:00:00' and '"+year+"-"+month+"-"+lostDay+" 23:59:59'");*///默認當天String nowDay = String.valueOf(DateUtilsEx.getMonthNowDay());sql.append(" and sj BETWEEN '"+year+"-"+month+"-"+nowDay+" 00:00:00' and '"+year+"-"+month+"-"+nowDay+" 23:59:59'");}if(StringUtils.isNotBlank(dataGrid.getSort())) {sql.append(" order by "+ dataGrid.getSort() +" "+dataGrid.getOrder());}else {sql.append(" order by sj DESC");}//測試jdbctemplatedata = DynamicDBUtil.findList("sql-server2008",sql.toString());List<Map<String, Object>> showList = null;//要顯示的數據int showLen = dataGrid.getRows();//動態得到前端需要顯示多少條int totlePage = data.size()%showLen == 0 ? data.size()/showLen : data.size()/showLen + 1;if(dataGrid.getPage() == 1 ) {if(showLen > data.size()) {showLen = data.size();}showList = data.subList(0, showLen);}else {if(dataGrid.getPage() == totlePage) {showList = data.subList(((dataGrid.getPage()-1)*showLen),data.size());}else {showList = data.subList(((dataGrid.getPage()-1)*showLen),((dataGrid.getPage()-1)*showLen)+showLen);}}dataGrid.setResults(showList);dataGrid.setTotal(data.size());//總條數TagUtil.datagrid(response, dataGrid);}
?
<t:datagrid name="clockinList" checkbox="true" pagination="true" fitColumns="true" title="員工考勤(默認當天考勤情況)" sortName="sj" actionUrl="clockinController.do?datagrid" idField="bh" fit="true" queryMode="group"><t:dgCol title="bh" field="bh" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="員工" field="userNo" query="true" dictionary="jform_resume_info,work_num,name" queryMode="single" width="120"></t:dgCol><t:dgCol title="用戶主見" field="user_serial" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="考勤日期" field="sj" formatter="yyyy-MM-dd hh:mm:ss" query="true" queryMode="group" extendParams="styler:fmtype" width="120"></t:dgCol><t:dgCol title="考勤方向" field="fx" queryMode="single" dictionary="clockin" width="120"></t:dgCol><t:dgCol title="iden" field="iden" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="正常打開記錄id" field="dev_serial" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="打開狀態" field="dev_state" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="jlzp_serial" field="jlzp_serial" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="gly_no" field="gly_no" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="lx" field="lx" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="審核" field="shenhe" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="yich" field="yich" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="打卡距上班差分鐘數" field="gapTime" hidden="true" queryMode="single" width="120"></t:dgCol><t:dgCol title="操作" field="opt" width="100"></t:dgCol>?
?
?
總結
以上是生活随笔為你收集整理的jeecg自定义datagrid封装列表分页数据显示自定义字段的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【数据竞赛】5行代码检测分布不一致,代码
- 下一篇: 电子邮件代码规范