xxl-job

index.js 7.1KB

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. content: (data.msg || I18n.job_dashboard_report_loaddata_fail ),
  63. icon: '2'
  64. });
  65. }
  66. }
  67. });
  68. }
  69. /**
  70. * line Chart Init
  71. */
  72. function lineChartInit(data) {
  73. var option = {
  74. title: {
  75. text: I18n.job_dashboard_date_report
  76. },
  77. tooltip : {
  78. trigger: 'axis',
  79. axisPointer: {
  80. type: 'cross',
  81. label: {
  82. backgroundColor: '#6a7985'
  83. }
  84. }
  85. },
  86. legend: {
  87. data:[I18n.job_dashboard_date_report_suc_count, I18n.job_dashboard_date_report_fail_count]
  88. },
  89. toolbox: {
  90. feature: {
  91. /*saveAsImage: {}*/
  92. }
  93. },
  94. grid: {
  95. left: '3%',
  96. right: '4%',
  97. bottom: '3%',
  98. containLabel: true
  99. },
  100. xAxis : [
  101. {
  102. type : 'category',
  103. boundaryGap : false,
  104. data : data.content.triggerDayList
  105. }
  106. ],
  107. yAxis : [
  108. {
  109. type : 'value'
  110. }
  111. ],
  112. series : [
  113. {
  114. name:I18n.job_dashboard_date_report_suc_count,
  115. type:'line',
  116. stack: 'Total',
  117. areaStyle: {normal: {}},
  118. data: data.content.triggerDayCountSucList
  119. },
  120. {
  121. name:I18n.job_dashboard_date_report_fail_count,
  122. type:'line',
  123. stack: 'Total',
  124. label: {
  125. normal: {
  126. show: true,
  127. position: 'top'
  128. }
  129. },
  130. areaStyle: {normal: {}},
  131. data: data.content.triggerDayCountFailList
  132. }
  133. ],
  134. color:['#00A65A', '#F39C12']
  135. };
  136. var lineChart = echarts.init(document.getElementById('lineChart'));
  137. lineChart.setOption(option);
  138. }
  139. /**
  140. * pie Chart Init
  141. */
  142. function pieChartInit(data) {
  143. var option = {
  144. title : {
  145. text: I18n.job_dashboard_rate_report ,
  146. /*subtext: 'subtext',*/
  147. x:'center'
  148. },
  149. tooltip : {
  150. trigger: 'item',
  151. formatter: "{a} <br/>{b} : {c} ({d}%)"
  152. },
  153. legend: {
  154. orient: 'vertical',
  155. left: 'left',
  156. data: [I18n.job_dashboard_rate_report_suc_count, I18n.job_dashboard_rate_report_fail_count ]
  157. },
  158. series : [
  159. {
  160. name: '分布比例',
  161. type: 'pie',
  162. radius : '55%',
  163. center: ['50%', '60%'],
  164. data:[
  165. {
  166. value:data.content.triggerCountSucTotal,
  167. name:I18n.job_dashboard_rate_report_suc_count
  168. },
  169. {
  170. value:data.content.triggerCountFailTotal,
  171. name:I18n.job_dashboard_rate_report_fail_count
  172. }
  173. ],
  174. itemStyle: {
  175. emphasis: {
  176. shadowBlur: 10,
  177. shadowOffsetX: 0,
  178. shadowColor: 'rgba(0, 0, 0, 0.5)'
  179. }
  180. }
  181. }
  182. ],
  183. color:['#00A65A', '#F39C12']
  184. };
  185. var pieChart = echarts.init(document.getElementById('pieChart'));
  186. pieChart.setOption(option);
  187. }
  188. });