UNPKG

eeeeeeuuuu-ui

Version:

uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水

12 lines (11 loc) 7.08 kB
require('../../../app.js'); (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["uview-ui/components/u-calendar/u-calendar"],{"35da":function(t,e,a){},c724:function(t,e,a){"use strict";var i=a("35da"),n=a.n(i);n.a},c9ea:function(t,e,a){"use strict";a.r(e);var i,n={uPopup:function(){return a.e("uview-ui/components/u-popup/u-popup").then(a.bind(null,"3626"))},uIcon:function(){return a.e("uview-ui/components/u-icon/u-icon").then(a.bind(null,"ece6"))},uButton:function(){return a.e("uview-ui/components/u-button/u-button").then(a.bind(null,"7e94"))}},s=function(){var t=this,e=t.$createElement,a=(t._self._c,t.__map(t.daysArr,(function(e,a){var i=t.__get_orig(e),n=t.openDisAbled(t.year,t.month,a+1),s=t.getColor(a,1),h=t.getColor(a,2);return{$orig:i,m0:n,m1:s,m2:h}})));t.$mp.data=Object.assign({},{$root:{l0:a}})},h=[],r=a("e14a"),o=r["a"],d=(a("c724"),a("f0c5")),u=Object(d["a"])(o,s,h,!1,null,"1b9cfa7e",null,!1,n,i);e["default"]=u.exports},e14a:function(t,e,a){"use strict";(function(t){e["a"]={name:"u-calendar",props:{safeAreaInsetBottom:{type:Boolean,default:!1},maskCloseAble:{type:Boolean,default:!0},value:{type:Boolean,default:!1},zIndex:{type:[String,Number],default:0},changeYear:{type:Boolean,default:!0},changeMonth:{type:Boolean,default:!0},mode:{type:String,default:"date"},maxYear:{type:[Number,String],default:2050},minYear:{type:[Number,String],default:1950},minDate:{type:[Number,String],default:"1950-01-01"},maxDate:{type:[Number,String],default:""},borderRadius:{type:[String,Number],default:20},monthArrowColor:{type:String,default:"#606266"},yearArrowColor:{type:String,default:"#909399"},color:{type:String,default:"#303133"},activeBgColor:{type:String,default:"#2979ff"},activeColor:{type:String,default:"#ffffff"},rangeBgColor:{type:String,default:"rgba(41,121,255,0.13)"},rangeColor:{type:String,default:"#2979ff"},startText:{type:String,default:"开始"},endText:{type:String,default:"结束"},btnType:{type:String,default:"primary"},isActiveCurrent:{type:Boolean,default:!0},isChange:{type:Boolean,default:!1},closeable:{type:Boolean,default:!0},toolTip:{type:String,default:"选择日期"}},data(){return{weekday:1,weekdayArr:[],days:0,daysArr:[],showTitle:"",year:2020,month:0,day:0,startYear:0,startMonth:0,startDay:0,endYear:0,endMonth:0,endDay:0,today:"",activeDate:"",startDate:"",endDate:"",isStart:!0,min:null,max:null,weekDayZh:["日","一","二","三","四","五","六"]}},computed:{dataChange(){return`${this.mode}-${this.minDate}-${this.maxDate}`},uZIndex(){return this.zIndex?this.zIndex:this.$u.zIndex.popup}},watch:{dataChange(t){this.init()}},created(){this.init()},methods:{getColor(t,e){let a=1==e?"":this.color,i=t+1,n=`${this.year}-${this.month}-${i}`,s=new Date(n.replace(/\-/g,"/")).getTime(),h=this.startDate.replace(/\-/g,"/"),r=this.endDate.replace(/\-/g,"/");return this.isActiveCurrent&&this.activeDate==n||this.startDate==n||this.endDate==n?a=1==e?this.activeBgColor:this.activeColor:this.endDate&&s>new Date(h).getTime()&&s<new Date(r).getTime()&&(a=1==e?this.rangeBgColor:this.rangeColor),a},init(){let t=new Date;this.year=t.getFullYear(),this.month=t.getMonth()+1,this.day=t.getDate(),this.today=`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`,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.endYear=0,this.endMonth=0,this.endDay=0,this.endDate="",this.isStart=!0,this.changeData()},initDate(t){let e=t.split("-");return{year:Number(e[0]||1920),month:Number(e[1]||1),day:Number(e[2]||1)}},openDisAbled:function(t,e,a){let i=!0,n=`${t}/${e}/${a}`,s=`${this.min.year}/${this.min.month}/${this.min.day}`,h=`${this.max.year}/${this.max.month}/${this.max.day}`,r=new Date(n).getTime();return r>=new Date(s).getTime()&&r<=new Date(h).getTime()&&(i=!1),i},generateArray:function(t,e){return Array.from(new Array(e+1).keys()).slice(t)},formatNum:function(t){return t<10?"0"+t:t+""},getMonthDay(t,e){let a=new Date(t,e,0).getDate();return a},getWeekday(t,e){let a=new Date(`${t}/${e}/01 00:00:00`);return a.getDay()},checkRange(e){let a=!1;return(e<this.minYear||e>this.maxYear)&&(t.showToast({title:"日期超出范围啦~",icon:"none"}),a=!0),a},changeMonthHandler(t){if(t){let t=this.month+1,e=t>12?this.year+1:this.year;this.checkRange(e)||(this.month=t>12?1:t,this.year=e,this.changeData())}else{let t=this.month-1,e=t<1?this.year-1:this.year;this.checkRange(e)||(this.month=t<1?12:t,this.year=e,this.changeData())}},changeYearHandler(t){let e=t?this.year+1:this.year-1;this.checkRange(e)||(this.year=e,this.changeData())},changeData(){this.days=this.getMonthDay(this.year,this.month),this.daysArr=this.generateArray(1,this.days),this.weekday=this.getWeekday(this.year,this.month),this.weekdayArr=this.generateArray(1,this.weekday),this.showTitle=`${this.year}年${this.month}月`,this.isChange&&"date"==this.mode&&this.btnFix(!0)},dateClick:function(t){if(t+=1,!this.openDisAbled(this.year,this.month,t)){this.day=t;let e=`${this.year}-${this.month}-${t}`;if("date"==this.mode)this.activeDate=e;else{let t=new Date(e.replace(/\-/g,"/")).getTime()<new Date(this.startDate.replace(/\-/g,"/")).getTime();this.isStart||t?(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.isStart=!1):(this.endDate=e,this.endYear=this.year,this.endMonth=this.month,this.endDay=this.day,this.isStart=!0)}}},close(){this.$emit("input",!1)},getWeekText(t){t=new Date(t.replace(/\-/g,"/")+" 00:00:00");let e=t.getDay();return"星期"+["日","一","二","三","四","五","六"][e]},btnFix(t){if(t||this.close(),"date"==this.mode){let t=this.activeDate.split("-"),e=this.isChange?this.year:Number(t[0]),a=this.isChange?this.month:Number(t[1]),i=this.isChange?this.day:Number(t[2]),n=this.getMonthDay(e,a),s=`${e}-${this.formatNum(a)}-${this.formatNum(i)}`,h=this.getWeekText(s),r=!1;`${e}-${a}-${i}`==this.today&&(r=!0),this.$emit("change",{year:e,month:a,day:i,days:n,result:s,week:h,isToday:r})}else{if(!this.startDate||!this.endDate)return;let t=this.formatNum(this.startMonth),e=this.formatNum(this.startDay),a=`${this.startYear}-${t}-${e}`,i=this.getWeekText(a),n=this.formatNum(this.endMonth),s=this.formatNum(this.endDay),h=`${this.endYear}-${n}-${s}`,r=this.getWeekText(h);this.$emit("change",{startYear:this.startYear,startMonth:this.startMonth,startDay:this.startDay,startDate:a,startWeek:i,endYear:this.endYear,endMonth:this.endMonth,endDay:this.endDay,endDate:h,endWeek:r})}}}}}).call(this,a("543d")["default"])}}]); ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([ 'uview-ui/components/u-calendar/u-calendar-create-component', { 'uview-ui/components/u-calendar/u-calendar-create-component':(function(module, exports, __webpack_require__){ __webpack_require__('543d')['createComponent'](__webpack_require__("c9ea")) }) }, [['uview-ui/components/u-calendar/u-calendar-create-component']] ]);