10.CRM分页实现客户开发计划

时间:2021-12-02 09:04:00

使用销售机会salechance已有的dao,service,impl 其他的只需要修改部分代码即可实现功能

4.Controller层的方法

@Controller
@RequestMapping("/saleChance")
public class SaleChanceController {

@Resource
private SaleChanceService saleChanceService;

@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); //true:允许输入空值,false:不能为空值
}

/**
* 分页条件查询销售机会
* @param page
* @param rows
* @param s_saleChance
* @param response
* @return
* @throws Exception
*/

@RequestMapping("/list")
public String list(@RequestParam(value="page",required=false)String page,@RequestParam(value="rows",required=false)String rows,SaleChance s_saleChance,HttpServletResponse response)throws Exception{
PageBean pageBean=new PageBean(Integer.parseInt(page),Integer.parseInt(rows));
Map<String,Object> map=new HashMap<String,Object>();
map.put("customerName", StringUtil.formatLike(s_saleChance.getCustomerName()));
map.put("overView", StringUtil.formatLike(s_saleChance.getOverView()));
map.put("createMan", StringUtil.formatLike(s_saleChance.getCreateMan()));
map.put("state", s_saleChance.getState());
map.put("devResult", s_saleChance.getDevResult());
map.put("start", pageBean.getStart());
map.put("size", pageBean.getPageSize());
List<SaleChance> saleChanceList=saleChanceService.find(map);
Long total=saleChanceService.getTotal(map);
JSONObject result=new JSONObject();
JsonConfig jsonConfig=new JsonConfig();
jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd HH:mm"));
JSONArray jsonArray=JSONArray.fromObject(saleChanceList,jsonConfig);
result.put("rows", jsonArray);
result.put("total", total);
ResponseUtil.write(response, result);
return null;
}

5.Mapper,xml配置查询数据库的方法

<select id="getTotal" parameterType="Map" resultType="Long">
select count(*) from t_sale_chance
<where>
<if test="customerName!=null and customerName!='' ">
and customerName like #{customerName}
</if>
<if test="overView!=null and overView!='' ">
and overView like #{overView}
</if>
<if test="createMan!=null and createMan!='' ">
and createMan like #{createMan}
</if>
<if test="state!=null">
and state = #{state}
</if>
<if test="devResult!=null ">
and devResult = #{devResult}
</if>
</where>
</select>

6.编写jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>


<script type="text/javascript">



function searchSaleChance(){
$("#dg").datagrid('load',{
"customerName":$("#s_customerName").val(),
"overView":$("#s_overView").val(),
"devResult":$("#s_devResult").combobox("getValue")
});
}

function formatState(val,row){
if(val==1){
return "已分配";
}else{
return "未分配";
}
}


function formatDevResult(val,row){
if(val==0){
return "未开发";
}else if(val==1){
return "开发中";
}else if(val==2){
return "开发成功";
}else if(val==3){
return "开发失败";
}
}

function formatAction(val,row){
if(row.devResult==0||row.devResult==1){
return "<a href=''>开发</a>";
}else{
return "<a href=''>查看详细信息</a>";
}
}


</script>
<title>Insert title here</title>
</head>
<body style="margin: 1px">
<table id="dg" title="客户开发计划管理" class="easyui-datagrid"
fitColumns="true" pagination="true" rownumbers="true"
url="${pageContext.request.contextPath}/saleChance/list.do?state=1" fit="true" toolbar="#tb">

<thead>
<tr>
<th field="cb" checkbox="true" align="center"></th>
<th field="id" width="50" align="center">编号</th>
<th field="chanceSource" width="200" align="center" hidden="true">机会来源</th>
<th field="customerName" width="80" align="center">客户名称</th>
<th field="cgjl" width="50" align="center" hidden="true">成功几率</th>
<th field="overView" width="150" align="center">概要</th>
<th field="linkMan" width="80" align="center">联系人</th>
<th field="linkPhone" width="100" align="center" hidden="true">联系电话</th>
<th field="description" width="200" align="center" hidden="true">机会描述</th>
<th field="createMan" width="80" align="center">创建人</th>
<th field="createTime" width="150" align="center">创建时间</th>
<th field="assignMan" width="50" align="center" >指派人</th>
<th field="assignTime" width="150" align="center" >指派时间</th>
<th field="state" width="100" align="center" formatter="formatState" hidden="true">状态</th>
<th field="devResult" width="100" align="center" formatter="formatDevResult">客户开发状态</th>
<th field="a" width="100" align="center" formatter="formatAction">操作</th>
</tr>
</thead>
</table>
<div id="tb">
<div>
&nbsp;客户名称:&nbsp;<input type="text" id="s_customerName" size="20" onkeydown="if(event.keyCode==13) searchSaleChance()"/>
&nbsp;概要:&nbsp;<input type="text" id="s_overView" size="20" onkeydown="if(event.keyCode==13) searchSaleChance()"/>
&nbsp;客户开发状态:&nbsp;<select class="easyui-combobox" id="s_devResult" editable="false" panelHeight="auto" >
<option value="">请选择...</option>
<option value="0">未开发</option>
<option value="1">开发中</option>
<option value="2">开发成功</option>
<option value="3">开发失败</option>
</select>
<a href="javascript:searchSaleChance()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
</div>
</div>


</body>
</html>

相关文章