function checkTxmqz0() {
debugger;
var txmqz0 = $("#txmqz0").val();
if (null != txmqz0 || "" !== txmqz0 || undefined !== txmqz0) {
var ob = {
};
ob.txmqz0 = txmqz0;
$.ajax({
type: "post",
url: "${ctx}/eis/lab/peYwzdTxmlb0/checkTxmqz0",
data:ob,
dataType: "json",
async: false,
success: function (datas) {
if(datas.result==true){
}else{
$("#txmqz0").val('');
$.jBox.tip(datas.errMsg, 'error');
}
},
error: function (err) {
}
});
}
}
后台
@RequestMapping(value = "checkTxmqz0")
@ResponseBody
public Object checkTxmqz0(HttpServletRequest request, HttpServletResponse response, Model model) {
HashMap result = new HashMap();
PeYwzdTxmlb0 txmlb0 = new PeYwzdTxmlb0();
try {
txmlb0.setTxmqz0(request.getParameter("txmqz0"));
peYwzdTxmlb0Service.getByTxmqz0(txmlb0);
result.put("result", true);
} catch (Exception e) {
this.logger.error("条形码前缀校验", e);
result.put("errMsg", e.getMessage());
result.put("result", false);
}
return result;
}
public void getByTxmqz0(PeYwzdTxmlb0 txmlb0 ) throws Exception{
if (this.dao.getByTxmqz0(txmlb0)>0) {
throw new Exception("该前缀:" +txmlb0.getTxmqz0() + " 已存在");
}
}