【问题标题】:Calculate the number of appointments in a timeslot计算时间段内的约会次数
【发布时间】:2014-06-26 16:07:51
【问题描述】:

我有一组医生。每个人都有专长(牙医、普通科、精神科医师等)
每个专业都有其预定义的会话(约会)时间分配,例如:

  • 牙医 - 预约时间:30 分钟
  • 普通博士 - 预约时间:30分钟
  • 精神科医生 - 预约时间:45 分钟

每位医生都会制定自己的日程安排,例如:

  • 精神科医生 - 周一 08:00 至 12:30
  • 牙医 - 周二 14:00 至 20:00

我正在使用 jQuery 和两 (2) 个 BSTimepicker 字段将时间段分配给每个医生
http://jdewit.github.io/bootstrap-timepicker/

有没有什么方法可以计算(使用 jQuery 或 MomentJS lib)医生在分配的时间段内能够参加的(圆形)预约次数?

提前非常感谢

【问题讨论】:

    标签: jquery algorithm math time momentjs


    【解决方案1】:

    编辑、更新

    试试

    var apps = [];
    var meds = {
        "psych": {
            "schedule": 4.5,
            "appointment_length" : function() {return this.schedule * 4},
            "appointment_slots" : function() {return this.appointment_length() / 3}
        },
    
        "dentist": {
            "schedule": 6,
            "appointment_length" : function() {return this.schedule * 2},
            "appointment_slots" : function() {return this.appointment_length() / 2}
        }
    };
    
    $.each(meds, function (index, value) {
        apps.push([index, Math.round(value.appointment_slots())]);
        meds.appointments = apps.slice(0, 2);
    });
    console.log(meds);
    

    jsfiddle http://jsfiddle.net/guest271314/sdxLH/

    【讨论】:

    • 感谢您的帮助,但我收到“ReferenceError: psych is not defined”。我对 JSON 对象不是很熟悉
    猜你喜欢
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 2015-04-27
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 2011-05-27
    • 2014-05-01
    相关资源
    最近更新 更多