order-list-jg.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //获取团队信息
  2. var request = getRequest(),
  3. teamCode = request.id || '',
  4. type = request.type;
  5. //记录页面控件的值
  6. var startDate = '',
  7. endDate = '',
  8. state = '', //状态
  9. dispensaryType = '', //配送方式
  10. page = 1,
  11. size = 10,
  12. hospital, //服务站code
  13. allocationType, //是否是待分配续方
  14. nameKey, //搜索的姓名
  15. totalOrderCount = 0,
  16. selectDoctor; //选中的医生
  17. $(function(){
  18. setTitle("续方订单");
  19. //填充下拉框数据
  20. orderAPI.getHFilterInfo().then(function(res){
  21. fillDropDown(res);
  22. //获得续方订单列表
  23. getPrescriptionList();
  24. });
  25. bindEvents();
  26. });
  27. //获得续方订单列表
  28. function getPrescriptionList( refresh){
  29. var params = {
  30. type: type,
  31. teamCode: teamCode,
  32. startDate: startDate,
  33. endDate: endDate,
  34. state: state,
  35. dispensaryType: 3,
  36. hospital: hospital,
  37. nameKey: nameKey
  38. };
  39. //先请求获得所有的数量
  40. orderAPI.getHOrderListCount({data:params}).then(function(res){
  41. if(res.status == 200){
  42. totalOrderCount = res.data.total;
  43. if(refresh){
  44. $("#prescriptTable").bootstrapTable('refresh');
  45. }
  46. var options = $.extend(orderAPI.getHOrderListTableAjaxObj, {
  47. queryParams: queryParams,
  48. queryParamsType: "limit",
  49. pagination: true,
  50. paginationLoop: true,
  51. sidePagination: 'server',
  52. pageNumber: 1,
  53. pageSize: 10,
  54. responseHandler: function (res) {
  55. var data = _.map(res.data, function(o){
  56. var result = "";
  57. for(var i=0; i<o.prescriptionDt.length; i++){
  58. if(i>0){
  59. result += ','+o.prescriptionDt[i].name;
  60. }else{
  61. result += o.prescriptionDt[i].name;
  62. }
  63. }
  64. o.result = result;
  65. o.statusName = getStatusName(o.status);
  66. o.express = getExpressName(o.dispensaryType);
  67. o.address = address;
  68. o.action = '<a class="c-12b7f5" href="prescription-main.html?code='+o.code+'&patiCode='+o.patientCode+'&teamCode='+teamCode+'&tab=2&patiCode='+o.name+'">查看</a>';
  69. return o;
  70. });
  71. return {
  72. rows: data,
  73. total: totalOrderCount
  74. }
  75. }
  76. })
  77. $("#prescriptTable").bootstrapTable(options);
  78. }
  79. });
  80. }
  81. function queryParams(params) {
  82. return {
  83. type: type,
  84. page: params.offset/params.limit + 1,
  85. size: params.limit,
  86. startDate: startDate,
  87. endDate: endDate,
  88. state: state,
  89. hospital: hospital,
  90. dispensaryType: 3,
  91. teamCode: teamCode,
  92. nameKey: nameKey
  93. };
  94. }
  95. function fillDropDown(res){
  96. if(res.status == 200){
  97. var stateHtml = template('state_tmpl', {list: res.data.states});
  98. $("#orderStatus").append(stateHtml);
  99. var expressHtml = template('address_tmpl', {list: res.data.hospitals});
  100. $("#address").append(expressHtml);
  101. }else{
  102. }
  103. }
  104. //绑定事件
  105. function bindEvents(){
  106. $(".n-tab").on('click', function(){
  107. if($(this).hasClass("active")){
  108. return false;
  109. }else{
  110. $(this).addClass("active");
  111. $(this).siblings().removeClass("active");
  112. var seDate = getStartEndDate($(this).attr("data-val"));
  113. startDate = seDate.startDate;
  114. endDate = seDate.endDate;
  115. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  116. getPrescriptionList(true);
  117. }
  118. });
  119. $("#orderStatus").on('change', function(){
  120. var $this = $(this);
  121. state = $this.val();
  122. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  123. getPrescriptionList(true);
  124. });
  125. $("#address").on('change', function(){
  126. hospital = $(this).val();
  127. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  128. getPrescriptionList(true);
  129. });
  130. $("#searchBtn").on('click', function(){
  131. var $input = $("#searchName"),
  132. text = $.trim($input.val());
  133. nameKey = text;
  134. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  135. getPrescriptionList(true);
  136. });
  137. }