(function($) {$.messagebox =function(message) {$.messager.show ({title: ' message box Prompt ', msg:message, ShowType: ' Show '}); };/** * Get time interval * @param type 1: January 1 to present of year; Type 2: Gets the first and last day of the month * return {starttime:xxxx,endtime:xxxx} */ $.gettimeinterval =function(type,date) {varStartTime, EndTime;if(type = = 1) {varYear =New Date(); StartTime =New Date(Year.getfullyear (), 0, 1);//year (XXXX-1-1)EndTime =New Date(); }Else if(type = = 2) {vary = Date.substr (0,4), M = Date.substr (4,2); StartTime =New Date(y,m-1,1). Format ("YYYY-MM-DD");varDays =New Date(y,m,0). GetDate (); EndTime =New Date(y,m-1,days). Format ("YYYY-MM-DD"); }return{starttime:starttime, endtime:endtime}; }//Prevent the dialog box from being dragged beyond the parent panel and need to be called in a dialog page$.setdialogposition =function() {varEasyuipanelonmove =function(left,Top) {varL = left;vart =Top;if(L < 1) {L = 1; }if(T < 1) {T = 1; }varwidth =parseint($( This).Parent(). CSS (' width ')) + 14;varHeight =parseint($( This).Parent(). css (' height ')) + 14;varright = L + width;varButtom = t + height;varBrowserwidth = $ (window). width ();varBrowserheight = $ (window). Height ();if(Right > Browserwidth) {L = browserwidth-width; }if(Buttom > Browserheight) {T = browserheight-height; } $( This).Parent(). CSS ({//Correction panel positionLeft:l,Top: t}); }; $.fn.dialog.defaults.onmove = Easyuipanelonmove; $.fn.window. Defaults.onmove = Easyuipanelonmove; $.fn.panel.defaults.onmove = Easyuipanelonmove; }; $.fn.Toolbar. defaults.valign =NULL;//Time formatting Date.prototype. Format =function(format) {varo = {"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. $, ( This. getFullYear () + ""). substr (4-RegExp. $.length)); for(varKinchOif(New RegExp("("+ K +")"). Test (format)) format = Format.replace (RegExp. $,RegExp. $.length= = 1? O[k]: ("xx"+ o[k]). substr (""+ o[k]).length));returnFormat }//Easyui Datebox Custom Check vardatepattern=/^ (\d{4}) [-/] (\d{1,2}) [-/] (\d{1,2}) $/,optext={">":"Greater than","<":"less than",">=":"greater than or equal","<=":"less than or equal"}; $.extend ($.fn.validatebox.defaults.rules, {comparedate_resettg:{Validator:function(Value, param) {if(Value && param.length> 0) {if(Datepattern.test (value)) {varEl = $ (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); varOp=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] = "invalid, should"+ Optext[op] + V; $ (param[2]). Datebox ("Reset");return false; } } } }Else{Param[0] = "Invalid";return false; } }return true; }, Message: ' Enter date {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 F Alse; }} else{if (type==1) {if (!VALUE&A mp;& (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: ' Can't be empty! ‘ }*/})}) (JQuery);//form data conversion JSONfunctionForm2json () {varo = {};varA = $ ("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 | | ‘‘; } });returno;}functionGetfilebatchno () {returnLoginaccount.accountid + "_" +New Date(). GetTime ();}functionIsLeaf (node) {returnNode.state = = undefined;}functionDowloadfile (downLoadFile) {varFileNames = [' Googlechromeframestandaloneenterprise.msi ', ' Flashplayer11-7_install_win_ax.exe '];varmsg = ["The system needs IE8 and above, if your browser version is too low! To provide a better experience, please click "OK" to download and install the browser plugin and restart the browser .", "Are you sure you downloaded the Flash control? "];varR =window.Confirm(Msg[downloadfile]);if(r) { Location. href = ctx + "/[+filenames[downloadfile]; }}functionResetdgfooterstyle () {$ ('. Datagrid-footer-inner '). CSS (' background ', ' #88CDEF ');}/** * Control Two dates cannot be filled with only one * @param TARGETFR * @param targetto * @return {Boolean} */varValidate =function(Targetfr,targetto) {varVFr = $ (TARGETFR). Getwidget (). GetValue () | |";varVTo = $ (Targetto). Getwidget (). GetValue () | |";varAllnotnull = vfr&&vto;varAllnull = vfr== ""&&vto=="";if(allnotnull| | Allnull) {return true; } $.Alert("please fill out the full date range");return false;}
Js: Message popup box, get time range, time format, Easyui datebox custom Check, form data conversion json, control two dates cannot be filled only one