123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- $.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);
- }
- });
- }
|