order-tracking.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. var request = getRequest(),
  2. prescriptionCode = request.code,
  3. from = request.from;
  4. var docInfo = window.localStorage.getItem("docInfo");
  5. docInfo = JSON.parse(docInfo);
  6. $(function(){
  7. getPrescriptionFollow();
  8. bindEvents();
  9. })
  10. function getPrescriptionFollow(){
  11. var params = {
  12. prescriptionCode: prescriptionCode
  13. };
  14. orderAPI.getPrescriptionFollow({data: params}).then(function(res){
  15. if(res.status == 200){
  16. //如果是健管师配送,且未分配健管师,则显示‘分配’按钮
  17. if((docInfo.code == res.data.leadCode) && (res.data.dispensaryDispensaryType == 3) && (!res.data.prescriptionExpressage.expressageName)){
  18. $(".btn-1").removeClass("hidden");
  19. }
  20. $("#applyDate").text(new Date(res.data.createTime).format('yyyy-MM-dd HH:mm:ss'));
  21. $("#checkDoc").text(res.data.doctorName);
  22. //填充收药信息的内容
  23. var obj = $.extend({
  24. dispensaryDispensaryType: res.data.dispensaryDispensaryType,
  25. dispensaryDispensaryTypeName: res.data.dispensaryDispensaryTypeName
  26. }, res.data.prescriptionExpressage);
  27. var syInfoHtml = template('syinfo_tmp', obj);
  28. $("#syInfo").empty().append(syInfoHtml);
  29. //填充订单记录信息
  30. var obj2 = {
  31. prescriptionStatusName: res.data.prescriptionStatusName,
  32. orderCode: res.data.prescriptionExpressage.code,
  33. prescriptionHospital: res.data.prescriptionHospital
  34. };
  35. var orderInfoHtml = template('record_tmp', obj2);
  36. $("#recordInfo").empty().append(orderInfoHtml);
  37. //填充药品信息
  38. var drugHtml = template('drug_tmp', {list: res.data.prescriptionInfos});
  39. $("#drugInfo").empty().append(drugHtml);
  40. }else{
  41. }
  42. })
  43. }
  44. function getOrderFollow(){
  45. var params = {
  46. prescriptionCode: prescriptionCode
  47. };
  48. orderAPI.getOrderFollow({data: params}).then(function(res){
  49. if(res.status == 200){
  50. var html = template('flow_tmp', {list: res.data});
  51. $("#orderLogs").empty().append(html);
  52. }else{
  53. }
  54. });
  55. }
  56. //获得健管师列表
  57. function getHealthDoctorList(isRefresh){
  58. if(isRefresh){
  59. $("#hDoctor").bootstrapTable('refresh');
  60. }
  61. var options = $.extend(orderAPI.getHealthDoctorTableAjaxObj, {
  62. queryParams: queryParams2,
  63. queryParamsType: "limit",
  64. pagination: true,
  65. paginationLoop: true,
  66. sidePagination: 'server',
  67. pageNumber: 1,
  68. pageSize: 8,
  69. pageList: [5,8,10],
  70. responseHandler: function (res) {
  71. return {
  72. rows: res.data.doctors,
  73. total: res.data.total
  74. }
  75. },
  76. columns: [{
  77. field: 'photo',
  78. title: '',
  79. width: '50',
  80. formatter: function(val, row, index){
  81. var url = "img/d-male.png";
  82. if(val.indexOf("http")>-1 || val.indexOf("https")>-1){
  83. url = val;
  84. }
  85. return '<img src="'+url+'" class="img-circle" width="40">';
  86. }
  87. }, {
  88. field: 'name',
  89. title: '',
  90. align: 'left'
  91. },{
  92. field: 'jobName',
  93. title: '职称',
  94. align: 'right'
  95. }],
  96. onClickRow: function(row, $el){
  97. $("#docInfo").text(row.name+row.jobName);
  98. $("#confirmModal").modal('toggle');
  99. selectDoctor = row.code;
  100. }
  101. });
  102. $("#hDoctor").bootstrapTable(options);
  103. }
  104. function queryParams2(params) {
  105. //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
  106. return {
  107. page: params.offset/params.limit + 1,
  108. size: params.limit,
  109. name: $.trim($("#doctorName").val())
  110. };
  111. }
  112. function getExpressInfo(){
  113. var params = {
  114. prescriptionCode: prescriptionCode
  115. };
  116. orderAPI.getOrderExpressInfo({data: params}).then(function(res){
  117. if(res.status == 200){
  118. var html = template("expressInfo_tmp", res.data);
  119. $("#expressInfo").empty().append(html);
  120. }else{
  121. }
  122. });
  123. }
  124. function getExpressRouteInfo(){
  125. var params = { prescriptionCode: prescriptionCode};
  126. orderAPI.getSfRouteService({data: params}).then(function(res){
  127. if(res.status == 200){
  128. var list = _.map(res.data.list, function(o){
  129. o.statusName = o.acceptRemark;
  130. o.createTime = o.acceptTime;
  131. return o;
  132. });
  133. var html = tempalte("flow_tmp", {list: list});
  134. $("#expressLogs").empty().append("flow_tmp");
  135. }else{
  136. }
  137. });
  138. }
  139. function showOrderFollow(){
  140. $("#myModal").modal("toggle");
  141. getOrderFollow();
  142. }
  143. function showExpressFollow(){
  144. $("#expressModal").modal('toggle');
  145. getExpressInfo();
  146. getExpressRouteInfo();
  147. }
  148. function bindEvents(){
  149. $(".btn-1").on('click', function(){
  150. $('#docModal').modal('toggle');
  151. getHealthDoctorList();
  152. })
  153. $(".btn-2").on('click', function(){
  154. // history.go(-1);
  155. if(from == 'tab') {
  156. top.toPrePrescriptionTab && top.toPrePrescriptionTab()
  157. } else {
  158. history.go(-1);
  159. }
  160. })
  161. $("#doctorName").on('keyup', function(e){
  162. if (e.which === 13) {
  163. getHealthDoctorList(true);
  164. }
  165. });
  166. $("#confirmBtn").on('click', function(){
  167. //发送请求确认的请求
  168. var params = {
  169. codes: prescriptionCode,
  170. healthDoctor: selectDoctor
  171. }
  172. orderAPI.distributeHealthDoctor({data: params}).then(function(res){
  173. if(res.status == 200){
  174. $('#docModal').modal('toggle');
  175. $('#confirmModal').modal('toggle');
  176. //更新数据
  177. getPrescriptionFollow();
  178. }else{
  179. }
  180. })
  181. });
  182. }