var result, chartSimulate;
|
$(document).ready( onDocumentReady );
|
|
function onDocumentReady() {
|
result={achieve:4000, growth:2000, access:1000, kpi:1500};
|
bindEvent();
|
initAchieve();
|
initGrowth();
|
initAccess();
|
initKpi();
|
pageInit(showSimulate);
|
}
|
|
function bindEvent() {
|
$("#input_achieve_rate").change(onAchieveRateChange);
|
$("#input_achieve_actual").change(onAchieveActualChange);
|
$("#input_growth_rate").change(onGrowthRateChange);
|
$("#input_growth_actual").change(onGrowthActualChange);
|
$("#input_access_1").change(refreshAccess);
|
$("#input_access_2").change(refreshAccess);
|
}
|
|
function initAchieve() {
|
var w=innerWidth-60;
|
var option={
|
from: 50,
|
to: 150,
|
step: 5,
|
scale: [50, 75, 100, 125, 150],
|
format: '%s%',
|
width: w,
|
showLabels: true,
|
showScale: true,
|
onstatechange:refreshAchieveRate
|
};
|
$('#range_achieve_rate').jRange(option);
|
refreshAchieveRate();
|
}
|
|
function initGrowth() {
|
var w=innerWidth-60;
|
var option={
|
from: 0,
|
to: 100,
|
step: 5,
|
scale: [0, 25, 50, 75, 100],
|
format: '%s%',
|
width: w,
|
showLabels: true,
|
showScale: true,
|
onstatechange:refreshGrowthRate
|
};
|
$('#range_growth_rate').jRange(option);
|
refreshGrowthRate();
|
}
|
|
function initAccess() {
|
refreshAccess();
|
}
|
|
function initKpi() {
|
var option={
|
from: 1,
|
to: 5,
|
step: 1,
|
scale: [1, 2, 3, 4, 5],
|
format: '%s分',
|
width: 140,
|
showLabels: true,
|
showScale: true,
|
onstatechange:refreshKpi
|
};
|
$('#range_kpi_1').jRange(option);
|
$('#range_kpi_2').jRange(option);
|
$('#range_kpi_3').jRange(option);
|
refreshKpi();
|
}
|
|
function refreshSimulate() {
|
$("#page_simulate").show();
|
$("#div_simulate_achieve").html(format(result.achieve));
|
$("#div_simulate_growth").html(format(result.growth));
|
$("#div_simulate_access").html(format(result.access));
|
$("#div_simulate_kpi").html(format(result.kpi));
|
result.total=result.achieve+result.growth+result.access+result.kpi;
|
$("#div_simulate_total").html(format(result.total));
|
|
var data=[
|
{label:"达成奖", color:"#F7464A", highlight:"#FF5A5E"},
|
{label:"增长奖", color:"#46BFBD", highlight:"#5AD3D1"},
|
{label:"进院奖", color: "#FDB45C", highlight: "#FFC870"},
|
{label:"行为奖", color: "#8291E3", highlight: "#92A1FF"}
|
];
|
|
data[0].value=Math.floor(result.achieve*100/result.total);
|
data[1].value=Math.floor(result.growth*100/result.total);
|
data[2].value=Math.floor(result.access*100/result.total);
|
data[3].value=Math.floor(result.kpi*100/result.total);
|
|
if (chartSimulate) {
|
chartSimulate.destroy();
|
}
|
var ctx=$("#canvas_simulate_chart").get(0).getContext("2d");
|
var option={percentageInnerCutout:40, tooltipTemplate:"<%=label%>: <%= value %>%",};
|
chartSimulate=new Chart(ctx).Doughnut(data, option);
|
}
|
|
function showSimulate() {
|
menuSwitch("simulate");
|
refreshSimulate();
|
}
|
|
|
/************ ACHIEVE **************/
|
|
|
function showAchieve() {
|
pageGo("achieve");
|
}
|
|
function refreshAchieveRate() {
|
var rate=$("#range_achieve_rate").val();
|
$("#input_achieve_rate").val(rate);
|
onAchieveRateChange();
|
}
|
|
function onAchieveRateChange() {
|
var target=parseInt($("#input_achieve_target").val());
|
var rate=parseInt($("#input_achieve_rate").val());
|
var base=parseInt($("#input_achieve_base").val());
|
var actual=Math.floor(target*rate/100);
|
result.achieve=Math.floor(base*rate/100);
|
$("#input_achieve_actual").val(actual);
|
$("#div_achieve_result").html(format(result.achieve));
|
}
|
|
function onAchieveActualChange() {
|
var target=parseInt($("#input_achieve_target").val());
|
var actual=parseInt($("#input_achieve_actual").val());
|
var base=parseInt($("#input_achieve_base").val());
|
var rate=Math.floor(actual*100/target);
|
result.achieve=Math.floor(base*rate/100);
|
$("#div_achieve_result").html(format(result.achieve));
|
$("#input_achieve_rate").val(rate);
|
$("#range_achieve_rate").val(rate);
|
}
|
|
/************ GROWTH **************/
|
|
function showGrowth() {
|
pageGo("growth");
|
}
|
|
function refreshGrowthRate() {
|
var rate=$("#range_growth_rate").val();
|
$("#input_growth_rate").val(rate);
|
onGrowthRateChange();
|
}
|
|
function onGrowthRateChange() {
|
var base=parseInt($("#input_growth_base").val());
|
var rate=parseInt($("#input_growth_rate").val());
|
var ratio=parseInt($("#input_growth_ratio").val());
|
var actual=Math.floor(base*(100+rate)/100);
|
result.growth=Math.max(Math.floor(rate*ratio),0);
|
$("#input_growth_actual").val(actual);
|
$("#div_growth_result").html(format(result.growth));
|
}
|
|
function onGrowthActualChange() {
|
var base=parseInt($("#input_growth_base").val());
|
var actual=parseInt($("#input_growth_actual").val());
|
var ratio=parseInt($("#input_growth_ratio").val());
|
var rate=Math.floor(actual*100/base-100);
|
result.growth=Math.max(Math.floor(rate*ratio),0);
|
$("#div_growth_result").html(format(result.growth));
|
$("#input_growth_rate").val(rate);
|
$("#range_growth_rate").val(rate);
|
}
|
|
/************ ACCESS **************/
|
|
function showAccess() {
|
pageGo("access");
|
}
|
|
function refreshAccess() {
|
var access1=parseInt($("#input_access_1").val());
|
var access2=parseInt($("#input_access_2").val());
|
result.access=access1*200+access2*100;
|
$("#div_access_result").html(format(result.access));
|
}
|
|
|
/************ KPI **************/
|
|
function showKpi() {
|
pageGo("kpi");
|
}
|
|
function refreshKpi() {
|
var kpi1=parseInt($("#range_kpi_1").val());
|
var kpi2=parseInt($("#range_kpi_2").val());
|
var kpi3=parseInt($("#range_kpi_3").val());
|
result.kpi=(kpi1+kpi2+kpi3)*100;
|
$("#div_kpi_result").html(format(result.kpi));
|
}
|
|
/************* Enquiry ************/
|
function showEnquiry() {
|
menuSwitch("enquiry");
|
var title=["季度", "奖项", "目标", "实际"];
|
var width=["20%", "30%", "25%", "25%"];
|
$("#div_enquiry_field").html(field(title, width));
|
|
var html="";
|
for (var q=1; q<=4; q++) {
|
html+=div("div_row", cell("","20%")+cell("达成奖","30%")+cell("4,000","25%","right")+cell("4,800","25%","right","#0090FF") );
|
html+=div("div_row", cell("","20%")+cell("增长奖","30%")+cell("2,000","25%","right")+cell("2,400","25%","right","#0090FF") );
|
html+=div("div_row", cell("","20%")+cell("进院奖","30%")+cell("1,000","25%","right")+cell("1,000","25%","right","#0090FF") );
|
html+=div("div_row", cell("","20%")+cell("行为奖","30%")+cell("1,500","25%","right")+cell("1,500","25%","right","#0090FF") );
|
html+=div("div_row_blue",
|
cell(q+"季度","20%")+cell("季度合计","30%")+cell("8,500","25%","right")+cell("9,700","25%","right","#0090FF") );
|
}
|
$("#div_enquiry_sheet").html(html);
|
}
|
|
function showAppeals() {
|
menuSwitch("appeals");
|
}
|
|
function setQuarter(i) {
|
toggleSwitch("quarter", i);
|
}
|
|
function setComponent(i) {
|
toggleSwitch("component", i);
|
}
|