怎么样实现我选择下拉框控件的值之后,日期控件默认当前日期。举例:下拉框选择是后,日期默认当前日期

image.png

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

给你的下拉框写编辑结束事件,js代码如下

Date.prototype.Format = function (fmt) { // author: meizz

  var o = {

    "M+": this.getMonth() + 1, // 月份

    "d+": this.getDate(), // 日

    "h+": this.getHours(), // 小时

    "m+": this.getMinutes(), // 分

    "s+": this.getSeconds(), // 秒

    "q+": Math.floor((this.getMonth() + 3) / 3), // 季度

    "S": this.getMilliseconds() // 毫秒

  };

  if (/(y+)/.test(fmt))

    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));

  for (var k in o)

    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

      return fmt;

}

var a = this.getValue();

var location = this.options.location; //获取当前控件的位置

var cr = FR.cellStr2ColumnRow(location);

var col = cr.col; //列号

var ro = cr.row; //行号

if (a == '是') {

//var myDate = new Date();

var b=new Date().Format("yyyy-MM-dd hh:mm:ss");

   // 获取日期与时间

contentPane.setCellValue(0, col+1, ro, b);

}

================

上传模板

WorkBook155.rar

image.png

最佳回答
0
孤陌Lv6资深互助
发布于2022-5-5 16:08

日期单元格 IF(LEN(A2)=0,"",NOW())

最佳回答
0
等哈炯Lv4初级互助
发布于2022-5-5 16:09(编辑于 2022-5-5 16:11)

直接写公式判断就行了,if(len(A1)>0,now(),""),记得把单元格的格式改成日期或者时间,时间的话会返回当前的年月日加时分秒,日期格式只返回年月日

  • 4关注人数
  • 529浏览人数
  • 最后回答于:2022-5-5 16:11
    请选择关闭问题的原因
    确定 取消
    返回顶部