index.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //@ sourceURL=index.js
  2. //菜单
  3. // var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  4. //
  5. // var randomScalingFactor = function () {
  6. // return Math.round(Math.random() * 100);
  7. // //return 0;
  8. // };
  9. // var randomColorFactor = function () {
  10. // return Math.round(Math.random() * 255);
  11. // };
  12. // var randomColor = function (opacity) {
  13. // var rgg='rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')';
  14. // console.log(rgg);
  15. // return rgg;
  16. // };
  17. var config = {
  18. type: 'line',
  19. data: {
  20. labels: [],
  21. datasets: [
  22. {
  23. label: "挂号金额",
  24. data: [],
  25. /* fill: false,*/
  26. // borderDash: [5, 5],
  27. borderColor: 'rgba(130,236,134,0.4)',
  28. backgroundColor: 'rgba(13,199,122,0.5)',
  29. // pointBorderColor: 'rgba(69,231,165,0.7)',
  30. // pointBackgroundColor: 'rgba(229,185,45,0.5)',
  31. pointBorderWidth: 1,
  32. },
  33. {
  34. //hidden: true,
  35. label: '接诊金额',
  36. data: [],
  37. borderColor: 'rgba(185,190,209,0.4)',
  38. backgroundColor: 'rgba(77,5,148,0.5)',
  39. pointBorderWidth: 1,
  40. },
  41. {
  42. label: "退号金额",
  43. data: [],
  44. borderColor: 'rgba(152,99,170,0.4)',
  45. backgroundColor: 'rgba(166,86,59,0.5)',
  46. pointBorderWidth: 1,
  47. },
  48. {
  49. label: "退费金额",
  50. data: [],
  51. borderColor: 'rgba(254,169,161,0.4)',
  52. backgroundColor: 'rgba(235,30,145,0.5)',
  53. // pointBorderColor: 'rgba(254,169,161,0.4)',
  54. // pointBackgroundColor: randomColor(0.5),
  55. pointBorderWidth: 1,
  56. }
  57. ]
  58. },
  59. options: {
  60. responsive: true,
  61. /* legend: {
  62. position: 'bottom',
  63. },*/
  64. // title: {
  65. // // display: true,
  66. // // text: '门诊运营趋势',
  67. // // },
  68. tooltips: {
  69. mode: 'label',
  70. callbacks: {
  71. // beforeTitle: function() {
  72. // return '...beforeTitle';
  73. // },
  74. // afterTitle: function() {
  75. // return '...afterTitle';
  76. // },
  77. // beforeBody: function() {
  78. // return '...beforeBody';
  79. // },
  80. // afterBody: function() {
  81. // return '...afterBody';
  82. // },
  83. // beforeFooter: function() {
  84. // return '...beforeFooter';
  85. // },
  86. // footer: function() {
  87. // return 'Footer';
  88. // },
  89. // afterFooter: function() {
  90. // return '...afterFooter';
  91. // },
  92. }
  93. },
  94. hover: {
  95. mode: 'dataset'
  96. },
  97. scales: {
  98. xAxes: [{
  99. display: true,
  100. scaleLabel: {
  101. show: true,
  102. labelString: 'Month'
  103. }
  104. }],
  105. yAxes: [{
  106. display: true,
  107. scaleLabel: {
  108. show: true,
  109. labelString: 'Value'
  110. },
  111. ticks: {
  112. suggestedMin: 0,
  113. suggestedMax: 250,
  114. }
  115. }]
  116. }
  117. }
  118. };
  119. // window.onload = function() {
  120. // var ctx = document.getElementById("canvas").getContext("2d");
  121. // window.myLine = new Chart(ctx, config);
  122. // };
  123. $(function () {
  124. init_daterangepicker();
  125. $('#reportrange span').html(moment().subtract(6, 'days').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
  126. $.ajax({
  127. type: "GET",
  128. url: '/thmz/getIndexCount',
  129. dataType: "json",
  130. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  131. success: function (res) {
  132. if (res == '401' || res == 401) {
  133. window.location.href = '/thmz/login/view'
  134. return;
  135. }
  136. if (res.code == 0) {
  137. $("#registrationNum").html(res.registrationNum);
  138. $("#haveClinicalNum").html(res.haveClinicalNum);
  139. if (res.ghAmount != null) {
  140. $("#ghAmount").html(res.ghAmount.toFixed(2));
  141. }
  142. if (res.sfAmount != null) {
  143. $("#sfAmount").html(res.sfAmount.toFixed(2));
  144. }
  145. }
  146. }
  147. });
  148. var rePortRangeArr = getRePortRangeArr();
  149. $.ajax({
  150. type: "POST",
  151. url: '/thmz/getMzyytsqs',
  152. contentType: "application/json;charset=UTF-8",
  153. dataType: "json",
  154. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  155. data: JSON.stringify({beginTime: new Date(rePortRangeArr[0]), endTime: new Date(rePortRangeArr[1])}),
  156. success: function (res) {
  157. if (res == '401' || res == 401) {
  158. window.location.href = '/thmz/login/view'
  159. return;
  160. }
  161. if (res.code == 0) {
  162. if(res.keyList!=null && res.keyList.length>0){
  163. for (var i=0;i<res.keyList.length;i++){
  164. config.data.labels[i]=res.keyList[i];
  165. }
  166. }
  167. if(res.data!=null && res.data.length>0){
  168. var ghje=config.data.datasets[0].data;
  169. var jzje=config.data.datasets[1].data;
  170. var thje=config.data.datasets[2].data;
  171. var tfje=config.data.datasets[3].data;
  172. for (var i=0;i<res.data.length;i++){
  173. ghje[i]=res.data[i].ghAmount;
  174. jzje[i]=res.data[i].sfAmount;
  175. thje[i]=res.data[i].thAmount;
  176. tfje[i]=Math.abs(res.data[i].tfAmount);
  177. }
  178. }
  179. var ctx = $("#canvas").get(0).getContext("2d");
  180. window.myLine = new Chart(ctx, config);
  181. }else {
  182. errorMesage(res);
  183. }
  184. }
  185. });
  186. });
  187. /**
  188. * 获取时间选择器的时间数组
  189. * @returns {string[]}
  190. */
  191. function getRePortRangeArr() {
  192. var rePortRange = $('#reportrange span').html();
  193. var rePortRangeArr = rePortRange.split(" - ");
  194. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  195. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  196. return rePortRangeArr;
  197. }