kaoqintiaozhengCountdemo.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. var myChart = echarts.init(document.getElementById('reportChar'),'walden');
  2. var myChart2 = echarts.init(document.getElementById('reportChar2'),'walden');
  3. var myChart3 = echarts.init(document.getElementById('reportChar3'),'walden');
  4. option = {
  5. color: ['#3398DB'],
  6. tooltip: {
  7. trigger: 'axis'
  8. },
  9. grid:{
  10. left: '3%',
  11. right: '4%',
  12. bottom: '1%',
  13. containLabel: true
  14. },
  15. legend: {
  16. data:[],
  17. width:'90%',
  18. left:'center'
  19. },
  20. xAxis:
  21. {
  22. type: 'category',
  23. data: [],
  24. axisLabel: {
  25. interval: 0,
  26. formatter:function(value)
  27. {
  28. var ret = "";//拼接加\n返回的类目项
  29. var maxLength = 1;//每项显示文字个数
  30. var valLength = value.length;//X轴类目项的文字个数
  31. var rowN = Math.ceil(valLength / maxLength); //类目项需要换行的行数
  32. if (rowN > 1)//如果类目项的文字大于3,
  33. {
  34. for (var i = 0; i < rowN; i++) {
  35. var temp = "";//每次截取的字符串
  36. var start = i * maxLength;//开始截取的位置
  37. var end = start + maxLength;//结束截取的位置
  38. //这里也可以加一个是否是最后一行的判断,但是不加也没有影响,那就不加吧
  39. temp = value.substring(start, end) + "\n";
  40. ret += temp; //凭借最终的字符串
  41. }
  42. return ret;
  43. }
  44. else {
  45. return value;
  46. }
  47. }
  48. }
  49. },
  50. yAxis: [
  51. {
  52. type: 'value',
  53. name:'考勤调整次数(次)'
  54. }
  55. ],
  56. dataZoom: [
  57. {
  58. type: 'inside',
  59. start: 0,
  60. end: 100
  61. }
  62. ],
  63. series: [
  64. {
  65. name:'',
  66. type:'bar',
  67. data:[]
  68. }
  69. ]
  70. };
  71. option2 = {
  72. color: ['#3398DB'],
  73. tooltip: {
  74. trigger: 'axis'
  75. },
  76. grid:{
  77. left: '3%',
  78. right: '4%',
  79. bottom: '1%',
  80. containLabel: true
  81. },
  82. legend: {
  83. data:[],
  84. width:'90%',
  85. left:'center'
  86. },
  87. xAxis:
  88. {
  89. type: 'category',
  90. data: []
  91. },
  92. yAxis: [
  93. {
  94. type: 'value',
  95. name:'考勤调整次数(次)'
  96. }
  97. ],
  98. dataZoom: [
  99. {
  100. type: 'inside',
  101. start: 0,
  102. end: 100
  103. }
  104. ],
  105. series: [
  106. {
  107. name:'',
  108. type:'bar',
  109. data:[]
  110. }
  111. ]
  112. };
  113. option3 = {
  114. color: ['#3398DB'],
  115. tooltip: {
  116. trigger: 'axis'
  117. },
  118. grid:{
  119. left: '3%',
  120. right: '4%',
  121. bottom: '1%',
  122. containLabel: true
  123. },
  124. legend: {
  125. data:[],
  126. width:'90%',
  127. left:'center'
  128. },
  129. xAxis:
  130. {
  131. type: 'category',
  132. data: []
  133. },
  134. yAxis: [
  135. {
  136. type: 'value',
  137. name:'考勤调整次数(次)'
  138. }
  139. ],
  140. dataZoom: [
  141. {
  142. type: 'inside',
  143. start: 0,
  144. end: 100
  145. }
  146. ],
  147. series: [
  148. {
  149. name:'',
  150. type:'bar',
  151. data:[]
  152. }
  153. ]
  154. };
  155. $(function() {
  156. $(document).ready(function() {
  157. kaoqinsearch();
  158. });
  159. });
  160. function kaoqinsearch(){
  161. handleAjaxSimple("desktopRptController.do?getKaoQinTiaoZhengCount", $("#reportForm").serialize(), handleSuccess);
  162. }
  163. function handleSuccess(data){
  164. if(data.cdata.noData){
  165. $(".content").hide();
  166. $("#uptb").hide();
  167. $("#upbg").hide();
  168. $("#upexport").hide();
  169. $(".err-info").show();
  170. }else{
  171. $(".content").show();
  172. $(".err-info").hide();
  173. //$("#upBtn").show();
  174. $("#uptb").show();
  175. $("#upbg").show();
  176. var srcstr = $("#uptb").attr("src");
  177. if(srcstr.indexOf("tb1.png") < 0){
  178. $("#upexport").show();
  179. }
  180. var rolefalg = $("#roleFlag").val();
  181. var prostr;
  182. prostr = '项目';
  183. // if(rolefalg == 1){
  184. // }else{
  185. // prostr = '部门';
  186. // }
  187. var charheadStr;
  188. var attType = $("#attType").val();
  189. charheadStr =$("#curYear").val()+"年"+$("#attMonth").val()+"月项目考勤调整次数排行榜";
  190. // if(attType == 0 ){
  191. // charheadStr =$("#curYear").val()+"年"+$("#attMonth")+prostr+"";
  192. // }else if(attType == 1){
  193. // var attQuarters = $("#attQuarters").val();
  194. // if(attQuarters == 1){
  195. // charheadStr = $("#curYear").val()+"年一季度(01月-03月)各"+prostr+"工资费用";
  196. // }else if(attQuarters == 2){
  197. // charheadStr = $("#curYear").val()+"年二季度(04月-06月)各"+prostr+"工资费用";
  198. // }else if(attQuarters == 3){
  199. // charheadStr = $("#curYear").val()+"年三季度(07月-09月)各"+prostr+"工资费用";
  200. // }else {
  201. // charheadStr = $("#curYear").val()+"年四季度(10月-12月)各"+prostr+"工资费用";
  202. // }
  203. // }else if(attType == 2){
  204. // charheadStr = $("#curYear").val()+"年度各"+prostr+"工资费用";
  205. // }
  206. $("#upcharheaddiv").html(charheadStr);
  207. initCharDate(data.cdata);
  208. initNdateList(data.tdata);
  209. }
  210. }
  211. function initNdateList(data){
  212. var rolefalg = $("#roleFlag").val();
  213. // if(rolefalg == 1){
  214. // }else{
  215. // pjNamestr = '项目名称';
  216. // pidNamestr='部门名称';
  217. // }
  218. var attType = $("#attType").val();
  219. var peopleTotalStr;
  220. peopleTotalStr="考勤调整次数排行榜";
  221. // if(attType == 0 ){
  222. // }else{
  223. // peopleTotalStr="每月工资平均人数";
  224. // }
  225. var colums = [[
  226. {field:'name',title:'项目名称',width:150},
  227. {field:'count',title:'考勤调整次数(次)',width:150 ,align:'center',halign:'center'},
  228. {field:'total',title:'考勤调整时长(分钟)',width:150,align:'center',halign:'center'}
  229. // {field:'peopleTotal',title:peopleTotalStr,width:150 ,align:'right',halign:'center' },
  230. ]]
  231. $('#reportTable').datagrid({
  232. singleSelect : true,
  233. loadMsg:'数据加载中,请稍后……',
  234. columns:colums,
  235. rownumbers:true,
  236. fitColumns:true
  237. }).datagrid('loadData',data);
  238. }
  239. function initCharDate(data){
  240. myChart.clear();
  241. option.xAxis.data = data.xAxisData;
  242. option.series = data.series;
  243. myChart.setOption(option);
  244. myChart.resize();
  245. }
  246. function showTabel(){
  247. $("#reportChar").hide();
  248. $("#tablediv").show();
  249. $("#upexport").show();
  250. $("#uptb").attr("src","images/tb.png");
  251. $("#upbg").attr("src","images/bg1.png");
  252. //$("#attendanceStatsTable").datagrid("resize");
  253. var h=$(".content").height();
  254. $('#reportTable').datagrid('resize', {
  255. height :h-50
  256. });
  257. }
  258. function showChar(){
  259. $("#tablediv").hide();
  260. $("#reportChar").show();
  261. $("#upexport").hide();
  262. $("#uptb").attr("src","images/tb1.png");
  263. $("#upbg").attr("src","images/bg.png");
  264. myChart.resize();
  265. }
  266. myChart.on('click', function (params) {
  267. console.log(params);
  268. var rolefalg = $("#roleFlag").val();
  269. var attType = $("#attType").val();
  270. // if(rolefalg == 1){
  271. $("#upcharheaddiv2").html(params.name + "-"+$("#curYear").val()+"年"+$("#attMonth").val()+"月考勤调整次数统计");
  272. // $("#upcharheaddiv2").html($("#curYear").val()+"年度项目工资费用");
  273. // if(attType == 2){
  274. var data ={
  275. "attYear" : $("#curYear").val(),
  276. "attMonth" : $("#attMonth").val(),
  277. "pid":params.data.id
  278. };
  279. handleAjaxSimple("desktopRptController.do?getKaoQinTiaoZhengCount", data, showDownChar);
  280. // }
  281. // }
  282. })
  283. myChart2.on('click', function (params) {
  284. console.log(params);
  285. var rolefalg = $("#roleFlag").val();
  286. var attType = $("#attType").val();
  287. // if(rolefalg == 1){
  288. $("#upcharheaddiv3").html(params.name + "-"+$("#curYear").val()+"年"+$("#attMonth").val()+"月考勤调整次数统计");
  289. // $("#upcharheaddiv2").html($("#curYear").val()+"年度项目工资费用");
  290. // if(attType == 2){
  291. var data ={
  292. "attYear" : $("#curYear").val(),
  293. "attMonth" : $("#attMonth").val(),
  294. "deptId":params.data.id
  295. };
  296. handleAjaxSimple("desktopRptController.do?getKaoQinTiaoZhengCount", data, showDown2Char);
  297. // }
  298. // }
  299. })
  300. function goBefore(){
  301. $("#reportChar2").css("display","none");
  302. $("#tablediv2").hide();
  303. $("#searchColums").show();
  304. $("#downcharhead").hide();
  305. $("#reportChar").show();
  306. $("#upcharhead").show();
  307. $("#upcharhead2div").hide();
  308. $("#upBtn").show();
  309. $("#downBtn").hide();
  310. $("#downexport").hide();
  311. $("#downtb").attr("src","images/tb1.png");
  312. $("#downbg").attr("src","images/bg.png");
  313. myChart.resize();
  314. }
  315. function goBefore2(){
  316. $("#reportChar3").css("display","none");
  317. $("#tablediv3").hide();
  318. $("#searchColums").show();
  319. $("#downcharhead").hide();
  320. $("#reportChar2").show();
  321. $("#upcharhead2div").show();
  322. $("#upcharhead3div").hide();
  323. $("#downBtn").show();
  324. $("#downBtn2").hide();
  325. //$("#upBtn").show();
  326. //$("#downBtn").hide();
  327. //$("#downexport").hide();
  328. $("#downtb").attr("src","images/tb1.png");
  329. $("#downbg").attr("src","images/bg.png");
  330. myChart2.resize();
  331. }
  332. //显示下钻图表
  333. function showDownChar(data){
  334. $("#reportChar").css("display","none");
  335. $("#reportChar2").show();
  336. $("#upBtn").hide();
  337. $("#downBtn").show();
  338. $("#searchColums").hide();
  339. $("#downcharhead").show();
  340. $("#upcharhead").hide();
  341. $("#upcharhead2").show();
  342. $("#yearspan2").html($("#curYear").val());
  343. $("#downBtn2").hide();
  344. initDownCharDate(data.cdata);
  345. initDownTabDate(data.tdata);
  346. }
  347. function initDownCharDate(data){
  348. myChart2.clear();
  349. option2.xAxis.data = data.xAxisData;
  350. option2.series = data.series;
  351. myChart2.setOption(option2);
  352. myChart2.resize();
  353. }
  354. function initDownTabDate(data){
  355. var colums = [[
  356. {field:'name',title:'部门名称',width:150},
  357. {field:'count',title:'考勤调整次数(次)',width:150 ,align:'center',halign:'center'},
  358. {field:'total',title:'考勤调整时长(分钟)',width:150,align:'center',halign:'center'}
  359. // {field:'peopleTotal',title:peopleTotalStr,width:150 ,align:'right',halign:'center' },
  360. ]]
  361. $('#reportTable2').datagrid({
  362. singleSelect : true,
  363. loadMsg:'数据加载中,请稍后……',
  364. columns:colums,
  365. rownumbers:true,
  366. fitColumns:true
  367. }).datagrid('loadData',data);
  368. }
  369. //显示下钻图表
  370. function showDown2Char(data){
  371. $("#reportChar2").css("display","none");
  372. $("#reportChar3").show();
  373. $("#upBtn").hide();
  374. $("#downBtn").hide();
  375. $("#searchColums").hide();
  376. $("#downcharhead").show();
  377. $("#upcharhead2").hide();
  378. $("#upcharhead3").show();
  379. $("#yearspan2").html($("#curYear").val());
  380. $("#downBtn2").show();
  381. initDown2CharDate(data.cdata);
  382. initDown2TabDate(data.tdata);
  383. }
  384. function initDown2CharDate(data){
  385. myChart3.clear();
  386. option3.xAxis.data = data.xAxisData;
  387. option3.series = data.series;
  388. myChart3.setOption(option3);
  389. myChart3.resize();
  390. }
  391. function initDown2TabDate(data){
  392. var colums = [[
  393. {field:'name',title:'员工姓名',width:150},
  394. {field:'count',title:'考勤调整次数(次)',width:150 ,align:'center',halign:'center'},
  395. {field:'total',title:'考勤调整时长(分钟)',width:150,align:'center',halign:'center'}
  396. // {field:'peopleTotal',title:peopleTotalStr,width:150 ,align:'right',halign:'center' },
  397. ]]
  398. $('#reportTable3').datagrid({
  399. singleSelect : true,
  400. loadMsg:'数据加载中,请稍后……',
  401. columns:colums,
  402. rownumbers:true,
  403. fitColumns:true
  404. }).datagrid('loadData',data);
  405. }
  406. function showDownTabelBtn(){
  407. $("#reportChar2").hide();
  408. $("#tablediv2").show();
  409. $("#downexport").show();
  410. $("#downtb").attr("src","images/tb.png");
  411. $("#downbg").attr("src","images/bg1.png");
  412. //$("#attendanceStatsTable2").datagrid("resize");
  413. var h=$(".content").height();
  414. $('#reportTable2').datagrid('resize', {
  415. height :h-50
  416. });
  417. }
  418. function showDownCharBtn(){
  419. $("#tablediv2").hide();
  420. $("#downexport").hide();
  421. $("#downtb").attr("src","images/tb1.png");
  422. $("#downbg").attr("src","images/bg.png");
  423. $("#reportChar2").show();
  424. myChart2.resize();
  425. }
  426. function showDownTabelBtn2(){
  427. $("#reportChar3").hide();
  428. $("#tablediv3").show();
  429. $("#downexport").show();
  430. $("#downtb2").attr("src","images/tb.png");
  431. $("#downbg2").attr("src","images/bg1.png");
  432. //$("#attendanceStatsTable2").datagrid("resize");
  433. var h=$(".content").height();
  434. $('#reportTable3').datagrid('resize', {
  435. height :h-50
  436. });
  437. }
  438. function showDownCharBtn2(){
  439. $("#tablediv3").hide();
  440. $("#downexport").hide();
  441. $("#downtb2").attr("src","images/tb1.png");
  442. $("#downbg2").attr("src","images/bg.png");
  443. $("#reportChar3").show();
  444. myChart3.resize();
  445. }
  446. function exportExcel(flag){
  447. var opts;
  448. if(flag == 1){
  449. opts = $('#reportTable').datagrid('getColumnFields'); //这是获取到所有的FIELD
  450. }else{
  451. opts = $('#reportTable2').datagrid('getColumnFields'); //这是获取到所有的FIELD
  452. }
  453. var exceltitles=[];
  454. for(i=0;i<opts.length;i++)
  455. {
  456. //var col = $('div[class$="'+opts[i]+'"] :not(.datagrid-sort-icon)').html();
  457. var col = $('td[field="'+opts[i]+'"] div :not(.datagrid-sort-icon)').html();
  458. exceltitles.push(col);//把TITLEPUSH到数组里去
  459. }
  460. var formdom = '<form method="post" id="formdom" action="desktopRptController.do?exportExcel"><input name="flag" value="'+flag+'" /><input name="exceltitles" value="'+exceltitles+'" /><input name="exceltitleIds" value="'+opts+'" /></form>';
  461. $("#export").html(formdom);
  462. $("#formdom").submit();
  463. }