order-tracking.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. var jobName = row.jobName || "";
  98. $("#docInfo").text(row.name+jobName);
  99. $("#confirmModal").modal('toggle');
  100. selectDoctor = row.code;
  101. }
  102. });
  103. $("#hDoctor").bootstrapTable(options);
  104. }
  105. function queryParams2(params) {
  106. //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
  107. return {
  108. page: params.offset/params.limit + 1,
  109. size: params.limit,
  110. name: $.trim($("#doctorName").val())
  111. };
  112. }
  113. function getExpressInfo(){
  114. var params = {
  115. prescriptionCode: prescriptionCode
  116. };
  117. orderAPI.getOrderExpressInfo({data: params}).then(function(res){
  118. if(res.status == 200){
  119. var html = template("expressInfo_tmp", res.data);
  120. $("#expressInfo").empty().append(html);
  121. }else{
  122. }
  123. });
  124. }
  125. function getExpressRouteInfo(){
  126. var params = { prescriptionCode: prescriptionCode};
  127. orderAPI.getSfRouteService({data: params}).then(function(res){
  128. if(res.status == 200){
  129. var list = _.map(res.data.list, function(o){
  130. o.statusName = o.acceptRemark;
  131. o.createTime = o.acceptTime;
  132. return o;
  133. });
  134. var html = tempalte("flow_tmp", {list: list});
  135. $("#expressLogs").empty().append("flow_tmp");
  136. }else{
  137. }
  138. });
  139. }
  140. function showOrderFollow(){
  141. $("#myModal").modal("toggle");
  142. getOrderFollow();
  143. }
  144. function showExpressFollow(){
  145. $("#expressModal").modal('toggle');
  146. getExpressInfo();
  147. getExpressRouteInfo();
  148. }
  149. function bindEvents(){
  150. $(".btn-1").on('click', function(){
  151. $('#docModal').modal('toggle');
  152. getHealthDoctorList();
  153. })
  154. $(".btn-2").on('click', function(){
  155. // history.go(-1);
  156. if(from == 'tab') {
  157. top.toPrePrescriptionTab && top.toPrePrescriptionTab()
  158. } else {
  159. history.go(-1);
  160. }
  161. })
  162. $("#doctorName").on('keyup', function(e){
  163. if (e.which === 13) {
  164. getHealthDoctorList(true);
  165. }
  166. });
  167. $("#confirmBtn").on('click', function(){
  168. //发送请求确认的请求
  169. var params = {
  170. codes: prescriptionCode,
  171. healthDoctor: selectDoctor
  172. }
  173. orderAPI.distributeHealthDoctor({data: params}).then(function(res){
  174. if(res.status == 200){
  175. $('#docModal').modal('toggle');
  176. $('#confirmModal').modal('toggle');
  177. //更新数据
  178. getPrescriptionFollow();
  179. }else{
  180. }
  181. })
  182. });
  183. }