distributionStats.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. var myChart = echarts.init(document.getElementById('attendanceStatsChar'),'walden');
  2. $(function() {
  3. $(document).ready(function() {
  4. attendanceStatssearch();
  5. });
  6. });
  7. function attendanceStatssearch(){
  8. handleAjaxSimple("distributionStatsController.do?distributionStatsData", $("#attendanceStatsForm").serialize(), handleSuccess);
  9. }
  10. function handleSuccess(data){
  11. if(data.cdata.noData){
  12. $(".content").hide();
  13. $("#uptb").hide();
  14. $("#upbg").hide();
  15. $("#upexport").hide();
  16. $(".err-info").show();
  17. }else{
  18. $(".content").show();
  19. $(".err-info").hide();
  20. //$("#upBtn").show();
  21. $("#uptb").show();
  22. $("#upbg").show();
  23. var srcstr = $("#uptb").attr("src");
  24. if(srcstr.indexOf("tb1.png") < 0){
  25. $("#upexport").show();
  26. }
  27. var pid = $("#pid").val();
  28. var str = "公司";
  29. if(pid != null && pid != ''){
  30. str = $("#departname").val();
  31. }
  32. var charheadStr;
  33. var attType = $("#attType").val();
  34. if(attType == 0 ){
  35. charheadStr =$("#curYear").val()+"年"+$("#attMonth").val()+"月"+str+"岗位人力分布";
  36. }else if(attType == 1){
  37. var attQuarters = $("#attQuarters").val();
  38. if(attQuarters == 1){
  39. charheadStr = $("#curYear").val()+"年一季度(01月-03月)"+str+"岗位人力分布";
  40. }else if(attQuarters == 2){
  41. charheadStr = $("#curYear").val()+"年二季度(04月-06月)"+str+"岗位人力分布";
  42. }else if(attQuarters == 3){
  43. charheadStr = $("#curYear").val()+"年三季度(07月-09月)"+str+"岗位人力分布";
  44. }else {
  45. charheadStr = $("#curYear").val()+"年四季度(10月-12月)"+str+"岗位人力分布";
  46. }
  47. }else if(attType == 2){
  48. charheadStr = $("#curYear").val()+"年度"+str+"岗位人力分布";
  49. }
  50. $("#upcharheaddiv").html(charheadStr);
  51. initCharDate(data);
  52. initNdateList(data.tdata);
  53. }
  54. }
  55. function initNdateList(data){
  56. var attType = $("#attType").val();
  57. var peopleNumstr;
  58. if(attType == 0 ){
  59. peopleNumstr ="当月岗位总人数";
  60. }else{
  61. peopleNumstr ="每月岗位平均人数";
  62. }
  63. var rolefalg = $("#roleFlag").val();
  64. var pjNamestr;
  65. var pidNamestr;
  66. var colums = [[
  67. {field:'departName',title:'岗位名称',width:150},
  68. {field:'peopleNum',title:peopleNumstr,width:120 ,align:'right',halign:'center'},
  69. {field:'proportion',title:'占比(%)',width:150 ,align:'right',halign:'center' },
  70. ]]
  71. $('#attendanceStatsTable').datagrid({
  72. singleSelect : true,
  73. loadMsg:'数据加载中,请稍后……',
  74. columns:colums,
  75. rownumbers:true,
  76. fitColumns:true
  77. }).datagrid('loadData',data);
  78. }
  79. function initCharDate(data){
  80. myChart.clear();
  81. option = {
  82. tooltip: {
  83. trigger: 'item',
  84. formatter: "{a} <br/>{b}: {c} ({d}%)"
  85. },
  86. legend: {
  87. orient: 'vertical',
  88. x: 'left',
  89. data:data.cdata.legend
  90. },
  91. series: [
  92. {
  93. name:'',
  94. type:'pie',
  95. radius: ['50%', '70%'],
  96. avoidLabelOverlap: false,
  97. label: {
  98. normal: {
  99. show: false,
  100. position: 'center'
  101. },
  102. emphasis: {
  103. show: true,
  104. textStyle: {
  105. fontSize: '30',
  106. fontWeight: 'bold'
  107. }
  108. }
  109. },
  110. labelLine: {
  111. normal: {
  112. show: false
  113. }
  114. },
  115. data:data.datamap
  116. }
  117. ]
  118. };
  119. myChart.setOption(option);
  120. myChart.resize();
  121. }
  122. function showTabel(){
  123. $("#attendanceStatsChar").hide();
  124. $("#tablediv").show();
  125. $("#upexport").show();
  126. $("#uptb").attr("src","images/tb.png");
  127. $("#upbg").attr("src","images/bg1.png");
  128. //$("#attendanceStatsTable").datagrid("resize")
  129. var h=$(".content").height();
  130. $('#attendanceStatsTable').datagrid('resize', {
  131. height :h-50
  132. });
  133. }
  134. function showChar(){
  135. $("#tablediv").hide();
  136. $("#attendanceStatsChar").show();
  137. $("#upexport").hide();
  138. $("#uptb").attr("src","images/tb1.png");
  139. $("#upbg").attr("src","images/bg.png");
  140. myChart.resize();
  141. }
  142. function exportExcel(flag){
  143. var opts;
  144. if(flag == 1){
  145. opts = $('#attendanceStatsTable').datagrid('getColumnFields'); //这是获取到所有的FIELD
  146. }else{
  147. opts = $('#attendanceStatsTable2').datagrid('getColumnFields'); //这是获取到所有的FIELD
  148. }
  149. var exceltitles=[];
  150. for(i=0;i<opts.length;i++)
  151. {
  152. //var col = $('div[class$="'+opts[i]+'"] :not(.datagrid-sort-icon)').html();
  153. var col = $('td[field="'+opts[i]+'"] div :not(.datagrid-sort-icon)').html();
  154. exceltitles.push(col);//把TITLEPUSH到数组里去
  155. }
  156. var formdom = '<form method="post" id="formdom" action="distributionStatsController.do?exportExcel"><input name="flag" value="'+flag+'" /><input name="exceltitles" value="'+exceltitles+'" /><input name="exceltitleIds" value="'+opts+'" /></form>';
  157. $("#export").html(formdom);
  158. $("#formdom").submit();
  159. }