标签:span default bool test || download bst css ida
(function ($) { $.messageBox = function (message) { $.messager.show({ title:‘消息框提示‘, msg:message, showType:‘show‘ }); }; /** * 获取时间区间 * @param type 1:当年的一月一日到现在;type 2:获取当月的第一天和最后一天 * return {startTime:xxxx,endTime:xxxx} */ $.getTimeInterval = function (type,date){ var startTime, endTime; if (type == 1) { var year = new Date(); startTime = new Date(year.getFullYear(), 0, 1); //年头(xxxx-1-1) endTime = new Date(); }else if(type == 2){ var y = date.substr(0,4), m = date.substr(4,2); startTime = new Date(y,m-1,1).format("yyyy-MM-dd"); var days = new Date(y,m,0).getDate(); endTime = new Date(y,m-1,days).format("yyyy-MM-dd"); } return {startTime:startTime, endTime:endTime}; } //防止dialog框拖动时超出父面板,需要在有dialog的页面调用 $.setDialogPosition = function () { var easyuiPanelOnMove = function (left, top) { var l = left; var t = top; if (l < 1) { l = 1; } if (t < 1) { t = 1; } var width = parseInt($(this).parent().css(‘width‘)) + 14; var height = parseInt($(this).parent().css(‘height‘)) + 14; var right = l + width; var buttom = t + height; var browserWidth = $(window).width(); var browserHeight = $(window).height(); if (right > browserWidth) { l = browserWidth - width; } if (buttom > browserHeight) { t = browserHeight - height; } $(this).parent().css({ //修正面板位置 left:l, top:t }); }; $.fn.dialog.defaults.onMove = easyuiPanelOnMove; $.fn.window.defaults.onMove = easyuiPanelOnMove; $.fn.panel.defaults.onMove = easyuiPanelOnMove; }; $.fn.toolbar.defaults.valign = null; //时间格式化 Date.prototype.format = function (format) { var o = { "M+":this.getMonth() + 1, //month "d+":this.getDate(), //day "h+":this.getHours(), //hour "m+":this.getMinutes(), //minute "s+":this.getSeconds(), //second "q+":Math.floor((this.getMonth() + 3) / 3), //quarter "S":this.getMilliseconds() //millisecond } 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; } // easyui datebox 自定义校验 var datePattern=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/,opText={">":"大于","<":"小于",">=":"大于等于","<=":"小于等于"}; $.extend($.fn.validatebox.defaults.rules, { compareDate_resetTg:{ validator:function (value, param) { if (value && param.length > 0) { if (datePattern.test(value)) { var el = $(param[0]), v = el.val() || el.getWidget().getValue(); if (v) { if (datePattern.test(v)) { // var op = param.length > 1 ? param[1] : ">", d1 = new Date(value), d2 = new Date(v); var op=param.length>1?param[1]:">",d1 = new Date(value.replace(/[-/]/g, "/")),d2 = new Date(v.replace(/[-/]/g, "/")); if (eval(d1.getTime() + op + d2.getTime())){ return true; } else { param[0] = "无效,应" + opText[op] + v; $(param[2]).datebox("reset"); return false; } } } } else { param[0] = "无效"; return false; } } return true; }, message: ‘输入日期{0}‘ } /* , ruleAppealOpinion:{ validator:function (value, param) { if(param.length > 0){ var count=$("#"+param[0]).getWidget()?$("#"+param[0]).getWidget().getValue():$("#"+param[0]).val(); var type=$("#"+param[1]).getWidget()?$("#"+param[1]).getWidget().getValue():$("#"+param[1]).val(); if(count>0){ if(!value&¶m[2]==3){ return false; } } else{ if(type==1){ if(!value&&(param[2]==1||param[2]==0)){ return false; } } else if(type==2){ if(!value&&(param[2]==2||param[2]==0)){ return false; } } else{ if(!value&¶m[2]==3){ return false; } } } } return true; }, message: ‘不能为空!‘ }*/ }) })(jQuery); //表单数据转化json function form2Json() { var o = {}; var a = $("form input").serializeArray(); $.each(a, function () { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ‘‘); } else { o[this.name] = this.value || ‘‘; } }); return o; } function getFileBatchNo(){ return loginAccount.accountId + "_" + new Date().getTime(); } function isLeaf(node) { return node.state == undefined; } function dowloadFile(downLoadFile) { var fileNames = [‘GoogleChromeframeStandaloneEnterprise.msi‘,‘flashplayer11-7_install_win_ax.exe‘]; var msg = ["系统需要ie8及以上版本,如果您的浏览器版本过低!为了提供更好的体验,请点击【确定】下载安装浏览器插件,并重启浏览器", "你确定下载flash控件?"]; var r = window.confirm(msg[downLoadFile]); if (r) { location.href = ctx + "/"+fileNames[downLoadFile]; } } function resetDgFooterStyle() { $(‘.datagrid-footer-inner‘).css(‘background‘, ‘#88CDEF‘); } /** * 控制两个日期不能只填一个 * @param targetFr * @param targetTo * @return {Boolean} */ var validate = function(targetFr,targetTo){ var vFr = $(targetFr).getWidget().getValue()||""; var vTo = $(targetTo).getWidget().getValue()||""; var allNotNull = vFr&&vTo; var allNull = vFr==""&&vTo==""; if(allNotNull||allNull){ return true; } $.alert("请填写完整的日期区间"); return false; }
Js:消息弹出框、获取时间区间、时间格式、easyui datebox 自定义校验、表单数据转化json、控制两个日期不能只填一个
标签:span default bool test || download bst css ida
原文地址:https://www.cnblogs.com/ios9/p/9335071.html