index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. $.ajax({
  188. type: "GET",
  189. url: '/thmz/getDoctorDateForDay',
  190. dataType: "json",
  191. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  192. success: function (res) {
  193. if (res == '401' || res == 401) {
  194. window.location.href = '/thmz/login/view'
  195. return;
  196. }
  197. if (res.code == 0) {
  198. $("#numberOfPatient").html(res.numberOfPatient);
  199. $("#numberOfPrescription").html(res.numberOfPrescription);
  200. var html='';
  201. if(res.numberOfIcdText!=null && res.numberOfIcdText.length>0){
  202. for(var i=0;i<res.numberOfIcdText.length;i++){
  203. var obj=res.numberOfIcdText[i];
  204. html+=' <div class="work_detail_full">';
  205. html+='<div title="'+obj.icd_text+'" style="text-overflow: ellipsis;white-space: nowrap;overflow: hidden;width: calc(100% - 300px);float: left;">';
  206. html+='<i class="fa fa-file-text" style="color: #6D31CF;margin-right: 10px;"></i>';
  207. html+=obj.icd_text+'</div>';
  208. html+='<div class="el-col el-col-4" style="float: right;text-align: right;margin-right: 5px;">';
  209. html+=obj.num;
  210. html+=' 次</div><div style="clear: both;"></div></div>';
  211. }
  212. }
  213. $("#numberOfIcdText").html(html);
  214. }
  215. }
  216. });
  217. });
  218. /**
  219. * 获取时间选择器的时间数组
  220. * @returns {string[]}
  221. */
  222. function getRePortRangeArr() {
  223. var rePortRange = $('#reportrange span').html();
  224. var rePortRangeArr = rePortRange.split(" - ");
  225. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  226. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  227. return rePortRangeArr;
  228. }
  229. /**
  230. * 获取时间选择器的时间数组
  231. * @returns {string[]}
  232. */
  233. function getRePortRangeArrById(id) {
  234. var rePortRange = $('#'+id+' span').html();
  235. var rePortRangeArr = rePortRange.split(" - ");
  236. rePortRangeArr[0] = rePortRangeArr[0] + " 00:00:00"
  237. rePortRangeArr[1] = rePortRangeArr[1] + " 23:59:59"
  238. return rePortRangeArr;
  239. }
  240. /**
  241. * 获取年龄(小于7岁精确到天)
  242. * @param birthDay 出生日期
  243. * @param nowDate 当前日期
  244. * @returns {string}
  245. */
  246. function getBirthSlot(birthDay,nowDate) {
  247. var birth = new Date(birthDay);
  248. var now = new Date(nowDate);
  249. var date1 = Date.parse(birth);
  250. var date2 = Date.parse(now);
  251. var day = Math.ceil((date2 - date1) / (60 * 60 * 1000 * 24));
  252. var age = '';
  253. var year = Math.floor(day / 365);
  254. if(year > 0) age += year + '岁';
  255. var y = day % 365;
  256. var month = Math.floor(y / 30);
  257. if(month > 0) age += month + '月';
  258. var d = Math.floor(day % 365 % 30);
  259. if(d > 0) age += d + '天';
  260. if(age.substring(0,age.indexOf('岁')) >= 7){
  261. age = age.substring(0,age.indexOf('岁')+1);
  262. }
  263. return age;
  264. }
  265. /**
  266. * 根据编码获取性别
  267. * @param code
  268. * @returns {string}
  269. */
  270. function getSex(code) {
  271. var sex = '';
  272. if (code == 1) {
  273. sex = '男';
  274. } else if (code == 2) {
  275. sex = '女';
  276. } else {
  277. sex = '未知';
  278. }
  279. return sex
  280. }