incidentDetailCtrl.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.wxIncidentId) {
  23. api_wechatfile.listAttachment("wechatRequesterIncident", $scope.model.wxIncidentId).then( (res) => {
  24. $scope.requestImgs = res.data || [];
  25. });
  26. }
  27. if ($scope.model.processInstanceId) {
  28. api_wechatfile.listAttachment("incident", $scope.model.processInstanceId).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.dialout = function (teleno) {
  72. $rootScope.callout = 2;
  73. if (localStorage.getItem('fenjiNumber')) {
  74. $rootScope.toggle('off-sidebar');
  75. }else if(localStorage.getItem('hk_phone')){
  76. var gid = "@0"
  77. var telephone = '9' + teleno
  78. $rootScope.callout = 2;
  79. if ($rootScope.takes) {
  80. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  81. if (data.errno == 0) {
  82. $rootScope.status = 6;
  83. }
  84. })
  85. } else {
  86. SweetAlert.swal({
  87. title: "呼叫失败",
  88. text: "请先签入呼叫中心!",
  89. type: "error",
  90. confirmButtonColor: "#DD6B55"
  91. });
  92. }
  93. } else {
  94. SweetAlert.swal({
  95. title: "呼叫失败",
  96. text: "请先签入呼叫中心!",
  97. type: "error",
  98. confirmButtonColor: "#DD6B55",
  99. });
  100. }
  101. };
  102. // 关闭
  103. $scope.closeModel = function () {
  104. $state.go('app.incident.list', {});
  105. };
  106. // init
  107. $scope.init = function(){
  108. $scope.getData($scope.incidentId);
  109. }
  110. $scope.incidentId && $scope.init();
  111. }]);