index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /**
  2. * Created by xuxueli on 17/4/24.
  3. */
  4. $(function () {
  5. // filter Time
  6. var rangesConf = {};
  7. rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')];
  8. rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')];
  9. rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')];
  10. rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')];
  11. rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks'), moment()];
  12. rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months'), moment()];
  13. $('#filterTime').daterangepicker({
  14. autoApply:false,
  15. singleDatePicker:false,
  16. showDropdowns:false, // 是否显示年月选择条件
  17. timePicker: true, // 是否显示小时和分钟选择条件
  18. timePickerIncrement: 10, // 时间的增量,单位为分钟
  19. timePicker24Hour : true,
  20. opens : 'left', //日期选择框的弹出位置
  21. ranges: rangesConf,
  22. locale : {
  23. format: 'YYYY-MM-DD HH:mm:ss',
  24. separator : ' - ',
  25. customRangeLabel : I18n.daterangepicker_custom_name ,
  26. applyLabel : I18n.system_ok ,
  27. cancelLabel : I18n.system_cancel ,
  28. fromLabel : I18n.daterangepicker_custom_starttime ,
  29. toLabel : I18n.daterangepicker_custom_endtime ,
  30. daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六'
  31. monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'
  32. firstDay : 1
  33. },
  34. startDate: rangesConf[I18n.daterangepicker_ranges_recent_month][0] ,
  35. endDate: rangesConf[I18n.daterangepicker_ranges_recent_month][1]
  36. }, function (start, end, label) {
  37. freshChartDate(start, end);
  38. });
  39. freshChartDate(rangesConf[I18n.daterangepicker_ranges_recent_month][0], rangesConf[I18n.daterangepicker_ranges_recent_month][1]);
  40. /**
  41. * fresh Chart Date
  42. *
  43. * @param startDate
  44. * @param endDate
  45. */
  46. function freshChartDate(startDate, endDate) {
  47. $.ajax({
  48. type : 'POST',
  49. url : base_url + '/triggerChartDate',
  50. data : {
  51. 'startDate':startDate.format('YYYY-MM-DD HH:mm:ss'),
  52. 'endDate':endDate.format('YYYY-MM-DD HH:mm:ss')
  53. },
  54. dataType : "json",
  55. success : function(data){
  56. if (data.code == 200) {
  57. lineChartInit(data)
  58. pieChartInit(data);
  59. } else {
  60. layer.open({
  61. title: I18n.system_tips ,
  62. btn: [ I18n.system_ok ],
  63. content: (data.msg || I18n.job_dashboard_report_loaddata_fail ),
  64. icon: '2'
  65. });
  66. }
  67. }
  68. });
  69. }
  70. /**
  71. * line Chart Init
  72. */
  73. function lineChartInit(data) {
  74. var option = {
  75. title: {
  76. text: I18n.job_dashboard_date_report
  77. },
  78. tooltip : {
  79. trigger: 'axis',
  80. axisPointer: {
  81. type: 'cross',
  82. label: {
  83. backgroundColor: '#6a7985'
  84. }
  85. }
  86. },
  87. legend: {
  88. data:[I18n.job_dashboard_date_report_suc_count, I18n.job_dashboard_date_report_fail_count]
  89. },
  90. toolbox: {
  91. feature: {
  92. /*saveAsImage: {}*/
  93. }
  94. },
  95. grid: {
  96. left: '3%',
  97. right: '4%',
  98. bottom: '3%',
  99. containLabel: true
  100. },
  101. xAxis : [
  102. {
  103. type : 'category',
  104. boundaryGap : false,
  105. data : data.content.triggerDayList
  106. }
  107. ],
  108. yAxis : [
  109. {
  110. type : 'value'
  111. }
  112. ],
  113. series : [
  114. {
  115. name:I18n.job_dashboard_date_report_suc_count,
  116. type:'line',
  117. stack: 'Total',
  118. areaStyle: {normal: {}},
  119. data: data.content.triggerDayCountSucList
  120. },
  121. {
  122. name:I18n.job_dashboard_date_report_fail_count,
  123. type:'line',
  124. stack: 'Total',
  125. label: {
  126. normal: {
  127. show: true,
  128. position: 'top'
  129. }
  130. },
  131. areaStyle: {normal: {}},
  132. data: data.content.triggerDayCountFailList
  133. }
  134. ],
  135. color:['#00A65A', '#F39C12']
  136. };
  137. var lineChart = echarts.init(document.getElementById('lineChart'));
  138. lineChart.setOption(option);
  139. }
  140. /**
  141. * pie Chart Init
  142. */
  143. function pieChartInit(data) {
  144. var option = {
  145. title : {
  146. text: I18n.job_dashboard_rate_report ,
  147. /*subtext: 'subtext',*/
  148. x:'center'
  149. },
  150. tooltip : {
  151. trigger: 'item',
  152. formatter: "{a} <br/>{b} : {c} ({d}%)"
  153. },
  154. legend: {
  155. orient: 'vertical',
  156. left: 'left',
  157. data: [I18n.job_dashboard_rate_report_suc_count, I18n.job_dashboard_rate_report_fail_count ]
  158. },
  159. series : [
  160. {
  161. name: '分布比例',
  162. type: 'pie',
  163. radius : '55%',
  164. center: ['50%', '60%'],
  165. data:[
  166. {
  167. value:data.content.triggerCountSucTotal,
  168. name:I18n.job_dashboard_rate_report_suc_count
  169. },
  170. {
  171. value:data.content.triggerCountFailTotal,
  172. name:I18n.job_dashboard_rate_report_fail_count
  173. }
  174. ],
  175. itemStyle: {
  176. emphasis: {
  177. shadowBlur: 10,
  178. shadowOffsetX: 0,
  179. shadowColor: 'rgba(0, 0, 0, 0.5)'
  180. }
  181. }
  182. }
  183. ],
  184. color:['#00A65A', '#F39C12']
  185. };
  186. var pieChart = echarts.init(document.getElementById('pieChart'));
  187. pieChart.setOption(option);
  188. }
  189. });