realtimeBroadcastCtrl.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. "idx": 0,
  72. "sum": 9999,
  73. "incident": {
  74. "assignee": $scope.user.id,
  75. "candidateGroups": $scope.user.group.map(v=>v.id).toString(),
  76. "statusId": statusId,
  77. "queryTask": "all",
  78. }
  79. };
  80. if($scope.user.duty){
  81. // 当前的所属责任科室
  82. postData.incident.duty = $scope.user.duty;
  83. }else if($scope.user.branch){
  84. // 当前的所属院区
  85. postData.incident.branch = $scope.user.branch.id;
  86. }
  87. api_user_data.fetchDataList('incident', postData).then(function (data) {
  88. // 可视区高度
  89. $scope.viewHeight = document.querySelector('.pharmacy-main__selectionWrap').offsetHeight;
  90. $scope.sum = parseInt($scope.viewHeight / 100);
  91. console.log($scope.viewHeight, $scope.sum);
  92. data.list = data.list || [];
  93. switch (type) {
  94. case 1:
  95. $scope.loading1 = false;
  96. data.list.forEach(v => {
  97. v.acceptDate = v.acceptDate ? moment(v.acceptDate).format('MM-DD HH:mm') : '';
  98. })
  99. $scope.waitingOrderList = _.chunk(data.list, $scope.sum);
  100. console.log($scope.waitingOrderList);
  101. break;
  102. case 2:
  103. $scope.loading2 = false;
  104. data.list.forEach(v => {
  105. v.acceptDate = v.acceptDate ? moment(v.acceptDate).format('MM-DD HH:mm') : '';
  106. })
  107. $scope.inProcessList = _.chunk(data.list, $scope.sum);
  108. break;
  109. }
  110. }, function () {
  111. switch (type) {
  112. case 1:
  113. $scope.loading1 = false;
  114. break;
  115. case 2:
  116. $scope.loading2 = false;
  117. break;
  118. }
  119. });
  120. }
  121. $scope.transferHandlerLog = function (currentLog) {
  122. if(!currentLog){
  123. return '无';
  124. }
  125. currentLog = angular.copy(currentLog);
  126. if(currentLog.extra1DTO && currentLog.extra2 && currentLog.startTime){
  127. return currentLog.extra1DTO.name+" "+ moment(currentLog.startTime).add(+currentLog.extra2, 'days').format('MM月DD日前完成');
  128. }else{
  129. return '无';
  130. }
  131. }
  132. // 初始化
  133. $(function(){
  134. // 待接单列表
  135. $scope.getPharmacyList(1, true);
  136. // 处理中列表
  137. $scope.getPharmacyList(2, true);
  138. // 自动刷新倒计时 start
  139. $scope.autoUpdate();
  140. // 自动刷新倒计时 end
  141. })
  142. }])