zoukankan      html  css  js  c++  java
  • 封装的一些例子

    /*
     * 该库主要封装DWZ的一些常用函数,适用于平台开发。
     * 
     * JQuery 1.4.4
     * Version 0.1
     */
    
    Namespace = new Object(); 
    // 全局对象仅仅存在register函数,参数为名称空间全路径,如"trisun.ajax"
    Namespace.register = function(fullNS)
    {
        // 将命名空间切成N部分, 比如trisun、ajax等
        var nsArray = fullNS.split('.');
        var sEval = "";
        var sNS = "";
        for (var i = 0; i < nsArray.length; i++){
            if (i != 0) sNS += ".";
            sNS += nsArray[i];
            // 依次创建构造命名空间对象(假如不存在的话)的语句
            // 比如先创建trisun,然后创建trisun.ajax,依次下去
            sEval += "if (typeof(" + sNS + ") == 'undefined') " + sNS + " = new Object();"
        }
        if (sEval != "") eval(sEval);
    };
    
    Namespace.register("trisun.ajax");
    Namespace.register("trisun.ui");
    Namespace.register("trisun.event");
    Namespace.register("dialog");
    /**
     * 设置查询参数url用于 导出查询结果
     */
    trisun.setParams =function (form){
        var param="";
        var arr = $(form).serializeArray();
        if(arr != null){
            for(var i=0;i<arr.length;i++){
                param = param + arr[i].name + "="+encodeURIComponent(arr[i].value)+"&";
            }
        }
        return param.substring(0,param.length-1);
    }
    
    trisun.ajax.navSubmitAndConfirm = function (form, dgId) {
    
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
        
        alertMsg.confirm("确定要归档工单吗?", {
            okCall:function() {
                $.ajax({
                    type: form.method || 'POST',
                    url:$form.attr("action"),
                    data:$form.serializeArray(),
                    dataType:"json",
                    cache: false,
                    beforeSend: function (){
                        $(":submit").each(function(){
                            $(this).attr('disabled', true);
                        });
                    },
                    success: navAjaxDoneFlush,
                    error: function(xhr, ajaxOptions, thrownError){
                        $(":submit").each(function(){
                            $(this).attr('disabled', false);
                        });
                        DWZ.ajaxError(xhr, ajaxOptions, thrownError);
                    }
                });
            }
        });
    
        
        // 提交表单后返回处理函数(主要功能:刷新表单)
        function navAjaxDoneFlush(json) {
            DWZ.ajaxDone(json);
            $(":submit").each(function(){
                $(this).attr('disabled', false);
            }); 
            if (json.statusCode == DWZ.statusCode.ok) {
                navTab.closeCurrentTab()
                $("#" + dgId).flexReload();
            }
        }
        return false;
    };
    
    trisun.ajax.navSubmitByAjaxAndFlushDG = function (form, dgId) {
    
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
    
        $.ajax({
            type: form.method || 'POST',
            url:$form.attr("action"),
            data:$form.serializeArray(),
            dataType:"json",
            cache: false,
            beforeSend: function (){
                $(":submit").each(function(){
                    $(this).attr('disabled', true);
                });
            },
            success: navAjaxDoneFlush,
            error: function(xhr, ajaxOptions, thrownError){
                $(":submit").each(function(){
                    $(this).attr('disabled', false);
                });
                DWZ.ajaxError(xhr, ajaxOptions, thrownError);
            }
        });
        // 提交表单后返回处理函数(主要功能:刷新表单)
        function navAjaxDoneFlush(json) {
            DWZ.ajaxDone(json);
            $(":submit").each(function(){
                $(this).attr('disabled', false);
            }); 
            if (json.statusCode == DWZ.statusCode.ok) {
                navTab.closeCurrentTab()
                $("#" + dgId).flexReload();
            }
        }
        return false;
    };
    
    
    
    //确认提醒框
    trisun.ui.distributeConfirm = function (form,dgId) {
        
        alertMsg.confirm("确定要吗?一经派单,不可回退!请慎重操作!",{
            okCall:function(){
                //alert("OK");
                trisun.ajax.submitByAjaxAndFlushDG(form,dgId);    
            }
        });
        return false;
    };
    
    //审核确认提醒框
    trisun.ui.distributeConfirmHouseRent = function (form,dgId) {
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
        alertMsg.confirm("确认审核信息!!!一经保存,不可回退!请慎重操作!",{
            okCall:function(){
                //alert("OK");
                trisun.ajax.submitByAjaxAndFlushDG(form,dgId);    
            }
        });
        return false;
    };
    
    //处理订单提醒框
    trisun.ui.dealConfirm = function (form,dgId) {
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
        alertMsg.confirm("确定要保存该处理结果吗?",{
            okCall:function(){
                //alert("OK");
                trisun.ajax.submitByAjaxAndFlushDG(form,dgId);
            }
        });
        return false;
    };
    /**
     * 修改费用的生成日期提示是否修改
     */
    trisun.ui.upCostinfDateConfirm = function (form,dgId) {
        
        alertMsg.confirm("您修改的数据会在下个月生效,请确定修改吗?",{
            okCall:function(){
                //alert("OK");
                trisun.ajax.submitByAjaxAndFlushDG(form,dgId);    
            }
        });
        return false;
    };
    
    /**
     * 普通ajax表单提交后,刷新DataGrid数据 
     * @param {Object} form
     * @param {Object} callback
     */
    trisun.ajax.submitByAjaxAndFlushDG = function (form, dgId) {
    
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
    
        $.ajax({
            type: form.method || 'POST',
            url:$form.attr("action"),
            data:$form.serializeArray(),
            dataType:"json",
            cache: false,
            beforeSend: function (){
                $(":submit").each(function(){
                    $(this).attr('disabled', true);
                });
            },
            success: dialogAjaxDoneFlush,
            error: function(xhr, ajaxOptions, thrownError){
                $(":submit").each(function(){
                    $(this).attr('disabled', false);
                });
                DWZ.ajaxError(xhr, ajaxOptions, thrownError);
            }
        });
        // 提交表单后返回处理函数(主要功能:刷新表单)
        function dialogAjaxDoneFlush(json) {
            DWZ.ajaxDone(json);
            $(":submit").each(function(){
                $(this).attr('disabled', false);
            }); 
            if (json.statusCode == DWZ.statusCode.ok) {
                if(null != $.pdialog.getCurrent())
                    $.pdialog.closeCurrent();
                //form.reset();
                $("#" + dgId).flexReload();
            }
        }
        return false;
    };
    
    /**
     * 带loading的ajax表单提交
     * @param {Object} form
     * @param {Object} dgId
     * @return {TypeName} 
     */
    trisun.ajax.submitByAjaxAndFlushDGAndLoading = function (form, dgId) {
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
        $(".dialog").mask(bms.terminal.waiting);
        $.ajax({
            type: form.method || 'POST',
            url:$form.attr("action"),
            data:$form.serializeArray(),
            dataType:"json",
            cache: false,
            success: dialogAjaxDoneFlushLoading,
            error: function(xhr, ajaxOptions, thrownError){
                $(".dialog").unmask();
                DWZ.ajaxError(xhr, ajaxOptions, thrownError);
            }
        });
        // 提交表单后返回处理函数(主要功能:刷新表单)
        function dialogAjaxDoneFlushLoading(json) {
            DWZ.ajaxDone(json);
            if (json.statusCode == DWZ.statusCode.ok) {
                if(null != $.pdialog.getCurrent())
                    $.pdialog.closeCurrent();
                $(".dialog").unmask();
                $("#" + dgId).flexReload();
            }else{
                $(".dialog").unmask();
            }
        }
        return false;
    };
    /**
     * 普通ajax表单提交
     * @param {Object} form
     * @param {Object} callback
     */
    trisun.ajax.submitByAjax = function (form) {
    
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
    
        $.ajax({
            type: form.method || 'POST',
            url:$form.attr("action"),
            data:$form.serializeArray(),
            dataType:"json",
            cache: false,
            beforeSend: function (){
                $(":submit").each(function(){
                    $(this).attr('disabled', true);
                });
            },
            success: dialogAjaxDone,
            error: function(xhr, ajaxOptions, thrownError){
                $(":submit").each(function(){
                    $(this).attr('disabled', false);
                });
                DWZ.ajaxError(xhr, ajaxOptions, thrownError);
            }
        });
        // 提交表单后返回处理函数(主要功能:刷新表单)
        function dialogAjaxDone(json) {
            DWZ.ajaxDone(json);
            $(":submit").each(function(){
                $(this).attr('disabled', false);
            }); 
            form.reset();
        }
        return false;
    };
    /**
     * 删除提示对话框
     * @param {} action  删除操作的action
     * @param {} prototype 后台接收参数
     * @param {} dgId DataGrid的ID
     */
    trisun.ui.delDialog = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        $("#" + dgId + " .noborder").each(function(){
            if($(this).attr("checked") == true){
                empty = false;
                url = url + prototype + "=" + $(this).val() + "&";
            }
        });
        if(empty == true) {
            alertMsg.info("请选择需要删除的记录!");
            return;
        }
        url = url.substring(0,url.length-1);
        
        alertMsg.confirm("确定要删除该记录?", {
            okCall:function() {
                $("#alertBackground").show();
                navTabTodo(url,function(json){
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                    }
                });
            }
        });
    };
    
    //add by jinac 
    /**
     * 催费通知下发提示对话框
     * @param {} action  操作的action
     * @param {} prototype 后台接收参数
     * @param {} dgId DataGrid的ID
     */
    trisun.ui.noticeDialog = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        $("#" + dgId + " .noborder").each(function(){
            if($(this).attr("checked") == true){
                empty = false;
                url = url + prototype + "=" + $(this).val() + "&";
            }
        });
        if(empty == true) {
            alertMsg.info("请选择需要下发的记录!");
            return;
        }
        url = url.substring(0,url.length-1);
        
        alertMsg.confirm("确定要下发该记录?", {
            okCall:function() {
                navTabTodo(url,function(json){
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                    }
                });
            }
        });
    };
    
    
    //add by jinac 
    /**
     * 全部催费通知下发提示对话框
     * @param {} action  操作的action
     * @param {} prototype 后台接收参数
     * @param {} dgId DataGrid的ID
     */
    trisun.ui.noticeAllDialog = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        url = url.substring(0,url.length-1);
        alertMsg.confirm("确定要下发全部记录?", {
            okCall:function() {
                navTabTodo(url,function(json){
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                    }
                });
            }
        });
    };
    
    trisun.ui.enabledDialog = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        $("#" + dgId + " .noborder").each(function(){
            if($(this).attr("checked") == true){
                empty = false;
                url = url + prototype + "=" + $(this).val() + "&";
            }
        });
        if(empty == true) {
            alertMsg.info("请选择需要激活的记录!");
            return;
        }
        url = url.substring(0,url.length-1);
        
        alertMsg.confirm("确定要执行激活吗?", {
            okCall:function() {
                navTabTodo(url,function(json){
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                    }
                });
            }
        });
    };
    
    
    //重启sip服务器 author wenl
    trisun.ui.restartServerDialog = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        $("#" + dgId + " .noborder").each(function(){
            if($(this).attr("checked") == true){
                empty = false;
                url = url + prototype + "=" + $(this).val() + "&";
            }
        });
        if(empty == true) {
            alertMsg.info("请选择需要重启服务的SIP账号!");
            return;
        }
        url = url.substring(0,url.length-1);
        
        alertMsg.confirm("确定要为选中的SIP账号重启服务?", {
            okCall:function() {
                navTabTodo(url,function(json){
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                    }
                });
            }
        });
    };
    
    //清理私有配置 author wenl
    trisun.ui.clearPrivateConfigDialog = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        $("#" + dgId + " .noborder").each(function(){
            if($(this).attr("checked") == true){
                empty = false;
                url = url + prototype + "=" + $(this).val() + "&";
            }
        });
        if(empty == true) {
            alertMsg.info("请选择需要清理配置的记录!");
            return;
        }
        url = url.substring(0,url.length-1);
        
        alertMsg.confirm("确定要为选中的记录清理配置?", {
            okCall:function() {
                navTabTodo(url,function(json){
                    //DWZ.ajaxDone(json);
                    
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                        
                        var basePath = trisun.getSysUrl("bms");
                        //重启服务操作
                        alertMsg.confirm("是否需要重启相关服务,使关联终端重新获取配置信息?", {
                            okCall:function() {
                                navTabTodo(basePath+"selectRestartSipServer.html?ids="+json.ids,function(back){
    
                                });
                            }
                        });
                    }
                    
                    
                });
            }
        });
    };
    
    
    /**
     * 以navTab的方式打开编辑对话框 -- add by wenchj
     * @param {} action 
     * @param {} dlgId 对话框ID
     * @param {} title 对话框标题
     */
    trisun.ui.editNavTab = function(tabid, url, data){
    //    navTab.openTab(tabid, title, url);
        navTab.openTab(tabid, url, data);
    };
    
    /**
     * 编辑对话框
     * @param {} action 
     * @param {} dlgId 对话框ID
     * @param {} title 对话框标题
     */
    trisun.ui.editDialog = function(action, dlgId, title, width, height){
        if(width == null){
            width = 800;
        }
        if(height == null){
            height = 400;
        }
        $.pdialog.open(action, dlgId, title,{
            width,
            height:height
        });
    };
    
    /**
     * 编辑对话框
     * @param {} action 
     * @param {} dlgId 对话框ID
     * @param {} title 对话框标题
     */
    trisun.ui.importDialog = function(action, dlgId, title, width, height){
        if(width == null){
            width = 800;
        }
        if(height == null){
            height = 400;
        }
        $.pdialog.importDialog(action, dlgId, title,{
            width,
            height:height
        });
    };
    
    /**
     * 自定义对话框
     * @param {} option 可选参数
     */
    trisun.ui.customDialog = function(action, dlgId, title,option){
        $.pdialog.open(action, dlgId, title,option);
    };
    
    /**
     * 表单查询Ajax操作
     * @param {} dgId
     * @param {} form
     * @return {Boolean}
     */
    trisun.ajax.search = function(dgId, form){
        var $form = $(form);
        var data = $form.serializeArray();
        var surl = $form.attr("action");
        
        // 05-04-07 搜索按钮 disabled + 遮罩进度圈
        var $subObj = $(":submit",$form);
        $subObj.css("color","gray").attr("disabled","disabled");
        $("#container").mask("数据加载中,请稍等...");
        
        $("#" +  dgId).flexReload({url:surl, params:data, newp:1});
        
        $subObj.css("color","#183152").removeAttr("disabled");
        $("#container").unmask();
        
        return false;
    };
    
    /**
     * 表单查询Ajax操作
     * @param {} dgId
     * @param {} form
     * @return {Boolean}
     */
    trisun.ajax.searchReserve = function(dgId, form, validate){
        validate();
        var $form = $(form);
        var data = $form.serializeArray();
        var surl = $form.attr("action");
        // 05-04-07 搜索按钮 disabled + 遮罩进度圈
        var $subObj = $(":submit",$form);
        $subObj.css("color","gray").attr("disabled","disabled");
        $("#container").mask("数据加载中,请稍等...");
        
        $("#" +  dgId).flexReload({url:surl, params:data, newp:1});
        
        $subObj.css("color","#183152").removeAttr("disabled");
        $("#container").unmask();
        
        return false;
    };
    
    /**
     * 锁定系统窗口
     */
    trisun.ui.lockDialog = function(){
        islock = true;
        // Ajax清除Session
        
        // 弹出提示窗口
        $.pdialog.open("lock.html", "lockDialog", "已锁定", {
            minable:false,
            maxable:false, 
            resizable:false,
            drawable:false,
            350,
            height:320,
            mask:true
        });
    };
    
    /**
     * 退出系统确认对话框
     */
    trisun.ui.logoutConfirm = function(){
        $.pdialog.open("logoutConfirm.html", "logoutConfirm", "提示", {
            minable:false,
            maxable:false, 
            resizable:false,
            drawable:false,
            550,
            height:200,
            mask:true
        });
    };
    
    /**
     * 解锁Ajax请求
     */
    trisun.ajax.unlock = function(form){
        var $form = $(form);
        $.ajax({
            type: form.method || 'POST',
            url:$form.attr("action"),
            data:$form.serializeArray(),
            dataType:"json",
            cache: false,
            success: unlockAjaxDone,
            error: DWZ.ajaxError
        });
    
        function unlockAjaxDone(json) {
            if (json.statusCode == DWZ.statusCode.ok) {
                islock = false;
                $.pdialog.close("lockDialog");
            }
        }
        return false;
    };
    
    /**
     * 获取DataGrid高度
     * @param {} btnBar 页面是否有btnBar
     * @param {} searchBar 页面是否有searchBar
     * @param {} rowNum 搜索栏行数
     * @return {}
     */
    trisun.ui.getDGHeight = function(btnBar, searchBar, rowNum){
        var h = $(".tabsPageContent").outerHeight(true);
        if(((searchBar == true) && (btnBar == true)) || ((searchBar == null) && (btnBar == null))){
            h = h-15-50-25-55; // -145
        }else {
            // 自定义
            if((btnBar == false) && (searchBar == true || searchBar == null)){
                h = h-15-50-55;
            }
            if((searchBar == false) && (btnBar == true || btnBar == null)){
                h = h-15-25-55;
            }
            if((btnBar == false) && (searchBar == false)){
                h = h-15-55;
            }
        }
        if(rowNum != null){
            h = h - 25*(rowNum-1);
        }
        return h;
    };
    
    /**
     * 上传图片后,刷新DataGrid数据 
     * @param {Object} form
     * @param {Object} callback
     */
    trisun.ajax.pictureUpLoadFormAndFlushDG = function(form, dgId){
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
            alert("验证错误");
            return false;
        }
        $(":submit").each(function(){
            $(this).attr('disabled', true);
        });
        window.donecallback = dialogAjaxDoneFlush;
        if ($("#callbackframe").size() == 0) {
            $("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
        }
        if(!form.ajax) {
            $(form).append('<input type="hidden" name="ajax" value="1" />');
        }
        form.target = "callbackframe";
        
        function dialogAjaxDoneFlush(json) {
            $(":submit").each(function(){
                $(this).attr('disabled', false);
            });
            DWZ.ajaxDone(json);
            if (json.statusCode == DWZ.statusCode.ok) {
                $.pdialog.closeCurrent();
                $("#" + dgId).flexReload();
            }
        }
    };
    
    
    /**
     * 上传文件表单提交后,刷新DataGrid数据 
     * @param {Object} form
     * @param {Object} callback
     */
    trisun.ajax.fileUpLoadFormAndFlushDG = function(form, dgId){
        var $form = $(form);
        try{
            if(!$form.validationEngine({returnIsValid:true})){
                return false;
            }
        }catch(e){
                
            alert("验证错误");
            
            return false;
        }
        $(":submit").each(function(){
            $(this).attr('disabled', true);
        });
        window.donecallback = dialogAjaxDoneFlush;
        if ($("#callbackframe").size() == 0) {
            $("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
        }
        if(!form.ajax) {
            $(form).append('<input type="hidden" name="ajax" value="1" />');
        }
        form.target = "callbackframe";
        
        function dialogAjaxDoneFlush(json) {
            $(":submit").each(function(){
                $(this).attr('disabled', false);
            });
            DWZ.ajaxDone(json);
            if (json.statusCode == DWZ.statusCode.ok) {
                $.pdialog.closeCurrent();
                $("#" + dgId).flexReload();
            }
        }
    };
    
    
    
    /**
     * 展示锁定系统事件
     * @type time 锁定时间(单位:秒)
     */
    var mouseTimes = 0;
    var islock = false;
    trisun.event.lock = function(time){
        setInterval(move, 1000);
        function move(){
            if(mouseTimes == time){
                if(!islock){
                    mouseTimes = 0;
                    trisun.ui.lockDialog();
                }
            }else{
                mouseTimes++;
            }
        }
        $(window).mousemove(function(e){
            mouseTimes = 0;
        });
    
    };
    
    /**
     * 获取子系统url
     * @param {} name 子系统名称
     */
    trisun.getSysUrl = function(name) {
        return $("#"+name).val();
    };
    
    /**
     * 按参数length截取长度
     * @param {Object} value
     * @param {Object} length
     * @return {TypeName} 
     */
    trisun.substring = function(str,len){
        if('' == str){
            return '';
        }
        if(len == ''){
            len = 20;
        }
       var str_length = 0;
       var str_len = 0;
          str_cut = new String();
          str_len = str.length;
          for(var i = 0;i<str_len;i++){
            a = str.charAt(i);
            str_length++;
            if(escape(a).length > 4)
            {
             //中文字符的长度经编码之后大于4
             str_length++;
             }
             str_cut = str_cut.concat(a);
             if(str_length>=len){
                 if(str.charAt(i+1) != ''){
                     str_cut = str_cut.concat("...");
                 }
                 return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+str+"'>"+str_cut+"</span>";
             }
          }
        //如果给定字符串小于指定长度,则返回源字符串;
        if(str_length<len){
             return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+str+"'>"+str+"</span>";
        }
    }
    
    
    trisun.substringHref = function(value, length){
        if('' == value){
            return '';
        }
        if(length == ''){
            length = 15;
        }
        if(value.length <= length){
            return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+value+"'>"+value+"</span>";
        }else{
            return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+value+"'>"+value.substring(0,length)+"...</span>";
        }
    };
    
    dialog.closeCurrent = function(dialogId) {
        $.validationEngine.isValid = true;
        if(dialogId == null){
            $.pdialog.closeCurrent();
        }else{
            $.pdialog.close(dialogId+"");
        }
    };
    
    
    //取得复选框的所有选中值,linsj[2012-02-17]
        function getCheckboxValue(objName){
            if(objName!=""){
                var objArr=document.getElementsByName(objName);
                var leng=objArr.length;
                var guids="";
                for(i=0;i<leng;i++){
                    var obj=objArr[i];
                    if(obj.checked){
                        guids+=obj.value;
                        if(i<leng-1){
                            guids+=",";
                        }
                    }
                }
                return guids;
            }
        }
        
        
    //复选框的全选,linsj[2012-02-17]    
    function setAllCheckbox(objName){
            if(objName!=""){
                var objArr=document.getElementsByName(objName);
                var leng=objArr.length;
                for(i=0;i<leng;i++){
                    var temp=objArr[i];
                    temp.checked=true;
                }
            }
        }
        
    //复选框的反选
    function setReverseCheckbox(objName){
            if(objName!=""){
                var objArr=document.getElementsByName(objName);
                var leng=objArr.length;
                for(i=0;i<leng;i++){
                    var temp=objArr[i];
                    if(temp.checked){
                        temp.checked=false;
                    }else{
                        temp.checked=true;
                    }
                }
            }
        }    
    
    
    /**
     * 
     * @param {} action  删除操作的action
     * @param {} prototype 后台接收参数
     * @param {} dgId DataGrid的ID
     * 
     *
     */
    trisun.ui.batchOpenAccount = function(action, prototype, dgId){
        var url = action + "?";
        var empty = true;
        $("#" + dgId + " .noborder").each(function(){
            if($(this).attr("checked") == true){
                empty = false;
                url = url + prototype + "=" + $(this).val() + "&";
            }
        });
        if(empty == true) {
            alertMsg.info("请选择需要开户的记录!");
            return;
        }
        url = url.substring(0,url.length-1);
        
        alertMsg.confirm("确定要给选择的记录进行开户?", {
            okCall:function() {
                navTabTodo(url,function(json){
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok){
                        $("#" + dgId).flexReload();
                    }
                });
            }
        });
    };
    
    /**
     * 功能开关
     */
    trisun.ui.singleOpenOrCloseDialog = function(action, status, id, dgId) {
        var url = action + "?id="+id;
        url = url + "&status=" + status;
        if (status == 1) {
            alertMsg.confirm("确定要开启小区功能?", {
                okCall:function() {
                    navTabTodo(url,function(json){
                        DWZ.ajaxDone(json);
                        if (json.statusCode == DWZ.statusCode.ok){
                            $("#" + dgId).flexReload();
                        }
                    })
                }
            });
        }
        if (status == 0) {
            alertMsg.confirm("确定要关闭小区功能?", {
                okCall:function() {
                    navTabTodo(url,function(json){
                        DWZ.ajaxDone(json);
                        if (json.statusCode == DWZ.statusCode.ok){
                            $("#" + dgId).flexReload();
                        }
                    })
                }
            });
        }
    
    };
    
    /**
     * 房屋出租上下架开关
     */
    trisun.ui.singleOpenOrCloseHouseRent= function(action, isShow, id, dgId) {
        var url = action + "?houseId="+id;
        url = url + "&isShow=" + isShow;
        if (isShow == 1) {
            alertMsg.confirm("确定要上架?", {
                okCall:function() {
                    navTabTodo(url,function(json){
                        DWZ.ajaxDone(json);
                        if (json.statusCode == DWZ.statusCode.ok){
                            $("#" + dgId).flexReload();
                        }
                    })
                }
            });
        }
        if (isShow == 2) {
            alertMsg.confirm("确定要下架?", {
                okCall:function() {
                    navTabTodo(url,function(json){
                        DWZ.ajaxDone(json);
                        if (json.statusCode == DWZ.statusCode.ok){
                            $("#" + dgId).flexReload();
                        }
                    })
                }
            });
        }
    
    };
    
    /**  
     * 转换long值为日期字符串  
     * @param l long值  
     * @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss  
     */  
    
     function getFormatDateByLong(l, pattern) {
         return getFormatDate(new Date(l), pattern);
     }
     /**  
      * 转换日期对象为日期字符串  
      * @param l long值  
      * @param pattern 格式字符串,例如:yyyy-MM-dd hh:mm:ss    */  
      function getFormatDate(date, pattern) {
          if (date == undefined) {
              date = new Date();
          }
          if (pattern == undefined) {
              pattern = "yyyy-MM-dd hh:mm:ss";
          }
          return date.format(pattern);
      }
    
      /**  
       * 扩展date.format
       */ 
      Date.prototype.format = function (format) {
          var o = {
              "M+": this.getMonth() + 1,
              "d+": this.getDate(),
              "h+": this.getHours(),
              "m+": this.getMinutes(),
              "s+": this.getSeconds(),
              "q+": Math.floor((this.getMonth() + 3) / 3),
              "S": this.getMilliseconds()
          }
          if (/(y+)/.test(format)) {
              format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
          }
          for (var k in o) {
              if (new RegExp("(" + k + ")").test(format)) {
                  format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
              }
          }
          return format;
      }
      /**  
      *转换日期对象为日期字符串  
      * @param date 日期对象  
      * @param isFull 是否为完整的日期数据,  
      *               为true时, 格式如"2000-03-05 01:05:04"  
      *               为false时, 格式如 "2000-03-05"  
      * @return 符合要求的日期字符串  
      */  
      function getSmpFormatDate(date, isFull) {
          var pattern = "";
          if (isFull == true || isFull == undefined) {
              pattern = "yyyy-MM-dd hh:mm:ss";
          } else {
              pattern = "yyyy-MM-dd";
          }
          return getFormatDate(date, pattern);
      }
      /**  
      *转换当前日期对象为日期字符串  
      * @param date 日期对象  
      * @param isFull 是否为完整的日期数据,  
      *               为true时, 格式如"2000-03-05 01:05:04"  
      *               为false时, 格式如 "2000-03-05"  
      * @return 符合要求的日期字符串  
      */  
    
      function getSmpFormatNowDate(isFull) {
          return getSmpFormatDate(new Date(), isFull);
      }
      /**  
      *转换long值为日期字符串  
      * @param l long值  
      * @param isFull 是否为完整的日期数据,  
      *               为true时, 格式如"2000-03-05 01:05:04"  
      *               为false时, 格式如 "2000-03-05"  
      * @return 符合要求的日期字符串  
      */  
    
      function getSmpFormatDateByLong(l, isFull) {
          return getSmpFormatDate(new Date(l), isFull);
      }
  • 相关阅读:
    vue-element-admin项目install出现的问题
    关于html5 Notification桌面通知无法在谷歌浏览器显示的问题
    C#调用存储过程执行缓慢,但在数据库中执行却很快的问题
    IdnentiyServer-使用客户端凭据访问API
    IdentityServer开题篇
    IdentityServer4客户端JWT解密实现(基于.net4.0)
    iis访问网络路径映射问题(UNC share)
    .net core部署在iis上
    git blame 查找修改者
    代码管理工具-将项目文件打成tar包,并且排除.git目录
  • 原文地址:https://www.cnblogs.com/lansy/p/4735994.html
Copyright © 2011-2022 走看看