123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- //需要引入bootstrap.min.js 和 sweetalert.min.js
- /**
- * 涉及到文件上传的ajax提交
- * @param formId
- * @param fun_success
- * @param fun_error
- */
- function ajaxFormUploadForBootStrap(formId,transCode,fun_success, fun_error) {
- url = sysWebAppName + 'TransServlet?transCode=' +transCode + '&clientToken='
- + $.__token + '&channelNo=service';
- var form = new FormData(document.getElementById(formId));
- $.ajax({
- type : "post",
- data : form,
- processData : false,
- contentType : false,
- /*
- * $("#" + formId).form( 'submit', {
- */
- url : encodeURI(url),
- timeout : ajaxTimeout,
- async : false,
- traditional : false,
- cache : false,
- ajaxSubmit : function() {
- return true;
- },
- success : function(result) {
- var data = (new Function("return " + result))();
- if (data.returnCode == 'EB8000006') {
-
- swal({
- title: "用户异常提示",
- text: "用户异常,是否重新登录!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "重新登录!",
- cancelButtonText: "取消!",
- closeOnConfirm: false
- },
- function(){
- $(".leftcurtain", window.parent.document).stop()
- .animate({
- width : '50%'
- }, 1500);
- $(".rightcurtain", window.parent.document).stop()
- .animate({
- width : '51%'
- }, 1500);
- $(".login", window.parent.document).show("slow").find(
- "input[type=password]").val("");
- parent.changeImage();
- });
-
- } else {
- if (data.returnCode == successCode) {
- fun_success && fun_success(data);
- } else {
- if (fun_error) {
- fun_error && fun_error(data);
- }
- }
- }
- },
- onLoadError : function() {
- //$.messager.alert('系统错误', '网络或系统忙提交失败,请重试!', 'error');
- }
- });
- }
- /**
- * ajax 通信工具类(本地)--针对bootstrap的页面
- *
- * @param transCode
- * 交易码
- * @param servletName
- * servlet名称
- * @param proNames
- * proName字段
- * @param params
- * 参数
- * @param fun_success
- * @param fun_error
- * @param isLoginOut
- */
- function syncAjaxCalllForBootstrap(transCode, servletName, params,
- fun_success, fun_error, isLoginOut) {
- if (params == null) {
- params = {};
- }
- __mask++;
- if (__mask >= 0) {
- showLoading(1);
- }
- url = sysWebAppName + servletName + '?transCode=' + transCode
- + '&clientToken=' + $.__token + '&channelNo=service';;
- $
- .ajax({
- url : encodeURI(url),
- data : params || "",
- type : "POST",
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
- dataType : "text",
- timeout : ajaxTimeout,
- success : function(data) {
- data = $.parseJSON(data);
- __mask--;
- if (data == null)
- return;
- if (__mask == 0) {
- showLoading(-1);
- }
- if (data.returnCode == 'EB8000006') {
- if (isLoginOut) {
- fun_success && fun_success(data);
- } else {
- if (__login > 0)
- return;
- swal({
- title: "用户异常提示",
- text: "用户异常,是否重新登录!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "重新登录!",
- cancelButtonText: "取消!",
- closeOnConfirm: false
- },
- function(data){
- if(data){
- $(".leftcurtain", window.parent.document)
- .stop().animate({
- width : '50%'
- }, 1500);
- $(".rightcurtain", window.parent.document)
- .stop().animate({
- width : '51%'
- }, 1500);
- $(".login", window.parent.document).show();
- $(".login", window.parent.document).find(
- "input[type=password]").val("");
- $(".login", window.parent.document).find(
- "input[type=text]").val("");
- parent.changeImage();
- __login--;
- }else{
- __login--;
- }
-
- });
-
- __login++;
- }
- } else {
- if (data.returnCode == undefined
- || data.returnCode == successCode
- || data.success) {
- fun_success && fun_success(data);
- } else {
- if (fun_error) {
- fun_error && fun_error(data);
- }
- }
- }
- },
- error : function(XMLHttpRequest, textStatus, errorThrown) {
- __mask--;
- if (__mask == 0) {
- showLoading(-1);
- }
- if (fun_error) {
- fun_error
- && fun_error(XMLHttpRequest, textStatus,
- errorThrown);
- }
- }
- });
- }
- /**
- * ajax 通信工具类(本地)--针对bootstrap的页面(调用Manager)
- *
- * @param transCode
- * 交易码
- * @param servletName
- * servlet名称
- * @param proNames
- * proName字段
- * @param params
- * 参数
- * @param fun_success
- * @param fun_error
- * @param isLoginOut
- */
- function syncAjaxCallManagerForBootstrap(transCode,params,
- fun_success, fun_error, isLoginOut) {
- if (params == null) {
- params = {};
- }
- __mask++;
- if (__mask >= 0) {
- showLoading(1);
- }
- url = sysWebAppName + 'TransServlet?transCode=' + transCode
- + '&clientToken=' + $.__token;
- $
- .ajax({
- url : encodeURI(url),
- data : params || '',
- type : "POST",
- contentType : "application/x-www-form-urlencoded; charset=utf-8",
- dataType : "text",
- timeout : ajaxTimeout,
- success : function(data) {
- data = $.parseJSON(data);
- __mask--;
- if (data == null)
- return;
- if (__mask == 0) {
- showLoading(-1);
- }
- if (data.returnCode == 'EB8000006') {
- if (isLoginOut) {
- fun_success && fun_success(data);
- } else {
- if (__login > 0)
- return;
- swal({
- title: "用户异常提示",
- text: "用户异常,是否重新登录!",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "重新登录!",
- cancelButtonText: "取消!",
- closeOnConfirm: false
- },
- function(data){
- if(data){
- $(".leftcurtain", window.parent.document)
- .stop().animate({
- width : '50%'
- }, 1500);
- $(".rightcurtain", window.parent.document)
- .stop().animate({
- width : '51%'
- }, 1500);
- $(".login", window.parent.document).show();
- $(".login", window.parent.document).find(
- "input[type=password]").val("");
- $(".login", window.parent.document).find(
- "input[type=text]").val("");
- parent.changeImage();
- __login--;
- }else{
- __login--;
- }
-
- });
-
- __login++;
- }
- } else {
- if (data.returnCode == undefined
- || data.returnCode == successCode
- || data.success) {
- fun_success && fun_success(data);
- } else {
- if (fun_error) {
- fun_error && fun_error(data);
- }
- }
- }
- },
- error : function(XMLHttpRequest, textStatus, errorThrown) {
- __mask--;
- if (__mask == 0) {
- showLoading(-1);
- }
- if (fun_error) {
- fun_error
- && fun_error(XMLHttpRequest, textStatus,
- errorThrown);
- }
- }
- });
- }
- //分页相关:
- /**
- * 对想要跳转的页面进行判断
- * @param index
- */
- function goPage(index){
- var toPage;
- var currentPage =parseInt($("#page1").val());
- var pageRows =parseInt($("#rows1").html());
- var total = parseInt($("#total1").html());
- var totalPage;
- if(total % pageRows == 0){
- totalPage = total/pageRows;
- }else{
- totalPage = parseInt(total/pageRows) + 1;
- }
-
- if(index == 'front'){
- toPage = 1;
- }else if(index == 'sub'){
- toPage = currentPage - 1;
- if(toPage <= 0){
- toPage = 1;
- }
- }else if(index == 'add'){
- toPage = currentPage + 1;
- if(toPage >= totalPage){
- toPage = totalPage;
- }
- }else if(index == 'last'){
- toPage = totalPage;
- }else if(index == 'changerows'){
- if(currentPage > totalPage){
- toPage = totalPage;
- }else{
- toPage = currentPage;
- }
- }else{
- if(index < 0){
- index = 1;
- }else if(index > totalPage){
- index = totalPage;
- }
- toPage = index;
- }
-
- $("#page1").val(toPage);
- doSearch(true);
-
- }
- /**
- * 改变分页的参数, 总数,总页数,开始,结束
- */
- function showPageIndex(total){
- var page = parseInt($("#page1").val());
- var pageRows =parseInt($("#rows1").html());
- var totalPage,startIndex,endIndex;
- if(total == 0){
- totalPage = 0;
- startIndex = 0;
- endIndex = 0;
- $("#page1").val(0);
- }else{
- if(total % pageRows == 0){
- totalPage = total/pageRows;
- }else{
- totalPage = parseInt(total/pageRows) + 1;
- }
- startIndex = (page - 1)*pageRows + 1;
- endIndex = page*pageRows;
- if(endIndex > total){
- endIndex = total;
- }
- }
-
- $("#total1").html(total);
- $("#totalPage1").html(totalPage);
- $("#startIndex1").html(startIndex);
- $("#endIndex1").html(endIndex);
- }
- function changeGMKB(numb,n){
- if(isNaN(numb)) {
- return numb;
- }
- n = n > 0 && n <= 20 ? n : 2;
- if(numb>-1 && numb<1024){
- return numb.toFixed(n)+'B';
- }else if(numb>1023 && numb<1048576){
- return (numb/1024).toFixed(n)+'Kb';
- }else if(numb>1048575 && numb<1073741824){
- return (numb/1048576).toFixed(n)+'M';
- }else if(numb>1073741823){
- return (numb/1073741824).toFixed(n)+'G';
- } else {
- numb = 0;
- return numb.toFixed(n)+'B';
- }
- }
- /**
- * 更改每页显示的条数
- */
- function changeRows(index){
- $("#rows1").html(index);
- goPage('changerows');
- }
- /**
- * 判断钱是否空
- * @param id
- */
- function ifMoneyNull(id){
- var tempVal = $("#"+id).val();
-
- var temp= tempVal.substr(0,tempVal.indexOf(".")+3);
- var tempNum= parseFloat(temp);
- if(temp == "" || temp == undefined || tempNum == 0){
- //$('#collapseOne').collapse('hide');
- //如果验证不通过,展开
- if(! $("#"+id).parents(".panel-collapse").hasClass("in")){
- $("#"+id).parents(".panel-collapse").collapse('show');
- $("#"+id).focus();
- return false;
- }
- var options={
- trigger:'manual',
- };
- $("#"+id).popover(options);
- $("#"+id).popover('show');
- $("#"+id).focus();
-
- return false;
- }else{
- return true;
- }
- }
- /**
- * 判断内容是否为空,来显示提示框
- * 对应的input必须有popover属性
- * @param id
- * @returns {Boolean}
- */
- function ifNull(id){
- var temp = $("#"+id).val();
- if(temp.replace(/(^\s*)|(\s*$)/g, "") == ""){
- //$('#collapseOne').collapse('hide');
- //如果验证不通过,展开
- if(! $("#"+id).parents(".panel-collapse").hasClass("in")){
- $("#"+id).parents(".panel-collapse").collapse('show');
- $("#"+id).focus();
- return false;
- }
- var options={
- trigger:'manual',
- };
- $("#"+id).popover(options);
- $("#"+id).popover('show');
- $("#"+id).focus();
-
- return false;
- }else{
- return true;
- }
- }
- /**
- * 判断用户是否输入,隐藏提示框
- * @param index
- */
- function ifNullInput(index){
- var temp = $(index).val();
- if(null != temp && undefined != temp){
- $(index).popover('hide');
- }
- };
- /**
- * 判断用户是否点击文件选择,隐藏提示框
- * @param index
- */
- function fileInpufHide(index){
- $(index).popover('hide');
- };
- /**
- * 日期格式化
- *
- * @param date
- * @returns {String}
- */
- function formatterDate2ss(date) {
- var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
- var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
- + (date.getMonth() + 1);
- var hh = date.getHours() > 9 ? date.getHours() : "0" + date.getHours();
- var mm = date.getMinutes() > 9 ? date.getMinutes() : "0" + date.getMinutes();
- var ss = date.getSeconds() > 9 ? date.getSeconds() : "0" + date.getSeconds();
- return date.getFullYear() + '-' + month + '-' + day + " " + hh+':'+mm+":"+ss;
- };
|