prescription-list.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var request = getRequest(),
  2. teamCode = request.teamCode,
  3. patient = request.patient,
  4. state,
  5. diseases,
  6. startDate = '',
  7. endDate = '',
  8. totalCount = 0;
  9. $(function(){
  10. if(!teamCode){
  11. getPatientInfo();
  12. }else{
  13. getFilter();
  14. getList();
  15. }
  16. bindEvents();
  17. })
  18. function getPatientInfo(){
  19. var params = {patient: patient};
  20. prescriptionListAPI.getPatientInfo({data: params}).then(function(res){
  21. if(res.status == 200){
  22. teamCode = res.data.jtAdminTeam;
  23. getFilter();
  24. getList();
  25. }else{
  26. showWarningMsg(res.msg);
  27. }
  28. })
  29. }
  30. function getFilter(){
  31. var params = {
  32. teamCode: teamCode,
  33. patient: patient
  34. };
  35. prescriptionListAPI.getFilter({data: params}).then(function(res){
  36. if(res.status == 200){
  37. fillDropDown(res);
  38. }else{
  39. showWarningMsg(res.msg);
  40. }
  41. });
  42. }
  43. function getList(isRefresh){
  44. var params = {
  45. startDate: startDate,
  46. endDate: endDate,
  47. state: state,
  48. diseases: diseases,
  49. teamCode: teamCode,
  50. patient: patient
  51. };
  52. prescriptionListAPI.getPrescriptionListCount({data: params}).then(function(res){
  53. if(res.status == 200){
  54. totalCount = res.data.total;
  55. if(isRefresh){
  56. $("#prescriptTable").bootstrapTable('refresh');
  57. }
  58. var options = $.extend(prescriptionListAPI.getPrescriptionListTableAjaxObj, {
  59. queryParams: queryParams,
  60. queryParamsType: "limit",
  61. pagination: true,
  62. paginationLoop: true,
  63. sidePagination: 'server',
  64. pageNumber: 1,
  65. pageSize: 10,
  66. responseHandler: function (res) {
  67. return {
  68. rows: res.data,
  69. total: totalCount
  70. }
  71. },
  72. columns: [{
  73. field: '',
  74. title:'',
  75. formatter: function(val, row, index){
  76. var html = template('info_tmp', row);
  77. return html;
  78. }
  79. },{
  80. field: 'createTime',
  81. title: '申请时间',
  82. class: 'c-999 pr20',
  83. align: 'right',
  84. formatter: function(val, row, index){
  85. return '<span class="pr10">'+val+'</span>';
  86. }
  87. }],
  88. onClickRow: function(row, $el){
  89. document.location.href = "prescription-detail.html?code="+row.code+'&id='+teamCode;
  90. }
  91. })
  92. $("#prescriptTable").bootstrapTable(options);
  93. }else{
  94. showWarningMsg(res.msg);
  95. }
  96. });
  97. }
  98. function queryParams(params) {
  99. return {
  100. page: params.offset/params.limit + 1,
  101. size: params.limit,
  102. startDate: startDate,
  103. endDate: endDate,
  104. state: state,
  105. diseases: diseases,
  106. teamCode: teamCode,
  107. patient: patient
  108. };
  109. }
  110. function fillDropDown(res){
  111. var statusHtml = template('status_tmp', {list: res.data.states});
  112. $("#status").append(statusHtml);
  113. var diseaseHtml = template('disease_tmp', {list: res.data.diseases});
  114. $("#disease").append(diseaseHtml);
  115. }
  116. function bindEvents(){
  117. $("#status").on('change', function(){
  118. var $this = $(this);
  119. state = $this.val();
  120. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  121. getList(true);
  122. });
  123. $("#disease").on('change', function(){
  124. var $this = $(this);
  125. diseases = $this.val();
  126. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  127. getList(true);
  128. });
  129. $("#time").on('change', function(){
  130. var $this = $(this);
  131. var seDate = getStartEndDate($this.val());
  132. startDate = seDate.startDate;
  133. endDate = seDate.endDate;
  134. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  135. getList(true);
  136. });
  137. template.helper('getStatusName', function(status){
  138. if(parseInt(status)< -1){
  139. return "续方取消";
  140. } else if(status == 69) {
  141. return "配送中";
  142. }
  143. return getStatusName(status);
  144. })
  145. }