现在前台技术用到的是ligerui,一直想写一个有关ligerui的显示,利用加班的今天偷点闲复制一下下,当自己的一些小资料吧,不会的时候,还可以来看看............稍微有点多,毕竟是从前后台一起写的,后台技术用到spring、mybatis。全部全部过程!
html:
<div id="grid"></div>
js:
var grid;//
var columns;
$(function(){
grid = $("#grid").ligerGrid({
columns: columns,
url: '/MCS/loanappro/getLoanApproveCommWithPagingList.do?openType='+openType,
sortName: 'bill_code', // 排序列名
sortOrder: 'asc', // 排序方式
rownumbers: true,
allowUnSelectRow: true,
usePager: true,
width: '100%',
height: '100%',
heightDiff: -4,
parms: {
_filterParms: -1
}
});
}); var columns=[
display: '单据编号',
name: 'bill_code',
width: 110,
minWidth: 110,
//添加超链接的东西
render: function (rowdata, rowindex, value) {
return '<a href="javascript:creditInfo('+rowdata.mcs_cre_credit_head_id+');" style="color:#056AFF;text-decoration: none;">'+value+'</a>';
},
},{
display: '申请时间',
name: 'create_timestamp',
width: 150,
minWidth: 150 },{
display: '贷款种类',
name:'loan_types',
isSort: false,
width:100,
render: function (rowdata, rowindex, value){
var h = "";
if (!rowdata._editing){
h += "抵押<input type='checkbox' style='width:20px;'/>";
h += "信用<input type='checkbox' style='width:20px;'/> ";
}else{
h += "抵押<input type='checkbox' style='width:20px;'/>";
h += "信用<input type='checkbox' style='width:20px;'/> ";
}
return h;
} } ];
前台我就简写了三列,可根据情况自己添写字段。
下面介绍到后台
Controller:
package com.goldcow.emanage.loanappro.web;
@Controller
public class McsCreCreditApproController
{
/**
* 查询列表分页
* @param queryInfo
* @return
*/
@RequestMapping(value="/loanappro/getLoanApproveCommWithPagingList.do",method={RequestMethod.GET,RequestMethod.POST})
@ResponseBody
public Map<String,Object> getLoanApproveCommWithPagingList(McsCreApproSearchBean queryInfo,HttpServletRequest request, String openType){
//获取当前登录人
HttpSession session = request.getSession();
UserBean user =(UserBean)session.getAttribute(GlobalVal.USER_SESSION);
return mcscrecreditapproService.getLoanApproveCommWithPagingList(queryInfo,user,openType);
}
}
service就不写了,直接写serviceImpl的内容:
package com.goldcow.emanage.loanappro.service.impl;
@Service("mcscrecreditapproService")
public class McsCreCreditApproServiceImpl implements IMcsCreCreditApproService
{
@Override
public Map<String, Object> getLoanApproveCommWithPagingList(
McsCreApproSearchBean queryInfo, UserBean user, String openType) {
Map<String,Object> paramMap=new HashMap<String,Object>();
paramMap.put("sortname", queryInfo.getSortname());
paramMap.put("sortorder", queryInfo.getSortorder());
paramMap.put("offset", queryInfo.getOffset());
paramMap.put("pagesize", queryInfo.getPagesize());
List<Map<String,Object>> list=mcscrecreditapproDao.getLoanApproveCommWithPagingList(paramMap);//查询search
GridDataBean<Map<String,Object>> bean =new GridDataBean<Map<String,Object>>(queryInfo.getPage(),mcscrecreditapproDao.getLoanApproveCommCount(paramMap),list);//getPage():第几页 getLoanApproveCommCount():查询共有条数据 list:查询
return bean.getGridData(); }
}
接下来就是dao了:
package com.goldcow.emanage.loanappro.persist;
@MyBatisRepository
public interface McsCreCreditApproDao{
List<Map<String,Object>> getLoanApproveCommWithPagingList(Map<String,Object> paramMap); int getLoanApproveCommCount(Map<String,Object> paramMap);
}
xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- namespace必须指向Dao接口 -->
<mapper namespace="com.goldcow.emanage.loanappro.persist.McsCreCreditApproDao">
<select id="getLoanApproveCommCount" parameterType="map" resultType="int">
select count(
mcs_cre_credit_experience_points_main_id
) as count from mcs_cre_credit_head </select> <select id="getLoanApproveCommWithPagingList" parameterType="map" resultType="java.util.HashMap">
select
mcs_cre_credit_head_id,
bill_code,
credit_purpose,
max_repayment_limit_per_month,
credit_limit
from mcs_cre_credit_head
<if test="sortname!=null and sortorder!=null">
order by ${sortname} ${sortorder}
</if>
<if test="offset!=null and pagesize!=null">
limit ${offset},${pagesize}
</if>
</select> </mapper>
缺少一个bean
package com.goldcow.emanage.util.gen.entity;
/**
* 个人银行贷款
* @author xuxiaohua
*
*/
public class McsCreApproSearchBean extends GridParamBean implements BaseEntity{
private Integer mcs_cre_credit_head_id; private String bill_code; private String credit_purpose; private Double max_repayment_limit_per_month; private Double credit_limit; private Integer max_repayment_time_limit;
//封装好这些私有字段之后 /**
* default val cols name array
*/
private static String[] defaultValColArr = {
}; /**
* pk cols name array
*/
private static String[] pkColArr = {
"mcs_cre_credit_head_id"
}; private static String[] columnNameArr = {
"mcs_cre_credit_head_id",
"bill_code",
"credit_purpose",
"max_repayment_limit_per_month",
"credit_limit",
"max_repayment_time_limit"
} /**
* put all columns into a map
*/
public void putInMap(Map<String, Object> paramMap) {
paramMap.put("mcs_cre_credit_head_id", this.mcs_cre_credit_head_id);
paramMap.put("bill_code", this.bill_code);
paramMap.put("credit_purpose", this.credit_purpose);
paramMap.put("max_repayment_limit_per_month", this.max_repayment_limit_per_month);
paramMap.put("credit_limit", this.credit_limit);
paramMap.put("max_repayment_time_limit", this.max_repayment_time_limit);
} /**
* return the columns map
*/
public Map<String, Object> getInfoMap() {
Map<String, Object> paramMap = new HashMap<String, Object>();
this.putInMap(paramMap);
return paramMap;
} /**
* remove default value and pk if it is null
*/
private Map<String, Object> dealWithMap(Map<String, Object> paramMap) {
Set<String> set = new HashSet<String>();
for (String colName : defaultValColArr) {
set.add(colName);
}
for (String colName : pkColArr) {
set.add(colName);
}
Iterator<String> iterator = set.iterator();
while (iterator.hasNext()) {
String colName = iterator.next();
if(paramMap.get(colName) == null) {
paramMap.remove(colName);
}
}
return paramMap;
}
}
好像已经写完了,啊,格式有点乱,凑合看吧!这个摁tab键也不好用啊。
有时间弄一份easyui的.
我觉得应该写一份有关mybatis的增删改查