function ShiJianYanZheng() {
    var dtarray = starttime.split(":");
    var etarray = endtime.split(":");

    var a = new Date();
    var aa = new Date(a.getFullYear(), a.getMonth(), a.getDay(), dtarray[0], dtarray[1], 0);
    var bb = new Date(a.getFullYear(), a.getMonth(), a.getDay(), etarray[0], etarray[1], 0);
    if (aa > bb) {
        $.tools.alert("结束时间不能小于开始时间");
        return;
    }
}
function getTimeStamp(timeStr) {
  return new Date(`2025-07-22 ${timeStr}`).getTime();
}
function isTimeInRange(targetTime, startTime, endTime) {
  const target = getTimeStamp(targetTime);
  const start = getTimeStamp(startTime);
  const end = getTimeStamp(endTime);
  return target >= start && target <= end;
}


function checkTimeOverlaps(timeRanges) {

    // 检查每对时间段是否有重叠
    for (let i = 0; i < timeRanges.length; i++) {
        for (let j = i + 1; j < timeRanges.length; j++) {
            const rangeA = timeRanges[i];
            const rangeB = timeRanges[j];
            
            // 判断重叠条件：A的开始时间小于B的结束时间，且A的结束时间大于B的开始时间
            if (rangeA.start < rangeB.end && rangeA.end > rangeB.start) {
                
                let a1=rangeA.start;
                let b1=rangeA.end;
                let a2=rangeB.start;
                let b2=rangeB.end;
                $.tools.alert(a1+"-"+b1+"和"+a2+"-"+b2+"有重叠");
                return true; // 发现重叠
            }
        }
    }
    return false; // 没有重叠叠
}

function saveTimerECOSetting() {

        var starttime1 = $('#kt_timer_starttime1').timespinner('getValue');
        var starttime2 = $('#kt_timer_starttime2').timespinner('getValue');
        var starttime3 = $('#kt_timer_starttime3').timespinner('getValue');

        console.log(starttime1);
        console.log(starttime2);
        console.log(starttime3);

        var eco_enable1 = $("#id_KT_Timer_enable1").is(":checked");
        var eco_enable2 = $("#id_KT_Timer_enable2").is(":checked");
        var eco_enable3 = $("#id_KT_Timer_enable3").is(":checked");


        var XiangDuZhi1 = $("#ID_KT_DingShi1").combobox('getValue');
        var XiangDuZhi2 = $("#ID_KT_DingShi2").combobox('getValue');
        var XiangDuZhi3 = $("#ID_KT_DingShi3").combobox('getValue');

        var params1 = {
            StartTime: starttime1,
            RelativeValue: XiangDuZhi1,
            IsEnable: eco_enable1
        };

        var params2 = {
            StartTime: starttime2,
            RelativeValue: XiangDuZhi2,
            IsEnable: eco_enable2
        };

        var params3 = {
            StartTime: starttime3,
            RelativeValue: XiangDuZhi3,
            IsEnable: eco_enable3
        };
        var LLL=[params1,params2,params3];
        var TStr= JSON.stringify(LLL);
        console.log(TStr);

        $.ajax({
            url: '/SysHotel/SaveConditionTimerECO/',
            type: 'Post',
            contentType: 'application/json',
            data: TStr,
            success: function(response) {
                console.log(response);
                console.log('所有操作已完成');
                InitData();
            },
            error: function(xhr, status, error) {
                console.log(error);
            },
            beforeSend: function(xhr) {
                console.log('Sending request...');
            },
            complete: function(xhr, status) {
                console.log('Request completed.');
            }
        });

}

