CustomSearchCharts.js 4.5 KB
$(function () {
    //设置charts区域的高度
    var chartsHight = $(window).height() - $("#top").height() - 30
    $("#charts").height(chartsHight);
    $("#chartsview").height(chartsHight);
    //详细表单隐藏和显示,默认为隐藏
    if ($("#dataFrom option:selected").val() == 1) {
        $("#customSql").parent().parent().hide();
    }
    //开启帮助提示
    $(".help").wTooltip({html: true});

    //检查必填
    if($("#title").length > 0 && $("#width").length > 0  && $("#name").length > 0  && $("#showorder").length > 0 ){
        checkinput("title", "titleimage");
        checkinput("width", "widthimage");
        checkinput("name", "nameimage");
        checkinput("showorder", "showorderimage");
    }
    window.onresize = function () {
        setTimeout(function(){
            var chartsHight = $(window).height() - $("#top").height() - 5;
            $("#showCharts").height(chartsHight);
            $("#chartsview").height(chartsHight);
        },300);

    };
});

/**
 * 移除详细图表
 * @param clos 当前div
 * @param message 提示信息
 * @param chartsId 图表的数据ID
 */
function removeChart(clos, message, chartsId) {
    window.Dialog.confirm(message, function () {
        $(clos).parent(".main").remove();
        //删除详细图表后台数据
        $.post('/formmode/search/CustomSeachCharts.jsp', {
            'chartsId': chartsId,
            'action': 'delChart'
        }, function () {
        });
    })
}

/**
 * 数据源切换change事件
 */
$("#dataFrom").change(function () {
    if ($("#dataFrom option:selected").val() == 1) {
        $("#customSql").parent().parent().hide();
        $("#xAxis").parent().parent().show();
        $("#yAxis").parent().parent().show();
        $("#groupField").parent().parent().show();
        $("#calculateType").parent().parent().show();
    } else {
        $("#xAxis").parent().parent().hide();
        $("#yAxis").parent().parent().hide();
        $("#groupField").parent().parent().hide();
        $("#calculateType").parent().parent().hide();
        $("#customSql").parent().parent().show();
    }
});

/**
 * 保存图表主信息
 */
function doSave() {
    if (check_form(base, 'title') && check_form(base, 'width')) {
        $.post('/formmode/search/CustomSeachCharts.jsp', {
            'customid': $("#customid").val(),
            'title': $("#title").val(),
            'width': $("#width").val(),
            'isExpand': $("#isExpand").val(),
            'isEnable': $("#isEnable").val(),
            'action': 'saveBase'
        }, function () {
            location.reload();
        });
    }
}

/**
 * 保存图表详细信息
 */
function addChart() {
    if (check_form(detail, 'name') && check_form(detail, 'showorder') && check_form(detail, 'chartsType') && check_form(detail, 'xAxis') && check_form(detail, 'yAxis') && check_form(detail, 'calculateType')) {
        $.post('/formmode/search/CustomSeachCharts.jsp', {
            'baseId': $("#baseId").val(),
            'name': $("#name").val(),
            'showorder': $("#showorder").val(),
            'chartsType': $("#chartsType").val(),
            'dataFrom': $("#dataFrom").val(),
            'xAxis': $("#xAxis").val(),
            'yAxis': $("#yAxis").val(),
            'groupField': $("#groupField").val(),
            'calculateType': $("#calculateType").val(),
            'customSql': $("#customSql").val(),
            'showAvgLine': "1",
            'action': 'addChart'
        }, function () {
            location.reload();
        });
    }
}

/**
 * 显示建模查询列表的统计区域
 * @param customid
 */
function showCharts(customid) {
    $("#showCharts").show();
}

/**
 * 统计区域失去焦点就隐藏
 * @param event
 */
$('body :not(#showCharts)').click(function () {
    $("#showCharts").hide();
})


/**
 * 收缩,展开
 */
function onflagshow(customid) {
    $("#showCharts").show();
    $("#flaghide").show();
    $("#flagshow").hide();
    $("#loading").show();
    $("#loading").html("加载中...");
    var listCondition = document.getElementById("tabcontentframe").contentWindow.document.getElementById("listCondition").value;
    var params = encodeURI('customid='+customid+'&listCondition='+listCondition);
    $("#chartsIframe").attr('src', '/formmode/search/ChartsView.jsp?'+params);
}

function onflaghide() {
    $("#showCharts").hide();
    $("#flagshow").show();
    $("#flaghide").hide();
}

function showConfig(customid) {
    window.open("CustomSeachCharts.jsp?customid="+customid);
}

function loading() {
    $("#loading").hide();
};