123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 'use strict';
- 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) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- // todo
- // 事件id
- $scope.incidentId = (/^\d+$/.test($stateParams.id)) ? parseInt($stateParams.id, 10): undefined;
- // 事件详情对象
- $scope.model = {};
- // 事件报修图片
- $scope.requestImgs = [];
- // 事件处理图片
- $scope.userImgs = [];
- // 事件处理节点
- $scope.followData = [];
- // 获取事件详情
- $scope.getData = function(incidentId){
- api_simple.fetchData('incident', incidentId).then(res => {
- if(res.status == 200){
- $scope.model = res.data || {};
- if ($scope.model.wxIncidentId) {
- api_wechatfile.listAttachment("wechatRequesterIncident", $scope.model.wxIncidentId).then( (res) => {
- $scope.requestImgs = res.data || [];
- });
- }
- if ($scope.model.processInstanceId) {
- api_wechatfile.listAttachment("incident", $scope.model.processInstanceId).then( (res) => {
- $scope.userImgs = res.data || [];
- });
- }
- if ($scope.model.id) {
- let postData = {
- idx: 0,
- sum: 9999,
- incidentLog: {
- incidentId: $scope.model.id,
- }
- }
- api_simple.fetchDataList('incidentLog', postData).then(function (result) {
- if (result.status == 200) {
- let newData = Restangular.stripRestangular(result);
- $scope.followData = newData.list || [];
- }
- });
- }
- }
- })
- }
- // 预览图片
- $scope.preview = function (type, url, idx) {
- let title = $scope[type][idx].title;
- $modal.open({
- backdrop: false,
- templateUrl: "assets/views/customform/tpl/ui-showimage.html",
- controller: function ($scope, $rootScope, scope, $modalInstance) {
- $scope.title = title;
- $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- },
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- });
- };
- // 拨打电话
- $scope.dialout = function (teleno) {
- $rootScope.callout = 2;
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.toggle('off-sidebar');
- }else if(localStorage.getItem('hk_phone')){
- var gid = "@0"
- var telephone = '9' + teleno
- $rootScope.callout = 2;
- if ($rootScope.takes) {
- api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
- if (data.errno == 0) {
- $rootScope.status = 6;
- }
- })
- } else {
- SweetAlert.swal({
- title: "呼叫失败",
- text: "请先签入呼叫中心!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- }
- } else {
- SweetAlert.swal({
- title: "呼叫失败",
- text: "请先签入呼叫中心!",
- type: "error",
- confirmButtonColor: "#DD6B55",
- });
- }
- };
- // 关闭
- $scope.closeModel = function () {
- $state.go('app.incident.list', {});
- };
- // init
- $scope.init = function(){
- $scope.getData($scope.incidentId);
- }
- $scope.incidentId && $scope.init();
- }]);
|