function saveLieECOSetting() {

        var ID1= $("#LieECOID1").val();
        var ID2= $("#LieECOID2").val();
        var ID3= $("#LieECOID3").val();
        var ID4= $("#LieECOID4").val();
        var ID5= $("#LieECOID5").val();

        var starttime1 = $('#starttime1').timespinner('getValue');
        var starttime2 = $('#starttime2').timespinner('getValue');
        var starttime3 = $('#starttime3').timespinner('getValue');
        var starttime4 = $('#starttime4').timespinner('getValue');
        var starttime5 = $('#starttime5').timespinner('getValue');

        var endtime1 = $('#endtime1').timespinner('getValue');
        var endtime2 = $('#endtime2').timespinner('getValue');
        var endtime3 = $('#endtime3').timespinner('getValue');
        var endtime4 = $('#endtime4').timespinner('getValue');
        var endtime5 = $('#endtime5').timespinner('getValue');

        var DingZhiOrXiangDui1 = $("input[name='Ding_Or_XiangDui1']:checked").val();
        var DingZhiOrXiangDui2 = $("input[name='Ding_Or_XiangDui2']:checked").val();
        var DingZhiOrXiangDui3 = $("input[name='Ding_Or_XiangDui3']:checked").val();
        var DingZhiOrXiangDui4 = $("input[name='Ding_Or_XiangDui4']:checked").val();
        var DingZhiOrXiangDui5 = $("input[name='Ding_Or_XiangDui5']:checked").val();

        var eco_enable1 = $("#id_LieECO_enable1").is(":checked");
        var eco_enable2 = $("#id_LieECO_enable2").is(":checked");
        var eco_enable3 = $("#id_LieECO_enable3").is(":checked");
        var eco_enable4 = $("#id_LieECO_enable4").is(":checked");
        var eco_enable5 = $("#id_LieECO_enable5").is(":checked");

       let timeRanges = [];
       if(eco_enable1==true)
       {
          var V1={ start: $('#starttime1').timespinner('getValue'), end: $('#endtime1').timespinner('getValue') };
          timeRanges.push(V1);
       }
       if(eco_enable2==true)
       {
          var V1={ start: $('#starttime2').timespinner('getValue'), end: $('#endtime2').timespinner('getValue') };
          timeRanges.push(V1);
       }
       if(eco_enable3==true)
       {
          var V1={ start: $('#starttime3').timespinner('getValue'), end: $('#endtime3').timespinner('getValue') };
          timeRanges.push(V1);
       }
       if(eco_enable4==true)
       {
          var V1={ start: $('#starttime4').timespinner('getValue'), end: $('#endtime4').timespinner('getValue') };
          timeRanges.push(V1);
       }

       if(eco_enable5==true)
       {
          var V1={ start: $('#starttime5').timespinner('getValue'), end: $('#endtime5').timespinner('getValue') };
          timeRanges.push(V1);
       }
       if (checkTimeOverlaps(timeRanges)) {
          return;
       } 

        var GuDingZhi1 = $("#guding_value1").combobox('getValue');
        var GuDingZhi2 = $("#guding_value2").combobox('getValue');
        var GuDingZhi3 = $("#guding_value3").combobox('getValue');
        var GuDingZhi4 = $("#guding_value4").combobox('getValue');
        var GuDingZhi5 = $("#guding_value5").combobox('getValue');

        var XiangDuZhi1 = $("#xiangduitiaowen_value1").combobox('getValue');
        var XiangDuZhi2 = $("#xiangduitiaowen_value2").combobox('getValue');
        var XiangDuZhi3 = $("#xiangduitiaowen_value3").combobox('getValue');
        var XiangDuZhi4 = $("#xiangduitiaowen_value4").combobox('getValue');
        var XiangDuZhi5 = $("#xiangduitiaowen_value5").combobox('getValue');


        var delay1 = $("#delaytime_value1").val();
        var delay2 = $("#delaytime_value2").val();
        var delay3 = $("#delaytime_value3").val();
        var delay4 = $("#delaytime_value4").val();
        var delay5 = $("#delaytime_value5").val();

        var ABSEnable1 = false;
        var Relative1 = false;
        if (DingZhiOrXiangDui1 == "abs") {
            ABSEnable1 = true;
        }
        else {
            Relative1 = true;
        }


        var ABSEnable2 = false;
        var Relative2 = false;
        if (DingZhiOrXiangDui2 == "abs") {
            ABSEnable2 = true;
        }
        else {
            Relative2 = true;
        }

        var ABSEnable3 = false;
        var Relative3 = false;
        if (DingZhiOrXiangDui3 == "abs") {
            ABSEnable3 = true;
        }
        else {
            Relative3 = true;
        }


        var ABSEnable4 = false;
        var Relative4 = false;
        if (DingZhiOrXiangDui4 == "abs") {
            ABSEnable4 = true;
        }
        else {
            Relative4 = true;
        }

        var ABSEnable5 = false;
        var Relative5 = false;
        if (DingZhiOrXiangDui5 == "abs") {
            ABSEnable5 = true;
        }
        else {
            Relative5 = true;
        }
        var params1 = {
            BiaoShiFlag: ID1,
            StartTime: starttime1,
            EndTime: endtime1,
            AbsEnable: ABSEnable1,
            AbsValue: GuDingZhi1,
            RelativeEnable: Relative1,
            RelativeValue: XiangDuZhi1,
            IsEnable: eco_enable1,
            Delay:delay1
        };
        console.log(params1);

        var params2 = {
            BiaoShiFlag: ID2,
            StartTime: starttime2,
            EndTime: endtime2,
            AbsEnable: ABSEnable2,
            AbsValue: GuDingZhi2,
            RelativeEnable: Relative2,
            RelativeValue: XiangDuZhi2,
            IsEnable: eco_enable2,
            Delay:delay2
        };

        var params3 = {
            BiaoShiFlag: ID3,
            StartTime: starttime3,
            EndTime: endtime3,
            AbsEnable: ABSEnable3,
            AbsValue: GuDingZhi3,
            RelativeEnable: Relative3,
            RelativeValue: XiangDuZhi3,
            IsEnable: eco_enable3,
            Delay:delay3
        };
        var params4 = {
            BiaoShiFlag: ID4,
            StartTime: starttime4,
            EndTime: endtime4,
            AbsEnable: ABSEnable4,
            AbsValue: GuDingZhi4,
            RelativeEnable: Relative4,
            RelativeValue: XiangDuZhi4,
            IsEnable: eco_enable4,
            Delay:delay4
        };
        var params5 = {
            BiaoShiFlag: ID5,
            StartTime: starttime5,
            EndTime: endtime5,
            AbsEnable: ABSEnable5,
            AbsValue: GuDingZhi5,
            RelativeEnable: Relative5,
            RelativeValue: XiangDuZhi5,
            IsEnable: eco_enable5,
            Delay:delay5
        };
        var A1= $.tools.post(params1, "/SysHotel/SaveConditionLieECO/", function (r) {

        });
        var A2= $.tools.post(params2, "/SysHotel/SaveConditionLieECO/", function (r) {

        });

        var A3= $.tools.post(params3, "/SysHotel/SaveConditionLieECO/", function (r) {

        });

        var A4= $.tools.post(params4, "/SysHotel/SaveConditionLieECO/", function (r) {

        });

        var A5= $.tools.post(params5, "/SysHotel/SaveConditionLieECO/", function (r) {
        });
        $.when(A1, A2, A3, A4, A5).then(function () {
            console.log('所有操作已完成');
            InitData();
        });
}


