123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- 'use strict';
- app.controller('realtimeBroadcastCtrl', ['$scope', '$modal', '$timeout', 'SweetAlert', 'api_user_data', function($scope, $modal, $timeout, SweetAlert, api_user_data){
- $scope.intervalTime = sessionStorage.getItem('intervalTime')?JSON.parse(sessionStorage.getItem('intervalTime')):{
- rotationInterval: 10,
- rotationIntervals: [3, 5, 10, 15, 20, 25, 30, 35, 40, 45],
- logTimeConst: 60,
- logTimeConsts: [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],
- }
- console.log($scope.intervalTime);
- $scope.logTimer = null; //定时器
- $scope.logTime = 0; //自动刷新秒数
- $scope.logTimeConst = $scope.intervalTime.logTimeConst; //自动刷新秒数
- $scope.rotationInterval = $scope.intervalTime.rotationInterval; //轮播间隔秒数
- // 回显当前所属院区或责任科室
- $scope.dutyOrBranch = '';
- if($scope.user.duty){
- $scope.dutyOrBranch = $scope.user.duty.dept;
- }else if($scope.user.branch){
- $scope.dutyOrBranch = $scope.user.branch.hosName;
- }
- // 自动刷新倒计时
- $scope.autoUpdate = function(){
- $scope.logTime = $scope.logTimeConst;
- clearInterval($scope.logTimer);
- $scope.logTimer = setInterval(() => {
- $scope.logTime--;
- if ($scope.logTime === 0) {
- $scope.logTime = $scope.logTimeConst;
- // 待接单列表
- $scope.getPharmacyList(1);
- // 处理中列表
- $scope.getPharmacyList(2);
- }
- }, 1000);
- }
- // 轮播1
- $scope.mySwiper1 = new Swiper(".swiper1", {
- autoplay: {
- delay: $scope.rotationInterval * 1000
- }, //可选选项,自动滑动
- observer: true, //修改swiper自己或子元素时,自动初始化swiper
- observeParents: true, //修改swiper的父元素时,自动初始化swiper
- });
- // 轮播2
- $scope.mySwiper2 = new Swiper(".swiper2", {
- autoplay: {
- delay: $scope.rotationInterval * 1000
- }, //可选选项,自动滑动
- observer: true, //修改swiper自己或子元素时,自动初始化swiper
- observeParents: true, //修改swiper的父元素时,自动初始化swiper
- });
- // 列表查询
- // 1为pc待接单、2为pc处理中
- $scope.loading1 = false;
- $scope.loading2 = false;
- $scope.waitingOrderList = [];
- $scope.inProcessList = [];
- $scope.getPharmacyList = function(type, flag = true) {
- let statusId;
- switch (type) {
- case 1:
- this.loading1 = flag ? true : false;
- statusId = 1543;
- break;
- case 2:
- this.loading2 = flag ? true : false;
- statusId = 1544;
- break;
- }
- let postData = {
- "assignee": $scope.user.id,
- "candidateGroups": $scope.user.group.map(v=>v.id).toString(),
- "searchType": "all",
- "idx": 0,
- "sum": 9999,
- "incident": {
- "deleted": false,
- "statusId": statusId,
- }
- };
- if($scope.user.duty){
- // 当前的所属责任科室
- postData.incident.duty = $scope.user.duty;
- }else if($scope.user.branch){
- // 当前的所属院区
- postData.incident.branch = $scope.user.branch.id;
- }
- api_user_data.fetchDataList('incident', postData).then(function (data) {
- // 可视区高度
- $scope.viewHeight = document.querySelector('.pharmacy-main__selectionWrap').offsetHeight;
- $scope.sum = parseInt($scope.viewHeight / 100);
- console.log($scope.viewHeight, $scope.sum);
- data.list = data.list || [];
- switch (type) {
- case 1:
- $scope.loading1 = false;
- data.list.forEach(v => {
- v.acceptDate = v.acceptDate ? moment(v.acceptDate).format('MM-DD HH:mm') : '';
- v.handlerLogs = v.handlerLogs.length ? v.handlerLogs.reverse().slice(0, 1) : [];
- })
- $scope.waitingOrderList = _.chunk(data.list, $scope.sum);
- console.log($scope.waitingOrderList);
- break;
- case 2:
- $scope.loading2 = false;
- data.list.forEach(v => {
- v.acceptDate = v.acceptDate ? moment(v.acceptDate).format('MM-DD HH:mm') : '';
- v.handlerLogs = v.handlerLogs.length ? v.handlerLogs.reverse().slice(0, 1) : [];
- })
- $scope.inProcessList = _.chunk(data.list, $scope.sum);
- break;
- }
- }, function () {
- switch (type) {
- case 1:
- $scope.loading1 = false;
- break;
- case 2:
- $scope.loading2 = false;
- break;
- }
- });
- }
- // 初始化
- $(function(){
- // 待接单列表
- $scope.getPharmacyList(1, true);
- // 处理中列表
- $scope.getPharmacyList(2, true);
- // 自动刷新倒计时 start
- $scope.autoUpdate();
- // 自动刷新倒计时 end
- })
- }])
|