| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view>
|
| | | <view class='calendar-Time-header under_line'>
|
| | | <view class="header-left">
|
| | | <!-- <image :src="lastDisabled ? disable : nodisable" mode="widthFix" @tap="subMonth"></image> -->
|
| | | <image :src="nodisable" mode="widthFix" @tap="subMonth"></image>
|
| | | <text>{{title_time}}</text>
|
| | | <image src="@/static/meeting/icon/ar_right@2x.png" mode="widthFix" @tap="addMonth"></image>
|
| | | </view>
|
| | | <view class="header-right" @tap="backToToday">åå°ä»å¤©</view>
|
| | | <!-- <text class='calendar-lastMonth' @tap="subMonth" v-bind:class="{'calendar-btn-disabled' : lastDisabled }">{{lastText}}</text>
|
| | | <text class='calendar-TimeH'>{{title_time}}</text>
|
| | | <text class='calendar-nextMonth' @tap="addMonth" v-bind:class="{'calendar-btn-disabled' : nextDisabled }">{{nextText}}</text>
|
| | | <text class='calendar-backToToday' @tap="backToToday">åå°ä»å¤©</text> -->
|
| | | </view>
|
| | | <view class='ClearBoth'></view>
|
| | | <view class="calendar-content">
|
| | | <view class="calendar-row calendar-header">
|
| | | <view class="calendar-col aligncanter">卿¥</view>
|
| | | <view class="calendar-col aligncanter">å¨ä¸</view>
|
| | | <view class="calendar-col aligncanter">å¨äº</view>
|
| | | <view class="calendar-col aligncanter">å¨ä¸</view>
|
| | | <view class="calendar-col aligncanter">å¨å</view>
|
| | | <view class="calendar-col aligncanter">å¨äº</view>
|
| | | <view class="calendar-col aligncanter">å¨å
</view>
|
| | | </view>
|
| | | <view class="calendar-row calendar-day" v-bind:style="{'transform':transformObj, 'transition-duration':transformTimeObj}" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend">
|
| | | <view class="calendar-col aligncanter calendar-col-lastMonth" v-for='item in beforeDateList' v-bind:key='item.key'
|
| | | @tap="subMonth" v-bind:class="{'calendar-out-of-Date' : item.outOfDate }">{{item.dateIndex}}
|
| | | <text class='calendar-text'>{{item.markText}}</text>
|
| | | </view>
|
| | |
|
| | | <view class="calendar-col aligncanter currentDays" v-bind:class="{'calendar-active' : item.dateIndex == currentSelectTime
|
| | | , 'calendar-today' : item.isToday |
| | | , 'calendar-range' : item.isRanges
|
| | | , 'calendar-out-of-Date' : item.outOfDate }"
|
| | | v-for='item in dateList' v-bind:key='item.key' @tap="selectedDateFun(item.dateIndex)">
|
| | | <view class='dayValue'>
|
| | | <text class='calendar-date calendar-day-6-7' v-if="item.isDaySunOrSat">{{item.dateIndex}}</text>
|
| | | <text v-else class='calendar-date'>{{item.dateIndex}}</text>
|
| | | <text class='calendar-point' v-if="item.pointText" v-bind:style="{'color':item.pointTextColor?item.pointTextColor:maskColor}">{{item.pointText}}</text>
|
| | | <text class='calendar-text' v-bind:style="{'color':item.markTextColor?item.markTextColor:maskColor}">{{item.markText}}</text>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view class="calendar-col aligncanter calendar-col-nextMonth" v-for='item in afterDateList' v-bind:key='item.key'
|
| | | @tap="addMonth" v-bind:class="{'calendar-out-of-Date' : item.outOfDate }">{{item.dateIndex}}
|
| | | <text class='calendar-text'>{{item.markText}}</text>
|
| | | </view>
|
| | | </view>
|
| | | <view class="ClearBoth"></view>
|
| | | </view>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import lunarYearTool from './sloarToLunar.js'
|
| | | import { getDay } from '@/utils/utils.js'
|
| | | export default {
|
| | | name: 'Li-Calendar',
|
| | | props: {
|
| | | /**
|
| | | * @description å½åæ¶é´ yyyy-MM-dd
|
| | | */
|
| | | currentTime: {
|
| | | type: String,
|
| | | default: function() {
|
| | | let timeObj = new Date();
|
| | | return timeObj.getFullYear() + "-" + (timeObj.getMonth() + 1) + "-" + timeObj.getDate();
|
| | | }
|
| | | },
|
| | | /**
|
| | | * @description æ è®°ç¹å表
|
| | | * time æ è®°æ¶é´ yyyy-MM-dd
|
| | | * text æ è®°å
容 |
| | | * markPoint æ¯å¦æ¾ç¤ºæ è®°ç¹ é»è®¤false
|
| | | * markTextColor æ è®°å
容é¢è²
|
| | | * pointText å·¦ä¸è§æ è®°ç¹å
容
|
| | | * pointTextColor æ è®°ç¹é¢è²
|
| | | */
|
| | | mark: {
|
| | | type: Array,
|
| | | default: function() {
|
| | | return undefined;
|
| | | }
|
| | | },
|
| | | /**
|
| | | * @description 䏿æå
|
| | | */
|
| | | lastText: {
|
| | | type: String,
|
| | | default: 'ã'
|
| | | },
|
| | | /**
|
| | | * @description 䏿æå
|
| | | */
|
| | | nextText: {
|
| | | type: String,
|
| | | default: 'ã'
|
| | | },
|
| | | /**
|
| | | * @description å
¨å±æ è®°ç¹é¢è²ï¼å
æ¬ç¹åæå
|
| | | */
|
| | | maskColor: {
|
| | | type: String,
|
| | | default: '#01AAED'
|
| | | },
|
| | | /**
|
| | | * @description æ¯å¦æ¾ç¤ºååï¼maskä¼å
级é«
|
| | | */
|
| | | showLunar: {
|
| | | type: Boolean,
|
| | | default: true
|
| | | },
|
| | | /**
|
| | | * @description 设置æ è®°èå´
|
| | | */
|
| | | range: {
|
| | | type: Object,
|
| | | default: function() {
|
| | | return {
|
| | | rangeStart: undefined, //设置æ è®°èå´å¼å§ï¼yyyy-MM-dd
|
| | | rangeEnd: undefined //设置æ è®°èå´ç»æï¼yyyy-MM-dd
|
| | | }
|
| | | }
|
| | | },
|
| | | /**
|
| | | * @description æ¯å¦å¼å¯èå´éæ©æ¨¡å¼
|
| | | */
|
| | | rangeMode: {
|
| | | type: Boolean,
|
| | | default: false
|
| | | },
|
| | | /**
|
| | | * @description æ¥åèµ·å§æ¶é´ yyyy-MM-dd
|
| | | */
|
| | | dateStart: {
|
| | | type: String,
|
| | | default: '1970-01-01'
|
| | | },
|
| | | /**
|
| | | * @description æ¥åç»ææ¶é´ yyyy-MM-dd
|
| | | */
|
| | | dateEnd: {
|
| | | type: String,
|
| | | default: '2100-12-31'
|
| | | },
|
| | | /**
|
| | | * @description æ¯å¦å¯ä»¥æ»å¨
|
| | | */
|
| | | canDrag:{
|
| | | type: Boolean,
|
| | | default: true
|
| | | },
|
| | | },
|
| | | created() {
|
| | | this.render();
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | nodisable: require('@/static/meeting/icon/ar_left@2x.png'),
|
| | | disable: require('@/static/meeting/icon/ar_left_disable.png'),
|
| | | |
| | | nextDisabled: false,
|
| | | lastDisabled: true,
|
| | | currentSelectTime: undefined, //ç¹å»æ¶ä¿åçdateIndex
|
| | | title_time: '', //é¡¶å¤´ææ¬
|
| | | year: undefined, //å½åå¹´
|
| | | month: undefined, //å½åæ
|
| | | beforeDateList: [], //ä¸ä¸ªæçæ¥æå表
|
| | | dateList: [], //æ¬æçæ¥æå表
|
| | | afterDateList: [], //ä¸ä¸ªæçæ¥æå表
|
| | | firstRangeSelected: false, // èå´å¼å§æ¶é´æ¯å¦å·²ç»éæ©
|
| | | rangeStart_: undefined, //æ è®°èå´å¼å§ï¼yyyyMM-dd
|
| | | rangeEnd_: undefined, //æ è®°èå´ç»æï¼yyyyMM-dd
|
| | | transform_x:0,
|
| | | transform_time:0,
|
| | | };
|
| | | },
|
| | | methods: {
|
| | | render(setTimeStr) { //åå§å
|
| | | let that = this;
|
| | | let currentTimeStr = setTimeStr ? setTimeStr : that.currentTime;
|
| | | let timeObj = this.toDateByStr(currentTimeStr); //å½åéå®çæ¶é´
|
| | | //计ç®å¤´é¨æ¾ç¤ºçå¹´æ
|
| | | let _tempTileMonth = (timeObj.getMonth() + 1);
|
| | | if (_tempTileMonth < 10)
|
| | | _tempTileMonth = '0' + _tempTileMonth;
|
| | | this.title_time = timeObj.getFullYear() + "å¹´" + _tempTileMonth + "æ";
|
| | |
|
| | | //è·åå½åæ¶é´æä»½1å·
|
| | | let firstDayStr = timeObj.getFullYear() + "/" + (timeObj.getMonth() + 1) + "/01";
|
| | | let date = that.toDateByStr(firstDayStr);
|
| | | that.year = date.getFullYear();
|
| | | that.month = date.getMonth() + 1;
|
| | | let firstDayWeek = date.getDay(); //第ä¸å¤©æ¯ææå
|
| | | let grid_sum = 0; //æ»æ ¼åæ° ï¼ç¨äºåé¢å¡«æ»¡æ ¼å
|
| | | //è·åä¸ä¸ä¸ªæç天æ°
|
| | | let TempMonth;
|
| | | let TempYear;
|
| | | if (that.month == 1) { //跨年
|
| | | TempMonth = 12;
|
| | | TempYear = that.year - 1;
|
| | | } else {
|
| | | TempYear = that.year;
|
| | | TempMonth = that.month - 1;
|
| | | }
|
| | | let TempLastMonthStr = TempYear + "/" + TempMonth + "/01";
|
| | | let lastMonthTotalDay = that.getTotalDay(TempLastMonthStr);
|
| | | let lastMonthStartDay = lastMonthTotalDay - firstDayWeek;
|
| | |
|
| | | let _dateStart = that.toDateByStr1(that.dateStart);
|
| | | let _dateEnd = that.toDateByStr1(that.dateEnd);
|
| | | // å建åé¢çæ¥æ
|
| | | that.beforeDateList = [];
|
| | | for (let i = 0; i < firstDayWeek; i++) {
|
| | | grid_sum++;
|
| | | lastMonthStartDay++;
|
| | | let tempObj = {
|
| | | dateIndex: lastMonthStartDay,
|
| | | key: 'before_' + i
|
| | | };
|
| | |
|
| | | //夿æ¯å¦è¶
åºæ¥æèå´
|
| | | let _tempBeforeDate = new Date(TempYear + "/" + TempMonth + "/" + lastMonthStartDay);
|
| | | if (_dateStart > _tempBeforeDate || _tempBeforeDate > _dateEnd) {
|
| | | tempObj.outOfDate = true;
|
| | | }
|
| | |
|
| | | //è·ååå
|
| | | if (that.showLunar) {
|
| | | let LunarDate = that.sloarToLunar(TempYear, TempMonth, lastMonthStartDay);
|
| | | let tempLunarDay = LunarDate.lunarDay == 'åä¸' ? LunarDate.lunarMonth + 'æ' : LunarDate.lunarDay;
|
| | | tempObj.markText = tempLunarDay;
|
| | | }
|
| | |
|
| | | that.beforeDateList.push(tempObj);
|
| | | }
|
| | |
|
| | | //è·åä¸ä¸ªæç天æ°
|
| | | let totalDay = that.getTotalDay(currentTimeStr);
|
| | | |
| | | //çææ¬ææ¥å
|
| | | let today = new Date();
|
| | | let today_year = today.getFullYear();
|
| | | let today_month = today.getMonth() + 1;
|
| | | let today_day = today.getDate();
|
| | | that.dateList = [];
|
| | | for (let i = 1; i <= totalDay; i++) { //å¾ªç¯æ¥
|
| | | grid_sum++;
|
| | |
|
| | | let tempObj = {
|
| | | dateIndex: i,
|
| | | key: 'date_' + i,
|
| | | isRanges: false,
|
| | | isToday: false
|
| | | };
|
| | | //å½åæ¥æåé
|
| | | let tempDay = that.toDateByStr(that.year + "/" + that.month + "/" + i);
|
| | |
|
| | | //夿æ¯å¦ä¸ºå½å¤©
|
| | | if (today_year == that.year && today_month == that.month && today_day == i)
|
| | | tempObj.isToday = true;
|
| | |
|
| | | //å¨å
å卿¥ï¼ç¹æ®å¤ç
|
| | | let tempCurrWeek = tempDay.getDay();
|
| | | if (tempCurrWeek == 0 || tempCurrWeek == 6)
|
| | | tempObj.isDaySunOrSat = true;
|
| | |
|
| | | //夿æ¯å¦è¶
åºæ¥æèå´
|
| | | if (_dateStart > tempDay || tempDay > _dateEnd) {
|
| | | tempObj.outOfDate = true;
|
| | | }
|
| | |
|
| | | //è·ååå
|
| | | if (that.showLunar) {
|
| | | let LunarDate = that.sloarToLunar(that.year, that.month, i);
|
| | | that.lunarMonth = LunarDate.lunarMonth;
|
| | | that.lunarYear = LunarDate.lunarYear;
|
| | | let tempLunarDay = LunarDate.lunarDay == 'åä¸' ? LunarDate.lunarMonth + 'æ' : LunarDate.lunarDay;
|
| | | tempObj.lunarMonth = LunarDate.lunarMonth;
|
| | | tempObj.lunarYear = LunarDate.lunarYear;
|
| | | tempObj.lunarDay = LunarDate.lunarDay;
|
| | | tempObj.markText = tempLunarDay;
|
| | | tempObj.markTextColor = '#454545';
|
| | | }
|
| | |
|
| | | //è®¾ç½®äºæ è®°ç¹
|
| | | if (that.mark) {
|
| | | for (let z = 0; z < that.mark.length; z++) { //夿æ¯å¦ä¸ºæ è®°ç¹
|
| | | let tempDayMark = that.toDateByStr1(that.mark[z].time.trim())
|
| | | if (tempDay.getTime() == tempDayMark.getTime()) {
|
| | | let tempTextStr = that.mark[z].text
|
| | | if (that.mark[z].markPoint != false) { // æ¯å¦æ¾ç¤ºç¹
|
| | | tempObj.pointText = that.mark[z].pointText ? that.mark[z].pointText : 'â';
|
| | | tempObj.pointTextColor = that.mark[z].pointTextColor ? that.mark[z].pointTextColor : undefined;
|
| | | }
|
| | | if (tempTextStr != undefined && tempTextStr != "") { // æ¯å¦æ¾ç¤ºæå
|
| | | tempObj.markText = tempTextStr;
|
| | | tempObj.markTextColor = that.mark[z].markTextColor ? that.mark[z].markTextColor : undefined;
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | that.dateList.push(tempObj);
|
| | | }
|
| | |
|
| | | that.setRange();
|
| | |
|
| | | // å建åé¢ç空ç½ï¼è¡¥å¤äºè¡
|
| | | that.afterDateList = [];
|
| | | if (grid_sum < 42) { // å建åé¢ç空ç½ï¼è¡¥å¤äºè¡
|
| | | let j = 0;
|
| | |
|
| | | //è·åä¸ä¸æ
|
| | | let TempMonthNext;
|
| | | let TempYearNext;
|
| | | if (that.month == 12) { //跨年
|
| | | TempMonthNext = 1;
|
| | | TempYearNext = that.year + 1;
|
| | | } else {
|
| | | TempYearNext = that.year;
|
| | | TempMonthNext = that.month + 1;
|
| | | }
|
| | |
|
| | | for (let i = grid_sum; i < 42; i++) {
|
| | | j++;
|
| | |
|
| | | let tempObj = {
|
| | | dateIndex: j,
|
| | | key: 'after_' + j
|
| | | };
|
| | | //è·ååå
|
| | | if (that.showLunar) {
|
| | | let LunarDate = that.sloarToLunar(TempYearNext, TempMonthNext, j);
|
| | | let tempLunarDay = LunarDate.lunarDay == 'åä¸' ? LunarDate.lunarMonth + 'æ' : LunarDate.lunarDay;
|
| | | tempObj.markText = tempLunarDay;
|
| | | }
|
| | |
|
| | | //夿æ¯å¦è¶
åºæ¥æèå´
|
| | | let _tempAfterDate = new Date(TempYearNext + "/" + TempMonthNext + "/" + j);
|
| | | if (_dateStart > _tempAfterDate || _tempAfterDate > _dateEnd) {
|
| | | tempObj.outOfDate = true;
|
| | | }
|
| | |
|
| | | that.afterDateList.push(tempObj);
|
| | | }
|
| | | }
|
| | | },
|
| | | sloarToLunar(year,month,day){
|
| | | // console.log('----')
|
| | | // console.log(year + "--" +month+ "--" + day)
|
| | | let result = lunarYearTool.sloarToLunar(year,month,day);
|
| | | //console.log(result)
|
| | | return result;
|
| | | },
|
| | | getTotalDay(time) { //è·åæ æ¥ææ»æ°
|
| | | time = time.replace(/-/g, "/");
|
| | | let selectedDate = new Date(time);
|
| | | if (selectedDate == "Invalid Date") {
|
| | | selectedDate = new Date(time + "/01");
|
| | | }
|
| | | |
| | | let dayMany = new Date(selectedDate.getFullYear(),(selectedDate.getMonth() + 1), 0).getDate()
|
| | | return dayMany;
|
| | | },
|
| | | toDateByStr(timeStr) { //åç¬¦ä¸²è½¬æ¢æ¶é´ï¼è½¬æ¢å¤±è´¥æè
ä¸ä¼ å符串åè¿åå½å
|
| | | let timeObj;
|
| | | if (timeStr) {
|
| | | timeObj = new Date(timeStr.replace(/-/g, "/"));
|
| | | }
|
| | | if (!timeStr || timeObj == "Invalid Date")
|
| | | timeObj = new Date();
|
| | | return timeObj;
|
| | | },
|
| | | toDateByStr1(timeStr) { //åç¬¦ä¸²è½¬æ¢æ¶é´ï¼è½¬æ¢å¤±è´¥æè
ä¸ä¼ å符串ånull
|
| | | try {
|
| | | let timeObj;
|
| | | if (timeStr) {
|
| | | timeObj = new Date(timeStr.replace(/-/g, "/"));
|
| | | }
|
| | | if (!timeStr || timeObj == "Invalid Date")
|
| | | return null;
|
| | | return timeObj;
|
| | | } catch (e) {
|
| | | return null;
|
| | | }
|
| | | },
|
| | | getTimeStrFormat(timeStr) { //è·åæ ¼å¼åçæ¶é´ yyyy-MM-dd
|
| | | let timeObj;
|
| | | if (timeStr) {
|
| | | timeObj = new Date(timeStr.replace(/-/g, "/"));
|
| | | }
|
| | | if (!timeStr || timeObj == "Invalid Date")
|
| | | timeObj = new Date();
|
| | | return timeObj.getFullYear() + "-" + (timeObj.getMonth() + 1) + "-" + timeObj.getDate();
|
| | | },
|
| | | selectedDateFun(index) { //ç¹å»æ¥æ
|
| | | let that = this;
|
| | | let selectObj = that.dateList[index - 1];
|
| | | selectObj.year = that.year;
|
| | | selectObj.month = that.month;
|
| | | selectObj.day = index;
|
| | | selectObj.time = that.year + "-" + that.month + "-" + index;
|
| | | that.$emit('dayChange', selectObj);
|
| | |
|
| | | //夿æ¯å¦è¶
åºæ¥æèå´
|
| | | if (that.checkOutOfDate(selectObj.time)) {
|
| | | return;
|
| | | }
|
| | |
|
| | | that.currentSelectTime = index;
|
| | | |
| | | console.log(index)
|
| | |
|
| | | //å¼å¯äºèå´éæ©æ¨¡å¼
|
| | | if (that.rangeMode) {
|
| | | if (!that.firstRangeSelected) { //éæ©å¼å§æ¶é´
|
| | | that.firstRangeSelected = !that.firstRangeSelected
|
| | | that.rangeStart_ = selectObj.time;
|
| | | that.rangeEnd_ = undefined;
|
| | | that.clearRange();
|
| | | } else { //éæ©äºç»ææ¶é´
|
| | | that.rangeEnd_ = selectObj.time;
|
| | | that.firstRangeSelected = !that.firstRangeSelected
|
| | | that.$emit('rangeChange', {
|
| | | start: that.rangeStart_,
|
| | | end: that.rangeEnd_,
|
| | | });
|
| | | that.setRange();
|
| | | }
|
| | | }
|
| | | },
|
| | | addMonth() { //å ä¸ä¸ªæ
|
| | | let that = this;
|
| | | that.currentSelectTime = ''
|
| | | let _Month = that.month;
|
| | | let _Year = that.year;
|
| | | if (that.month == 12) { //跨年
|
| | | _Month = 1;
|
| | | _Year += 1;
|
| | | } else {
|
| | | _Month += 1;
|
| | | }
|
| | |
|
| | | let str = _Year + "/" + _Month + "/01";
|
| | |
|
| | | //夿æ¯å¦è¶
åºæ¥æèå´
|
| | | if (that.checkOutOfDate(str)) {
|
| | | that.nextDisabled = true;
|
| | | return;
|
| | | }
|
| | |
|
| | | that.month = _Month;
|
| | | that.year = _Year;
|
| | | that.lastDisabled = false;
|
| | |
|
| | | //æ£æ¥æ¥æä¸é弿¯å¦å¨å½æå
ï¼å¦æå¨åä¸è½å忢ä¸ä¸ªæ
|
| | | if (that.checkDateRange(that.year, that.month, 1)) {
|
| | | that.nextDisabled = true;
|
| | | }
|
| | |
|
| | | if (that.rangeMode) { //å¼å¯äºèå´æ¨¡å¼
|
| | | that.currentSelectTime = undefined;
|
| | | }
|
| | |
|
| | | that.$emit('monthChange', {
|
| | | date: str
|
| | | });
|
| | | that.render(str);
|
| | | },
|
| | | subMonth() { //åä¸ä¸ªæ
|
| | | let that = this;
|
| | | |
| | | that.currentSelectTime = ''
|
| | |
|
| | | let _Month = that.month;
|
| | | let _Year = that.year;
|
| | | if (that.month == 1) { //跨年
|
| | | _Month = 12;
|
| | | _Year -= 1;
|
| | | } else {
|
| | | _Month -= 1;
|
| | | }
|
| | |
|
| | | let str = _Year + "/" + _Month + "/01";
|
| | |
|
| | | //夿æ¯å¦è¶
åºæ¥æèå´
|
| | | let _totalDay = that.getTotalDay(str);
|
| | | if (that.checkOutOfDate(_Year + "/" + _Month + "/" + _totalDay)) {
|
| | | that.lastDisabled = true;
|
| | | return;
|
| | | }
|
| | |
|
| | | that.month = _Month;
|
| | | that.year = _Year;
|
| | | that.nextDisabled = false;
|
| | |
|
| | | //æ£æ¥æ¥æä¸é弿¯å¦å¨å½æå
ï¼å¦æå¨åä¸è½å忢ä¸ä¸ªæ
|
| | | if (that.checkDateRange(that.year, that.month)) {
|
| | | that.lastDisabled = true;
|
| | | }
|
| | |
|
| | | if (that.rangeMode) { //å¼å¯äºèå´æ¨¡å¼
|
| | | that.currentSelectTime = undefined;
|
| | | }
|
| | |
|
| | | that.$emit('monthChange', {
|
| | | date: str
|
| | | });
|
| | | that.render(str);
|
| | | },
|
| | | backToToday() { //åå°ä»å¤©
|
| | | let currDate = new Date();
|
| | | let _year = currDate.getFullYear();
|
| | | let _month = currDate.getMonth() + 1;
|
| | |
|
| | | this.currentSelectTime = getDay().day
|
| | | |
| | | this.$emit('dayChange', { time: getDay().date });
|
| | |
|
| | | //å¦æå·²ç»æ¯å½æ
|
| | | if (_year == this.year && _month == this.month) {
|
| | | return;
|
| | | }
|
| | | |
| | | let value = _year + "/" + _month + "/" + currDate.getDate();
|
| | | this.$emit('monthChange', {
|
| | | date: value
|
| | | });
|
| | | this.lastDisabled = true
|
| | | |
| | | this.render(value);
|
| | | },
|
| | | setRange() { //设置èå´
|
| | | let that = this;
|
| | | let rangeStartDate = that.toDateByStr1(that.rangeStart_);
|
| | | let rangeEndDate = that.toDateByStr1(that.rangeEnd_);
|
| | | if (!rangeStartDate || !rangeEndDate)
|
| | | return;
|
| | | if (rangeStartDate > rangeEndDate) { //鲿¢èå´åºé
|
| | | let tempD = rangeEndDate;
|
| | | rangeEndDate = rangeStartDate;
|
| | | rangeStartDate = tempD;
|
| | | }
|
| | |
|
| | | //循ç¯å¤æèå´
|
| | | for (let i = 0; i < that.dateList.length; i++) {
|
| | | let _TempDtStr = that.year + "/" + that.month + "/" + that.dateList[i].dateIndex;
|
| | | let _TempDt = that.toDateByStr1(_TempDtStr);
|
| | | that.dateList[i].isRanges = false;
|
| | | if (rangeStartDate <= _TempDt && _TempDt <= rangeEndDate) //æ¶é´å¨èå´å
|
| | | that.dateList[i].isRanges = true;
|
| | | }
|
| | | },
|
| | | clearRange() { //å
³éèå´æ¨¡å¼èå´
|
| | | let that = this;
|
| | | //循ç¯å¤æèå´
|
| | | for (let i = 0; i < that.dateList.length; i++) {
|
| | | that.dateList[i].isRanges = false;
|
| | | }
|
| | | },
|
| | | checkOutOfDate(time) { //夿æ¯å¦è¶
åºæ¥æèå´,yyyy-MM-dd
|
| | | let that = this;
|
| | | let _dateStart = that.toDateByStr1(that.dateStart);
|
| | | let _dateEnd = that.toDateByStr1(that.dateEnd);
|
| | | let _tempDate = that.toDateByStr1(time);
|
| | | if (_dateStart > _tempDate || _tempDate > _dateEnd) {
|
| | | return true;
|
| | | } else
|
| | | return false;
|
| | | },
|
| | | checkDateRange(year, month, type) { //夿èå´çé弿¯å¦å¨å½æå
,yyyy-MM-dd,typeï¼1 ä¸éå¼,å
¶ä»ï¼ä¸éå¼
|
| | | let that = this;
|
| | |
|
| | | let totalDay = that.getTotalDay(year + '/' + month + '/01');
|
| | | let firstD = that.toDateByStr1(year + '/' + month + '/01');
|
| | | let lastD = that.toDateByStr1(year + '/' + month + '/' + totalDay);
|
| | |
|
| | | if (type == 1) { //ä¸éå¼
|
| | | let _dateEnd = that.toDateByStr1(that.dateEnd);
|
| | | if (firstD <= _dateEnd && _dateEnd <= lastD) {
|
| | | return true;
|
| | | } else
|
| | | return false;
|
| | | } else { //ä¸éå¼
|
| | | let _dateStart = that.toDateByStr1(that.dateStart);
|
| | | if (firstD <= _dateStart && _dateStart <= lastD) {
|
| | | return true;
|
| | | } else
|
| | | return false;
|
| | | }
|
| | | },
|
| | | calendarTransform(x,time){ //æ¥åæ»å¨å¨ç»
|
| | | this.transform_x = x;
|
| | | this.transform_time = time;
|
| | | },
|
| | | touchstart(event) {
|
| | | if(!this.canDrag)
|
| | | return;
|
| | | this.startPageX = event.touches[0].pageX;
|
| | | this.startPageY = event.touches[0].pageY;
|
| | | },
|
| | | touchmove(event) {
|
| | | if(!this.canDrag)
|
| | | return;
|
| | | let touchmovePageX = event.touches[0].pageX;
|
| | | let result = touchmovePageX - this.startPageX;
|
| | | this.calendarTransform(result,0);
|
| | | },
|
| | | touchend(event) {
|
| | | if(!this.canDrag)
|
| | | return;
|
| | | let that = this;
|
| | | let endPageX = event.changedTouches[0].pageX;
|
| | | let endPageY = event.changedTouches[0].pageY;
|
| | | let x = Math.abs(that.startPageX - endPageX); //æ¨ªåæ ä¹å·®
|
| | | let y = Math.abs(that.startPageY - endPageY); //çºµåæ ä¹å·®
|
| | | |
| | | let screenX = 0;
|
| | | try {
|
| | | const res = uni.getSystemInfoSync();
|
| | | screenX = res.windowWidth;
|
| | | } catch (e) {
|
| | | console.error(e)
|
| | | return;
|
| | | }
|
| | | if (that.startPageX > endPageX) { //å·¦æ»
|
| | | let a = Math.atan(y / x);
|
| | | let Rate = x / screenX;
|
| | | if (a < Math.PI / 6 && Rate > 0.3) {
|
| | | screenX = -screenX;
|
| | | that.calendarTransform(screenX,300);
|
| | | setTimeout(function(){
|
| | | that.addMonth();
|
| | | that.calendarTransform(0,0);
|
| | | },300);
|
| | | }
|
| | | else{
|
| | | that.calendarTransform(0,300);
|
| | | }
|
| | | } else {
|
| | | let a = Math.atan(y / x);
|
| | | let Rate = x / screenX;
|
| | | if (a < Math.PI / 6 && Rate > 0.3) {
|
| | | that.calendarTransform(screenX,300);
|
| | | setTimeout(function(){
|
| | | that.subMonth();
|
| | | that.calendarTransform(0,0);
|
| | | },300);
|
| | | }
|
| | | else{
|
| | | that.calendarTransform(0,300);
|
| | | }
|
| | | }
|
| | | }
|
| | | },
|
| | | watch: {
|
| | | currentTime: function(val, oldVal) { //æ¶é´æ¹å
|
| | | let dateNew = this.toDateByStr1(val);
|
| | | if (dateNew.getFullYear() == this.year && (dateNew.getMonth() + 1) == this.month) {
|
| | | console.log('time is not change')
|
| | | } else {
|
| | | this.currentSelectTime = dateNew.getDate();
|
| | | this.render();
|
| | | }
|
| | | },
|
| | | range: function(val, oldVal) { //èå´æ¹å
|
| | | if (val.rangeStart != oldVal.rangeStart || val.rangeEnd != oldVal.rangeEnd) {
|
| | | this.rangeStart_ = val.rangeStart;
|
| | | this.rangeEnd_ = val.rangeEnd;
|
| | | this.setRange();
|
| | | }
|
| | | },
|
| | | mark: function(val, oldVal) { //æ è®°æ¹å
|
| | | this.render();
|
| | | },
|
| | | rangeMode: function(val, oldVal) { //èå´æ¹å
|
| | | if (!val) { //妿æ¯å
³éèå´æ¨¡å¼
|
| | | this.rangeStart_ = undefined; //æ è®°èå´å¼å§ï¼yyyyMM-dd
|
| | | this.rangeEnd_ = undefined; //æ è®°èå´ç»æï¼yyyyMM-dd
|
| | | this.firstRangeSelected = false;
|
| | | this.clearRange()
|
| | | }
|
| | | },
|
| | | },
|
| | | computed: {
|
| | | transformObj:function () { |
| | | return 'translate3d(' + this.transform_x + 'px, 0px, 0px) translateZ(0px)';
|
| | | },
|
| | | transformTimeObj:function () {
|
| | | return this.transform_time + 'ms';
|
| | | }
|
| | | },
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style>
|
| | | @import url("./Li-Calendar.css");
|
| | | </style>
|