function cbxRoomNumberOnSelect(r) {
    var opts = $(this).combobox("options");
    if (r[opts.textField] == lang.CheckAll) {
        $("#cbtGroup").combotree("enable");
        $("#cbxRoomStatus").combobox("enable");
        $("#cbxRoomType").combobox("enable");
    } else {
        $("#cbtGroup").combotree("disable");
        $("#cbxRoomStatus").combobox("disable");
        $("#cbxRoomType").combobox("disable").combobox("select", r.RoomTypeID);
    }
}

function cbtGroupOnLoadSuccess(node, data) {
    if (data != null && data.length > 0) {
        $('#cbtGroup').combotree('setValue', data[0].id);
    }
}

function cbxRoomTypeOnSelect(r) {
    //$("#cbxModalID")
    //.combobox("clear")
    //.combobox("reload", "/AirConditionControl/LoadAirConditionsForCombobox/?roomTypeID=" + r.ID);
}
function getFilterParams() {
    return {
        hostID: $("#cbxRoomNumber").combobox("getValue"),
        groupID: $("#cbtGroup").combotree("getValue"),
        roomStatusID: $("#cbxRoomStatus").combobox("getValue"),
        roomTypeID: $("#cbxRoomType").combobox("getValue")
    };
}
//季节下发
function setSeason() {
    var filter = getFilterParams();
    var params = $.extend({ airNo: 0, Property: "Season", Status: 0,
        month1: $('#cbxMonth1').combobox('getValue'),
        month2: $('#cbxMonth2').combobox('getValue'),
        month3: $('#cbxMonth3').combobox('getValue'),
        month4: $('#cbxMonth4').combobox('getValue'),
        month5: $('#cbxMonth5').combobox('getValue'),
        month6: $('#cbxMonth6').combobox('getValue'),
        month7: $('#cbxMonth7').combobox('getValue'),
        month8: $('#cbxMonth8').combobox('getValue'),
        month9: $('#cbxMonth9').combobox('getValue'),
        month10: $('#cbxMonth10').combobox('getValue'),
        month11: $('#cbxMonth11').combobox('getValue'),
        month12: $('#cbxMonth12').combobox('getValue')
    }, filter);
    $.tools.post(params, "/AirConditionControl/SetAirProperty/");
}
//保存白天时间
function saveHotelTime() {
    var morningTime = $('#txtMorning').combobox('getValue');
    var afternoonTime = $('#txtAfternoon').combobox('getValue');
    var params = { morningTime: morningTime, afternoonTime: afternoonTime };
    $.tools.post(params, "/SysHotel/SaveHotelTime/");
}
//保存ECO设置
function saveECOSetting() {
    var id = $("#ecoid").val();
    var starttime = $('#txtstarttime').timespinner('getValue');
    var endtime = $('#txtendtime').timespinner('getValue');
    var dtarray = starttime.split(":");
    var etarray = endtime.split(":");

    var a = new Date();
    var aa = new Date(a.getFullYear(), a.getMonth(), a.getDay(), dtarray[0], dtarray[1], 0);
    var bb = new Date(a.getFullYear(), a.getMonth(), a.getDay(), etarray[0], etarray[1], 0);
    if (aa > bb) {
        $.tools.alert("结束时间不能小于开始时间");
        return;
    }

    var add_or_minute = $("input[name='addorminute']:checked").val();
    var eco_enable = $("#id_eco_enable").is(":checked");

    var tempval = $("#tiaowen_value").combobox('getValue');
    var params = { id: id, StartTime: starttime, EndTime: endtime, Action: add_or_minute, TempVal: tempval, IsEnable: eco_enable };
    $.tools.post(params, "/SysHotel/SaveAirConditionECO/", function (r) {

    });
}

