123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- //解决 jquery Cannot read property 'msie' of undefined的问题
- jQuery.browser = {}; (function () { jQuery.browser.msie = false; jQuery.browser.version = 0; if (navigator.userAgent.match(/MSIE ([0-9]+)./)) { jQuery.browser.msie = true; jQuery.browser.version = RegExp.$1; } })();
- // 获取路由参数 name:参数名
- function getUrlOption(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return decodeURI(r[2]); return null;
- }
- function showErrorMsg(d) {
- //d = JSON.parse(d);
- if (d.Ret == -1001001)
- window.location.href = "/Error/Msg?code=1&msg=" + d.msg + "&url=/";
- else {
- //$.messager.alert("提示", d.Msg);
- layer.alert(d.Msg, { icon: 6 });
- }
- }
- //实现页面不跳转
- function formResult(tagForm, isAlert, funcall, successMsg, goUrl) {
- $("#" + tagForm + " button[class='btn btn-success']").attr("disabled", true);
- $("#" + tagForm).ajaxSubmit({
- success: function (data) {
- var flag = isJsonString(data);
- if (flag)
- data = JSON.parse(data);
- if (data.Ret == 0) {
- if (isAlert) {
- if (successMsg)
- {
- layer.msg(successMsg, { icon: 1 });
- //$.messager.alert("提示", successMsg);
- }
- else
- {
- layer.msg('操作成功', { icon: 1 });
- //$.messager.alert("提示", "操作成功");
- }
- if (funcall != null)
- {
- funcall();
- }
-
- if (goUrl) {
- setTimeout(function () {
- location.href = goUrl;
- }, 2000);
- }
- } else {
- if (goUrl) {
- setTimeout(function () {
- location.href = goUrl;
- }, 2000);
- }
- }
- $("#" + tagForm + " button[class='btn btn-success']").removeAttr("disabled");
- }
- else {
- showErrorMsg(data);
- $("#" + tagForm + " button[class='btn btn-success']").removeAttr("disabled");
- }
- },
- error: function () {
- $("#" + tagForm + " button[class='btn btn-success']").removeAttr("disabled");
- }
- });
- }
- function FunDo(url, paras) {
- $.post(url, paras, function (data) {
- if (data.Ret == 0) {
- layer.msg('操作成功', { icon: 1 });
- //$.messager.alert("提示", "操作成功");
- //setTimeout(function () {
- // location.reload();
- //}, 1000);
- }
- else {
- layer.alert(d.Msg, { icon: 6 });
- //$.messager.alert("提示", data.Msg);
- }
- });
- }
- function isJsonString(str) {
- try {
- if (typeof JSON.parse(str) == "object") {
- return true;
- }
- } catch (e) {
- }
- return false;
- }
- var telPhoneRegex = /^(0\\d{2}-\\d{8}(-\\d{1,4})?)|(0\\d{3}-\\d{7,8}(-\\d{1,4})?)$/;
- var mobilePhoneRegex = /^[1][3,4,5,7,8][0-9]{9}$/;
- var emailRegex = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
- var idCardRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
- function FunEdit(url) {
- var rows = $('#Ctr_DataGrid').datagrid('getSelected');
- if (!rows) {
- layer.alert("修改时,请选择一行需要【修改】的数据", { icon: 6 });
- //$.messager.alert("提示", "修改时,请选择一行需要【修改】的数据");
- return false;
- }
- var idEdit = rows.Id;
- window.location.href = url + "?id=" + idEdit;
- }
- //删除
- function FunDelete(url) {
- var rows = $('#Ctr_DataGrid').datagrid('getSelected');
- if (!rows) {
- layer.alert("删除时,请选择一行需要【删除】的数据", { icon: 6 });
- return false;
- }
- var IdDel = rows.Id;
- layer.confirm('您确定要删除吗?', {
- icon: 4,
- title: '提示' //按钮
- }, function () {
- $.post(url,
- {
- id: IdDel
- },
- function (data) {
- if (data.Ret == 0) {
- layer.msg("删除成功", { icon: 1 });
- FunRefresh();
- } else {
- layer.alert(data.Msg, { icon: 6 });
- }
- }, "json");
- });
- }
- $(function () {
- $(".onlyNum_one").keyup(function () {
- var tmptxt = $(this).val();
- if ($(this).val() == "-1") {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- return;
- }
- if (tmptxt.length >= 1 ) {
- tmptxt = tmptxt.substring(1, 0);
- }
-
- $(this).val(tmptxt.replace(/[^-0-9]/g, ''));
-
- if ($(this).val() < 9)
- {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
-
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^/g, ''));
- })
- $(".onlyNum_two").keyup(function () {
- var tmptxt = $(this).val();
- if (tmptxt.length >= 2) {
- tmptxt = tmptxt.substring(2, 0);
- }
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- if ($(this).val().length >= 2) {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- })
- $(".onlyNum_two_qlc").keyup(function () {
- var tmptxt = $(this).val();
- if (tmptxt > 30)
- tmptxt = tmptxt.substring(1, 0);
- if (tmptxt.length >= 2) {
- tmptxt = tmptxt.substring(2, 0);
- }
- $(this).val(tmptxt.replace(/\D|^/g, ''));
- if ($(this).val().length >= 2) {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- })
- $(".onlyNum_two_16").keyup(function () {
- var tmptxt = $(this).val();
- if ($(this).val() == "-1") {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- return;
- }
- if (tmptxt > 16)
- tmptxt = tmptxt.substring(1, 0);
- if (tmptxt.length >= 2) {
- tmptxt = tmptxt.substring(2, 0);
- }
- $(this).val(tmptxt.replace(/[^-0-9]/g, ''));
- if ($(this).val().length >= 2) {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- })
- $(".onlyNum_two_33").keyup(function () {
- var tmptxt = $(this).val();
- if ($(this).val() == "-1") {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- return;
- }
- if (tmptxt > 33)
- tmptxt = tmptxt.substring(1, 0);
- if (tmptxt.length >= 2) {
- tmptxt = tmptxt.substring(2, 0);
- }
- $(this).val(tmptxt.replace(/[^-0-9]/g, ''));
- if ($(this).val().length >= 2) {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- })
- $(".onlyNum_two_35").keyup(function () {
- var tmptxt = $(this).val();
- if (tmptxt > 35)
- tmptxt = tmptxt.substring(1, 0);
- if (tmptxt.length >= 2) {
- tmptxt = tmptxt.substring(2, 0);
- }
- $(this).val(tmptxt.replace(/\D|^/g, ''));
- if ($(this).val().length >= 2) {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- })
- $(".onlyNum_two_12").keyup(function () {
- var tmptxt = $(this).val();
- if (tmptxt > 12)
- tmptxt = tmptxt.substring(1, 0);
- if (tmptxt.length >= 2) {
- tmptxt = tmptxt.substring(2, 0);
- }
- $(this).val(tmptxt.replace(/\D|^/g, ''));
- if ($(this).val().length >= 2) {
- var $input = $('input:text:not(:disabled)');
- var n = $input.length;
- var nextIndex = $input.index(this) + 1;
- if (nextIndex < n) {
- $input[nextIndex].focus();
- $input[nextIndex].select()
- }
- else {
- $input[nextIndex - 1].blur();
- $input[nextIndex - 1].select()
- }
- }
- }).bind("paste", function () {
- var tmptxt = $(this).val();
- $(this).val(tmptxt.replace(/\D|^0/g, ''));
- })
- })
|