m0_56789428 2023-05-08 17:14 采纳率: 94.9%
浏览 42
已结题

日历展示考勤,怎么判断哪天是休息时间

日历展示考勤,上几天休几天的那种,我不知道怎么判断哪天是休息时间?

img

 // start_date开始时间,end_date结束时间,以下是开始时间和结束时间的年月日
       var start_year = new Date(start_date).getFullYear();
        var start_month =new Date(start_date).getMonth()+1;
        var start_day = new Date(start_date).getDate();
        var end_year = new Date(end_date).getFullYear();
        var end_month =new Date(end_date).getMonth()+1;
        var end_day = new Date(end_date).getDate();
  var work_no ="3" // 上班天数 
 var rest_no  = "2" // 休息天数。
//totalDay是当月的天数
for (var i = 1; i <= totalDay; i++) {
 // 此循环遍历的当月日期 var date = my_year + "-" + (my_month + 1) + '-' + i;
}


  • 写回答

1条回答 默认 最新

  • 文盲老顾 WEB应用领新星创作者 2023-05-08 22:11
    关注

    根据班制数据判断,你这没头没尾的。。。。让我一通追问才弄明白

    data  = [{
        "end_date": "2023-05-20 10:58:46.0",
        "trusday": "",
        "saturday": "",
        "sf_id": "797795276940116965",
        "person_sex": "男",
        "work_no": "2",
        "frequency_name": "班次二",
        "closing_time": "00:00:00",
        "wednesday": "",
        "friday": "",
        "id": "846475598908882982",
        "person_collection_id": "13a003bfc58d4b6483b834907beb5070",
        "start_date": "2023-04-26 10:34:15.0",
        "monday": "",
        "station_name": "桥西区中转站",
        "work_cycle": "1",
        "create_time": "",
        "rest_no": "1",
        "station_id": "86b1d606baf04dba87230243b6aa2c2a",
        "thursday": "",
        "person_name": "张唐廷",
        "person_age": "34",
        "sunday": "",
        "frequency_id": "797795276940116965",
        "work_time": "04:00:00",
        "organ_id": "57cbf560-7552-44a4-a726-8873a1fd8351"
    },
    {
        "end_date": "2023-05-30 00:00:00.0",
        "trusday": "0",
        "saturday": "1",
        "sf_id": "843471547225079872",
        "person_sex": "男",
        "work_no": "",
        "frequency_name": "班次三",
        "closing_time": "17:00:00",
        "wednesday": "0",
        "friday": "0",
        "id": "825830464555057319",
        "person_collection_id": "1c0d596547444cfba7b96669846ba568",
        "start_date": "2023-05-01 00:00:00.0",
        "monday": "0",
        "station_name": "河东区中转站",
        "work_cycle": "0",
        "create_time": "",
        "rest_no": "",
        "station_id": "76303b4b78434fe8962b379f29fd53a3",
        "thursday": "0",
        "person_name": "赵六",
        "person_age": "59",
        "sunday": "1",
        "frequency_id": "843471547225079872",
        "work_time": "09:00:00",
        "organ_id": "6ba42ba4-7114-4f84-b877-86a197bea261"
    }]
    
    for (var i = 0; i < data.length ; i ++ )
    {
        var e = new Date(data[i]['end_date'].replace(/\s+.*$/gi,''));
        var s = new Date(data[i]['start_date'].replace(/\s+.*$/gi,''));
        var days = (e - s) / 1000 / 60 / 60 / 24;
        var b = data[i]['work_no'];
        if (b.length > 0 && parseInt(b) > 0)
        {
            work = parseInt(b);
            rest = parseInt(data[i]['rest_no']);
            arr = Array.from(new Array(days)).map((x,y) => y % (work + rest) < work ? 1 : 0)
        }else{
            week = s.getDay();
            bc = [data[i]['monday'],data[i]['trusday'],0,0,0,data[i]['saturday'],data[i]['sunday']]
            arr = Array.from(new Array(days)).map((x,y) => bc[(y + week) % 7])
        }
        console.log(arr);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 5月16日
  • 已采纳回答 5月8日
  • 修改了问题 5月8日
  • 创建了问题 5月8日

悬赏问题

  • ¥15 没输出运行不了什么问题
  • ¥20 输入import torch显示Intel MKL FATAL ERROR,系统驱动1%,: Cannot load mkl_intel_thread.dll.
  • ¥15 点云密度大则包围盒小
  • ¥15 nginx使用nfs进行服务器的数据共享
  • ¥15 C#i编程中so-ir-192编码的字符集转码UTF8问题
  • ¥15 51嵌入式入门按键小项目
  • ¥30 海外项目,如何降低Google Map接口费用?
  • ¥15 fluentmeshing
  • ¥15 手机/平板的浏览器里如何实现类似荧光笔的效果
  • ¥15 盘古气象大模型调用(python)