prescription-management.js 4.6 KB

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