/* 中文UTF-8 */ /* 交互效果功能,封装的一些方法,提供给程序员调用。 */ /* 函数名称:WindowTimeoutResize() 创建时间:20216-08-04 实现功能:触发窗体 resize 事件 */ function WindowTimeoutResize() { setTimeout(function() { $(window).resize(); }, 210); } /* * 函数名称:TipsFrame.close(), TipsFrame.open() 创建时间:20216-08-01 实现功能:关闭|打开 右侧温馨提示框 */ var TipsFrame = { close : function() { $(".div-rightside:eq(0)").removeClass("show-tips-frame"); }, open : function() { $(".div-rightside:eq(0)").addClass("show-tips-frame"); } } /* * 函数名称:ModalWindow.close(), ModalWindow.open() 创建时间:20216-08-01 实现功能:关闭|打开 模态窗口 * * var ModalWindow = { close:function(divID){ * $("body").removeClass("modal-open"); $("#" +divID).removeClass("in"); * $(".modal-backdrop:last").removeClass("in"); setTimeout(function(){ $("#" * +divID).hide(); $(".modal-backdrop:last").remove(); },150); }, * open:function(divID){ $("body").addClass("modal-open"); $("#" * +divID).css({"display":"block"}); $("body").append(""); var $modalDialog = $("#" * +divID).find(".modal-dialog:eq(0)"); var $winWidth = $(window).width(); * $modalDialog.css({left:(($winWidth - $modalDialog.width())/2),top:'50px'}); * var handleID = divID + "_handle"; * $modalDialog.find(".modal-header:eq(0)").attr("id",handleID); //使它能够拖放 * $modalDialog.draggable({ "handle":"#"+handleID }); setTimeout(function(){ * $("#" +divID).addClass("in"); }); } } */ /* * 函数名称:LeftNav.toggle() 创建时间:20216-08-02 实现功能:关闭|打开 左侧栏 */ var LeftNav = { toggle : function() { var $body = $("body:eq(0)"); if ($body.hasClass("body-full-mode")) { $body.removeClass("body-full-mode"); } else { $body.addClass("body-full-mode"); } WindowTimeoutResize(); } } /* * 函数名称:AddPanel.toggle() 创建时间:20216-08-03 实现功能:关闭|打开 分块加减行 参 数:按钮自身 this */ var AddPanel = { toggle : function(element) { var $group = $(element).parent().parent(); var $hid_div = $group.find(".hid"); if ($($hid_div[0]).is(":hidden")) { $group.addClass("panel-closed"); $hid_div.slideDown(); } else { $group.removeClass("panel-closed"); $hid_div.slideUp(); } } } /* * 函数名称:FormSearch.toggle(divID) 创建时间:20216-08-04 实现功能:关闭|打开 高级搜索 参 数:search 的 * div ID */ var FormSearch = { toggle : function(divID) { var $divSearch = $("#" + divID); var $hidFormGroup = $divSearch.find(".hid-form-group:eq(0)"); var $gaoJiBtn = $divSearch.find(".btn-group>button:eq(1)"); if ($hidFormGroup.is(":hidden")) { // $hidFormGroup.slideDown("fast"); $hidFormGroup.show(); $gaoJiBtn.text(_btn_puTong); } else { // $hidFormGroup.slideUp("fast"); $hidFormGroup.hide(); $gaoJiBtn.text(_btn_gaoJi); } WindowTimeoutResize(); } } /* * 函数名称:TreeFrame.toggle() 创建时间:20216-08-02 实现功能:关闭|打开 左侧栏 */ var TreeFrame = { toggle : function() { var $rightSide = $(".div-rightside:eq(0)"); if ($rightSide.hasClass("show-tree-panel")) { $rightSide.removeClass("show-tree-panel"); } else { $rightSide.addClass("show-tree-panel"); } WindowTimeoutResize(); } } /* * 函数名称:datagridResizeWidth() 创建时间:20216-08-04 实现功能:给 easyui grid * 使用,窗口大小改变后,回调重新计算宽度 */ function datagridResizeWidth() { var $rightSide = $(".div-rightside:eq(0)"); var $mainFrame = $(".main-frame:eq(0)"); var gridWidth = $rightSide.width() - (parseInt($rightSide.css("padding-left")) * 2) - parseInt($mainFrame.css("padding-left") - parseInt($mainFrame.css("padding-right"))); return gridWidth; } /* * 函数名称:NavTab() 创建时间:20216-08-04 实现功能:页签点击选中状态 */ function NavTab(element) { var $element = $(element); var $navtab = $element.parent().parent(); $navtab.find("li").removeClass("active"); $element.parent().addClass("active"); } /* * 函数名称:ModelWindow 创建时间:20216-08-04 实现功能:弹出框对象 */ var ModelWindow = { _openPageDivId : null,// 弹出页面的divid _openMsgBoxPageDivId : null,// 弹出消息页面的divid _msgbox_callback : null, // 保存回调函数 _confirm_callback : null, // 保存回调函数 _openPage_callback : null, // 保存回调函数 _confirm_callbacks : null, // 保存回调函数 _close : function(divID) { if(typeof(divID)=="undefined") { divID=this._openPageDivId; } $("#" + divID).removeClass("in"); $(".modal-backdrop:last").removeClass("in"); setTimeout(function() { $("#" + divID).remove(); $(".modal-backdrop:last").remove(); if($(".modal").size()==0) { $("body").removeClass("modal-open"); } }, 150); }, _closeMsgBoxPage : function() { this._close(this._openMsgBoxPageDivId); }, _closeOpenPage : function(type,divID) { if (type == '1') { this.confirm('是否取消当前操作?', '系统确认', null, function(status) { this._close(divID); }); } else { this._close(divID); } }, _callbackClose : function(divID, status, type) { //$(ev).attr("disabled", true);//禁用确定按钮,防止多次点击 var _status = status ? true : false; // console.log("_status="+_status); if (type == '1') { // msgbox if (this._msgbox_callback) { this._msgbox_callback(); } this._close(divID); } else if (type == '2') { // confirm if (_status && this._confirm_callback) { this._confirm_callback(); } this._close(divID); } else if (type == '3') { // var isClose; // // openPage //// console.log(_status); // if (_status && eval("ModelWindow._openPage_callback"+divID)) // { //// console.log(divID); //// this._openPage_callback(); // isClose = eval("ModelWindow._openPage_callback"+divID+'()'); // } // console.log("isClose==="+isClose); // if(isClose!=false){ // this._close(divID); // } // openPage if (_status && this._openPage_callback) { this._openPage_callback(); } if (!_status) { this._close(divID); } } // hideSubmitLoading(); }, _open : function(divID) { $("body").addClass("modal-open"); $("#" + divID).css({ "display" : "block" }); $("body").append(""); var $modalDialog = $("#" + divID).find(".modal-dialog:eq(0)"); var $winWidth = $(window).width(); $modalDialog.css({ left : (($winWidth - $modalDialog.width()) / 2), top : '50px' }); var handleID = divID + "_handle"; $modalDialog.find(".modal-header:eq(0)").attr("id", handleID); // 使它能够拖放 $modalDialog.draggable({ "handle" : "#" + handleID }); setTimeout(function() { $("#" + divID).addClass("in"); }); }, _openWithoutMask : function(divID) { $("#" + divID).css({ "display" : "block" }); var $modalDialog = $("#" + divID).find(".modal-dialog:eq(0)"); var $winWidth = $(window).width(); $modalDialog.css({ left : (($winWidth - $modalDialog.width()) / 2), top : '50px' }); setTimeout(function() { $("#" + divID).addClass("in"); }); }, msgbox : function(msg, title, width, callback) { var _title = title ? title : "系统消息"; var _width = width ? width : 600; var html = ""; var _id = "modelwindow_" + Math.round(Math.random() * 1000); html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "

" + _title + "

"; html += "
"; html += "
"; html += msg; html += "
"; html += "
"; html += " "; html += "
"; html += "
"; html += "
"; html += "
"; html += ""; $('body').append(html); this._open(_id); this._openMsgBoxPageDivId = _id; this._msgbox_callback = null; if (callback) { this._msgbox_callback = callback; } $("#"+_id).find(".modal-footer > .btn-success").focus(); }, loading : function(msg, title, width, callback) { if ($("#modelwindow_loading").size() > 0) { return; } var _title = title ? title : "系统消息"; var _width = width ? width : 600; var html = ""; // var _id = "modelwindow_" + Math.round(Math.random() * 1000); var _id = "modelwindow_loading"; html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "

" + _title + "

"; html += "
"; html += "
"; html += "
"; html += "
"; html += msg; html += "
如果长时间没有反应请刷新页面
"; html += "
"; html += "
"; html += "
"; html += "
"; html += ""; $('body').append(html); this._open(_id); this._msgbox_callback = null; if (callback) { this._msgbox_callback = callback; } $("#"+_id).find(".modal-header > .close").focus(); }, confirm : function(msg, title, width, callback) { var _title = title ? title : "系统消息"; var _width = width ? width : 600; var html = ""; var _id = "modelwindow_" + Math.round(Math.random() * 1000); html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "

" + _title + "

"; html += "
"; html += "
"; html += msg; html += "
"; html += "
"; html += " "; html += " "; html += "
"; html += "
"; html += "
"; html += "
"; html += ""; $('body').append(html); this._open(_id); this._confirm_callback = null; if (callback) { this._confirm_callback = callback; } $("#"+_id).find(".modal-footer > .btn-success").focus(); }, open : function(url, title, width, callback) { var _title = title ? title : "系统消息"; var _width = width ? width : 600; var html = ""; var _id = "modelwindow_" + Math.round(Math.random() * 1000); html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "

" + _title + "

"; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += " "; html += "
"; html += "
"; html += "
"; html += "
"; html += ""; $('body').append(html); if (url.indexOf("?") > -1) { url += "&"; } else { url += "?"; } url += "rand=" + Math.random(); $("#" + _id + " .content-frame:eq(0)").load(url); // 加随机字符串防止缓存 this._open(_id); this._openPageDivId = _id; // eval("this._openPage_callback+_id") = null; // eval("ModelWindow._openPage_callback"+_id+'=null'); // if (callback) // { //// this._openPage_callback = callback; // eval("ModelWindow._openPage_callback"+_id+'=callback'); // } // $("#"+_id).find(".modal-footer > .btn-success").focus(); // return _id; this._openPage_callback = null; if (callback) { this._openPage_callback = callback; } $("#"+_id).find(".modal-footer > .btn-success").focus(); return this; }, view : function(url, title, width) { var _title = title ? title : "系统消息"; var _width = width ? width : 600; var html = ""; var _id = "modelwindow_" + Math.round(Math.random() * 1000); html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "

" + _title + "

"; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "
"; html += "
"; html += "
"; html += "
"; html += ""; $('body').append(html); if (url.indexOf("?") > -1) { url += "&"; } else { url += "?"; } url += "rand=" + Math.random(); $("#" + _id + " .content-frame:eq(0)").load(url); // 加随机字符串防止缓存 this._open(_id); $("#"+_id).find(".modal-footer > .btn-default").focus(); }, tips : function(msg, sec) { var _sec = sec ? sec : 1000; var html = ""; var _id = "modelwindow_" + Math.round(Math.random() * 1000); html += "
"; html += "
"; html += "
"; html += "
"; html += msg; html += "
"; html += "
"; html += "
"; html += "
"; html += ""; $('body').append(html); this._openWithoutMask(_id); var tmpWindow = this; setTimeout(function() { tmpWindow._close(_id); }, _sec); $("#"+_id).focus(); }, confirmHuiYi: function(msg, title, width, callback, options) { var _title = title ? title : "系统消息"; var _width = width ? width : 600; var html = ""; var _id = "modelwindow_" + Math.round(Math.random() * 1000); // 解析options参数 var _options = options || {}; var createText = _options.createText || "创建"; var cancelText = _options.cancelText || "不创建"; html += "
"; html += "
"; html += "
"; html += "
"; html += " "; html += "

" + _title + "

"; html += "
"; html += "
"; html += msg; html += "
"; html += "
"; html += " "; html += " "; html += "
"; html += "
"; html += "
"; html += "
"; $('body').append(html); this._open(_id); // 存储回调函数 this._confirm_callbacks = { id: _id, callback: callback, options: _options }; $("#" + _id).find(".modal-footer > .btn-success").focus(); }, // 新增确认处理方法 _onConfirm: function(id, isConfirmed) { var callbacks = this._confirm_callbacks; if (callbacks && callbacks.id === id) { // 方式1:如果options中有直接执行函数 if (callbacks.options.onConfirm && isConfirmed) { callbacks.options.onConfirm(); } else if (callbacks.options.onCancel && !isConfirmed) { callbacks.options.onCancel(); } // 方式2:如果传入了回调函数 else if (callbacks.callback) { callbacks.callback(isConfirmed); } } // 关闭弹窗 this._close(id); } } /* * html += "
"; html += " *
"; html += "
"; html += " *
"; html += " "; * html += "

" + _title + "

"; html += " *
"; html += "
"; html += msg; html += " *
"; html += "
"; html += " "; html += " "; * html += "
"; html += "
"; html += "
"; html += "
"; * html += ""; */ /** * 页面流程图封装 jieDuanJson = 枚举json jieDuanBH 当前状态 number 流程图状态显示数量 */ function showJieDuan(divId, jieDuanJson, jieDuanBH) { $("#" + divId).empty(); // 如果阶段编号对10求余大于0 则显示余数+0 阶段 if (jieDuanBH != null && parseInt(jieDuanBH) % 10 > 0) { jieDuanBH = parseInt(jieDuanBH) % 10 + "0"; } var jieDuanJson = eval(jieDuanJson); // 去获取流程图该展示什么 var newJieDuanJson = new Array(); for (var i = 0; i < jieDuanJson.length; i++) { if (parseInt(jieDuanJson[i].BH) > 0 && parseInt(jieDuanJson[i].BH) % 10 == 0 && parseInt(jieDuanJson[i].BH) !=200)// 只显示10,20,30。。。其他0,21,31不显示 { newJieDuanJson.push(jieDuanJson[i]); } } // 流程图HTML var liuChengHtml = "
"; $("#" + divId).append(liuChengHtml); } /** * 区域启动验证或者关闭验证(可以传多个divID) * * @param divID */ function panDuanQuYuShiFouYanZheng(divIDs) { var xuYaoYanZhengQuYuId = new Array(); if (divIDs != "" && divIDs.length > 0) { if (divIDs.indexOf(",") > 0) { xuYaoYanZhengQuYuId = divIDs.split(","); } else { xuYaoYanZhengQuYuId.push(divIDs); } } if (xuYaoYanZhengQuYuId.length > 0) { for (var i = 0; i < xuYaoYanZhengQuYuId.length; i++) { var sfbt = true;// 是否不验证 $("#" + xuYaoYanZhengQuYuId[i]).find(".form-control").each(function() { // 获取该DIV下全部输入项 if ($(this).attr("type") != "hidden")// 排除隐藏域 { if ($(this).val() != "") { sfbt = false return false; } } }); if (sfbt) { $("#" + xuYaoYanZhengQuYuId[i]).form("disableValidation"); } else { $("#" + xuYaoYanZhengQuYuId[i]).form("enableValidation"); } } } } /** * 根据项目类型 切换不同字段的名称 * 页面上的id和该方法里面的对应,此处的id不是动态的,如需添加其他id 请在此方法内添加。 * 项目类型传入顺序 按照 货物 1,工程 2,服务 3 */ function changeName(pageFlag,xiangmuleixing){ var htmlSpan="*"; var gongQiDiv = "供货期:"; var gongChengDiDianDiv = "送货地点:"; var neiRongDiv = "采购需求   
(技术指标)内容:"; if("1" == xiangmuleixing){ gongQiDiv = "供货期:"; gongChengDiDianDiv = htmlSpan+"送货地点:"; neiRongDiv = htmlSpan+"采购需求   
(技术指标)内容:"; }else if("2" == xiangmuleixing){ gongQiDiv = htmlSpan+"工期:"; gongChengDiDianDiv = htmlSpan+"施工地点:"; neiRongDiv = htmlSpan+"施工内容:"; }else if("3" == xiangmuleixing){ gongQiDiv = htmlSpan+"服务期限:"; gongChengDiDianDiv = htmlSpan+"服务地点:"; neiRongDiv = htmlSpan+"服务内容:"; } // if(0 == pageFlag){ // gongQiDiv = htmlSpan + gongQiDiv; // gongChengDiDianDiv = htmlSpan + gongChengDiDianDiv; // neiRongDiv = htmlSpan + neiRongDiv; // } $("#gongQiDiv").html(gongQiDiv); $("#gongChengDiDianDiv").html(gongChengDiDianDiv); $("#neiRongDiv").html(neiRongDiv); } //初始化CA的对象 function initCAObject() { try { //初始化陕西CA readyCertSign(); console.log("SXCA load success"); } catch (e) { console.log("SXCA load fail"); console.log("未安装陕西CA的证书驱动"+e.message); } } //检测证书设备 function check_ca_device(callBackFun) { ModelWindow._closeMsgBoxPage(); initCAObject(); var sxca_device_count = 0; //陕西CA证书设备数量 try { sxca_device_count = getKeyCount(); } catch (e) { sxca_device_count = 0; console.log("获取陕西CA证书设备数量失败,可能未安装陕西CA的驱动程序!"); } var bjca_device_count = 0; //北京CA证书设备数量 try { init(function(){ console.log("BJCA load success"); myGetDeviceCount(function(deviceCount){ bjca_device_count=deviceCount; if(typeof(sxca_device_count)=='undefined') { sxca_device_count=0; } if(typeof(bjca_device_count)=='undefined') { bjca_device_count=0; } get_ca_device_type(sxca_device_count,bjca_device_count,callBackFun); }); },function(){ console.log("BJCA load fail"); if(typeof(sxca_device_count)=='undefined') { sxca_device_count=0; } if(typeof(bjca_device_count)=='undefined') { bjca_device_count=0; } get_ca_device_type(sxca_device_count,bjca_device_count,callBackFun); }); } catch (e) { bjca_device_count = 0; console.log("获取北京CA证书设备数量失败,可能未安装陕西CA的驱动程序!"); } } //获取CA类型 function get_ca_device_type(sxca_device_count,bjca_device_count,callBackFun) { console.log(bjca_device_count+" || "+sxca_device_count); var ca_device_type=""; if(sxca_device_count == 0 && bjca_device_count == 0) { ca_device_type="NOCA"; showCAMsgBox("请插入数字证书设备!"); } else if(sxca_device_count >1 || bjca_device_count>1) { ca_device_type="MANYCA"; showCAMsgBox("您的电脑上插入了多把数字证书设备,请将多余的证书移除!"); } else if((sxca_device_count == 1 && (bjca_device_count == 1 || bjca_device_count == 0))) { ca_device_type="SXCA"; } else if((sxca_device_count == 0 && bjca_device_count == 1)) { ca_device_type="BJCA"; } if (typeof(callBackFun) == 'function') { callBackFun(ca_device_type); } return ca_device_type; } /** * 是否IE浏览器 * @returns {Boolean} */ function isIEBrowser() { return navigator.userAgent.toLowerCase().search(/(msie\s|trident.*rv:)([\w.]+)/) != -1; } //展示CA消息框 function showCAMsgBox(msgStr) { var isHasMsgbox=false; var _msg=msgStr; $(".modal-body").each(function(){ var msg=$(this).html().trim(); if(msg==_msg) { isHasMsgbox=true; } }); if(!isHasMsgbox) { ModelWindow._closeMsgBoxPage(); ModelWindow.msgbox(_msg, '温馨提示', null, null); } }