$("#confirmDealDelete").click(function(){
$("#deleteForm").show();
$("#modal-result").hide();
var v_id='${ClientForm.id}';
var v_advancedPassword=$("#advancedPassword").val();
var v_reAdvancedPassword=$("#reAdvancedPassword").val();
if(v_advancedPassword != v_reAdvancedPassword){
$("#modal-result").html("高级密码不一致");
$("#modal-result").show();
return false;
}
marks();
$.ajax({
type: "POST",
url: "/client/deleteClient.json",
dataType:"json",
data: {client: v_id, advancedPassword: v_advancedPassword, reAdvancedPassword: v_reAdvancedPassword},
cache: false,
success: function (result) {
console.log(result.result);
unMarks();
$("#clientList").trigger("reloadGrid");
$("#details").html("");
if(result.result == undefined || result.result==false){
$("#modal-result").html("删除失败");
$("#modal-result").show();
}else{
$("#modal-result").html("删除成功");
$("#modal-result").show();
$("#deleteForm").hide();
}
},
error: function () {
unMarks();
$("#info").attr("class", "info-error");
$("#info").html("Sorry,request error");
}
});
});
});
@RequestMapping(value = "/deleteClient.json", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public JSONObject deleteClient( @RequestParam(value = "advancedPassword", required = false) String advancedPassword,
@RequestParam(value = "reAdvancedPassword", required = false) String reAdvancedPassword,
@RequestParam(value = "client", required = false) long clientId){
UserAccount userAccount= userAccountService.findUserAccountById(getUserIdBySpring());
JSONObject result=new JSONObject();
if (userAccount !=null && userAccount.getId() >0 && userAccount.isActivated() && advancedPassword !=null
&& StringUtils.equals(advancedPassword,reAdvancedPassword)){
String md5=Md5Encrypt.md5(advancedPassword);
if (md5 !=null && StringUtils.equals(md5,userAccount.getAdvancedPassword())){
clientService.deleteClientByUserId(clientId);
result.put("result",true);
}else {
result.put("result",false);
}
}else {
result.put("result", false);
}
return result;
}
function getAccountDetails(id) {
$.ajax({
type:"GET",
url:"/client/client-details",
data:{id:id},
timeout:50000,
cache:false,
success:function (result) {
$("#details").html(result);
mScroll("details");
unMarks();
} ,
error:function(){
$("#message").html("Request time out");
unMarks();
}
});
}
@RequestMapping(value = "/client-details",method = RequestMethod.GET)
public String accountDetails(HttpServletRequest request,
ModelMap modelMap,
@RequestParam(value = "id",required = false,defaultValue = "0") long id) {
Client client= clientService.findClientById(id);
ClientForm form =domainToForm(client);
modelMap.addAttribute("ClientForm",form);
return "/client/clientDetail";
}
本文转自wiwi博客51CTO博客,原文链接http://blog.51cto.com/wiwili/1965958如需转载请自行联系原作者
wiwili