a0c0593893b129dd2b614ee317124ad56937dbf3.svn-base 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  2. var realName = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  3. //部门id
  4. var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
  5. var corp_Id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  6. var corp_name = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  7. //部门名称
  8. var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
  9. //父部门id
  10. var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
  11. //var colorArr = ["#ff7f50","#87cefa","#da70d6","#32cd32","#6495ed","#ff69b4","#ba55d3","#cd5c5c","#ffa500"];
  12. var colorArr = ["#6495ed","#ff69b4","#ba55d3","#ff7f50","#87cefa","#da70d6","#32cd32","#cd5c5c","#ffa500"];
  13. /**
  14. * 纵向图表
  15. */
  16. var fristChart = function(){
  17. var _this = this;
  18. _this.chart1 = null;
  19. _this.chart2 = null;
  20. //
  21. var eval_dept_id = "" ,sys_id ="", sysIdData = [],level_id="",eval_id="",project_id = "";
  22. var chart1Data = [];
  23. var rightText = "";
  24. function initEvalDeptId(){
  25. $("#eval_dept_id").OrgSel({"orgOkCallBack":function(){
  26. eval_dept_id = $("#eval_dept_id").val();
  27. initSysId();
  28. }});
  29. eval_dept_id = corp_Id;
  30. $("#show_eval_dept_id").val(corp_name);
  31. $("#eval_dept_id").val(eval_dept_id);
  32. $("#eval_dept_id_show").val(corp_name);
  33. initSysId();
  34. }
  35. function initSysId(){
  36. console.log(eval_dept_id);
  37. var url = $.pathname() + '/ws/scoreGrade/ScoreService/getSysIdByDeptId';
  38. var params = {eval_dept_id:eval_dept_id};
  39. $.request.query(url,params,function(data){
  40. console.log(data);
  41. sysIdData = data;
  42. $("#sys_id").data("data",{list:data});
  43. $("#sys_id").render();
  44. if(data.length != 0){
  45. sys_id = data[0].value;
  46. project_id = data[0].FD_OBJECTID;
  47. $("#sys_id").setValue(sys_id);
  48. $("#sys_id").render();
  49. var levelData = getLevelSelect(parseInt(data[0].LEVEL_NUM));
  50. initLevelId(levelData);
  51. }else{
  52. sys_id = "";
  53. project_id = "";
  54. initLevelId([]);
  55. }
  56. });
  57. }
  58. function initLevelId(data){
  59. $("#level_id").data("data",{list:data});
  60. $("#level_id").render();
  61. if(data.length != 0){
  62. level_id = data[0].value;
  63. $("#level_id").setValue(level_id);
  64. $("#level_id").render();
  65. initEvalId();
  66. }else{
  67. level_id = "";
  68. initEvalId();
  69. }
  70. }
  71. function initEvalId(){
  72. //console.log(eval_dept_id);
  73. //console.log(sys_id);
  74. //console.log(level_id);
  75. var url = $.pathname() + '/ws/scoreGrade/ScoreService/setSelectData';
  76. var params = {
  77. level : level_id,
  78. sys_id : sys_id
  79. };
  80. $.request.query(url,params,function(data){
  81. data = data[0].result;
  82. $("#eval_id").data("data",{list:data});
  83. $("#eval_id").render();
  84. if(data.length != 0){
  85. eval_id = data[0].value;
  86. $("#eval_id").setValue(eval_id);
  87. $("#eval_id").render();
  88. getLongitudinalChartData();
  89. }else{
  90. eval_id = "";
  91. getLongitudinalChartData();
  92. }
  93. });
  94. }
  95. function getLongitudinalChartData(){
  96. //console.log(eval_dept_id);
  97. //console.log(sys_id);
  98. //console.log(level_id);
  99. //console.log(eval_id);
  100. var url = $.pathname() + '/ws/scoreGrade/ScoreService/getLongitudinalChartData';
  101. var params = {
  102. sys_id:sys_id,
  103. project_id:project_id,
  104. eval_id:eval_id
  105. };
  106. $.request.query(url,params,function(data){
  107. if(_this.chart2) _this.chart2.clear();
  108. //console.log(data);
  109. chart1Data = data[0].barResult[0].series;
  110. var option1 = getBarOption(data[0].barResult[0]);
  111. //console.log("第一个");
  112. //console.log(option1);
  113. $.newEcharts().init(function(ec){
  114. _this.chart1 = ec.init(document.getElementById("left_id"));
  115. _this.chart1.setOption(option1);
  116. _this.chart1.on("click",function(params){
  117. //console.log(params);
  118. rightText = params.seriesName+params.name;
  119. var evalId = "";
  120. var curColor = colorArr[params.seriesIndex];
  121. //console.log(curColor);
  122. for(var i=0;i<chart1Data.length;i++){
  123. if(params.seriesName == chart1Data[i].name){
  124. evalId = chart1Data[i].eval_id;
  125. }
  126. }
  127. var scorenum = (params.name).split("分")[0];
  128. getRightChartData(evalId,scorenum,curColor);
  129. });
  130. });
  131. });
  132. }
  133. function getRightChartData(evalId,scorenum,curColor){
  134. //console.log(eval_dept_id);
  135. //console.log(sys_id);
  136. //console.log(evalId);
  137. //console.log(scorenum);
  138. var url = $.pathname() + '/ws/scoreGrade/ScoreService/getRightChartData';
  139. var params = {
  140. sys_id:sys_id,
  141. project_id:project_id,
  142. evalId:evalId,
  143. scorenum:scorenum
  144. };
  145. $.request.query(url,params,function(data){
  146. //console.log("1234567");
  147. //console.log(data);
  148. var option2 = getBarOption(data[0].barResult[0]);
  149. option2.title.text = rightText;
  150. option2.title.subtext = "下级--曲线图";
  151. option2.series[0].itemStyle.normal.color = curColor;
  152. option2.series[0].type = "line";
  153. if(option2.series[0].data.length>9){
  154. option2.grid.y2 = 130;
  155. option2.xAxis[0].axisLabel = {
  156. interval:0,//横轴信息全部显示
  157. rotate:30,//-30度角倾斜显示
  158. };
  159. }else if(option2.series[0].data.length>3){
  160. option2.grid.y2 = 100;
  161. option2.xAxis[0].axisLabel = {
  162. interval:0,//横轴信息全部显示
  163. rotate:30,//-30度角倾斜显示
  164. };
  165. }
  166. //console.log("第二个");
  167. //console.log(option2);
  168. $.newEcharts().init(function(ec){
  169. _this.chart2 = ec.init(document.getElementById("right_id"));
  170. _this.chart2.setOption(option2);
  171. });
  172. });
  173. }
  174. function getBarOption(data){
  175. //console.log(JSON.stringify(data));
  176. if(JSON.stringify(data) == "{}"){
  177. return data;
  178. }
  179. var option = {};
  180. var json = {};
  181. json.text = $("#eval_id").attr("relText");
  182. json.subtext = $("#level_id").attr("relText")+"下--柱状图";
  183. json.legendData = [];
  184. //json.trigger = "item";
  185. json.tooltipPosition = function(params){
  186. //console.log(params);
  187. if(params[0]>267){
  188. return [params[0]-175,params[1]-60];
  189. }else{
  190. return [params[0]+30,params[1]-60];
  191. }
  192. };
  193. json.tooltipFormatter = function(val){
  194. var aa = val[0]["name"]+"<br/>";
  195. for(var i=0;i<val.length;i++){
  196. aa += val[i]["0"]+":"+val[i]["2"]+"%<br/>";
  197. }
  198. return aa;
  199. };
  200. json.magicType = {show: true, type: ['line', 'bar', 'stack', 'tiled']};
  201. json.xAxisData = [];
  202. var xAxisData = data.xAxisData;
  203. //if(typeof xAxisData == "string") xAxisData = JSON.parse(xAxisData);
  204. //console.log(xAxisData);
  205. for(var i=0;i<xAxisData.length;i++){
  206. if(isNaN(parseInt(xAxisData[i].SCORE))){
  207. json.xAxisData.push(xAxisData[i].SCORE);
  208. }else{
  209. json.xAxisData.push(xAxisData[i].SCORE+"分");
  210. }
  211. }
  212. /*json.max = (Math.ceil(parseInt(data.max)/5)+1)*5;
  213. json.min = Math.floor(parseInt(data.min)/5)*5;*/
  214. json.max = parseInt(data.max);
  215. json.min = parseInt(data.min);
  216. json.series = [];
  217. var seriesData = data.series;
  218. //if(typeof seriesData == "string") seriesData = JSON.parse(seriesData);
  219. //console.log(seriesData);
  220. for(i=0;i<seriesData.length;i++){
  221. json.legendData.push(seriesData[i].name);
  222. var xData = [];
  223. var itemData = seriesData[i].data;
  224. for(var j=0;j<itemData.length;j++){
  225. xData.push(itemData[j].num);
  226. }
  227. var serie = {
  228. name:seriesData[i].name,
  229. type:'bar',
  230. smooth:true,
  231. barMaxWidth:30,
  232. data:xData,
  233. itemStyle: {
  234. normal: {
  235. color:colorArr[i],
  236. label:{
  237. show:true,
  238. position:"top",
  239. formatter: function (param) {
  240. return param.value == 0? "":param.value+"%";
  241. },
  242. textStyle: {
  243. color: "black",
  244. fontSize: 12,
  245. fontStyle: "normal",
  246. fontWeight: "bold"
  247. }
  248. }
  249. }
  250. }
  251. };
  252. json.series.push(serie);
  253. }
  254. option.title = $.getTitle(json);
  255. option.tooltip = $.getTooltip(json);
  256. option.legend = $.getLegend(json);
  257. option.grid = { x : 40,x2 : 10};
  258. if(json.legendData.length>8){
  259. option.legend.y = "85%";
  260. option.grid.y2 = 130;
  261. option.align = 'right';
  262. }else if(json.legendData.length>4){
  263. option.grid.y2 = 100;
  264. option.align = 'right';
  265. }
  266. option.toolbox = $.getToolbox(json);
  267. option.calculable = true;
  268. option.xAxis = $.getXAxis(json);
  269. option.yAxis = $.getYAxis(json);
  270. option.yAxis[0].axisLabel = {
  271. formatter: function(val){
  272. console.log(val);
  273. if(val==0){
  274. return "0";
  275. }else{
  276. return (val+"%");
  277. }
  278. }
  279. };
  280. option.series = json.series;
  281. //console.log(JSON.stringify(option));
  282. //console.log(option);
  283. return option;
  284. }
  285. return {
  286. init:function(){
  287. initEvalDeptId();
  288. $("#eval_dept_id").change(function(){
  289. eval_dept_id = $(this).attr("relValue");
  290. initSysId();
  291. });
  292. $("#sys_id").change(function(){
  293. sys_id = $(this).attr("relValue");
  294. project_id = getCulomValueFromJson(sysIdData,sys_id,"FD_OBJECTID");
  295. var num = getCulomValueFromJson(sysIdData,sys_id,"LEVEL_NUM");
  296. var levelData = getLevelSelect(parseInt(num));
  297. initLevelId(levelData);
  298. });
  299. $("#level_id").change(function(){
  300. level_id = $(this).attr("relValue");
  301. initEvalId();
  302. });
  303. $("#eval_id").change(function(){
  304. eval_id = $(this).attr("relValue");
  305. getLongitudinalChartData();
  306. });
  307. }
  308. };
  309. }();
  310. /**
  311. * 横向图表
  312. */
  313. var secondChart = function(){
  314. var _this = this;
  315. _this.chart1 = null;
  316. _this.chart2 = null;
  317. //
  318. var eval_dept_id = "" ,sys_id ="", level_id="",eval_id="",project_id = "";
  319. var projectData = [];
  320. var deptData = [];
  321. var sysIdsData = [];
  322. var rightText = "";
  323. function initDeptAndEvalByTime(){
  324. var url = $.pathname() + '/ws/scoreGrade/ScoreService/initDeptAndEvalByTime';
  325. var params = {};
  326. $.request.query(url,params,function(data){
  327. console.log(data);
  328. projectData = data[0].result;
  329. deptData = data[0].resultdept;
  330. sysIdsData = data[0].resultSysId;
  331. //setTimeout(function(){
  332. initSysId(sysIdsData);
  333. initDeptidsView(deptData);
  334. initProjectidsView(projectData,"");
  335. //},4000);
  336. });
  337. }
  338. function initSysId(data){
  339. var html = '';
  340. for(var i=0;i<data.length;i++){
  341. html += ('<div class="sel-item">'
  342. +' <input type="radio" class="'+data[i].value+'" name="sys_id" id="'+data[i].value+'"/> <label for="'+data[i].value+'">'+data[i].key+'</label>'
  343. +'</div>');
  344. }
  345. $("#sys_id02").html("");
  346. $("#sys_id02").append(html);
  347. $("#sys_id02").find(".sel-item input").bind("click",function(){
  348. var $checked = $("#dept_id02").find("input:checkbox:checked");
  349. if($checked.length<2){
  350. var valuse = "";
  351. if($checked.length==1){
  352. valuse = $checked.eq(0).attr("id");
  353. }
  354. $("#project_id02").parent().show();
  355. initProjectidsView(projectData,valuse);
  356. }else{
  357. $("#project_id02").html("");
  358. $("#project_id02").parent().hide();
  359. }
  360. initLevelId();
  361. });
  362. }
  363. function initDeptidsView(data){
  364. var html = '';
  365. for(var i=0;i<data.length;i++){
  366. html += ('<div class="sel-item">'
  367. +' <input type="checkbox" id="'+data[i].value+'"/> <label for="'+data[i].value+'">'+data[i].key+'</label>'
  368. +'</div>');
  369. }
  370. $("#dept_id02").html("");
  371. $("#dept_id02").append(html);
  372. $("#dept_id02").find(".sel-item input").bind("click",function(){
  373. var $checked = $("#dept_id02").find("input:checkbox:checked");
  374. if($checked.length<2){
  375. var valuse = "";
  376. if($checked.length==1){
  377. valuse = $checked.eq(0).attr("id");
  378. }
  379. $("#sys_id02 input").attr("disabled",false);
  380. $("#project_id02").parent().show();
  381. initProjectidsView(projectData,valuse);
  382. initLevelId();
  383. }else{
  384. $("#project_id02").html("");
  385. $("#project_id02").parent().hide();
  386. var valuse = "";
  387. for(var i=0;i<$checked.length;i++){
  388. valuse += ($checked.eq(i).attr("id")+"|");
  389. }
  390. getSysIdsByDeptIds(valuse);
  391. }
  392. });
  393. }
  394. function initProjectidsView(data,delids){
  395. var html = '';
  396. $("#project_id02").html("");
  397. var radioVal = $("input:radio[name='sys_id']:checked").attr("id");
  398. console.log(!radioVal);
  399. for(var i=0;i<data.length;i++){
  400. if(!radioVal || radioVal == data[i].SYS_ID){
  401. if(delids == data[i].EVAL_DEPT_ID){
  402. var $html = $('<div class="sel-item">'
  403. +' <input name="'+data[i].SYS_ID+'" type="checkbox" id="'+data[i].FD_OBJECTID+'"/> <label for="'+data[i].FD_OBJECTID+'">'+data[i].NAME+'</label>'
  404. +'</div>');
  405. $html.data("itemData",data[i]);
  406. $("#project_id02").append($html);
  407. }
  408. }
  409. }
  410. $("#project_id02").find(".sel-item input").bind("click",function(){
  411. var itemData = $(this).parent().data("itemData");
  412. if($(this).attr("checked")){
  413. $("#project_id02 input").attr("disabled",true);
  414. $("input[name='"+itemData.SYS_ID+"']").attr("disabled",false);
  415. }else{
  416. var $checked = $('#project_id02 input:checkbox:checked');
  417. if($checked.length!=0){
  418. $("#project_id02 input").attr("disabled",true);
  419. }else{
  420. $("#project_id02 input").attr("disabled",false);
  421. }
  422. for(var i=0;i<$checked.length;i++){
  423. var value = $checked.eq(i).parent().data("itemData").SYS_ID;
  424. $("input[name='"+value+"']").attr("disabled",false);
  425. }
  426. }
  427. itemData = $('#project_id02 input:checkbox:checked').eq(0).parent().data("itemData");
  428. if(itemData){
  429. $("#sys_id02 ."+itemData.SYS_ID).attr("checked",true);
  430. }else{
  431. var $radio = $("#sys_id02 input");
  432. for(var i=0;i<$radio.length;i++){
  433. $radio.eq(i).attr("checked",false);
  434. }
  435. }
  436. initLevelId();
  437. });
  438. }
  439. function getSysIdsByDeptIds(ids){
  440. var url = $.pathname() + '/ws/scoreGrade/ScoreService/getSysIdsByDeptIds';
  441. var params = {deptIds : ids};
  442. $.request.query(url,params,function(data){
  443. console.log(JSON.stringify(data));
  444. var $radio = $("#sys_id02 input");
  445. for(var i=0;i<$radio.length;i++){
  446. $radio.eq(i).attr("checked",false);
  447. }
  448. $("#sys_id02 input").attr("disabled",true);
  449. for(var i=0;i<data.length;i++){
  450. $("#sys_id02 ."+data[i].SYS_ID).attr("disabled",false);
  451. }
  452. initLevelId();
  453. });
  454. }
  455. function initLevelId(){
  456. sys_id = $("input:radio[name='sys_id']:checked").attr("id");
  457. var levaNum = getCulomValueFromJson(sysIdsData,sys_id,"LEVEL_NUM");
  458. var data = [];
  459. if(levaNum != ""){
  460. data = getLevelSelect(parseInt(levaNum));
  461. }
  462. $("#level_id02").data("data",{list:data});
  463. $("#level_id02").render();
  464. if(data.length != 0){
  465. level_id = data[0].value;
  466. }else{
  467. level_id = "";
  468. }
  469. $("#level_id02").setValue(level_id);
  470. $("#level_id02").render();
  471. initEvalId();
  472. }
  473. function initEvalId(){
  474. var url = $.pathname() + '/ws/scoreGrade/ScoreService/setSelectData';
  475. var params = {
  476. level : level_id,
  477. sys_id : sys_id
  478. };
  479. $.request.query(url,params,function(data){
  480. data = data[0].result;
  481. $("#eval_id02").data("data",{list:data});
  482. $("#eval_id02").render();
  483. if(data.length != 0){
  484. eval_id = data[0].value;
  485. }else{
  486. eval_id = "";
  487. }
  488. $("#eval_id02").setValue(eval_id);
  489. $("#eval_id02").render();
  490. console.log("开始请求数据");
  491. });
  492. }
  493. return {
  494. init : function(){
  495. initDeptAndEvalByTime();
  496. $("#level_id02").change(function(){
  497. level_id = $(this).attr("relValue");
  498. initEvalId();
  499. });
  500. $("#eval_id02").change(function(){
  501. eval_id = $(this).attr("relValue");
  502. });
  503. }
  504. };
  505. }();
  506. //启动函数
  507. $(function(){
  508. $(".toggle-btn").live("click",function(){
  509. console.log(this);
  510. var _this = $(this);
  511. if(_this.hasClass("toggle-btn-hide")){
  512. _this.removeClass("toggle-btn-hide");
  513. }else{
  514. _this.addClass("toggle-btn-hide");
  515. }
  516. _this.next().slideToggle(200);
  517. setTimeout(function(){
  518. if(_this.hasClass("new-cont")){
  519. _this.removeClass("new-cont");
  520. if(_this.html().trim() == "评估结果横向比较:"){
  521. secondChart.init();
  522. }
  523. if(_this.html().trim() == "评估结果平均分比较:"){
  524. //threeChart.init();
  525. }
  526. }
  527. setPageHeight();
  528. },200);
  529. });
  530. $("#tabContId02").bind("actived",function(ele,i){
  531. //console.log(ele);
  532. //console.log(i);
  533. });
  534. fristChart.init();
  535. setPageHeight();
  536. });
  537. function setPageHeight(){
  538. $(parent.document.body).find("#frmright").css("height",$(window.document.body).height()+30);
  539. }
  540. function getLevelSelect(numb){
  541. var resutl = [];
  542. for(var i=0;i<numb-2;i++){
  543. var json = {key:NumbToChina(i)+"级项目",value:i};
  544. if(i==0){
  545. json = {key:"评估体系",value:0};
  546. }
  547. resutl.push(json);
  548. }
  549. //console.log(resutl);
  550. return resutl;
  551. }
  552. //通过数字转化成汉字
  553. function NumbToChina(numb){
  554. var result = "";
  555. switch (numb) {
  556. case 1: result = "一"; break;
  557. case 2: result = "两"; break;
  558. case 3: result = "三"; break;
  559. case 4: result = "四"; break;
  560. case 5: result = "五"; break;
  561. case 6: result = "六"; break;
  562. case 7: result = "七"; break;
  563. case 8: result = "八"; break;
  564. case 9: result = "九"; break;
  565. case 10: result = "十"; break;
  566. default: break;
  567. }
  568. return result;
  569. }
  570. function getCulomValueFromJson(arr,value,coloum){
  571. var result = "";
  572. for(var i=0;i<arr.length;i++){
  573. if(arr[i].value == value){
  574. result = arr[i][coloum];
  575. }
  576. }
  577. return result;
  578. }