order-list-jg.js 4.2 KB

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