00017-layui 對話框 layer.open 點擊保存,按鈕失效,保存完後,再恢復

var dialog = layer.open({
   type: 2
   ,title: '客戶訂單'
   ,content: 'ordersForm.jsp'
   ,maxmin: true
   ,area: layui.setter.area
   ,btn: ['保存', '取消']
   ,btnAlign: 'c'
   ,yes: function(index, layero){
      var iframeWindow = window['layui-layer-iframe'+ index]
         ,submit = layero.find('iframe').contents().find("#ordersForm-submit");
      iframeWindow.layui.form.on('submit(ordersForm-submit)', function(data){
                        var btn = $("a.layui-layer-btn0");
                        if(btn.hasClass("layui-btn-disabled")){
                            return;
                        }
                        btn.addClass("layui-btn-disabled");
                        var field = data.field;
                        field.id = rec.id;
                        var orderServiceList = window.formData.orderServiceList;
                        if(!orderServiceList || orderServiceList.length==0){
                            btn.removeClass("layui-btn-disabled");
                            return layer.msg('請添加合同事項');
                        }
                        field = $.extend(field,{orderServiceJson:JSON.stringify(orderServiceList)})
                        var orderAttachmentList = window.formData.orderAttachmentList;
                        if(!orderAttachmentList|| orderAttachmentList.length==0){
                            btn.removeClass("layui-btn-disabled");
                            return layer.msg('請上傳合同附件');
                        }
                        field = $.extend(field,{orderAttachmentJson:JSON.stringify(orderAttachmentList)})
                        field.status = 1;
                        var rtn = admin.syncReq(ctx+"/order/orders/modify",field);
                        console.log("field",field);
                        if(rtn && rtn.code==0){
                            layer.msg('操做成功');
                            active.reload();
                            form.render();
                            btn.removeClass("layui-btn-disabled");
                            layer.close(index);
                        }else{
                            layer.msg('操做失敗');
                            btn.removeClass("layui-btn-disabled");
                        }

      });
      submit.trigger('click');
   }
});

關鍵代碼:一開始直接添加禁用樣式jsp

var btn = $("a.layui-layer-btn0");
                        if(btn.hasClass("layui-btn-disabled")){
                            return;
                        }
                        btn.addClass("layui-btn-disabled");

操做完後,恢復:ui

btn.removeClass("layui-btn-disabled");
相關文章
相關標籤/搜索