//保存空调设置
function saveAirControl(conditionType) {

    var h1 = $("input[name='guankongtiao']:checked").val();
    var t1 = $('#wendu_id option:selected').val();
    var t2 = $('#DelayTimeId option:selected').val();
    var ida = $("#nobodyroomid").val();
    if (ida == "") {
        ida = 0;
    }
    var params = {
        yanchitime: t2,
        how: h1,
        temp: t1,
        id: ida,
        conditionType: conditionType,
        delayTime: parseInt($('#cmbDelayTime' + conditionType.toString() + '1').combobox('getValue')),
        id1: parseInt($('#hidID' + conditionType.toString() + '1').val()),
        season1: 1,
        activeIndicator1: $('#chkActiveIndicator' + conditionType.toString() + '1').prop("checked"),
        status1: parseInt($('#cmbStatus' + conditionType.toString() + '1').combobox('getValue')),
        settingTemp1: parseInt($('#numSettingTemp' + conditionType.toString() + '1').numberspinner('getValue')),
        mode1: parseInt($('#cmbMode' + conditionType.toString() + '1').combobox('getValue')),
        fanSpeed1: parseInt($('#cmbFanSpeed' + conditionType.toString() + '1').combobox('getValue')),
        id2: parseInt($('#hidID' + conditionType.toString() + '2').val()),
        season2: 2,
        activeIndicator2: $('#chkActiveIndicator' + conditionType.toString() + '2').prop("checked"),
        status2: parseInt($('#cmbStatus' + conditionType.toString() + '2').combobox('getValue')),
        settingTemp2: parseInt($('#numSettingTemp' + conditionType.toString() + '2').numberspinner('getValue')),
        mode2: parseInt($('#cmbMode' + conditionType.toString() + '2').combobox('getValue')),
        fanSpeed2: parseInt($('#cmbFanSpeed' + conditionType.toString() + '2').combobox('getValue')),
        id3: parseInt($('#hidID' + conditionType.toString() + '3').val()),
        season3: 3,
        activeIndicator3: $('#chkActiveIndicator' + conditionType.toString() + '3').prop("checked"),
        status3: parseInt($('#cmbStatus' + conditionType.toString() + '3').combobox('getValue')),
        settingTemp3: parseInt($('#numSettingTemp' + conditionType.toString() + '3').numberspinner('getValue')),
        mode3: parseInt($('#cmbMode' + conditionType.toString() + '3').combobox('getValue')),
        fanSpeed3: parseInt($('#cmbFanSpeed' + conditionType.toString() + '3').combobox('getValue'))

    };

    //    $.ajax({
    //        url: "/AirConditionControl/SaveAirControlRoomNoBody/",
    //        type: "POST",
    //        data: { "How": "close", "Temperature": 30 },
    //        success: function (r) {
    //        }
    //    });

    //    var pf = { "How": "close", "Temperature": 30 };
    //    $.tools.post(pf, "/AirConditionControl/SaveAirControlRoomNoBody/", function (r) {
    //        if (r.IsSuccess) {
    //            $.tools.alert("aaaaaaa");
    //        }
    // 
    //    });
    $.tools.post(params, "/AirConditionControl/SaveAirControl/", function (r) {
        if (r.IsSuccess) {
            $('#hidID' + conditionType.toString() + "1").val(r.ID1);
            $('#hidID' + conditionType.toString() + "2").val(r.ID2);
            $('#hidID' + conditionType.toString() + "3").val(r.ID3);
            $("#nobodyroomid").val(r.ID4);
        }
        $.tools.alert(r.Message);
    });


}

