Files
td_official/public/sdk/3rdparty/jedate/jedate.min.js

9 lines
39 KiB
JavaScript
Raw Normal View History

2025-05-21 11:24:53 +08:00
/**
@Name : jeDate v6.5.0 日期控件
@Author: chen guojun
@Date: 2018-04-30
@QQ群516754269
@官网http://www.jemui.com/ 或 https://github.com/singod/jeDate
*/
!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.jeDate=b()}(this,function(){function DateTime(a,b){var c=this,d=new Date,e=["FullYear","Month","Date","Hours","Minutes","Seconds"],f=jet.extend({YYYY:null,MM:null,DD:null,hh:d.getHours(),mm:d.getMinutes(),ss:d.getSeconds()},b),g=void 0==b?d:new Date(f.YYYY,f.MM,f.DD,f.hh,f.mm,f.ss);(a||[]).length>0&&jet.each(a,function(a,b){g["set"+e[a]]("Month"==e[a]?parseInt(b)-1:parseInt(b))}),c.reDate=function(){return new DateTime},c.GetValue=function(){return g},c.GetYear=function(){return g.getFullYear()},c.GetMonth=function(){return g.getMonth()+1},c.GetDate=function(){return g.getDate()},c.GetHours=function(){return g.getHours()},c.GetMinutes=function(){return g.getMinutes()},c.GetSeconds=function(){return g.getSeconds()}}function jeDatePick(a,b){var c={language:{name:"cn",month:["01","02","03","04","05","06","07","08","09","10","11","12"],weeks:["日","一","二","三","四","五","六"],times:["小时","分钟","秒数"],timetxt:["时间选择","开始时间","结束时间"],backtxt:"返回日期",clear:"清空",today:"现在",yes:"确定"},format:"YYYY-MM-DD hh:mm:ss",minDate:"1900-01-01 00:00:00",maxDate:"2099-12-31 23:59:59",isShow:!0,multiPane:!0,onClose:!0,range:!1,trigger:"click",position:[],valiDate:[],isinitVal:!1,initDate:{},isTime:!0,isClear:!0,isToday:!0,isYes:!0,festival:!1,fixed:!0,zIndex:999999,method:{},theme:{},shortcut:[],donefun:null,before:null,succeed:null};this.$opts=jet.extend(c,b||{}),this.valCell=$Q(a),this.format=this.$opts.format,null!=this.valCell?this.init():alert(a+" ID或类名不存在!"),jet.extend(this,this.$opts.method),delete this.$opts.method}function jeLunar(a,b,c){function o(a){var w,b=function(a,b){var c=new Date(31556925974.7*(a-1900)+6e4*e[b]+Date.UTC(1900,0,6,2,5));return c.getUTCDate()},c=function(a){var b,c=348;for(b=32768;b>8;b>>=1)c+=d[a-1900]&b?1:0;return c+p(a)},o=function(a){return f.charAt(a%10)+g.charAt(a%12)},p=function(a){var b=q(a)?65536&d[a-1900]?30:29:0;return b},q=function(a){return 15&d[a-1900]},r=function(a,b){return d[a-1900]&65536>>b?30:29},s=function(a){var b,d=0,e=0,f=new Date(1900,0,31),g=(a-f)/864e5;for(this.dayCyl=g+40,this.monCyl=14,b=1900;2050>b&&g>0;b++)e=c(b),g-=e,this.monCyl+=12;for(0>g&&(g+=e,b--,this.monCyl-=12),this.year=b,this.yearCyl=b-1864,d=q(b),this.isLeap=!1,b=1;13>b&&g>0;b++)d>0&&b==d+1&&0==this.isLeap?(--b,this.isLeap=!0,e=p(this.year)):e=r(this.year,b),1==this.isLeap&&b==d+1&&(this.isLeap=!1),g-=e,0==this.isLeap&&this.monCyl++;0==g&&d>0&&b==d+1&&(this.isLeap?this.isLeap=!1:(this.isLeap=!0,--b,--this.monCyl)),0>g&&(g+=e,--b,--this.monCyl),this.month=b,this.day=g+1},t=function(a){return 10>a?"0"+(0|a):a},u=function(a,b){var c=a;return b.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g,function(a){switch(a){case"yyyy":var b="000"+c.getFullYear();return b.substring(b.length-4);case"dd":return t(c.getDate());case"d":return c.getDate().toString();case"MM":return t(c.getMonth()+1);case"M":return c.getMonth()+1}})},v=function(a,b){var c;switch(b){case 10:c="初十";break;case 20:c="二十";break;case 30:c="三十";break;default:c=k.charAt(Math.floor(b/10)),c+=j.charAt(b%10)}return c};this.isToday=!1,this.isRestDay=!1,this.solarYear=u(a,"yyyy"),this.solarMonth=u(a,"M"),this.solarDate=u(a,"d"),this.solarWeekDay=a.getDay(),this.inWeekDays="星期"+j.charAt(this.solarWeekDay),w=new s(a),this.lunarYear=w.year,this.shengxiao=h.charAt((this.lunarYear-4)%12),this.lunarMonth=w.month,this.lunarIsLeapMonth=w.isLeap,this.lnongMonth=this.lunarIsLeapMonth?"闰"+l[w.month-1]:l[w.month-1],this.lunarDate=w.day,this.showInLunar=this.lnongDate=v(this.lunarMonth,this.lunarDate),1==this.lunarDate&&(this.showInLunar=this.lnongMonth+"月"),this.ganzhiYear=o(w.yearCyl),this.ganzhiMonth=o(w.monCyl),this.ganzhiDate=o(w.dayCyl++),this.jieqi="",this.restDays=0,b(this.solarYear,2*(this.solarMonth-1))==u(a,"d")&&(this.showInLunar=this.jieqi=i[2*(this.solarMonth-1)]),b(this.solarYear,2*(this.solarMonth-1)+1)==u(a,"d")&&(this.showInLunar=this.jieqi=i[2*(this.solarMonth-1)+1]),"清明"==thi
}),jet.extend(a[b],c[b])});b=that.setValue(a,that.format,opts.isShow?!0:!1),opts.isShow&&that.closeDate(),opts.donefun&&opts.donefun.call(that,{elem:that.valCell,val:b,date:a})},blankArea:function(){jet.on(document,"mouseup",function(a){jet.stopPropagation(a),that.closeDate()}),jet.on($Q(elx),"mouseup",function(a){jet.stopPropagation(a)})}})},eachYear:function(a,b){var l,c=this,e=(c.$opts,parseInt(a)),f=[],g="",h=c.selectDate,j=jet.reMatch(c.minDate),k=jet.reMatch(c.maxDate),i=1==b?e:c.yindex;for(c.yindex=1==b?12+e:12+c.yindex,l=void 0==h[1]?"":h[1].YYYY;i<c.yindex;i++)g=i==h[0].YYYY||i==l?"action":i>h[0].YYYY&&l>i?"contain":i<j[0]||i>k[0]?"disabled":"",f.push({style:g,y:i});return f},eachMonth:function(a){var c=this,d=c.$opts,f=(d.range,[]),g=c.selectDate,h="",i=d.language.month,j=jet.reMatch(c.minDate),k=jet.reMatch(c.maxDate),l=parseInt(j[0]+""+jet.digit(j[1])),m=parseInt(k[0]+""+jet.digit(k[1])),n=parseInt(g[0].YYYY+""+jet.digit(g[0].MM)),o=g[1]?parseInt(g[1].YYYY+""+jet.digit(g[1].MM)):0;return jet.each(i,function(b,c){var d=parseInt(a+""+jet.digit(c));h=d==n||d==o?"action":d>n&&o>d?"contain":l>d||d>m?"disabled":"",f.push({style:h,y:a,m:c})}),f},eachDays:function(a,b){var F,G,H,I,J,K,L,M,N,O,P,Q,R,e=this,f=0,g=[],h=e.$opts,j=(jet.isBool(h.multiPane),new Date(a,b-1,1).getDay()||7),l=(0!=h.range,jet.getDaysNum(a,b)),n=e.selectDate,o=jet.prevMonth(a,b),q=(jet.isBool(h.isShow),jet.getDaysNum(a,o.m)),r=jet.nextMonth(a,b),t=(e.valCell,h.language),u=h.valiDate||[],v=jet.reMatch(e.minDate),w=parseInt(v[0]+""+jet.digit(v[1])+jet.digit(v[2])),x=jet.reMatch(e.maxDate),y=parseInt(x[0]+""+jet.digit(x[1])+jet.digit(x[2])),z=n[0]?parseInt(n[0].YYYY+""+jet.digit(n[0].MM)+jet.digit(n[0].DD)):"",A=n[1]?parseInt(n[1].YYYY+""+jet.digit(n[1].MM)+jet.digit(n[1].DD)):"",B=function(a,b,c){var d=h.marks,e=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1},f=jet.isType(d,"array");return f&&d.length>0&&e(d,a+"-"+jet.digit(b)+"-"+jet.digit(c))?'<i class="marks"></i>':""},C=function(a,b,c){var e,f,g,d="";return 1==h.festival&&"cn"==t.name?(e=jeLunar(a,b-1,c),f=e.solarFestival||e.lunarFestival,g=""!=(f&&e.jieqi)?f:e.jieqi||e.showInLunar,d='<p><span class="solar">'+c+'</span><span class="lunar">'+g+"</span></p>"):d='<p class="nolunar">'+c+"</p>",d},D=function(a,b,c,d){var e=parseInt(a+""+jet.digit(b)+jet.digit(c));if(d){if(e>=w&&y>=e)return!0}else if(w>e||e>y)return!0},E=function(a,b){var d,f,g,h,i,c=function(a,b){for(var c in b)if(b[c]==a)return!0;return!1};return u.length>0&&""!=u[0]&&(/\%/g.test(u[0])?(d=u[0].replace(/\%/g,"").split(","),f=[],jet.each(d,function(a,b){f.push(jet.digit(parseInt(b)))}),g=0==c(jet.digit(a),f),b=jet.isBool(u[1])?g?" disabled":b:g?b:" disabled"):(h=e.dateRegExp(u[0]),i=h.test(jet.digit(a)),b=jet.isBool(u[1])?i?" disabled":b:i?b:" disabled")),b};for(F=q-j+1;q>=F;F++,f++)G=B(o.y,o.m,F),H=D(o.y,o.m,F,!1)?"disabled":"other",H=E(F,H),g.push({style:H,ymd:o.y+"-"+jet.digit(o.m)+"-"+jet.digit(F),day:C(o.y,o.m,F)+G});for(I=1;l>=I;I++,f++)J=B(a,b,I),K="",L=parseInt(a+""+jet.digit(b)+jet.digit(I)),M=L>z,N=A>L,K=D(a,b,I,!0)?L==z||L==A?" action":M&&N?" contain":"":" disabled",K=E(I,K),g.push({style:"normal"+K,ymd:a+"-"+jet.digit(b)+"-"+jet.digit(I),day:C(a,b,I)+J});for(O=1,P=42-f;P>=O;O++)Q=B(r.y,r.m,O),R=D(r.y,r.m,O,!1)?"disabled":"other",R=E(O,R),g.push({style:R,ymd:r.y+"-"+jet.digit(r.m)+"-"+jet.digit(O),day:C(r.y,r.m,O)+Q});return g},eachTime:function(a,b){var c=this,d=c.$opts,e=d.range,f=d.multiPane,g=[],h=[],i=["hh","mm","ss"],j=[],k="",l=c.format,m=jet.trim(c.minDate).replace(/\s+/g," "),n=jet.trim(c.maxDate).replace(/\s+/g," "),o=m.split(" "),p=n.split(" ");return c.dlen>3&&/\:/.test(o)&&/\:/.test(p)&&(g=jet.reMatch(/\s/.test(m)&&c.dlen>3?o[1]:m),h=jet.reMatch(/\s/.test(n)&&c.dlen>3?p[1]:n)),jet.each([24,60,60],function(d,m){var n,p,q,r;for(j[d]=[],n=void 0==g[d]||0==g[d]?a[i[d]]:g[d],p=""==c.getValue()?n:a[i[d]],c.dlen>3&&/\:/.test(o)&&1==b&&(c.selectTime[0][i[d]]=p),q=0;m>q;q++)r=new RegExp(i[d],"g").test(l),k=q==p?r?"action":"disabled":!r||!e&&f&&(q<g[d]||q>h[d])?"disabled":f?"":1==b&&q<g[d]||2==b&&