日期控件如何控制只能选择每月的周一日期

PLQ1(UVHC9OEUT@9L3903JI.pngDJEMN6)@E3C@M8Z(O(P1BWR.png

FineReport 用户f0613105 发布于 2023-11-2 10:44 (编辑于 2023-11-2 14:08)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
Z4u3z1Lv6专家互助
发布于2023-11-2 10:44

----帆软日期控件限定只选周一 控件初始化事件加js

this._createCalendar = function() {

var o = this.options;

var self = this;

if (this.options.need2BuildConfig === true && this.options.data) {

this.options.data.resetStatus(this.createDependencePara4Data());

var data = this.options.data.getData();

if (data[0].data) {

if (data[0].data.startDate) {

var sd = new Date(data[0].data.startDate);

if (!FR.isInvalidDate(sd)) {

o.startDate = FR.date2Str(sd, 'yyyy-MM-dd');

this.std = this._createStartDate(o.startDate, o.format, this.viewMode);

}

}

if (data[0].data.endDate) {

var ed = new Date(data[0].data.endDate);

if (!FR.isInvalidDate(ed)) {

o.endDate = FR.date2Str(ed, 'yyyy-MM-dd');

this.edd = this._createEndDate(o.endDate, o.format, this.viewMode);

}

}

}

this.options.rebuildConfig = false;

}

this.datepicker = new FR.DatePicker({

renderEl: this.$view,

viewMode: this.viewMode,

date: FR.str2Date(this.editComp.val(), o.format),

dateFormat: o.format,

startDate: this.std,

endDate: this.edd,

onDateUpdate: function() {

if ($(':focus').length === 0) {

self.editComp.focus();

}

self.editComp.val(FR.date2Str(this.getValue(), o.format));

self.isValidateInput();

self.fireEvent(FR.Events.AFTEREDIT);

}

});

this.datepicker._loadDateData = function(table, date) {

if (!date) {

return;

}

var year = date.getFullYear(),

month = date.getMonth(),

day = date.getDate();

var today = new Date(),

TY = today.getFullYear(),

TM = today.getMonth(),

TD = today.getDate();

this.cache.showYear = year;

this.cache.showMonth = month;

var std = this.options.startDate,

edd = this.options.endDate;

table.$title.text(Date._MN[month] + ", " + year);

var nextDay = new Date(date);

nextDay.setDate(nextDay.getMonthDays() + 1);

if ((edd && nextDay > edd) || nextDay.getFullYear() > this.CONSTS.MAXYEAR) {

table.$nextm.addClass('disabled').removeClass('hover').data('disabled', true);

} else {

table.$nextm.removeClass('disabled').data('disabled', false);

}

var prevDay = new Date(date);

prevDay.setDate(0);

if ((std && prevDay < std) || prevDay.getFullYear() < this.CONSTS.MINYEAR) {

table.$prevm.addClass('disabled').removeClass('hover').data('disabled', true);

} else {

table.$prevm.removeClass('disabled').data('disabled', false);

}

date.setDate(1);

var day1 = (date.getDay() - this.CONSTS.FIRSTDAY) % 7;

date.setDate(0 - day1);

date.setDate(date.getDate() + 1);

var $frow = table.find('tbody').children().eq(0);

for (var i = 0; i < 6; i++) {

if (!$frow.length) {

break;

}

var $cell = $frow.children().eq(0);

$cell.addClass('week wn').text(date.getWeekNumber());

var iday;

for (var j = 0; j < 7; ++j, date.setDate(iday + 1)) {

$cell = $cell.next();

$cell.removeClass().data('nav', this.CONSTS.NAV['day']);

if (!$cell.length) {

break;

}

iday = date.getDate();

$cell.text(iday);

var current_month = (date.getMonth() == month);

if (!current_month || j != 1) {

$cell.addClass('oday').data('disabled', true);

continue;

}

var disabled = false;

if ((std != null && std > date) || (edd != null && edd < date)) {

$cell.addClass('day disabled');

disabled = true;

} else {

$cell.addClass('day');

}

$cell.data('disabled', disabled);

if (!disabled) {

if (current_month && iday == day) {

this.cache.selectedDate && this.cache.selectedDate.removeClass('selected');

$cell.addClass('selected');

this.cache.selectedDate = $cell;

this.cache.showDay = iday;

}

if (date.getFullYear() == TY &&

date.getMonth() == TM &&

iday == TD) {

$cell.addClass('today');

}

var wday = date.getDay();

if ([0, 6].indexOf(wday) != -1) {

$cell.addClass("weekend");

}

}

}

$frow = $frow.next();

}

}

if (FR.Browser.isIE8() && this.$view.css('visibility') == 'hidden') {

this.$view.css("visibility", "visible");

} else {

this.$view.show();

}

$(document).bind('mousedown', this, this.collapseIf);

this.modifyPosition();

var tr = $('tbody>tr', this.datepicker.$datetable);

for (var i = 0; i < tr.length; i++) {

var $days = $('td[class!="week wn"]', tr);

for (var j = 0; j < $days.length; j++) {

var $day = $($days[j]);

if (1 != j && !$day.hasClass('oday')) {

$day.data("disabled", true);

$day.attr('class', 'oday');

}

}

}

}

  • 用户f0613105 用户f0613105(提问者) 请问大哥,如果每月只能选周五呢
    2023-11-02 13:56 
  • 二向箔 二向箔 你好想问一下只能选每月的最后一天和昨天的要怎么实现呢
    2024-02-29 18:23 
  • Z4u3z1 Z4u3z1 回复 二向箔 z直接用下拉简单方便
    2024-02-29 18:34 
最佳回答
0
ID1208Lv6高级互助
发布于2023-11-2 11:44(编辑于 2023-11-2 14:19)

image.png

日期控件初始化事件,移动端不支持

WorkBook3.rar

周五.rar

时间区间,时间控件设置

时间函数

=DATEINWEEK(today(),1)

=DATEINWEEK(today(),5)

image.png

  • 用户f0613105 用户f0613105(提问者) 那如果只能选周五呢
    2023-11-02 13:56 
  • ID1208 ID1208 回复 用户f0613105(提问者) 上面附件
    2023-11-02 14:04 
  • 用户f0613105 用户f0613105(提问者) 回复 ID1208 多谢大哥,还有个小问题大哥,如果我想默认最近的周一和周五的日期该怎么默认呢,您可以看上边图,比如最近的是30号到3号
    2023-11-02 14:09 
  • ID1208 ID1208 回复 用户f0613105(提问者) 区间吗?最近的周一到周五?
    2023-11-02 14:13 
  • 用户f0613105 用户f0613105(提问者) 回复 ID1208 大哥我有点看不懂这个js,如果我想让日期只选择周日,需要改哪里呢
    2023-11-02 15:57 
  • 3关注人数
  • 312浏览人数
  • 最后回答于:2023-11-2 14:19
    请选择关闭问题的原因
    确定 取消
    返回顶部