prescription-management.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 {
  73. o.statusName = getStatusName(o.status);
  74. }
  75. o.drugs = getDrugs(o.prescriptionInfo);
  76. o.daysRemaining = getDaysRemaining(o)
  77. o.action = '<a class="c-12b7f5" href="prescription-main.html?tab=1&teamCode='+teamCode+'&code='+o.code+'&patiName='+o.name+'">查看</a>';
  78. return o;
  79. });
  80. return {
  81. rows: data,
  82. total: totalCount
  83. }
  84. }
  85. })
  86. $("#prescriptTable").bootstrapTable(options);
  87. }
  88. });
  89. }
  90. function queryParams(params) {
  91. console.log(params);
  92. //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
  93. page = params.offset/params.limit + 1;
  94. selectItemNum = 0;
  95. $("#selectAll").prop("checked", false);
  96. $("#selectedCount").text(0);
  97. $("#arrange").addClass("disabled");
  98. return {
  99. teamCode: teamCode,
  100. page: params.offset/params.limit + 1,
  101. size: params.limit,
  102. startDate: startDate,
  103. endDate: endDate,
  104. state: state,
  105. diseases: dispensaryType,
  106. nameKeyword: nameKey
  107. };
  108. }
  109. function fillDropDown(res){
  110. if(res.status == 200){
  111. var stateHtml = template('state_tmpl', {list: res.data.states});
  112. $("#presctiptionStatus").append(stateHtml);
  113. var expressHtml = template('express_tmpl', {list: res.data.diseases});
  114. $("#express").append(expressHtml);
  115. }else{
  116. }
  117. }
  118. //绑定事件
  119. function bindEvents(){
  120. $(".n-tab").on('click', function(){
  121. if($(this).hasClass("active")){
  122. return false;
  123. }else{
  124. $(this).addClass("active");
  125. $(this).siblings().removeClass("active");
  126. var seDate = getStartEndDate($(this).attr("data-val"));
  127. startDate = seDate.startDate;
  128. endDate = seDate.endDate;
  129. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  130. getPrescriptionList(true);
  131. }
  132. });
  133. $("#presctiptionStatus").on('change', function(){
  134. var $this = $(this);
  135. state = $this.val();
  136. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  137. getPrescriptionList(true);
  138. });
  139. $("#express").on('change', function(){
  140. dispensaryType = $(this).val();
  141. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  142. getPrescriptionList(true);
  143. });
  144. $("#searchBtn").on('click', function(){
  145. var $input = $("#searchName"),
  146. text = $.trim($input.val());
  147. nameKey = text;
  148. $('#prescriptTable').bootstrapTable('refreshOptions',{pageNumber:1});
  149. getPrescriptionList(true);
  150. });
  151. }