prescription-management.js 4.7 KB

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