66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
var mdref = {
|
|
create : function(){
|
|
data = $('#mdref').serialize();
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url':"/admin/data/ref/ac/mdref/",
|
|
'data':data,
|
|
'success':mdref.onsuccessed,
|
|
'timeout': 30000,
|
|
'error': function(){
|
|
$("#alert-info").attr('class','alert alert-error');
|
|
$("#alert-info").html("出现错误,请稍后重试");
|
|
$('#submit-loading').hide();
|
|
return false;
|
|
},
|
|
'beforeSend': function(){
|
|
$("#submit_btn").addClass('disabled');
|
|
$("#submit_btn").attr('disabled','disabled');
|
|
$('#submit-loading').show();
|
|
},
|
|
'complete': function(){
|
|
$("#submit_btn").removeClass('disabled');
|
|
$("#submit_btn").removeAttr('disabled');
|
|
$('#submit-loading').hide();
|
|
}
|
|
});
|
|
},
|
|
onsuccessed : function(data){
|
|
if (typeof(data)=='object')
|
|
{
|
|
if(typeof(data.error)!='undefined')
|
|
{
|
|
$("#alert-info").attr('class','alert alert-error');
|
|
$("#alert-info").html(data.error);
|
|
return false;
|
|
}
|
|
if(typeof(data.success)!='undefined')
|
|
{
|
|
$("#alert-info").attr('class','alert alert-success');
|
|
$("#alert-info").html("添加成功!");
|
|
setTimeout("$('#mdref-form').modal('hide');",1000);
|
|
setTimeout("window.location.href = window.location.href",2000);
|
|
return false;
|
|
}
|
|
}
|
|
else{
|
|
$("#alert-info").attr('class','alert alert-error');
|
|
$("#alert-info").html('请求中发生错误,请重试');
|
|
return false;
|
|
}
|
|
},
|
|
edit : function(id,refid,uuid,reftype,place)
|
|
{
|
|
$('#mdref input[name=id]').val(id);
|
|
$('#mdref input[name=refid]').val(refid);
|
|
$('#mdref input[name=uuid]').val(uuid);
|
|
$('#mdref input[name=place]').val(place);
|
|
$('input[name=reftype]').each(function(index, element) {
|
|
if($(this).val() == reftype)
|
|
{
|
|
$(this).attr('checked','checked');
|
|
}
|
|
});
|
|
$('#mdref-form').modal('show');
|
|
}
|
|
} |