statis.js 13 KB

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