@Ellen翔 新增按钮录的BS 就是点完按钮后执行的服务端逻辑. 按钮切分成几个部分: 1.Button 包括按钮的渲染,按钮的事件 2.Dialog 点按钮以后是跳一个页面,还是直接异步请求服务端?,如果是异步请求服务端就没有弹Dialog这茬 3.服务端 如果有跳页面的需求,就是两个方法 一个 toXxxx 否则就只有 一个 doXxxx 上面出现调用两次 就是因为 根本就没有弹Dialog的需求,你却弹了Dialog,(可这里又执行的是,do的逻辑),所以就乱套了.
public void cancelReviewNewAgreement() throws Exception { String xdids = getPara(0); String xdnames=getPara(1); System.out.println("com.oss.product.ReviewController.cancelReviewNewAgreement> xdids=[" + xdids + "]"+"xdnames=["+xdnames+"]"); String xdidlist[]=xdids.split(","); String xdnameslist[]=xdnames.split(","); for(int i=0;i<xdidlist.length;i++){ Agreement agreement=new Agreement(); agreement.set("xdid", xdidlist[i]); agreement.set("xdname", xdnameslist[i]); agreement.save(); } renderText(" 新增成功! \n\n\n 请确定返回后点快速查询刷新表单!"); }
按钮ui:/review/btn/cancelReviewNewAgreement.html bs:/review/cancelReviewNewAgreement
html: <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'${button.icon!}',plain:true" onclick="NewAgreement()"> ${button.name!} </a> <script type="text/javascript"> //弹出Dialog var saveAgreement = function(name, url, width, height) { if(!width){ width = 920; } if(!height){ height = $(window).height() * 0.9; } // 弹出窗口 var dialog = parent.sy.modalDialog({ title : name, url : url, buttons : [ { text : ' 确 定 ', handler : function() { dialog.dialog('close'); } } ] }, width, height); }; var NewAgreement = function() { var $grid = $('#${gridId}'); var rows = $grid.datagrid('getSelections'); var num = rows.length; if (num == "0") { $.slideMsg("请至少选择一条记录!"); return; } var vals = []; var xdnames = []; for (var i = 0; i < rows.length; i++) { //组成一个字符串,ID主键用逗号隔开 vals.push(rows[i]['xdid']); xdnames.push(rows[i]['xdname']); } saveAgreement('${object.name}', '/review/cancelReviewNewAgreement/' + vals.join(',')+'-'+xdnames.join(','), 320, 200); if($grid.context.URL.indexOf('/single_tree') != -1){ $grid.treegrid('load'); } else { $grid.datagrid('load'); } }; </script>
com.oss.product.ReviewController.cancelReviewNewAgreement> xdids=[1000048]xdnames=[11] Sql: insert into agreement(id, xdid, xdname) values(seq_agreement.nextval, ?, ?) JFinal action report -------- 2018-01-10 16:53:50 ------------------------------ Controller : com.oss.product.ReviewController.(ReviewController.java:1) Method : cancelReviewNewAgreement UrlPara : 1000048-11 Interceptor : com.eova.interceptor.LoginInterceptor.(LoginInterceptor.java:1) -------------------------------------------------------------------------------- Sql: select * from eova_object where code = ? com.oss.product.ReviewController.cancelReviewNewAgreement> xdids=[1000048]xdnames=[11] Sql: insert into agreement(id, xdid, xdname) values(seq_agreement.nextval, ?, ?) Sql: select * from eova_field where object_code = ? order by order_num JFinal action report -------- 2018-01-10 16:53:50 ------------------------------ Controller : com.oss.product.ReviewController.(ReviewController.java:1) Method : cancelReviewNewAgreement UrlPara : 1000048-11 Interceptor : com.eova.interceptor.LoginInterceptor.(LoginInterceptor.java:1)
@Ellen翔 对按钮的工作机制和运行流程理解上出现了偏差,所以才存在这个问题,实际实现比你想的要简单,代码也要少很多: 请仔细看这个文档: http://doc.eova.cn
@Ellen翔 正确的思路是 点击按钮触发事件{ 获取选中行(单/多都可以) $.post(异步提交服务端){ 弹执行提示 成功,还是失败! } }