From 2d43a1df3f5ba42710e6d21c27d1e13bdb8dfd56 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期一, 24 三月 2025 09:23:08 +0800 Subject: [PATCH] - --- src/uni_modules/uview-plus/components/u-calendar/month.vue | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/uni_modules/uview-plus/components/u-calendar/month.vue b/src/uni_modules/uview-plus/components/u-calendar/month.vue index 600bf1d..bde2dee 100644 --- a/src/uni_modules/uview-plus/components/u-calendar/month.vue +++ b/src/uni_modules/uview-plus/components/u-calendar/month.vue @@ -12,11 +12,11 @@ :class="[item1.selected && 'u-calendar-month__days__day__select--selected']"> <view class="u-calendar-month__days__day__select" :style="[daySelectStyle(index, index1, item1)]"> <text class="u-calendar-month__days__day__select__info" - :class="[item1.disabled && 'u-calendar-month__days__day__select__info--disabled']" + :class="[(item1.disabled || isForbid(item1) ) ? 'u-calendar-month__days__day__select__info--disabled' : '']" :style="[textStyle(item1)]">{{ item1.day }}</text> <text v-if="getBottomInfo(index, index1, item1)" class="u-calendar-month__days__day__select__buttom-info" - :class="[item1.disabled && 'u-calendar-month__days__day__select__buttom-info--disabled']" + :class="[(item1.disabled || isForbid(item1) ) ? 'u-calendar-month__days__day__select__buttom-info--disabled' : '']" :style="[textStyle(item1)]">{{ getBottomInfo(index, index1, item1) }}</text> <text v-if="item1.dot" class="u-calendar-month__days__day__select__dot"></text> </view> @@ -126,6 +126,14 @@ allowSameDay: { type: Boolean, default: false + }, + forbidDays: { + type: Array, + default: () => [] + }, + forbidDaysToast: { + type: String, + default: '' } }, data() { @@ -158,16 +166,16 @@ const dayWidth = Number(parseFloat(this.width / 7).toFixed(3).slice(0, -1)) // 寰楀嚭姣忎釜鏃ユ湡鐨勫搴� // #ifdef APP-NVUE - style.width = addUnit(dayWidth) + style.width = addUnit(dayWidth, 'px') // #endif style.height = addUnit(this.rowHeight) if (index2 === 0) { // 鑾峰彇褰撳墠涓烘槦鏈熷嚑锛屽鏋滀负0锛屽垯涓烘槦鏈熷ぉ锛屽噺涓�涓烘瘡鏈堢涓�澶╂椂锛岄渶瑕佸悜宸﹀亸绉荤殑item涓暟 week = (week === 0 ? 7 : week) - 1 - style.marginLeft = addUnit(week * dayWidth) + style.marginLeft = addUnit(week * dayWidth, 'px') } if (this.mode === 'range') { - // 涔嬫墍浠ラ渶瑕佽繖涔堝啓锛屾槸鍥犱负DCloud鍏徃鐨刬OS瀹㈡埛绔殑寮�鍙戣�呰兘鍔涙湁闄愬鑷寸殑bug + // 涔嬫墍浠ラ渶瑕佽繖涔堝啓锛屾槸鍥犱负DCloud鍏徃鐨刬OS瀹㈡埛绔鑷寸殑bug style.paddingLeft = 0 style.paddingRight = 0 style.paddingBottom = 0 @@ -297,6 +305,13 @@ }) }) }, + isForbid(item) { + let date = dayjs(item.date).format("YYYY-MM-DD") + if (this.mode !== 'range' && this.forbidDays.includes(date)) { + return true + } + return false + }, // 鍒ゆ柇涓や釜鏃ユ湡鏄惁鐩哥瓑 dateSame(date1, date2) { return dayjs(date1).isSame(dayjs(date2)) @@ -362,6 +377,12 @@ this.item = item const date = dayjs(item.date).format("YYYY-MM-DD") if (item.disabled) return + if (this.isForbid(item)) { + uni.showToast({ + title: this.forbidDaysToast + }) + return + } // 瀵逛笂涓�娆¢�夋嫨鐨勬棩鏈熸暟缁勮繘琛屾繁搴﹀厠闅� let selected = deepClone(this.selected) if (this.mode === 'single') { -- Gitblit v1.9.1