function InitData() {
    //initPage();
    $.tools.ajaxLoading(lang.LoadingData);
    $.ajax({
        url: "/AirConditionControl/LoadSeason/",
        type: "GET",
        success: function (r) {
            if (r.Data != null && r.Data != "") {
                $("#cbxMonth1").combobox("select", r.Data.Month1);
                $("#cbxMonth2").combobox("select", r.Data.Month2);
                $("#cbxMonth3").combobox("select", r.Data.Month3);
                $("#cbxMonth4").combobox("select", r.Data.Month4);
                $("#cbxMonth5").combobox("select", r.Data.Month5);
                $("#cbxMonth6").combobox("select", r.Data.Month6);
                $("#cbxMonth7").combobox("select", r.Data.Month7);
                $("#cbxMonth8").combobox("select", r.Data.Month8);
                $("#cbxMonth9").combobox("select", r.Data.Month9);
                $("#cbxMonth10").combobox("select", r.Data.Month10);
                $("#cbxMonth11").combobox("select", r.Data.Month11);
                $("#cbxMonth12").combobox("select", r.Data.Month12);
            }
            if (r.AirControlData != null) {
                for (var i = 0; i < r.AirControlData.length; i++) {
                    $('#hidID' + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).val(r.AirControlData[i].ID);
                    $('#chkActiveIndicator' + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).attr('checked', r.AirControlData[i].ActiveIndicator);
                    $("#cmbStatus" + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).combobox("select", r.AirControlData[i].Status);
                    $('#numSettingTemp' + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).numberspinner('setValue', r.AirControlData[i].SettingTemp);
                    $("#cmbMode" + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).combobox("select", r.AirControlData[i].Mode);
                    $("#cmbFanSpeed" + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).combobox("select", r.AirControlData[i].FanSpeed);
                    $("#cmbDelayTime" + r.AirControlData[i].ConditionType.toString() + r.AirControlData[i].Season.toString()).combobox("select", r.AirControlData[i].DelayTime);
                }
            }
            if (r.HotelData != null) {
                if (r.HotelData.StartDayTime != null) {
                    $("#txtMorning").combobox("select", r.HotelData.StartDayTime);
                }
                if (r.HotelData.EndDayTime != null) {
                    $("#txtAfternoon").combobox("select", r.HotelData.EndDayTime);
                }
            }

            if (r.RoomNoBodyHowTo != null) {
                var q1 = r.RoomNoBodyHowTo;
                var h2 = q1.How;
                var t2 = q1.Temperature;
                var tid = q1.ID;
                var dtime = q1.DelayTime;

                $("#nobodyroomid").val(tid);
                if (h2 == "close") {
                    $("#Radio1").prop("checked", true);
                }
                else if (h2 == "monitor") {
                    $("#Radio2").prop("checked", true);
                }
                else if (h2 == "without") {
                    $("#Radio3").prop("checked", true);
                }
                else { }

                var ele = $("#wendu_id option[value='" + t2 + "']");
                var t1 = ele.prop("selected", true);

                var delaytime = $("#DelayTimeId option[value='" + dtime + "']");
                var tss = delaytime.prop("selected", true);

            }

            if (r.ECO_Setting != null) {
                var qq = r.ECO_Setting;
                var tid = qq.ID;
                var st = qq.StartTime;
                var et = qq.EndTime;
                var add_minus = qq.AddOrCutDown;
                var a_v = qq.ActValue;
                var enable = qq.IsEnable;

                $("#ecoid").val(tid);
                $('#txtstarttime').timespinner('setValue', st);
                $('#txtendtime').timespinner('setValue', et);

                if (add_minus == "add") {
                    $("#sheng").prop("checked", true);
                }
                else if (add_minus == "minus") {
                    $("#jiang").prop("checked", true);
                }
                else { }

                $("#tiaowen_value").combobox("select", a_v);
                var tss = $("#id_eco_enable").prop("checked", enable);

            }


            if (r.LieECOList != null) {
                var Len = r.LieECOList.length;
                console.log(Len);
                R = r.LieECOList[0];
                FuZhi(R, 1);

                R1 = r.LieECOList[1];
                FuZhi(R1, 2);

                R2 = r.LieECOList[2];
                FuZhi(R2, 3);
                console.log(R2);

                R3 = r.LieECOList[3];
                FuZhi(R3, 4);

                R4 = r.LieECOList[4];
                FuZhi(R4, 5);
            }
            if(r.TimerECO!=null)
            {
                R = r.TimerECO[0];
                TimerECOFuZhi(R, 1);

                R1 = r.TimerECO[1];
                TimerECOFuZhi(R1, 2);

                R2 = r.TimerECO[2];
                TimerECOFuZhi(R2, 3);
                console.log(R2);
            }

            $.tools.ajaxLoadEnd();
        },
        error: function () {
            $.tools.ajaxLoadEnd();
            $.tools.alert(lang.LoadingDataError);
        }
    });
}


