mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-04-16 18:48:03 +08:00
优化流程节点显示
This commit is contained in:
208
OpenAuth.Mvc/Content/scripts/utils/form.js
Normal file
208
OpenAuth.Mvc/Content/scripts/utils/form.js
Normal file
@@ -0,0 +1,208 @@
|
||||
$.SaveForm = function (options) {
|
||||
var defaults = {
|
||||
url: "",
|
||||
param: [],
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
loading: "正在处理数据...",
|
||||
success: null,
|
||||
close: true
|
||||
};
|
||||
var options = $.extend(defaults, options);
|
||||
Loading(true, options.loading);
|
||||
if ($('[name=__RequestVerificationToken]').length > 0) {
|
||||
options.param["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
|
||||
}
|
||||
window.setTimeout(function () {
|
||||
$.ajax({
|
||||
url: options.url,
|
||||
data: options.param,
|
||||
type: options.type,
|
||||
dataType: options.dataType,
|
||||
success: function (data) {
|
||||
if (data.type == "3") {
|
||||
dialogAlert(data.message, -1);
|
||||
} else {
|
||||
Loading(false);
|
||||
dialogMsg(data.message, 1);
|
||||
options.success(data);
|
||||
if (options.close == true) {
|
||||
dialogClose();
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
Loading(false);
|
||||
dialogMsg(errorThrown, -1);
|
||||
},
|
||||
beforeSend: function () {
|
||||
Loading(true, options.loading);
|
||||
},
|
||||
complete: function () {
|
||||
Loading(false);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
$.SetForm = function (options) {
|
||||
var defaults = {
|
||||
url: "",
|
||||
param: [],
|
||||
type: "get",
|
||||
dataType: "json",
|
||||
success: null,
|
||||
async:false
|
||||
};
|
||||
var options = $.extend(defaults, options);
|
||||
$.ajax({
|
||||
url: options.url,
|
||||
data: options.param,
|
||||
type: options.type,
|
||||
dataType: options.dataType,
|
||||
async: options.async,
|
||||
success: function (data) {
|
||||
if (data != null && data.type == "3") {
|
||||
dialogAlert(data.message, -1);
|
||||
} else {
|
||||
options.success(data);
|
||||
}
|
||||
},
|
||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
dialogMsg(errorThrown, -1);
|
||||
}, beforeSend: function () {
|
||||
Loading(true);
|
||||
},
|
||||
complete: function () {
|
||||
Loading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
$.RemoveForm = function (options) {
|
||||
var defaults = {
|
||||
msg: "注:您确定要删除吗?该操作将无法恢复",
|
||||
loading: "正在删除数据...",
|
||||
url: "",
|
||||
param: [],
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
success: null
|
||||
};
|
||||
var options = $.extend(defaults, options);
|
||||
dialogConfirm(options.msg, function (r) {
|
||||
if (r) {
|
||||
Loading(true, options.loading);
|
||||
window.setTimeout(function () {
|
||||
var postdata = options.param;
|
||||
if ($('[name=__RequestVerificationToken]').length > 0) {
|
||||
postdata["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
|
||||
}
|
||||
$.ajax({
|
||||
url: options.url,
|
||||
data: postdata,
|
||||
type: options.type,
|
||||
dataType: options.dataType,
|
||||
success: function (data) {
|
||||
if (data.type == "3") {
|
||||
dialogAlert(data.message, -1);
|
||||
} else {
|
||||
dialogMsg(data.message, 1);
|
||||
options.success(data);
|
||||
}
|
||||
},
|
||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
Loading(false);
|
||||
dialogMsg(errorThrown, -1);
|
||||
},
|
||||
beforeSend: function () {
|
||||
Loading(true, options.loading);
|
||||
},
|
||||
complete: function () {
|
||||
Loading(false);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
$.ConfirmAjax = function (options) {
|
||||
var defaults = {
|
||||
msg: "提示信息",
|
||||
loading: "正在处理数据...",
|
||||
url: "",
|
||||
param: [],
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
success: null
|
||||
};
|
||||
var options = $.extend(defaults, options);
|
||||
dialogConfirm(options.msg, function (r) {
|
||||
if (r) {
|
||||
Loading(true, options.loading);
|
||||
window.setTimeout(function () {
|
||||
var postdata = options.param;
|
||||
if ($('[name=__RequestVerificationToken]').length > 0) {
|
||||
postdata["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
|
||||
}
|
||||
$.ajax({
|
||||
url: options.url,
|
||||
data: postdata,
|
||||
type: options.type,
|
||||
dataType: options.dataType,
|
||||
success: function (data) {
|
||||
Loading(false);
|
||||
if (data.type == "3") {
|
||||
dialogAlert(data.message, -1);
|
||||
} else {
|
||||
dialogMsg(data.message, 1);
|
||||
options.success(data);
|
||||
}
|
||||
},
|
||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
Loading(false);
|
||||
dialogMsg(errorThrown, -1);
|
||||
},
|
||||
beforeSend: function () {
|
||||
Loading(true, options.loading);
|
||||
},
|
||||
complete: function () {
|
||||
Loading(false);
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
}
|
||||
$.ExistField = function (controlId, url, param) {
|
||||
var $control = $("#" + controlId);
|
||||
if (!$control.val()) {
|
||||
return false;
|
||||
}
|
||||
var data = {
|
||||
keyValue: request('keyValue')
|
||||
};
|
||||
data[controlId] = $control.val();
|
||||
var options = $.extend(data, param);
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: options,
|
||||
type: "get",
|
||||
dataType: "text",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (data.toLocaleLowerCase() == 'false') {
|
||||
ValidationMessage($control, '已存在,请重新输入');
|
||||
$control.attr('fieldexist', 'yes');
|
||||
} else {
|
||||
$control.attr('fieldexist', 'no');
|
||||
}
|
||||
},
|
||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||
dialogMsg(errorThrown, -1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user