泛微OA之获取每月固定日期

文章目录


1.需求及效果

1.1需求

复制代码
需要获取每个月的7号作为需发布日期,需要自动填充

1.2效果

复制代码
自动获取每个月的七号

2. 思路

复制代码
1.功能并不复杂,可以用泛微前端自带的插入代码块的功能来实现。
2.将这需要赋值的三个id拿到,然后进行赋值即可

3. 实现

java 复制代码
<script>
    jQuery(document).ready(function (){
        //将三个值取出来
        var firstDate = jQuery("#field10375");
        var secondDate = jQuery("#field10376");
        var thirdDate = jQuery("#field10377");

        var currentDate = new Date();

        //设置日期为每个月的7号
        currentDate.setDate(7);

        //使用getFullYear()、getMouth()和getDate()方法获取年月日,使用padStart()方法将月和日补零,确保是两位数
        var year = currentDate.getFullYear();
        var mouth = String(currentDate.getMonth()+1).padStart(2,'0');
        var day = String(currentDate.getDate()).padStart(2,'0');

        //将年月日拼接为格式化的日期字符串
        var formttedDate = year + '-' +mouth + '-' +day;
        firstDate.val(formttedDate);
        secondDate.val(formttedDate);
        thirdDate.val(formttedDate);

    })


</script>
相关推荐
zhensherlock2 小时前
Protocol Launcher 系列:Working Copy 文件操作与高级命令详解
javascript·git·typescript·node.js·自动化·github·js
zhensherlock1 天前
Protocol Launcher 系列:Working Copy 提交与同步全攻略
javascript·git·typescript·node.js·自动化·github·js
天若有情6731 天前
【开源推荐】form-validator-cn 轻量级中文表单校验库 | TS 零依赖、极简开箱即用
前端·npm·开源·node·js·表单校验
zhensherlock2 天前
Protocol Launcher 系列:Trello 看板管理的协议自动化
前端·javascript·typescript·node.js·自动化·github·js
珊瑚怪人5 天前
分享一个Edge浏览器播放H265 RTSP流的问题,涉及到ZLMediaKit、WebRTC
音视频·视频·js·zlmediakit·视频流处理
双普拉斯6 天前
打造工业级全栈文件管理器:深度解析上传、回收站与三重下载流控技术
spring·vue·js
zhensherlock7 天前
Protocol Launcher 系列:Overcast 一键订阅播客
前端·javascript·typescript·node.js·自动化·github·js
拆房老料9 天前
5分钟上手 OnlyOffice 连接器,打通业务系统与文档编辑器
编辑器·开源软件·js
zhensherlock14 天前
Protocol Launcher 系列:Mail Assistant 轻松发送 HTML 邮件
前端·javascript·typescript·node.js·html·github·js
cuoluoche14 天前
postman接口请求response是base64-图片这类的可视化。
js