yunshangxie/unpackage/dist/build/mp-weixin/tuniao-ui/components/tn-calendar/tn-calendar.js

11 lines
8.3 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["tuniao-ui/components/tn-calendar/tn-calendar"],{"4b1b":function(t,e,a){"use strict";a.r(e);var n=a("b7e6"),i=a.n(n);for(var r in n)["default"].indexOf(r)<0&&function(t){a.d(e,t,(function(){return n[t]}))}(r);e["default"]=i.a},"888c":function(t,e,a){"use strict";a.r(e);var n=a("c7f6"),i=a("4b1b");for(var r in i)["default"].indexOf(r)<0&&function(t){a.d(e,t,(function(){return i[t]}))}(r);a("db48");var o=a("f0c5"),s=Object(o["a"])(i["default"],n["b"],n["c"],!1,null,"a55073ce",null,!1,n["a"],void 0);e["default"]=s.exports},ac36:function(t,e,a){},b7e6:function(t,e,a){"use strict";(function(t){var n=a("4ea4");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=n(a("18c4")),r={name:"tn-calendar",props:{value:{type:Boolean,default:!1},mode:{type:String,default:"date"},changeYear:{type:Boolean,default:!0},changeMonth:{type:Boolean,default:!0},maxYear:{type:[Number,String],default:2100},minYear:{type:[Number,String],default:1970},minDate:{type:String,default:"1970-01-01"},maxDate:{type:String,default:""},monthArrowColor:{type:String,default:"#AAAAAA"},yearArrowColor:{type:String,default:"#C8C8C8"},color:{type:String,default:"#080808"},activeBgColor:{type:String,default:"#01BEFF"},activeColor:{type:String,default:"#FFFFFF"},rangeBgColor:{type:String,default:"#E6E6E655"},rangeColor:{type:String,default:"#01BEFF"},startText:{type:String,default:"开始"},endText:{type:String,default:"结束"},btnColor:{type:String,default:"#01BEFF"},lunarColor:{type:String,default:"#AAAAAA"},isActiveCurrent:{type:Boolean,default:!0},isChange:{type:Boolean,default:!1},showLunar:{type:Boolean,default:!0},toolTips:{type:String,default:"请选择日期"},borderRadius:{type:Number,default:8},safeAreaInsetBottom:{type:Boolean,default:!1},maskCloseable:{type:Boolean,default:!0},zIndex:{type:Number,default:0},closeBtn:{type:Boolean,default:!1}},computed:{dateChange:function(){return"".concat(this.mode,"-").concat(this.minDate,"-").concat(this.maxDate)},elIndex:function(){return this.zIndex?this.zIndex:this.$tn.zIndex.popup},colorValue:function(){var t=this;return function(e,a){var n="bg"===a?"":t.color,i=e+1,r="".concat(t.year,"-").concat(t.month,"-").concat(i),o=new Date(r.replace(/\-/g,"/")).getTime(),s=t.startDate.replace(/\-/g,"/"),h=t.endDate.replace(/\-/g,"/");return"date"===t.mode&&t.isActiveCurrent&&t.activeDate==r||t.startDate==r||t.endDate==r?n="bg"===a?t.activeBgColor:t.activeColor:t.endDate&&o>new Date(s).getTime()&&o<new Date(h).getTime()&&(n="bg"===a?t.rangeBgColor:t.rangeColor),n}}},data:function(){return{weekday:1,weekdayArr:[],weekDayZh:["日","一","二","三","四","五","六"],days:0,daysArr:[],year:2021,month:0,day:0,startYear:0,startMonth:0,startDay:0,endYear:0,endMonth:0,endDay:0,today:"",activeDate:"",startDate:"",endDate:"",min:null,max:null,dateTitle:"",chooseStart:!1}},watch:{dateChange:function(){this.init()}},created:function(){this.init()},methods:{init:function(){var t=new Date;this.year=t.getFullYear(),this.month=t.getMonth()+1,this.day=t.getDate(),this.today="".concat(this.year,"-").concat(this.month,"-").concat(this.day),this.activeDate=this.today,this.min=this.initDate(this.minDate),this.max=this.initDate(this.maxDate||this.today),this.startDate="",this.startYear=0,this.startMonth=0,this.startDay=0,this.endDate="",this.endYear=0,this.endMonth=0,this.endDay=0,this.chooseStart=!1,this.changeData()},changeMonthHandler:function(t){if(t){var e=this.month+1,a=e>12?this.year+1:this.year;this.checkRange(a)||(this.month=e>12?1:e,this.year=a,this.changeData())}else{var n=this.month-1,i=n<1?this.year-1:this.year;this.checkRange(i)||(this.month=n<1?12:n,this.year=i,this.changeData())}},changeYearHandler:function(t){var e=t?this.year+1:this.year-1;this.checkRange(e)||(this.year=e,this.changeData())},dateClick:function(t){if(t+=1,!this.disabledChoose(this.year,this.month,t)){this.day=t;var e="".concat(this.year,"-").concat(this.month,"-").concat(t);if("date"===this.mode)this.activeDate=e;else{var a=new Date(e.replace(/\-/g,"/")).getTime()<new Date(this.startDate.replace(/\-/g,"/")).getTime();!this.chooseStart||a?(this.startDate=e,this.startYear=this.year,this.startMonth=this.month,this.startDay=this.day,this.endYear=0,this.endMonth=0,this.endDay=0,this.endDate="",this.activeDate="",this.chooseStart=!0):(this.endDate=e,this.endYear=this.year,this.endMonth=this.month,this.endDay=this.day,this.chooseStart=!1)}this.daysArr=this.handleDaysArr()}},changeData:function(){this.days=this.getMonthDay(this.year,this.month),this.daysArr=this.handleDaysArr(),this.weekday=this.getMonthFirstWeekDay(this.year,this.month),this.weekdayArr=this.generateArray(1,this.weekday),this.dateTitle="".concat(this.year,"年").concat(this.month,"月"),this.isChange&&"date"===this.mode&&this.handleBtnClick(!0)},handleBtnClick:function(t){if(t||this.close(),"date"===this.mode){var e=this.activeDate.split("-"),a=this.isChange?this.year:Number(e[0]),n=this.isChange?this.month:Number(e[1]),i=this.isChange?this.day:Number(e[2]),r=this.getMonthDay(a,n),o="".concat(a,"-").concat(this.formatNumber(n),"-").concat(this.formatNumber(i)),s=this.getWeekText(o),h=!1;"".concat(a,"-").concat(n,"-").concat(i)===this.today&&(h=!0),this.$emit("change",{year:a,month:n,day:i,days:r,week:s,isToday:h,date:o,switch:t})}else{if(!this.startDate||!this.endDate)return;var c=this.formatNumber(this.startMonth),d=this.formatNumber(this.startDay),u="".concat(this.startYear,"-").concat(c,"-").concat(d),l=this.getWeekText(u),y=this.formatNumber(this.endMonth),m=this.formatNumber(this.endDay),f="".concat(this.endYear,"-").concat(y,"-").concat(m),g=this.getWeekText(f);this.$emit("change",{startYear:this.startYear,startMonth:this.startMonth,startDay:this.startDay,startDate:u,startWeek:l,endYear:this.endYear,endMonth:this.endMonth,endDay:this.endDay,endDate:f,endWeek:g})}},disabledChoose:function(t,e,a){var n=!0,i="".concat(t,"/").concat(e,"/").concat(a),r="".concat(this.min.year,"/").concat(this.min.month,"/").concat(this.min.day),o="".concat(this.max.year,"/").concat(this.max.month,"/").concat(this.max.day),s=new Date(i).getTime();return s>=new Date(r).getTime()&&s<=new Date(o).getTime()&&(n=!1),n},checkRange:function(e){var a=!1;return(e<this.minYear||e>this.maxYear)&&(t.showToast({title:"所选日期超出范围",icon:"none"}),a=!0),a},initDate:function(t){var e=t.split("-");return{year:Number(e[0]||1970),month:Number(e[1]||1),day:Number(e[2]||1)}},handleDaysArr:function(){var t=this,e=this.generateArray(1,this.days),a=e.map((function(e){var a=t.showLunar?i.default.solar2lunar(t.year,t.month,e).IDayCn:"",n=t.showLunar?t.lunarColor:t.activeColor;return("date"===t.mode&&t.day==e||"range"===t.mode&&(t.startDay==e||t.endDay==e))&&(n=t.activeColor),"range"===t.mode&&(t.startDay==e&&t.startDay!=t.endDay&&(a=t.startText),t.endDay==e&&(a=t.endText)),{day:e,color:n,bottomInfo:a}}));return a},getMonthDay:function(t,e){return new Date(t,e,0).getDate()},getMonthFirstWeekDay:function(t,e){return new Date("".concat(t,"/").concat(e,"/01 00:00:00")).getDay()},getWeekText:function(t){t=new Date("".concat(t.replace(/\-/g,"/")," 00:00:00"));var e=t.getDay();return"星期"+this.weekDayZh[e]},generateArray:function(t,e){return Array.from(new Array(e+1).keys()).slice(t)},formatNumber:function(t){return t<10?"0"+t:t+""},close:function(){this.$emit("input",!1)}}};e.default=r}).call(this,a("543d")["default"])},c7f6:function(t,e,a){"use strict";a.d(e,"b",(function(){return i})),a.d(e,"c",(function(){return r})),a.d(e,"a",(function(){return n}));var n={tnPopup:function(){return Promise.all([a.e("common/vendor"),a.e("tuniao-ui/components/tn-popup/tn-popup")]).then(a.bind(null,"3b24"))}},i=function(){var t=this,e=t.$createElement,a=(t._self._c,t.__map(t.daysArr,(function(e,a){var n=t.__get_orig(e),i=t.disabledChoose(t.year,t.month,a+1),r=t.colorValue(a,"bg"),o=t.colorValue(a,"text");return{$orig:n,m0:i,m1:r,m2:o}})));t.$mp.data=Object.assign({},{$root:{l0:a}})},r=[]},db48:function(t,e,a){"use strict";var n=a("ac36"),i=a.n(n);i.a}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'tuniao-ui/components/tn-calendar/tn-calendar-create-component',
{
'tuniao-ui/components/tn-calendar/tn-calendar-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('543d')['createComponent'](__webpack_require__("888c"))
})
},
[['tuniao-ui/components/tn-calendar/tn-calendar-create-component']]
]);