function toggleHandlebarLink(openTitle, closeTitle) {
|
jQuery(escapeVfId('Page:rightBlock')).toggleClass('sidebarCollapsed');
|
if (jQuery(escapeVfId('Page:rightBlock')).hasClass('sidebarCollapsed')) {
|
jQuery('#handlebarLink').attr('title', openTitle);
|
document.cookie = "peSidebar=0;";
|
} else {
|
jQuery('#handlebarLink').attr('title', closeTitle);
|
document.cookie = "peSidebar=1;";
|
}
|
}
|
function defaultSidebarToggle() {
|
if (document.cookie) {
|
var cookies = document.cookie.split("; ");
|
for (var i = 0; i < cookies.length; i++) {
|
var str = cookies[i].split("=");
|
// Page:rightBlockを制御、1:開、0:閉
|
if (str[0] == "peSidebar" && str[1] == "0") {
|
jQuery(escapeVfId('Page:rightBlock')).toggleClass('sidebarCollapsed');
|
jQuery('#handlebarLink').attr('title', '单击打开侧栏');
|
}
|
}
|
}
|
}
|
function windowResize() {
|
blockHeight = jQuery(window).innerHeight() - jQuery(escapeVfId('Page:Form')).height() - jQuery('#tabCommentPop').height() - 50;
|
jQuery('#in_Tab').css('height', blockHeight + 'px');
|
jQuery('#in_Tab_container').css('height', jQuery('#in_Tab').height() + 2 + 'px');
|
jQuery(escapeVfId('Page:rightBlock')).css('max-height', (jQuery('#in_Tab_container').height() + 50) + 'px');
|
}
|
function tabHighlight() {
|
if (peTabRange != "") {
|
var range = peTabRange.split(",");
|
for (var i = 0; i < range.length; i++) {
|
//jQuery(escapeVfId('Page:Form2:tab' + range[i] + '_lbl')).css('background-color', 'yellow');
|
jQuery(escapeVfId('Page:Form2:tab' + range[i] + '_lbl')).css('color', 'red');
|
}
|
}
|
}
|
/*
|
http://www.mediacollege.com/internet/javascript/form/limit-characters.html
|
*/
|
function limitText(limitField, limitNum) {
|
var limitCount = jQuery(limitField).parent().children('input.countdown');
|
limitCount = limitCount[0];
|
if (limitField.value.length > limitNum) {
|
limitField.value = limitField.value.substring(0, limitNum);
|
} else {
|
limitCount.value = limitNum - limitField.value.length;
|
}
|
}
|
|
function saveTabComment(pBtn) {
|
var jBtn = jQuery(pBtn);
|
var jPop = jBtn.parent();
|
var pTab = jPop.attr("tab");
|
jBtn.hide();
|
var limitField = jPop.children('textarea.limitedtextarea');
|
limitField = limitField[0];
|
var limitFieldValue = limitField.value;
|
if (limitFieldValue.length > 0) {
|
var pUser = jQuery(escapeVfId('Page:Form:selectUser')).val();
|
var pProvinceUser = jQuery(escapeVfId('Page:Form2:userForComment_lkid')).val();
|
// 省チェック
|
var pProvince = "";
|
if (pProvince != undefined && pProvince != "" && pProvinceUser == "000000000000000") {
|
alert("必须选择用户");
|
jBtn.show();
|
return;
|
}
|
limitField.value = "发送中...";
|
|
var oldScroll = jQuery("#in_Tab")[0].contentWindow.document.body.scrollTop;
|
// 上に移動
|
jQuery("#in_Tab")[0].contentWindow.document.body.scrollTop = 0;
|
var body = jQuery("#in_Tab").contents().find('body');
|
html2canvas(body, { onrendered: function(canvas) {
|
// キャプチャ取った後、Scrollを戻す
|
jQuery("#in_Tab")[0].contentWindow.document.body.scrollTop = oldScroll;
|
var imgData = canvas.toDataURL();
|
|
if (pProvince == "") {
|
PersonalEvaluationController.saveComment(pUser, "01210000000RDua", pTab, limitFieldValue, imgData, pTab, "", "", function(res, event) {
|
limitField.value = "";
|
jBtn.show();
|
if(event.status) {
|
PersonalEvaluationController.sendPeEmail(res.Id, function(res2, event2) {
|
if(event2.status) {
|
alert("发送完毕");
|
var jTabF = jQuery("#tabComment");
|
jTabF[0].src = "/apex/PersonalEvaluationCommentList?user=" + pUser + "&tab=" + pTab + "&expand=1&t=" + (new Date()).getTime();
|
} else {
|
alert(event2.message);
|
}}, {buffer: false, escape: true, timeout: 20000});
|
} else {
|
alert(event.message);
|
}}, {buffer: false, escape: true, timeout: 20000});
|
}
|
else {
|
ProvinceEvaluationController.saveComment(pProvinceUser, "01210000000RDua", pTab, limitFieldValue, imgData, pTab, "", "", pProvince, function(res, event) {
|
limitField.value = "";
|
jBtn.show();
|
if(event.status) {
|
PersonalEvaluationController.sendPeEmail(res.Id, function(res2, event2) {
|
if(event2.status) {
|
alert("发送完毕");
|
var jTabF = jQuery("#tabComment");
|
jTabF[0].src = "/apex/PersonalEvaluationCommentList?user=" + pUser + "&tab=" + pTab + "&expand=1&t=" + (new Date()).getTime();
|
} else {
|
alert(event2.message);
|
}}, {buffer: false, escape: true, timeout: 20000});
|
} else {
|
alert(event.message);
|
}}, {buffer: false, escape: true, timeout: 20000});
|
}
|
}, width: 1000});
|
} else {
|
jBtn.show();
|
}
|
}
|
|
/*******************************************************************************/
|
// jqPlot にて グラフを描画
|
tick1KFmt = function (format, val) {
|
if (val == 0) return 0;
|
var num = val/1000;
|
var numStr = String(Math.round(num * 10) /10).replace( /(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
|
if (numStr == "0") {
|
return Math.round(val * 10) /10;
|
} else {
|
return numStr + "K";
|
}
|
};
|
targetPercent2Fmt = function (val1, targetSum) {
|
if (targetSum == 0) return "0";
|
return "" + (Math.round(val1 * 10000 / targetSum) / 100);
|
};
|
targetPercentFmt = function (val1, targetSum) {
|
if (targetSum == 0) return "0";
|
return "" + (Math.round(val1 * 100 / targetSum));
|
};
|
jQuery(document).ready(function() {
|
var selectedTab = jQuery('#selectedTab').val();
|
if (selectedTab != 'TabNameJ') return;
|
var pUser = jQuery(escapeVfId('Page:Form:selectUser')).val();
|
var currentfiscalyear = '{!$Label.Current_fiscalyear}';
|
var loadError = null;
|
var jLoading = jQuery('div.jqplot-target > div.loadingMask');
|
if (jLoading.size() == 0) return; // 対象がありません
|
var sapMap = null;
|
PersonalEvaluationController.getJsonSAP('', pUser,currentfiscalyear, function(res, event) {
|
if(event.status) {
|
sapMap = eval("("+res+")");
|
} else {
|
loadError = event.message;
|
}
|
}, {buffer: true, escape: false, timeout: 120000});
|
var oppSumMap = null;
|
PersonalEvaluationController.getJsonOppSum('', pUser, function(res, event) {
|
if(event.status) {
|
oppSumMap = eval("("+res+")");
|
} else {
|
loadError = event.message;
|
}
|
}, {buffer: true, escape: false, timeout: 120000});
|
var saMap = null;
|
PersonalEvaluationController.getJsonMBSA('', pUser, function(res, event) {
|
if(event.status) {
|
saMap = eval("("+res+")");
|
} else {
|
loadError = event.message;
|
}
|
}, {buffer: true, escape: false, timeout: 120000});
|
var forcastList = null;
|
PersonalEvaluationController.getJsonForcast('', pUser, function(res, event) {
|
if(event.status) {
|
var forcastMapList = eval("("+res+")");
|
forcastList = [];
|
for (var i = 0; i < forcastMapList.length; i++) {
|
for (var k in forcastMapList[i]) {
|
forcastList.push([k, forcastMapList[i][k]]);
|
}
|
}
|
} else {
|
loadError = event.message;
|
}
|
}, {buffer: true, escape: false, timeout: 120000});
|
|
var check = function() {
|
if(loadError != null || (sapMap != null && oppSumMap != null && saMap != null && forcastList != null)) {
|
if (loadError == null) {
|
var targetMap = sapMap.Target_wt;
|
var shipMap = sapMap.Ship_wt;
|
var bOrdMap = sapMap.BackOrder_wt;
|
var targetNumMap = sapMap.Target_num;
|
var shipNumMap = sapMap.Ship_num;
|
var bOrdNumMap = sapMap.BackOrder_num;
|
// 正常
|
jLoading.hide();
|
// run when condition is met
|
var targetSum = 0;
|
var targetNum = 0;
|
for ( var key in targetMap) {
|
targetSum += targetMap[key];
|
targetNum += targetNumMap[key];
|
}
|
targetMap = jQuery.extend({GI:0,ET:0,BF:0,GS:0,URO:0,GYN:0,ENT:0,OTH:0}, targetMap);
|
var shipSum = 0;
|
var shipNum = 0;
|
for ( var key in shipMap) {
|
shipSum += shipMap[key];
|
shipNum += shipNumMap[key];
|
}
|
shipMap = jQuery.extend({GI:0,ET:0,BF:0,GS:0,URO:0,GYN:0,ENT:0,OTH:0}, shipMap);
|
var bOrdSum = 0;
|
var bOrdNum = 0;
|
for ( var key in bOrdMap) {
|
bOrdSum += bOrdMap[key];
|
bOrdNum += bOrdNumMap[key];
|
}
|
bOrdMap = jQuery.extend({GI:0,ET:0,BF:0,GS:0,URO:0,GYN:0,ENT:0,OTH:0}, bOrdMap);
|
|
// chart1
|
if (jQuery("#chart1").size() > 0)
|
var plot1 = jQuery.jqplot('chart1', [[targetPercent2Fmt(shipSum, targetSum)]], {
|
title: personalEvaluationMap[0]['Report1_1_Name__c'],
|
grid: {
|
drawGridLines:true,
|
background: 'white',
|
borderWidth: 2.0,
|
borderColor: '#999999'
|
},
|
seriesDefaults: {
|
renderer: jQuery.jqplot.MeterGaugeRenderer,
|
rendererOptions: {
|
min: 0,
|
max: 100,
|
label: targetPercent2Fmt(shipSum, targetSum) + ' %',
|
labelPosition: 'bottom',
|
intervals:[50, 70, 100],
|
intervalColors:['#cc6666', '#E7E658', '#66cc66']
|
}
|
}
|
});
|
// chart2
|
var oppBase = shipSum + bOrdSum;
|
var oppBid = oppBase + oppSumMap.oppBid.wt;
|
var oppAuth = oppBid + oppSumMap.oppAuth.wt;
|
var oppA = oppAuth + oppSumMap.oppA.wt * 0.8;
|
var oppB = oppA + oppSumMap.oppB.wt * 0.5;
|
var oppC = oppB + oppSumMap.oppC.wt * 0.3;
|
// Can specify a custom tick Array.
|
var c2ticks = ['目标', '发货', '注残', '已中标', '已授权', 'A', 'B', 'C'];
|
var plot2Data = [[targetSum,0,0,0,0,0,0,0], [0,shipSum,0,0,0,0,0,0], [0,0,oppBase,0,0,0,0,0], [0,0,0,oppBid,0,0,0,0], [0,0,0,0,oppAuth,0,0,0], [0,0,0,0,0,oppA,0,0], [0,0,0,0,0,0,oppB,0], [0,0,0,0,0,0,0,oppC]];
|
if (jQuery("#chart2").size() > 0)
|
var plot2 = jQuery.jqplot('chart2', plot2Data, {
|
// title: personalEvaluationMap[0]['Report1_2_Name__c'],
|
grid: {shadow: false, background: 'white'},
|
stackSeries: true,
|
seriesDefaults: {
|
renderer: jQuery.jqplot.BarRenderer,
|
rendererOptions: {
|
// Put a 5 pixel margin between bars.
|
barMargin: 10
|
},
|
pointLabels: {hideZeros: true, stackedValue: true}
|
},
|
axes: {
|
xaxis: {
|
renderer: jQuery.jqplot.CategoryAxisRenderer,
|
ticks: c2ticks
|
},
|
yaxis: {
|
// Don't pad out the bottom of the data range. By default,
|
// axes scaled as if data extended 10% above and below the
|
// actual range to prevent data points right on grid boundaries.
|
// Don't want to do that here.
|
min: 0,
|
tickOptions: {formatter: tick1KFmt}
|
}
|
},
|
legend: {
|
labels: ['%', targetPercentFmt(shipSum,targetSum), targetPercentFmt(oppBase,targetSum),
|
targetPercentFmt(oppBid,targetSum), targetPercentFmt(oppAuth,targetSum),
|
targetPercentFmt(oppA,targetSum), targetPercentFmt(oppB,targetSum),
|
targetPercentFmt(oppC,targetSum)],
|
// labels: ['-', ''+shipNum, ''+bOrdNum, ''+oppSumMap.oppBid.num, ''+oppSumMap.oppAuth.num, ''+oppSumMap.oppA.num, ''+oppSumMap.oppB.num, ''+oppSumMap.oppC.num],
|
show: true,
|
marginTop: 0,
|
placement: 'outsideGrid',
|
location: 'n',
|
renderer: jQuery.jqplot.EnhancedLegendRenderer,
|
rendererOptions: {
|
numberColumns: 8,
|
seriesToggle: false
|
}
|
}
|
});
|
|
// chart3
|
// Can specify a custom tick Array.
|
var c3ticks = ['GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'OTH'];
|
var sumYP = targetSum - shipSum - bOrdSum; if (sumYP < 0) sumYP = 0;
|
var sumGI = targetMap.GI - shipMap.GI - bOrdMap.GI; if (sumGI < 0) sumGI = 0;
|
var sumET = targetMap.ET - shipMap.ET - bOrdMap.ET; if (sumET < 0) sumET = 0;
|
var sumBF = targetMap.BF - shipMap.BF - bOrdMap.BF; if (sumBF < 0) sumBF = 0;
|
var sumGS = targetMap.GS - shipMap.GS - bOrdMap.GS; if (sumGS < 0) sumGS = 0;
|
var sumURO = targetMap.URO - shipMap.URO - bOrdMap.URO; if (sumURO < 0) sumURO = 0;
|
var sumGYN = targetMap.GYN - shipMap.GYN - bOrdMap.GYN; if (sumGYN < 0) sumGYN = 0;
|
var sumENT = targetMap.ENT - shipMap.ENT - bOrdMap.ENT; if (sumENT < 0) sumENT = 0;
|
var sumOTH = targetMap.OTH - shipMap.OTH - bOrdMap.OTH; if (sumOTH < 0) sumOTH = 0;
|
var plot3Data = [[[1,shipMap.GI, 0], [2,shipMap.ET], [3,shipMap.BF], [4,shipMap.GS], [5,shipMap.URO], [6,shipMap.GYN], [7,shipMap.ENT], [8,shipMap.OTH]],
|
[[1,bOrdMap.GI, 0], [2,bOrdMap.ET], [3,bOrdMap.BF], [4,bOrdMap.GS], [5,bOrdMap.URO], [6,bOrdMap.GYN], [7,bOrdMap.ENT], [8,bOrdMap.OTH]],
|
[[1,sumGI,sumGI], [2,sumET,sumET], [3,sumBF,sumBF], [4,sumGS,sumGS], [5,sumURO,sumURO], [6,sumGYN,sumGYN], [7,sumENT,sumENT], [8,sumOTH,sumOTH]]
|
];
|
if (jQuery("#chart3").size() > 0)
|
var plot3 = jQuery.jqplot('chart3', plot3Data, {
|
title: personalEvaluationMap[0]['Report1_3_Name__c'],
|
grid: {shadow: false, background: 'white'},
|
stackSeries: true,
|
series: [
|
{color: '#EAA228'},
|
{color: '#c5b47f'},
|
{color: 'white'} // #fffdf6
|
],
|
seriesDefaults: {
|
renderer: jQuery.jqplot.BarRenderer,
|
rendererOptions: {
|
// Put a 5 pixel margin between bars.
|
barMargin: 10
|
},
|
pointLabels: {
|
show: true, hideZeros: true, stackedValue: true,
|
ypadding: -1,
|
location: 'n'
|
}
|
},
|
axes: {
|
xaxis: {
|
renderer: jQuery.jqplot.CategoryAxisRenderer,
|
ticks: c3ticks
|
},
|
yaxis: {
|
// Don't pad out the bottom of the data range. By default,
|
// axes scaled as if data extended 10% above and below the
|
// actual range to prevent data points right on grid boundaries.
|
// Don't want to do that here.
|
min:0,
|
tickOptions: {formatter: tick1KFmt}
|
}
|
},
|
legend: {
|
show: false,
|
}
|
});
|
|
// chart4
|
if (jQuery("#chart4").size() > 0)
|
var plot4 = jQuery.jqplot('chart4',
|
[[['订单数', saMap.Order], ['未付款数', saMap.NClct], ['无用户合同书', saMap.NCtrc]]],
|
{
|
title: personalEvaluationMap[0]['Report5_1_Name__c'],
|
grid: {shadow: false, background: 'white'},
|
axes: {
|
xaxis: {
|
renderer: jQuery.jqplot.CategoryAxisRenderer,
|
}
|
},
|
seriesDefaults: {
|
renderer: jQuery.jqplot.BarRenderer,
|
pointLabels: {
|
show: true, hideZeros: true,
|
ypadding: -1,
|
location: 'n'
|
},
|
rendererOptions: {
|
barWidth: 40,
|
varyBarColor: true
|
}
|
}
|
});
|
|
// chart7
|
if (jQuery("#chart7").size() > 0)
|
var plot7 = jQuery.jqplot('chart7', [forcastList], {
|
title: personalEvaluationMap[0]['Report6_1_Name__c'],
|
grid: {shadow: false, background: 'white'},
|
axes: {
|
xaxis: {
|
renderer: jQuery.jqplot.CategoryAxisRenderer,
|
},
|
yaxis: {
|
tickOptions: {formatString:'%d'}
|
}
|
},
|
seriesDefaults: {
|
renderer: jQuery.jqplot.BarRenderer,
|
pointLabels: {
|
show: true, hideZeros: true,
|
ypadding: -1,
|
location: 'n'
|
}
|
}
|
});
|
|
// chart8
|
var c8ticks = ['已中标', '已授权', 'A', 'B', 'C', 'D', 'E'];
|
var plot8Data = [[Math.floor(oppSumMap.oppBid.num),0,0,0,0,0,0],
|
[0,Math.floor(oppSumMap.oppAuth.num),0,0,0,0,0], [0,0,Math.floor(oppSumMap.oppA.num),0,0,0,0],
|
[0,0,0,Math.floor(oppSumMap.oppB.num),0,0,0],[0,0,0,0,Math.floor(oppSumMap.oppC.num),0,0],
|
[0,0,0,0,0,Math.floor(oppSumMap.oppD.num),0], [0,0,0,0,0,0,Math.floor(oppSumMap.oppE.num)]];
|
if (jQuery("#chart8").size() > 0)
|
var plot8 = jQuery.jqplot('chart8', plot8Data, {
|
title: personalEvaluationMap[0]['Report6_2_Name__c'],
|
grid: {shadow: false, background: 'white'},
|
stackSeries: true,
|
series: [
|
{color: '#579575'},
|
{color: '#839557'},
|
{color: '#958c12'},
|
{color: '#953579'},
|
{color: '#4b5de4'},
|
{color: '#d8b83f'},
|
{color: '#ff5800'}
|
],
|
seriesDefaults: {
|
renderer: jQuery.jqplot.BarRenderer,
|
rendererOptions: {
|
// Put a 5 pixel margin between bars.
|
barMargin: 10
|
},
|
pointLabels: {show: true, hideZeros: true, stackedValue: true}
|
},
|
axes: {
|
xaxis: {
|
renderer: jQuery.jqplot.CategoryAxisRenderer,
|
ticks: c8ticks
|
},
|
yaxis: {
|
// Don't pad out the bottom of the data range. By default,
|
// axes scaled as if data extended 10% above and below the
|
// actual range to prevent data points right on grid boundaries.
|
// Don't want to do that here.
|
padMin: 0,
|
tickOptions: {formatString:'%d'}
|
}
|
},
|
});
|
} else {
|
// Error
|
jLoading.children('div.loadingPanel').hide();
|
jLoading.children('span.loadingMsg').text("报表未返回结果。");
|
if (loadError == 'Unable to connect to the server (communication failure).') {
|
// なにもしない
|
} else {
|
alert(loadError);
|
}
|
}
|
}
|
else {
|
setTimeout(check, 1000); // check again in a second
|
}
|
}
|
// ここは最後
|
check();
|
});
|