Нет описания

individualWorkloadBar.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. * 个人工作量柱状图
  3. * */
  4. var myChart = null;
  5. var labelOption = {
  6. normal: {
  7. show: true,
  8. position: 'top',
  9. distance: 5,
  10. align: 'center',
  11. verticalAlign: 'middle',
  12. rotate: 0,
  13. formatter: '{c}',
  14. fontSize: 16,
  15. }
  16. };
  17. $(function() {
  18. $('.tool_bars').authorizeButton();
  19. //项目下拉
  20. helper.getDropList.getProlistDrop($('#sc_pro'));
  21. laydate.render({
  22. elem: '#sc_times',
  23. range: '~',
  24. theme: '#249fea',
  25. });
  26. //初始化图形
  27. initBars();
  28. //获取数据
  29. getBardatas();
  30. //搜索
  31. $("#sc_btns").click(function() {
  32. getBardatas();
  33. })
  34. });
  35. //初始化图形
  36. function initBars() {
  37. myChart = echarts.init(document.getElementById('workBar'));
  38. myChart.clear();
  39. myChart.showLoading();
  40. var option = {
  41. tooltip: {
  42. trigger: 'axis',
  43. },
  44. legend: {
  45. data: ['报修接单量', '巡检接单量', '保养接单量','超时工单量','汇总'],
  46. top: 10,
  47. padding: 5,
  48. },
  49. grid: {
  50. bottom: 200
  51. },
  52. dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
  53. type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
  54. xAxisIndex: 0,
  55. start: 0, // 左边在 0% 的位置。
  56. end: 100, // 右边在 100% 的位置。
  57. bottom: 100,
  58. }, ],
  59. xAxis: [{
  60. type: 'category',
  61. data: [],
  62. axisPointer: {
  63. type: 'shadow'
  64. },
  65. axisLabel: {
  66. interval: 0,
  67. rotate: 0
  68. }
  69. }],
  70. yAxis: [{
  71. type: 'value',
  72. name: '接单量',
  73. nameLocation: 'end',
  74. axisLabel: {
  75. formatter: '{value} '
  76. }
  77. }],
  78. series: [],
  79. color: ['#a1ef9f', '#66d1e8', '#32a1e8', '#f8a6ad']
  80. };
  81. myChart.setOption(option);
  82. }
  83. //获取数据
  84. function getBardatas() {
  85. $.ajax({
  86. type: "get",
  87. url: huayi.config.callcenter_url + "equipmentapi/api/RunningRepair/getuserworkcount",
  88. async: true,
  89. dataType: 'json',
  90. data: {
  91. projectid: $('#sc_pro').val(), // 否 string 项目id
  92. start: $('#sc_times').val() && $('#sc_times').val().split('~')[0], // 否 string 开始日期2018-12-13
  93. end: $('#sc_times').val() && $('#sc_times').val().split('~')[1] // 否 string 结束日期2018-12-13
  94. },
  95. success: function(data) {
  96. myChart.hideLoading();
  97. if (data.state.toLowerCase() == "success") {
  98. data = data.data;
  99. var xData = [];
  100. var repaircount = [];
  101. var equipmentrunningcount = [];
  102. var maintaincount = [];
  103. var timeoutcount = [];
  104. var totalcount = [];
  105. if (data && data.length > 0) {
  106. $('#warnTip').hide();
  107. $('#workBar').show();
  108. for (var i = 0; i < data.length; i++) {
  109. var res = data[i];
  110. // xData.push(res.username + '(' + res.usercode + ')');
  111. xData.push(res.username);
  112. repaircount.push(res.repaircount);
  113. equipmentrunningcount.push(res.equipmentrunningcount);
  114. maintaincount.push(res.maintaincount);
  115. timeoutcount.push(res.timeoutcount);
  116. totalcount.push(res.totalcount);
  117. }
  118. }else{
  119. $('#workBar').hide();
  120. $('#warnTip').show();
  121. }
  122. myChart.setOption({
  123. xAxis: [{
  124. data: xData
  125. }],
  126. series: [{
  127. type: 'bar',
  128. name: '报修接单量',
  129. label: labelOption,
  130. data: repaircount
  131. }, {
  132. type: 'bar',
  133. name: '巡检接单量',
  134. label: labelOption,
  135. data: equipmentrunningcount
  136. }, {
  137. type: 'bar',
  138. name: '保养接单量',
  139. label: labelOption,
  140. data: maintaincount
  141. }, {
  142. type: 'bar',
  143. name: '超时工单量',
  144. label: labelOption,
  145. data: timeoutcount
  146. }, {
  147. type: 'bar',
  148. name: '汇总',
  149. label: labelOption,
  150. data: totalcount
  151. }]
  152. });
  153. }
  154. }
  155. });
  156. }