prescription-management.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //获取团队信息
  2. var request = getRequest(),
  3. teamCode = request.id,
  4. isLeader = isTeamLeader();
  5. //记录页面控件的值
  6. var startDate = '',
  7. endDate = '',
  8. state = '0,2,3,4,10', // 状态,初始为:审核中
  9. dispensaryType = '', //配送方式
  10. page = 1,
  11. size = 10,
  12. nameKey, //搜索的姓名
  13. totalCount = 0,
  14. selectDoctor; //选中的医生
  15. $(function(){
  16. setTitle("续方管理");
  17. //非团队长隐藏操作按钮
  18. if(!isLeader){
  19. $("#arrange").hide();
  20. }
  21. //填充下拉框数据
  22. managementApis.getFilterInfo({
  23. data:{
  24. teamCode: teamCode
  25. }
  26. }).then(function(res){
  27. fillDropDown(res);
  28. $('#presctiptionStatus').val(state);
  29. //获得续方订单列表
  30. getPrescriptionList();
  31. });
  32. bindEvents();
  33. });
  34. //获得续方订单列表
  35. function getPrescriptionList( refresh){
  36. var params = {
  37. teamCode: teamCode,
  38. startDate: startDate,
  39. endDate: endDate,
  40. state: state,
  41. diseases: dispensaryType,
  42. nameKeyword: nameKey
  43. };
  44. //先请求获得所有的数量
  45. managementApis.getListCount({data:params}).then(function(res){
  46. if(res.status == 200){
  47. totalCount = res.data.total;
  48. if(refresh){
  49. $("#prescriptTable").bootstrapTable('refresh');
  50. }
  51. var options = $.extend(managementApis.getListTableAjaxObj, {
  52. queryParams: queryParams,
  53. queryParamsType: "limit",
  54. pagination: true,
  55. paginationLoop: true,
  56. sidePagination: 'server',
  57. pageNumber: 1,
  58. pageSize: 10,
  59. responseHandler: function (res) {
  60. var data = _.map(res.data, function(o){
  61. var result = "";
  62. for(var i=0; i<o.prescriptionDt.length; i++){
  63. if(i>0){
  64. result += ','+o.prescriptionDt[i].name;
  65. }else{
  66. result += o.prescriptionDt[i].name;
  67. }
  68. }
  69. o.result = result;
  70. if(o.status*1 < -1) {
  71. o.statusName = "续方取消"
  72. } else if(o.status == 69) {
  73. o.statusName = "配送中"
  74. } else {
  75. o.statusName = getStatusName(o.status);
  76. }
  77. o.drugs = getDrugs(o.prescriptionInfo);
  78. o.daysRemaining = getDaysRemaining(o)
  79. o.action = '<a class="c-12b7f5" href="prescription-main.html?tab=1&teamCode='+teamCode+'&code='+o.code+'&patiName='+o.name+'">查看</a>';
  80. return o;
  81. });
  82. return {
  83. rows: data,
  84. total: totalCount
  85. }
  86. }
  87. })
  88. $("#prescriptTable").bootstrapTable(options);
  89. }
  90. });
  91. }
  92. function queryParams(params) {
  93. console.log(params);
  94. //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
  95. page = params.offset/params.limit + 1;
  96. selectItemNum = 0;
  97. $("#selectAll").prop("checked", false);
  98. $("#selectedCount").text(0);
  99. $("#arrange").addClass("disabled");
  100. return {
  101. teamCode: teamCode,
  102. page: params.offset/params.limit + 1,
  103. size: params.limit,
  104. startDate: startDate,
  105. endDate: endDate,
  106. state: state,
  107. diseases: dispensaryType,
  108. nameKeyword: nameKey
  109. };
  110. }
  111. function fillDropDown(res){
  112. if(res.status == 200){
  113. var stateHtml = template('state_tmpl', {list: res.data.states});
  114. $("#presctiptionStatus").append(stateHtml);
  115. var expressHtml = template('express_tmpl', {list: res.data.diseases});
  116. $("#express").append(expressHtml);
  117. }else{
  118. }
  119. }
  120. //绑定事件
  121. function bindEvents(){
  122. $(".n-tab").on('click', function(){
  123. if($(this).hasClass("active")){
  124. return false;
  125. }else{
  126. $(this).addClass("active");
  127. $(this).siblings().removeClass("active");
  128. var seDate = getStartEndDate($(this).attr("data-val"));
  129. startDate = seDate.startDate;
  130. endDate = seDate.endDate;
  131. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  132. getPrescriptionList(true);
  133. }
  134. });
  135. $("#presctiptionStatus").on('change', function(){
  136. var $this = $(this);
  137. state = $this.val();
  138. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  139. getPrescriptionList(true);
  140. });
  141. $("#express").on('change', function(){
  142. dispensaryType = $(this).val();
  143. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  144. getPrescriptionList(true);
  145. });
  146. $("#searchBtn").on('click', function(){
  147. var $input = $("#searchName"),
  148. text = $.trim($input.val());
  149. nameKey = text;
  150. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  151. getPrescriptionList(true);
  152. });
  153. }