//@ sourceURL=data_util.js

$(function () {
    //修改病人医嘱时间
    $('#btn_1').click(function () {
        $("#btn_1Modal").modal();
    });

    //调整护理记录单病室
    $('#btn_2').click(function () {
        $("#btn_2Modal").modal();
    });

    $(".selectpicker").selectpicker({
        dropuAuto: false
    });

    $("#save_btn_1").click(function (t) {
        if (!confirm("小工具修复数据会改变数据状态，确认数据填写无误且保存吗？")) {
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=UTF-8",
            url: "/thmz/setYzActOrderDate",
            dataType: 'json',
            data: JSON.stringify({
                "orderTime": $("#orderTime").val(),
                "enterTime":$("#enterTime").val(),
                "startTime":$("#startTime").val(),
                "endTime":$("#endTime").val(),
                "confirmTime":$("#confirmTime").val(),
                "statusTime":$("#statusTime").val(),
                "performanceTime":$("#performanceTime").val(),
                "inpatientNo":$("#inpatientNo").val(),
                "actOrderNos":$("#actOrderNo").val()
            }),
            headers:{'Accept': 'application/json','Authorization':'Bearer '+ localStorage.getItem("token")},
            success: function(result) {
                if(result=='401' || result==401){
                    window.location.href='/thmz/login/view'
                    return;
                }
                if(result.code == 0) {
                    successMesage(result);
                    $("#btn_1Modal").modal("hide");
                } else {
                    errorMesage(result);
                }
            }
        });
    });


    $("#save_btn_2").click(function (t) {
        if (!confirm("小工具修复数据会改变数据状态，确认数据填写无误且保存吗？")) {
            return;
        }
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=UTF-8",
            url: "/thmz/setTemperatureWard",
            dataType: 'json',
            data: JSON.stringify({
                "ward": $("#deptNoParam").val(),
                "inpatientNo":$("#inpatientNo2").val(),
                "detailNos":$("#detailNos").val()
            }),
            headers:{'Accept': 'application/json','Authorization':'Bearer '+ localStorage.getItem("token")},
            success: function(result) {
                if(result=='401' || result==401){
                    window.location.href='/thmz/login/view'
                    return;
                }
                if(result.code == 0) {
                    successMesage(result);
                    $("#btn_2Modal").modal("hide");
                } else {
                    errorMesage(result);
                }
            }
        });
    });

    initListDeptSelect();

});






/**
 * 入院登记的病区列表
 */
function initListDeptSelect() {
    //科室列表
    $.ajax({
        type: "GET",
        url: '/thmz/allInpatientWard',
        dataType: "json",
        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
        success: function (data) {
            if (data == '401' || data == 401) {
                window.location.href = '/thmz/login/view'
                return;
            }
            var html = '';
            $.each(data.data, function (commentIndex, comment) {
                html += '<option value="' + comment.code + '">' + comment.name + '(' + comment.pyCode + ')</option>';
            });
            $('#deptNoParam').empty();
            $('#deptNoParam').html(html);
            $('#deptNoParam').selectpicker('refresh');
        }
    });
}


