realtimeBroadcastCtrl.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. 'use strict';
  2. app.controller('realtimeBroadcastCtrl', ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', function($scope, $modal, $timeout, SweetAlert, api_user_data){
  3. $scope.intervalTime = sessionStorage.getItem('intervalTime')?JSON.parse(sessionStorage.getItem('intervalTime')):{
  4. rotationInterval: 10,
  5. rotationIntervals: [3, 5, 10, 15, 20, 25, 30, 35, 40, 45],
  6. logTimeConst: 60,
  7. logTimeConsts: [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],
  8. }
  9. console.log($scope.intervalTime);
  10. $scope.logTimer = null; //定时器
  11. $scope.logTime = 0; //自动刷新秒数
  12. $scope.logTimeConst = $scope.intervalTime.logTimeConst; //自动刷新秒数
  13. $scope.rotationInterval = $scope.intervalTime.rotationInterval; //轮播间隔秒数
  14. // 回显当前所属院区或责任科室
  15. $scope.dutyOrBranch = '';
  16. if($scope.user.duty){
  17. $scope.dutyOrBranch = $scope.user.duty.dept;
  18. }else if($scope.user.branch){
  19. $scope.dutyOrBranch = $scope.user.branch.hosName;
  20. }
  21. // 自动刷新倒计时
  22. $scope.autoUpdate = function(){
  23. $scope.logTime = $scope.logTimeConst;
  24. clearInterval($scope.logTimer);
  25. $scope.logTimer = setInterval(() => {
  26. $scope.logTime--;
  27. if ($scope.logTime === 0) {
  28. $scope.logTime = $scope.logTimeConst;
  29. // 待接单列表
  30. $scope.getPharmacyList(1);
  31. // 处理中列表
  32. $scope.getPharmacyList(2);
  33. }
  34. }, 1000);
  35. }
  36. // 轮播1
  37. $scope.mySwiper1 = new Swiper(".swiper1", {
  38. autoplay: {
  39. delay: $scope.rotationInterval * 1000
  40. }, //可选选项,自动滑动
  41. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  42. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  43. });
  44. // 轮播2
  45. $scope.mySwiper2 = new Swiper(".swiper2", {
  46. autoplay: {
  47. delay: $scope.rotationInterval * 1000
  48. }, //可选选项,自动滑动
  49. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  50. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  51. });
  52. // 列表查询
  53. // 1为pc待接单、2为pc处理中
  54. $scope.loading1 = false;
  55. $scope.loading2 = false;
  56. $scope.waitingOrderList = [];
  57. $scope.inProcessList = [];
  58. $scope.getPharmacyList = function(type, flag = true) {
  59. let statusId;
  60. switch (type) {
  61. case 1:
  62. this.loading1 = flag ? true : false;
  63. statusId = 1543;
  64. break;
  65. case 2:
  66. this.loading2 = flag ? true : false;
  67. statusId = 1544;
  68. break;
  69. }
  70. let postData = {
  71. "assignee": $scope.user.id,
  72. "candidateGroups": $scope.user.group.map(v=>v.id).toString(),
  73. "searchType": "all",
  74. "idx": 0,
  75. "sum": 9999,
  76. "incident": {
  77. "deleted": false,
  78. "statusId": statusId,
  79. }
  80. };
  81. if($scope.user.duty){
  82. // 当前的所属责任科室
  83. postData.incident.duty = $scope.user.duty;
  84. }else if($scope.user.branch){
  85. // 当前的所属院区
  86. postData.incident.branch = $scope.user.branch.id;
  87. }
  88. api_user_data.fetchDataList('incident', postData).then(function (data) {
  89. // 可视区高度
  90. $scope.viewHeight = document.querySelector('.pharmacy-main__selectionWrap').offsetHeight;
  91. $scope.sum = parseInt($scope.viewHeight / 100);
  92. console.log($scope.viewHeight, $scope.sum);
  93. data.list = data.list || [];
  94. switch (type) {
  95. case 1:
  96. $scope.loading1 = false;
  97. data.list.forEach(v => {
  98. v.acceptDate = v.acceptDate ? moment(v.acceptDate).format('MM-DD HH:mm') : '';
  99. v.handlerLogs = v.handlerLogs.length ? v.handlerLogs.reverse().slice(0, 1) : [];
  100. })
  101. $scope.waitingOrderList = _.chunk(data.list, $scope.sum);
  102. console.log($scope.waitingOrderList);
  103. break;
  104. case 2:
  105. $scope.loading2 = false;
  106. data.list.forEach(v => {
  107. v.acceptDate = v.acceptDate ? moment(v.acceptDate).format('MM-DD HH:mm') : '';
  108. v.handlerLogs = v.handlerLogs.length ? v.handlerLogs.reverse().slice(0, 1) : [];
  109. })
  110. $scope.inProcessList = _.chunk(data.list, $scope.sum);
  111. break;
  112. }
  113. }, function () {
  114. switch (type) {
  115. case 1:
  116. $scope.loading1 = false;
  117. break;
  118. case 2:
  119. $scope.loading2 = false;
  120. break;
  121. }
  122. });
  123. }
  124. // 初始化
  125. $(function(){
  126. // 待接单列表
  127. $scope.getPharmacyList(1, true);
  128. // 处理中列表
  129. $scope.getPharmacyList(2, true);
  130. // 自动刷新倒计时 start
  131. $scope.autoUpdate();
  132. // 自动刷新倒计时 end
  133. })
  134. }])