function TimerECOFuZhi(R, i) {
    if (R) {
        var st = R.StartTime;
        var RelativeValue = R.RelativeValue;
        var IsEnable = R.IsEnable;

        $('#kt_timer_starttime' + i).timespinner('setValue', st);
        $("#ID_KT_DingShi"+i).combobox("select", RelativeValue);
        if (IsEnable == true) {
            var tss = $("#id_KT_Timer_enable" + i).prop("checked", IsEnable);
        }
    }
}

$(function () {
    InitData();
});


function FuZhi(R, i) {
    if (R) {
        var tid = R.ID;
        var st = R.StartTime;
        var et = R.EndTime;
        console.log(R);

        console.log(st);
        console.log(et);
        var AbsEnable = R.AbsEnable;
        var AbsValue = R.AbsValue;

        var RelativeValue = R.RelativeValue;
        var RelativeEnable = R.RelativeEnable;

        var IsEnable = R.IsEnable;
        var DelayTime = R.DelayTime;
        var HotelCode = R.HotelCode;
        var HotelID = R.HotelID;
        var CreateTime = R.CreateTime;

        $("#LieECOID"+i).val(tid);

        $('#starttime' + i).timespinner('setValue', st);
        $('#endtime' + i).timespinner('setValue', et);

        if (AbsEnable == true) {
            $("#id_abs_enable" + i).prop("checked", true);
            $("#guding_value"+i).combobox("select", AbsValue);
        }

        if (RelativeEnable == true) {
            $("#idrelative"+i).prop("checked", true);
            $("#xiangduitiaowen_value"+i).combobox("select", RelativeValue);
        }
        if (IsEnable == true) {
            var tss = $("#id_LieECO_enable" + i).prop("checked", IsEnable);
        }
        let uus="#delaytime_value"+i.toString();
        $(uus).val(DelayTime);
    }
}
/*

function cbxModalIDOnSelect(r) {
if (r) {
$("#txtNo").textbox("setValue", r.No);
$("#txtControlType").textbox("setValue", r.ControlTypeName);

if (r.ControlType == 0) {
//二管制时禁用
$("#cbxColdHotMode").combobox("disable");
$("#txtDeadTemp").numberspinner("disable");
$("#txtHotDevition").numberspinner("disable");
$("#txtColdDevition").numberspinner("disable");
} else {
//四管制时启用
$("#cbxColdHotMode").combobox("enable");
$("#txtDeadTemp").numberspinner("enable");
$("#txtHotDevition").numberspinner("enable");
$("#txtColdDevition").numberspinner("enable");
}
}
}

function send() {
var filter = getFilterParams();
if (filter.roomTypeID == "") {
$.tools.alert(lang.PSRT);
return;
}
var formData = $("#airForm").serializeJson();
if (formData.ModalTypeID == "") {
$.tools.alert(lang.PSTAC);
return;
}
if ($("#airForm").form("enableValidation").form("validate")) {
var params = {};
$.extend(formData, {
IsLockTemp: $("#chkIsLockTemp").is(":checked"),
LockTemp: $("#txtLockTemp").numberspinner("getValue"),
ColdHotMode: $("#cbxColdHotMode").combobox("getValue"),
DeadTemp: $("#txtDeadTemp").numberspinner("getValue"),
HotDevition: $("#txtHotDevition").numberspinner("getValue"),
ColdDevition: $("#txtColdDevition").numberspinner("getValue"),
RelateRoomStatus: $("#chkRelateRoomStatus").is(":checked"),
RelateDoorContact: $("#chkRelateDoorContact").is(":checked"),
FanStop: $("#chkFanStop").is(":checked"),
DisableFanHighSpeed: $("#chkDisableFanHighSpeed").is(":checked"),
SleepFlag: $("#chkSleepFlag").is(":checked"),
SleepStartTime: $("#txtSleepStartTime").timespinner("getValue"),
SleepEndTime: $("#txtSleepEndTime").timespinner("getValue"),
SleepDevition: $("#txtSleepDevition").numberspinner("getValue"),
TimeFlag: $("#chkTimeFlag").is(":checked"),
TimeStartTime1: $("#txtTimeStartTime1").timespinner("getValue"),
TimeEndTime1: $("#txtTimeEndTime1").timespinner("getValue"),
TimeStartTime2: $("#txtTimeStartTime2").timespinner("getValue"),
TimeEndTime2: $("#txtTimeEndTime2").timespinner("getValue"),
TimeStartTime3: $("#txtTimeStartTime3").timespinner("getValue"),
TimeEndTime3: $("#txtTimeEndTime3").timespinner("getValue")
});
$.extend(params, getFilterParams(), { jsonAirConditionSetting: JSON.stringify(formData) });
$.tools.post(params, "/AirConditionControl/Send/");
}
}
//空调单个属性下发
function setAirProperty(property, status) {
var filter = getFilterParams();
if (filter.roomTypeID == '') {
$.tools.alert(lang.PSRT);
return;
}
var airNo = $('#cbxModalID').combobox('getValue');
if (airNo == '') {
$.tools.alert(lang.PSTAC);
}
var params = $.extend({ airNo: airNo, Property: property, Status: status }, filter);
$.tools.post(params, "/AirConditionControl/SetAirProperty/");
}
//冷热模式
function setAirMode() {
var status = $('#cbxMode').combobox('getValue');
setAirProperty('Mode', status);
}
//手自动模式
function setAirHotColdMode() {
var status = $('#cbxColdHotMode').combobox('getValue');
setAirProperty('ColdHotMode', status);
}
//设置温度
function setAirSettingTemp() {
var status = $('#txtSettingTemp').numberspinner('getValue');
setAirProperty('SettingTemp', status);
}
//风速
function setAirSpeed() {
var status = $('#cbxSpeed').combobox('getValue');
setAirProperty('Speed', status);
}
//保温温度
function setAirKeepTemp() {
var status = $('#txtKeepTemp').numberspinner('getValue');
setAirProperty('KeepTemp', status);
}
//初始温度
function setAirInitTemp() {
var status = $('#txtInitTemp').numberspinner('getValue');
setAirProperty('InitTemp', status);
}
//死区温度
function setAirDeadTemp() {
var status = $('#txtDeadTemp').numberspinner('getValue');
setAirProperty('DeadTemp', status);
}
//最低温度
function setAirLowerTemp() {
var status = $('#txtLowerTemp').numberspinner('getValue');
setAirProperty('LowerTemp', status);
}
//最高温度
function setAirHighTemp() {
var status = $('#txtHighTemp').numberspinner('getValue');
setAirProperty('HighTemp', status);
}
//热偏差
function setAirHotDevition() {
var status = $('#txtHotDevition').numberspinner('getValue');
setAirProperty('HotDevition', status);
}
//冷偏差
function setAirColdDevition() {
var status = $('#txtColdDevition').numberspinner('getValue');
setAirProperty('ColdDevition', status);
}
//冷热转换延时
function setAirColdHotSwitchDelayTime() {
var status = $('#txtColdHotSwitchDelayTime').numberspinner('getValue');
setAirProperty('ColdHotSwitchDelayTime', status);
}
//欢迎模式时间
function setAirWelcomeTime() {
var status = $('#txtWelcomeTime').numberspinner('getValue');
setAirProperty('WelcomeTime', status);
}
//关联房态
function setAirRelateRoomStatus() {
var status = $('#chkRelateRoomStatus').is(':checked');
setAirProperty('RelateRoomStatus', status ? 1 : 0);
}
//关联门磁
function setAirRelateDoorContact() {
var status = $('#chkRelateDoorContact').is(':checked');
setAirProperty('RelateDoorContact', status ? 1 : 0);
}
//温度到达停止风机运行
function setAirFanStop() {
var status = $('#chkFanStop').is(':checked');
setAirProperty('FanStop', status ? 1 : 0);
}
function setAirDisableFanHighSpeed() {
var status = $('#chkDisableFanHighSpeed').is(':checked');
setAirProperty('DisableFanHighSpeed', status ? 1 : 0);
}
//补偿温度
function setAirCompensatoryTemp() {
var filter = getFilterParams();
if (filter.roomTypeID == '') {
$.tools.alert(lang.PSRT);
return;
}
var airNo = $('#cbxModalID').combobox('getValue');
if (airNo == '') {
$.tools.alert(lang.PSTAC);
}
var status = $('#txtCompensatoryTemp').numberspinner('getValue');
var params = $.extend({ airNo: airNo, Status: status }, filter);
$.tools.post(params, "/AirConditionControl/SetAirCompensatoryTemp/");
}
function setAirLockTemp() {
var filter = getFilterParams();
if (filter.roomTypeID == '') {
$.tools.alert(lang.PSRT);
return;
}
var airNo = $('#cbxModalID').combobox('getValue');
if (airNo == '') {
$.tools.alert(lang.PSTAC);
}
var isLock = $('#chkIsLockTemp').is(':checked');
var lockTemp = $('#txtLockTemp').numberspinner('getValue');
var params = $.extend({ airNo: airNo, isLock: isLock, lockTemp: lockTemp }, filter);
$.tools.post(params, "/AirConditionControl/SetAirLockTemp/");
}
//空调睡眠模式
function setAirSleepMode() {
var filter = getFilterParams();
if (filter.roomTypeID == '') {
$.tools.alert(lang.PSRT);
return;
}
var airNo = $('#cbxModalID').combobox('getValue');
if (airNo == '') {
$.tools.alert(lang.PSTAC);
}
var sleepFlag = $('#chkSleepFlag').is(':checked');
var sleepDevition = $('#txtSleepDevition').numberspinner('getValue');
var sleepStartTime = $('#txtSleepStartTime').timespinner('getValue');
var sleepEndTime = $('#txtSleepEndTime').timespinner('getValue');
var params = $.extend({
AirNo: airNo,
SleepFlag: sleepFlag,
SleepDevition: sleepDevition,
SleepStartTime: sleepStartTime,
SleepEndTime: sleepEndTime
}, filter);
$.tools.post(params, "/AirConditionControl/SetAirSleepMode/");
}
//空调定时设置
function setAirTimeSetting() {
var filter = getFilterParams();
if (filter.roomTypeID == '') {
$.tools.alert(lang.PSTAC);
return;
}
var airNo = $('#cbxModalID').combobox('getValue');
if (airNo == '') {
$.tools.alert(lang.PSTAC);
}
var timeFlag = $('#chkTimeFlag').is(':checked');
var startTime1 = $('#txtTimeStartTime1').numberspinner('getValue');
var endTime1 = $('#txtTimeEndTime1').timespinner('getValue');
var startTime2 = $('#txtTimeStartTime2').numberspinner('getValue');
var endTime2 = $('#txtTimeEndTime2').timespinner('getValue');
var startTime3 = $('#txtTimeStartTime3').numberspinner('getValue');
var endTime3 = $('#txtTimeEndTime3').timespinner('getValue');
var params = $.extend({
AirNo: airNo,
TimeFlag: timeFlag,
StartTime1: startTime1,
EndTime1: endTime1,
StartTime2: startTime2,
EndTime2: endTime2,
StartTime3: startTime3,
EndTime3: endTime3
}, filter);
$.tools.post(params, "/AirConditionControl/SetAirTimeSetting/");
}

function enableLockTemp(enable) {
$("#txtLockTemp").numberspinner(enable ? "enable" : "disable");
}

// 启用/禁用睡眠温度设置
// true/启用，false/禁用
function enableSleep(enable) {
if (enable) {
$("#txtSleepStartTime").timespinner("enable");
$("#txtSleepEndTime").timespinner("enable");
$("#txtSleepDevition").numberspinner("enable");
} else {
$("#txtSleepStartTime").timespinner("disable");
$("#txtSleepEndTime").timespinner("disable");
$("#txtSleepDevition").numberspinner("disable");
}
}

// 启用/禁用空调定时设置
// true/启用，false/禁用
function enableTime(enable) {
if (enable) {
$("#txtTimeStartTime1").timespinner("enable");
$("#txtTimeEndTime1").timespinner("enable");
$("#txtTimeStartTime2").timespinner("enable");
$("#txtTimeEndTime2").timespinner("enable");
$("#txtTimeStartTime3").timespinner("enable");
$("#txtTimeEndTime3").timespinner("enable");
} else {
$("#txtTimeStartTime1").timespinner("disable");
$("#txtTimeEndTime1").timespinner("disable");
$("#txtTimeStartTime2").timespinner("disable");
$("#txtTimeEndTime2").timespinner("disable");
$("#txtTimeStartTime3").timespinner("disable");
$("#txtTimeEndTime3").timespinner("disable");
}
}
function initPage() {
$("#chkIsLockTemp").on("change", function () { enableLockTemp(this.checked); }).change();
$("#chkSleepFlag").on("change", function () { enableSleep(this.checked); }).change();
$("#chkTimeFlag").on("change", function () { enableTime(this.checked); }).change();
}
*/