incidentDetailCtrl.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. 'use strict';
  2. app.controller('incidentDetailCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", '$parse', "$injector", "$aside", 'toaster', 'api_simple', 'api_wechatfile', 'api_text', function ($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, $parse, $injector, $aside, toaster, api_simple, api_wechatfile, api_text) {
  3. $scope.langs = i18nService.getAllLangs();
  4. $scope.lang = 'zh-cn';
  5. i18nService.setCurrentLang($scope.lang);
  6. // todo
  7. // 事件id
  8. $scope.incidentId = (/^\d+$/.test($stateParams.id)) ? parseInt($stateParams.id, 10): undefined;
  9. // 事件详情对象
  10. $scope.model = {};
  11. // 事件报修图片
  12. $scope.requestImgs = [];
  13. // 事件处理图片
  14. $scope.userImgs = [];
  15. // 事件处理节点
  16. $scope.followData = [];
  17. // 获取事件详情
  18. $scope.getData = function(incidentId){
  19. api_simple.fetchData('incident', incidentId).then(res => {
  20. if(res.status == 200){
  21. $scope.model = res.data || {};
  22. if ($scope.model.id) {
  23. api_wechatfile.listAttachment("wechatRequesterIncident", $scope.model.id).then( (res) => {
  24. $scope.requestImgs = res.data || [];
  25. });
  26. }
  27. if ($scope.model.id) {
  28. api_wechatfile.listAttachment("incident", $scope.model.id).then( (res) => {
  29. $scope.userImgs = res.data || [];
  30. });
  31. }
  32. if ($scope.model.id) {
  33. let postData = {
  34. idx: 0,
  35. sum: 9999,
  36. incidentLog: {
  37. incidentId: $scope.model.id,
  38. }
  39. }
  40. api_simple.fetchDataList('incidentLog', postData).then(function (result) {
  41. if (result.status == 200) {
  42. let newData = Restangular.stripRestangular(result);
  43. $scope.followData = newData.list || [];
  44. }
  45. });
  46. }
  47. }
  48. })
  49. }
  50. // 预览图片
  51. $scope.preview = function (type, url, idx) {
  52. let title = $scope[type][idx].title;
  53. $modal.open({
  54. backdrop: false,
  55. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  56. controller: function ($scope, $rootScope, scope, $modalInstance) {
  57. $scope.title = title;
  58. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  59. $scope.cancel = function () {
  60. $modalInstance.dismiss("cancel");
  61. };
  62. },
  63. resolve: {
  64. scope: function () {
  65. return $scope;
  66. },
  67. },
  68. });
  69. };
  70. // 转换协同人
  71. $scope.transferSynergetic = function(synergetic){
  72. return (synergetic && synergetic.length) ? synergetic.map(v => v.name).join(',') : ''
  73. }
  74. // 转换处理人
  75. $scope.transferUser = function(incidentData){
  76. if(incidentData.state && incidentData.state.value == 'pending' && incidentData.currentLog){
  77. return incidentData.currentLog.workerName;
  78. }else if(incidentData.state && incidentData.state.value != 'pending' && incidentData.handlingPersonnelUser){
  79. return incidentData.handlingPersonnelUser.name;
  80. }else{
  81. return '';
  82. }
  83. }
  84. // 拨打电话
  85. $scope.dialout = function (teleno) {
  86. $rootScope.callout = 2;
  87. if (localStorage.getItem('fenjiNumber')) {
  88. $rootScope.toggle('off-sidebar');
  89. }else if(localStorage.getItem('hk_phone')){
  90. var gid = "@0"
  91. var telephone = '9' + teleno
  92. $rootScope.callout = 2;
  93. if ($rootScope.takes) {
  94. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  95. if (data.errno == 0) {
  96. $rootScope.status = 6;
  97. }
  98. })
  99. } else {
  100. SweetAlert.swal({
  101. title: "呼叫失败",
  102. text: "请先签入呼叫中心!",
  103. type: "error",
  104. confirmButtonColor: "#DD6B55"
  105. });
  106. }
  107. } else {
  108. SweetAlert.swal({
  109. title: "呼叫失败",
  110. text: "请先签入呼叫中心!",
  111. type: "error",
  112. confirmButtonColor: "#DD6B55",
  113. });
  114. }
  115. };
  116. // 关闭
  117. $scope.closeModel = function () {
  118. $state.go('app.incident.list', {});
  119. };
  120. // init
  121. $scope.init = function(){
  122. $scope.getData($scope.incidentId);
  123. }
  124. $scope.incidentId && $scope.init();
  125. }]);