客户需求:
用户在市场活动明细页面,点击"修改"市场活动备注的图标,弹出修改市场活动备注的模态窗口;
用户在修改市场活动备注的模态窗口,填写表单,点击"更新"按钮,完成修改市场活动备注的功能.
*备注内容不能为空
*修改成功之后,关闭模态窗口,刷新备注列表
*修改失败,提示信息,模态窗口不关闭,列表也不刷新
功能开发:
1.根据客户需求画出修改市场活动的UML时序图
2.ActivityRemarkMapper接口
/**
* 修改市场活动备注
* @param activityRemark
* @return
*/
int updateActivityRemark(ActivityRemark activityRemark);
ActivityRemarkMapper.xml文件
<update id="updateActivityRemark" parameterType="com.it.crm.workbench.entity.ActivityRemark">
update tbl_activity_remark
set note_content=#{noteContent},edit_time=#{editTime},edit_by=#{editBy},edit_flag=#{editFlag}
where id=#{id}
</update>
3.ActivityRemarkService接口
ActivityRemarkServiceImpl类
4.ActivityRemarkController
@RequestMapping(value = "/workbench/activity/saveEditActivityRemark.do")
@ResponseBody
public Object saveEditActivityRemark(ActivityRemark activityRemark,HttpSession session){
User user = (User) session.getAttribute(Contants.SESSION_USER);
ReturnObject returnObject=new ReturnObject();
//封装参数
activityRemark.setEditTime(DateUtils.formateDateTime(new Date()));
activityRemark.setEditBy(user.getName());
activityRemark.setEditFlag(Contants.REMARK_EDIT_FLAG_YES_EDITED);
//调用service,保存修改的市场活动备注
try{
int ret = activityRemarkService.saveEditActivityRemark(activityRemark);
if (ret>0){
returnObject.setCode(Contants.RETURN_OBJECT_CODE_SUCCESS);
returnObject.setReturnData(activityRemark);
}else {
returnObject.setCode(Contants.RETURN_OBJECT_CODE_FAIL);
returnObject.setMessage("系统忙,请稍后重试!");
}
}catch (Exception e){
e.printStackTrace();
returnObject.setCode(Contants.RETURN_OBJECT_CODE_FAIL);
returnObject.setMessage("系统忙,请稍后重试!");
}
return returnObject;
}
5.activity的detail.jsp页面
//给修改图标添加单击事件
$("#remarkDivList").on("click","a[name='editA']",function () {
var id=$(this).attr("remarkId");
var noteContent=$("#div_"+id+" h5").text();
//设置模态窗口中的值
$("#edit-id").val(id);
$("#noteContent").val(noteContent);
$("#editRemarkModal").modal("show");
});
//给更新按钮添加单击事件
$("#updateRemarkBtn").click(function () {
//收集参数
var id=$("#edit-id").val();
var noteContent=$.trim($("#noteContent").val());
//表单验证
if (noteContent==""){
alert("备注内容不能为空!");
return;
}
//发送请求
$.ajax({
url:"workbench/activity/saveEditActivityRemark.do",
data:{
id:id,
noteContent:noteContent
},
type:'post',
dataType:'json',
success:function (data) {
if (data.code=="1"){
//关闭模态窗口
$("#editRemarkModal").modal("hide");
//刷新备注列表
$("#div_"+data.returnData.id+" h5").text(data.returnData.noteContent);
$("#div_"+data.returnData.id+" small").text(" "+data.returnData.editTime+" 由${sessionScope.sessionUser.name}修改");
}else {
//提示信息
alert(data.message);
//模态窗口不关闭
$("#editRemarkModal").modal("show");
}
}
});
});
功能测试:
进入市场活动列表页面,点击市场活动进入市场活动备注页面
点击修改市场活动备注按钮,弹出模态窗口进行数据回显
修改内容,点击保存