123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616 |
- var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var realName = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
- //部门id
- var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
- var corp_Id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- var corp_name = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
- //部门名称
- var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
- //父部门id
- var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
- //var colorArr = ["#ff7f50","#87cefa","#da70d6","#32cd32","#6495ed","#ff69b4","#ba55d3","#cd5c5c","#ffa500"];
- var colorArr = ["#6495ed","#ff69b4","#ba55d3","#ff7f50","#87cefa","#da70d6","#32cd32","#cd5c5c","#ffa500"];
- /**
- * 纵向图表
- */
- var fristChart = function(){
- var _this = this;
- _this.chart1 = null;
- _this.chart2 = null;
- //
- var eval_dept_id = "" ,sys_id ="", sysIdData = [],level_id="",eval_id="",project_id = "";
- var chart1Data = [];
- var rightText = "";
-
- function initEvalDeptId(){
- $("#eval_dept_id").OrgSel({"orgOkCallBack":function(){
- eval_dept_id = $("#eval_dept_id").val();
- initSysId();
- }});
- eval_dept_id = corp_Id;
- $("#show_eval_dept_id").val(corp_name);
- $("#eval_dept_id").val(eval_dept_id);
- $("#eval_dept_id_show").val(corp_name);
- initSysId();
- }
-
- function initSysId(){
- console.log(eval_dept_id);
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/getSysIdByDeptId';
- var params = {eval_dept_id:eval_dept_id};
- $.request.query(url,params,function(data){
- console.log(data);
- sysIdData = data;
- $("#sys_id").data("data",{list:data});
- $("#sys_id").render();
- if(data.length != 0){
- sys_id = data[0].value;
- project_id = data[0].FD_OBJECTID;
- $("#sys_id").setValue(sys_id);
- $("#sys_id").render();
- var levelData = getLevelSelect(parseInt(data[0].LEVEL_NUM));
- initLevelId(levelData);
- }else{
- sys_id = "";
- project_id = "";
- initLevelId([]);
- }
- });
- }
-
- function initLevelId(data){
- $("#level_id").data("data",{list:data});
- $("#level_id").render();
- if(data.length != 0){
- level_id = data[0].value;
- $("#level_id").setValue(level_id);
- $("#level_id").render();
- initEvalId();
- }else{
- level_id = "";
- initEvalId();
- }
- }
-
- function initEvalId(){
- //console.log(eval_dept_id);
- //console.log(sys_id);
- //console.log(level_id);
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/setSelectData';
- var params = {
- level : level_id,
- sys_id : sys_id
- };
- $.request.query(url,params,function(data){
- data = data[0].result;
- $("#eval_id").data("data",{list:data});
- $("#eval_id").render();
- if(data.length != 0){
- eval_id = data[0].value;
- $("#eval_id").setValue(eval_id);
- $("#eval_id").render();
- getLongitudinalChartData();
- }else{
- eval_id = "";
- getLongitudinalChartData();
- }
- });
- }
-
- function getLongitudinalChartData(){
- //console.log(eval_dept_id);
- //console.log(sys_id);
- //console.log(level_id);
- //console.log(eval_id);
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/getLongitudinalChartData';
- var params = {
- sys_id:sys_id,
- project_id:project_id,
- eval_id:eval_id
- };
- $.request.query(url,params,function(data){
- if(_this.chart2) _this.chart2.clear();
- //console.log(data);
- chart1Data = data[0].barResult[0].series;
- var option1 = getBarOption(data[0].barResult[0]);
- //console.log("第一个");
- //console.log(option1);
- $.newEcharts().init(function(ec){
- _this.chart1 = ec.init(document.getElementById("left_id"));
- _this.chart1.setOption(option1);
- _this.chart1.on("click",function(params){
- //console.log(params);
- rightText = params.seriesName+params.name;
- var evalId = "";
- var curColor = colorArr[params.seriesIndex];
- //console.log(curColor);
- for(var i=0;i<chart1Data.length;i++){
- if(params.seriesName == chart1Data[i].name){
- evalId = chart1Data[i].eval_id;
- }
- }
- var scorenum = (params.name).split("分")[0];
- getRightChartData(evalId,scorenum,curColor);
- });
- });
- });
- }
-
- function getRightChartData(evalId,scorenum,curColor){
- //console.log(eval_dept_id);
- //console.log(sys_id);
- //console.log(evalId);
- //console.log(scorenum);
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/getRightChartData';
- var params = {
- sys_id:sys_id,
- project_id:project_id,
- evalId:evalId,
- scorenum:scorenum
- };
- $.request.query(url,params,function(data){
- //console.log("1234567");
- //console.log(data);
- var option2 = getBarOption(data[0].barResult[0]);
- option2.title.text = rightText;
- option2.title.subtext = "下级--曲线图";
- option2.series[0].itemStyle.normal.color = curColor;
- option2.series[0].type = "line";
- if(option2.series[0].data.length>9){
- option2.grid.y2 = 130;
- option2.xAxis[0].axisLabel = {
- interval:0,//横轴信息全部显示
- rotate:30,//-30度角倾斜显示
- };
- }else if(option2.series[0].data.length>3){
- option2.grid.y2 = 100;
- option2.xAxis[0].axisLabel = {
- interval:0,//横轴信息全部显示
- rotate:30,//-30度角倾斜显示
- };
- }
- //console.log("第二个");
- //console.log(option2);
- $.newEcharts().init(function(ec){
- _this.chart2 = ec.init(document.getElementById("right_id"));
- _this.chart2.setOption(option2);
- });
- });
- }
-
- function getBarOption(data){
- //console.log(JSON.stringify(data));
- if(JSON.stringify(data) == "{}"){
- return data;
- }
- var option = {};
- var json = {};
- json.text = $("#eval_id").attr("relText");
- json.subtext = $("#level_id").attr("relText")+"下--柱状图";
- json.legendData = [];
- //json.trigger = "item";
- json.tooltipPosition = function(params){
- //console.log(params);
- if(params[0]>267){
- return [params[0]-175,params[1]-60];
- }else{
- return [params[0]+30,params[1]-60];
- }
- };
- json.tooltipFormatter = function(val){
- var aa = val[0]["name"]+"<br/>";
- for(var i=0;i<val.length;i++){
- aa += val[i]["0"]+":"+val[i]["2"]+"%<br/>";
- }
- return aa;
- };
- json.magicType = {show: true, type: ['line', 'bar', 'stack', 'tiled']};
- json.xAxisData = [];
- var xAxisData = data.xAxisData;
- //if(typeof xAxisData == "string") xAxisData = JSON.parse(xAxisData);
- //console.log(xAxisData);
- for(var i=0;i<xAxisData.length;i++){
- if(isNaN(parseInt(xAxisData[i].SCORE))){
- json.xAxisData.push(xAxisData[i].SCORE);
- }else{
- json.xAxisData.push(xAxisData[i].SCORE+"分");
- }
- }
- /*json.max = (Math.ceil(parseInt(data.max)/5)+1)*5;
- json.min = Math.floor(parseInt(data.min)/5)*5;*/
- json.max = parseInt(data.max);
- json.min = parseInt(data.min);
- json.series = [];
- var seriesData = data.series;
- //if(typeof seriesData == "string") seriesData = JSON.parse(seriesData);
- //console.log(seriesData);
- for(i=0;i<seriesData.length;i++){
- json.legendData.push(seriesData[i].name);
- var xData = [];
- var itemData = seriesData[i].data;
- for(var j=0;j<itemData.length;j++){
- xData.push(itemData[j].num);
- }
- var serie = {
- name:seriesData[i].name,
- type:'bar',
- smooth:true,
- barMaxWidth:30,
- data:xData,
- itemStyle: {
- normal: {
- color:colorArr[i],
- label:{
- show:true,
- position:"top",
- formatter: function (param) {
- return param.value == 0? "":param.value+"%";
- },
- textStyle: {
- color: "black",
- fontSize: 12,
- fontStyle: "normal",
- fontWeight: "bold"
- }
- }
- }
- }
- };
- json.series.push(serie);
- }
- option.title = $.getTitle(json);
- option.tooltip = $.getTooltip(json);
- option.legend = $.getLegend(json);
- option.grid = { x : 40,x2 : 10};
- if(json.legendData.length>8){
- option.legend.y = "85%";
- option.grid.y2 = 130;
- option.align = 'right';
- }else if(json.legendData.length>4){
- option.grid.y2 = 100;
- option.align = 'right';
- }
- option.toolbox = $.getToolbox(json);
- option.calculable = true;
- option.xAxis = $.getXAxis(json);
- option.yAxis = $.getYAxis(json);
- option.yAxis[0].axisLabel = {
- formatter: function(val){
- console.log(val);
- if(val==0){
- return "0";
- }else{
- return (val+"%");
- }
- }
- };
- option.series = json.series;
- //console.log(JSON.stringify(option));
- //console.log(option);
- return option;
- }
-
- return {
- init:function(){
- initEvalDeptId();
- $("#eval_dept_id").change(function(){
- eval_dept_id = $(this).attr("relValue");
- initSysId();
- });
- $("#sys_id").change(function(){
- sys_id = $(this).attr("relValue");
- project_id = getCulomValueFromJson(sysIdData,sys_id,"FD_OBJECTID");
- var num = getCulomValueFromJson(sysIdData,sys_id,"LEVEL_NUM");
- var levelData = getLevelSelect(parseInt(num));
- initLevelId(levelData);
- });
- $("#level_id").change(function(){
- level_id = $(this).attr("relValue");
- initEvalId();
- });
- $("#eval_id").change(function(){
- eval_id = $(this).attr("relValue");
- getLongitudinalChartData();
- });
- }
-
- };
-
- }();
- /**
- * 横向图表
- */
- var secondChart = function(){
- var _this = this;
- _this.chart1 = null;
- _this.chart2 = null;
- //
- var eval_dept_id = "" ,sys_id ="", level_id="",eval_id="",project_id = "";
- var projectData = [];
- var deptData = [];
- var sysIdsData = [];
- var rightText = "";
-
- function initDeptAndEvalByTime(){
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/initDeptAndEvalByTime';
- var params = {};
- $.request.query(url,params,function(data){
- console.log(data);
- projectData = data[0].result;
- deptData = data[0].resultdept;
- sysIdsData = data[0].resultSysId;
- //setTimeout(function(){
- initSysId(sysIdsData);
- initDeptidsView(deptData);
- initProjectidsView(projectData,"");
- //},4000);
- });
- }
-
- function initSysId(data){
- var html = '';
- for(var i=0;i<data.length;i++){
- html += ('<div class="sel-item">'
- +' <input type="radio" class="'+data[i].value+'" name="sys_id" id="'+data[i].value+'"/> <label for="'+data[i].value+'">'+data[i].key+'</label>'
- +'</div>');
- }
- $("#sys_id02").html("");
- $("#sys_id02").append(html);
- $("#sys_id02").find(".sel-item input").bind("click",function(){
- var $checked = $("#dept_id02").find("input:checkbox:checked");
- if($checked.length<2){
- var valuse = "";
- if($checked.length==1){
- valuse = $checked.eq(0).attr("id");
- }
- $("#project_id02").parent().show();
- initProjectidsView(projectData,valuse);
- }else{
- $("#project_id02").html("");
- $("#project_id02").parent().hide();
- }
- initLevelId();
- });
- }
-
- function initDeptidsView(data){
- var html = '';
- for(var i=0;i<data.length;i++){
- html += ('<div class="sel-item">'
- +' <input type="checkbox" id="'+data[i].value+'"/> <label for="'+data[i].value+'">'+data[i].key+'</label>'
- +'</div>');
- }
- $("#dept_id02").html("");
- $("#dept_id02").append(html);
- $("#dept_id02").find(".sel-item input").bind("click",function(){
- var $checked = $("#dept_id02").find("input:checkbox:checked");
- if($checked.length<2){
- var valuse = "";
- if($checked.length==1){
- valuse = $checked.eq(0).attr("id");
- }
- $("#sys_id02 input").attr("disabled",false);
- $("#project_id02").parent().show();
- initProjectidsView(projectData,valuse);
- initLevelId();
- }else{
- $("#project_id02").html("");
- $("#project_id02").parent().hide();
- var valuse = "";
- for(var i=0;i<$checked.length;i++){
- valuse += ($checked.eq(i).attr("id")+"|");
- }
- getSysIdsByDeptIds(valuse);
- }
- });
- }
-
- function initProjectidsView(data,delids){
- var html = '';
- $("#project_id02").html("");
- var radioVal = $("input:radio[name='sys_id']:checked").attr("id");
- console.log(!radioVal);
- for(var i=0;i<data.length;i++){
- if(!radioVal || radioVal == data[i].SYS_ID){
- if(delids == data[i].EVAL_DEPT_ID){
- var $html = $('<div class="sel-item">'
- +' <input name="'+data[i].SYS_ID+'" type="checkbox" id="'+data[i].FD_OBJECTID+'"/> <label for="'+data[i].FD_OBJECTID+'">'+data[i].NAME+'</label>'
- +'</div>');
- $html.data("itemData",data[i]);
- $("#project_id02").append($html);
- }
- }
- }
- $("#project_id02").find(".sel-item input").bind("click",function(){
- var itemData = $(this).parent().data("itemData");
- if($(this).attr("checked")){
- $("#project_id02 input").attr("disabled",true);
- $("input[name='"+itemData.SYS_ID+"']").attr("disabled",false);
- }else{
- var $checked = $('#project_id02 input:checkbox:checked');
- if($checked.length!=0){
- $("#project_id02 input").attr("disabled",true);
- }else{
- $("#project_id02 input").attr("disabled",false);
- }
- for(var i=0;i<$checked.length;i++){
- var value = $checked.eq(i).parent().data("itemData").SYS_ID;
- $("input[name='"+value+"']").attr("disabled",false);
- }
- }
- itemData = $('#project_id02 input:checkbox:checked').eq(0).parent().data("itemData");
- if(itemData){
- $("#sys_id02 ."+itemData.SYS_ID).attr("checked",true);
- }else{
- var $radio = $("#sys_id02 input");
- for(var i=0;i<$radio.length;i++){
- $radio.eq(i).attr("checked",false);
- }
- }
- initLevelId();
- });
- }
-
- function getSysIdsByDeptIds(ids){
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/getSysIdsByDeptIds';
- var params = {deptIds : ids};
- $.request.query(url,params,function(data){
- console.log(JSON.stringify(data));
- var $radio = $("#sys_id02 input");
- for(var i=0;i<$radio.length;i++){
- $radio.eq(i).attr("checked",false);
- }
- $("#sys_id02 input").attr("disabled",true);
- for(var i=0;i<data.length;i++){
- $("#sys_id02 ."+data[i].SYS_ID).attr("disabled",false);
- }
- initLevelId();
- });
- }
-
-
- function initLevelId(){
- sys_id = $("input:radio[name='sys_id']:checked").attr("id");
- var levaNum = getCulomValueFromJson(sysIdsData,sys_id,"LEVEL_NUM");
- var data = [];
- if(levaNum != ""){
- data = getLevelSelect(parseInt(levaNum));
- }
- $("#level_id02").data("data",{list:data});
- $("#level_id02").render();
- if(data.length != 0){
- level_id = data[0].value;
- }else{
- level_id = "";
- }
- $("#level_id02").setValue(level_id);
- $("#level_id02").render();
- initEvalId();
- }
-
- function initEvalId(){
- var url = $.pathname() + '/ws/scoreGrade/ScoreService/setSelectData';
- var params = {
- level : level_id,
- sys_id : sys_id
- };
- $.request.query(url,params,function(data){
- data = data[0].result;
- $("#eval_id02").data("data",{list:data});
- $("#eval_id02").render();
- if(data.length != 0){
- eval_id = data[0].value;
- }else{
- eval_id = "";
- }
- $("#eval_id02").setValue(eval_id);
- $("#eval_id02").render();
- console.log("开始请求数据");
-
- });
- }
-
-
- return {
- init : function(){
- initDeptAndEvalByTime();
- $("#level_id02").change(function(){
- level_id = $(this).attr("relValue");
- initEvalId();
- });
- $("#eval_id02").change(function(){
- eval_id = $(this).attr("relValue");
-
- });
- }
- };
-
- }();
- //启动函数
- $(function(){
- $(".toggle-btn").live("click",function(){
- console.log(this);
- var _this = $(this);
- if(_this.hasClass("toggle-btn-hide")){
- _this.removeClass("toggle-btn-hide");
- }else{
- _this.addClass("toggle-btn-hide");
- }
- _this.next().slideToggle(200);
- setTimeout(function(){
- if(_this.hasClass("new-cont")){
- _this.removeClass("new-cont");
- if(_this.html().trim() == "评估结果横向比较:"){
- secondChart.init();
- }
- if(_this.html().trim() == "评估结果平均分比较:"){
- //threeChart.init();
- }
- }
- setPageHeight();
- },200);
- });
- $("#tabContId02").bind("actived",function(ele,i){
- //console.log(ele);
- //console.log(i);
- });
- fristChart.init();
- setPageHeight();
- });
- function setPageHeight(){
- $(parent.document.body).find("#frmright").css("height",$(window.document.body).height()+30);
- }
- function getLevelSelect(numb){
- var resutl = [];
- for(var i=0;i<numb-2;i++){
- var json = {key:NumbToChina(i)+"级项目",value:i};
- if(i==0){
- json = {key:"评估体系",value:0};
- }
- resutl.push(json);
- }
- //console.log(resutl);
- return resutl;
- }
- //通过数字转化成汉字
- function NumbToChina(numb){
- var result = "";
- switch (numb) {
- case 1: result = "一"; break;
- case 2: result = "两"; break;
- case 3: result = "三"; break;
- case 4: result = "四"; break;
- case 5: result = "五"; break;
- case 6: result = "六"; break;
- case 7: result = "七"; break;
- case 8: result = "八"; break;
- case 9: result = "九"; break;
- case 10: result = "十"; break;
- default: break;
- }
- return result;
- }
- function getCulomValueFromJson(arr,value,coloum){
- var result = "";
- for(var i=0;i<arr.length;i++){
- if(arr[i].value == value){
- result = arr[i][coloum];
- }
- }
- return result;
- }
|