Commit 8290989f4eedbb9c1879fdfa1aff131dc39bc4c6
1 parent
e03a7f8c
Exists in
master
correção
Showing
1 changed file
with
624 additions
and
595 deletions
Show diff stats
cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | +citApp.controller( 'GerenciarProcessoController', [ | |
4 | + '$scope', | |
5 | + '$translate', | |
6 | + '$timeout', | |
7 | + 'GerenciarProcessoRepository', | |
8 | + 'ProcessoRepository', | |
9 | + 'RuntimeManagerRepository', | |
10 | + '$rootScope', | |
11 | + 'DocumentoGedRepository', | |
12 | + 'HistoricoAlteracaoProcessoRepository', | |
13 | + 'UnidadeRepository', | |
14 | + 'UnidadeProcessoRepository', | |
15 | + 'CredencialProcessoRepository', | |
16 | + function GerenciarProcessoController ( $scope, $translate, $timeout, GerenciarProcessoRepository, ProcessoRepository, RuntimeManagerRepository, $rootScope, DocumentoGedRepository, | |
17 | + HistoricoAlteracaoProcessoRepository, UnidadeRepository, UnidadeProcessoRepository, CredencialProcessoRepository ) { | |
18 | + | |
19 | + $scope.processo = {}; | |
20 | + $scope.iconAnexo = {}; | |
21 | + $scope.taskVariables = []; | |
22 | + $scope.unidades = []; | |
23 | + | |
24 | + // INICIALIZA VARIAVEIS PARA HABILITAR E FECHAR DIVS DE AÇÕES DO PROCESSO | |
25 | + | |
26 | + $scope.isHistoricoProcesso = true; | |
27 | + $scope.fecharPagina = function () { | |
28 | + $scope.isProcessoRelacionado = false; | |
29 | + $scope.isDocumentoEdit = false; | |
30 | + $scope.isProcessoEdit = false; | |
31 | + $scope.isHistoricoProcesso = false; | |
32 | + $scope.isVersoesDocumento = false; | |
33 | + $scope.isEnviarProcesso = false; | |
34 | + $scope.isCancelarDocumento = false; | |
35 | + $scope.isJustificativaAcaoProcesso = false; | |
36 | + $scope.isHistoricoJustificativa = false; | |
37 | + $scope.isAnexarProcesso = false; | |
38 | + $scope.widgetExemploIsCollapsed = true; | |
39 | + $scope.tratimitado(); | |
40 | + $scope.isGerenciarCredencialProcesso = false; | |
41 | + $scope.isClassificarProcessoDocumento = false; | |
3 | 42 | |
4 | -citApp.controller('GerenciarProcessoController', [ '$scope', '$translate', '$timeout','GerenciarProcessoRepository', 'ProcessoRepository', 'RuntimeManagerRepository','$rootScope', 'DocumentoGedRepository', 'HistoricoAlteracaoProcessoRepository','UnidadeRepository','UnidadeProcessoRepository','CredencialProcessoRepository', | |
5 | - function GerenciarProcessoController($scope, $translate, $timeout, GerenciarProcessoRepository, ProcessoRepository, RuntimeManagerRepository,$rootScope, DocumentoGedRepository, HistoricoAlteracaoProcessoRepository,UnidadeRepository, UnidadeProcessoRepository,CredencialProcessoRepository ) { | |
6 | - | |
7 | - $scope.processo = {}; | |
8 | - $scope.iconAnexo = {}; | |
9 | - $scope.taskVariables = []; | |
10 | - $scope.unidades = []; | |
11 | - | |
12 | - //INICIALIZA VARIAVEIS PARA HABILITAR E FECHAR DIVS DE AÇÕES DO PROCESSO | |
13 | - | |
14 | - $scope.isHistoricoProcesso = true; | |
15 | - $scope.fecharPagina = function() { | |
16 | - $scope.isProcessoRelacionado = false; | |
17 | - $scope.isDocumentoEdit = false; | |
18 | - $scope.isProcessoEdit = false; | |
19 | - $scope.isHistoricoProcesso = false; | |
20 | - $scope.isVersoesDocumento = false; | |
21 | - $scope.isEnviarProcesso = false; | |
22 | - $scope.isCancelarDocumento = false; | |
23 | - $scope.isJustificativaAcaoProcesso = false; | |
24 | - $scope.isHistoricoJustificativa = false; | |
25 | - $scope.isAnexarProcesso = false; | |
26 | - $scope.widgetExemploIsCollapsed = true; | |
27 | - $scope.tratimitado(); | |
28 | - $scope.isGerenciarCredencialProcesso = false; | |
29 | - $scope.isClassificarProcessoDocumento = false; | |
30 | - | |
31 | - }; | |
32 | - | |
33 | - //CRIAR RELACIONAMENTO DE PROCESSO | |
34 | - $scope.editProcessoRelacionado = function(){ | |
35 | - | |
36 | - $scope.fecharPagina(); | |
37 | - $scope.isProcessoRelacionado = true; | |
38 | - | |
39 | - $timeout(function() { | |
40 | - angular.element("#editProcessoRelacionado").scope().getProcessoRelacionado(); | |
41 | - }); | |
42 | - | |
43 | - }; | |
44 | - | |
45 | - $scope.historicoJustificativa = function(){ | |
46 | - $scope.fecharPagina(); | |
47 | - $scope.isHistoricoJustificativa = true; | |
48 | - $timeout(function() { | |
49 | - angular.element("#justificativaAcaoProcessoList").scope().inicializarJustificativa(); | |
50 | - }); | |
51 | - }; | |
52 | - | |
53 | - $scope.abrirJustificativa = function(acao){ | |
54 | - $scope.fecharPagina(); | |
55 | - $scope.isCancelarDocumento = true; | |
56 | - }; | |
57 | - | |
58 | - | |
59 | - // CRIA NOVO DOCUMENTO | |
60 | - $scope.newDocument = function() { | |
61 | - | |
62 | - $scope.fecharPagina(); | |
63 | - $scope.isDocumentoEdit = true; | |
64 | - $scope.isVersoesDocumento = false; | |
65 | - $timeout(function() { | |
66 | - angular.element("#editDocumentoGed").scope().resetForm(); | |
67 | - }); | |
68 | - }; | |
69 | - | |
70 | - // Abre a tela de edição do documento | |
71 | - $scope.editDocument = function(editarDocumento, edit) { | |
72 | - | |
73 | - $scope.fecharPagina(); | |
74 | - $scope.isDocumentoEdit = true; | |
75 | - $scope.isVersoesDocumento = false; | |
76 | - | |
77 | - $timeout(function() { | |
78 | - angular.element("#editDocumentoGed").scope().getDocumentoGed(editarDocumento.id, edit); | |
79 | - }); | |
80 | - }; | |
81 | - | |
82 | - // ABRE ABA PARA CRIAR NOVO PROCESSO | |
83 | - $scope.novoProcesso = function() { | |
84 | - | |
85 | - var workspace = angular.element('#editProcessoEcm').scope().workspace; | |
86 | - if (workspace) { | |
87 | - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); | |
88 | - } | |
89 | - | |
90 | - $scope.openWorkspaceIfNotOpen($translate.instant('ECM.LABEL.PROCESSO'), '/cit-ecm-web/html/processo/processo.html', 'mod-orange'); | |
91 | - | |
92 | - $timeout(function() { | |
93 | - angular.element('#editProcessoEcm').scope().$showPageEditWorkspace(angular.element('#editProcessoEcm').scope().workspace); | |
94 | - angular.element('#editProcessoEcm').scope().resetForm(); | |
95 | - | |
96 | - }, 600); | |
97 | - | |
98 | - }; | |
99 | - | |
100 | - //Gerenciar as credenciais do processo | |
101 | - $scope.gerenciarCredenciaisProcesso = function() { | |
102 | - | |
103 | - $scope.fecharPagina(); | |
104 | - $scope.isGerenciarCredencialProcesso = true; | |
105 | - | |
106 | - $timeout(function() { | |
107 | - angular.element("#credencialProcessoEdit").scope().iniciarCredencial($scope.processo.id, $scope.credencialUsuarioProcesso); | |
108 | - }); | |
109 | - }; | |
110 | - | |
111 | - | |
112 | - //EXECUÇÃO PROCESSO | |
113 | - $scope.executarProcesso = function(action){ | |
114 | - $scope.flowAction = action; | |
115 | - | |
116 | - if(action.requireReason){ | |
117 | - $scope.fecharPagina(); | |
118 | - $scope.isJustificativaAcaoProcesso = true; | |
119 | - $timeout(function() { | |
120 | - angular.element("#justificativaAcaoProcesso").scope().resetForm(); | |
121 | - }); | |
122 | - }else{ | |
123 | - $scope.closeWidget(); | |
124 | - | |
125 | - DocumentoGedRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { | |
126 | - if(!result){ | |
127 | - var mensagem = $translate.instant('ECM.MSG.PROCESSO_SEM_DOCUMENTO') + $scope.flowAction.name; | |
128 | - $scope.showAlert("warning", mensagem ); | |
129 | - } else{ | |
130 | - var mensagem = $translate.instant('ECM.MSG.CONFIRMA_EXECUCAO_FLUXO'); | |
131 | - mensagem += $scope.flowAction.name; | |
132 | - $scope.$openModalConfirm({message: mensagem, callback: $scope.avancarFluxo}); | |
133 | - } | |
134 | - }); | |
135 | - | |
136 | - $scope.saveHistoricoProcessoAcao(); | |
137 | - } | |
138 | - }; | |
139 | - | |
140 | - $scope.avancarFluxo = function (){ | |
141 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
142 | - $scope.updateTask(true); | |
143 | - | |
144 | - }; | |
145 | - | |
146 | - //Salvar Historico Execução Processo | |
147 | - $scope.saveHistoricoProcessoAcao = function(){ | |
148 | - | |
149 | - var historicoAlteracaoProcesso = { | |
150 | - descricaoAcao : $translate.instant('ECM.MSG_HISTORICO_ECM.ACAO_PROCESSO'), | |
151 | - processo : $scope.processo, | |
152 | - autor : $scope.usuarioLogado, | |
153 | - acaoAlteracao : "ACAO_PROCESSO", | |
154 | - mapaAtributos : {"protocolo" : $scope.processo.nup, "acao" : $scope.flowAction.name} | |
155 | - }; | |
156 | - | |
157 | - HistoricoAlteracaoProcessoRepository.saveParams(historicoAlteracaoProcesso).then(function(result){ | |
158 | - }); | |
159 | - }; | |
160 | - | |
161 | - | |
162 | - //Conclui o proceso | |
163 | - $scope.concluir = function(){ | |
164 | - | |
165 | - DocumentoGedRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { | |
166 | - if(!result){ | |
167 | - var mensagem = $translate.instant('ECM.MSG.PROCESSO_SEM_DOCUMENTO') +" " +$translate.instant('ECM.LABEL.CONCLUIR') ; | |
168 | - $scope.showAlert("warning", mensagem ); | |
169 | - } else{ | |
170 | - | |
171 | - $scope.$openModalConfirm({message: $translate.instant('ECM.MSG.CONFIRMA_CONCLUIR_PROCESSO'), callback: $scope.saveConcluir}); | |
172 | - } | |
173 | - }); | |
174 | - }; | |
175 | - | |
176 | - $scope.saveConcluir = function(){ | |
177 | - | |
178 | - ProcessoRepository.concluir({"idProcesso" : $scope.processo.id, "idTask" : $scope.task.id}).then(function(result) { | |
179 | - | |
180 | - //Verifica se foi concluido em todas unidades. | |
181 | - $timeout(function() { | |
182 | - if(result){ | |
183 | - if($scope.task.flowElement.actions && $scope.task.flowElement.actions.length == 1){ | |
184 | - $scope.executarProcesso($scope.task.flowElement.actions[0]); | |
43 | + }; | |
44 | + | |
45 | + // CRIAR RELACIONAMENTO DE PROCESSO | |
46 | + $scope.editProcessoRelacionado = function () { | |
47 | + | |
48 | + $scope.fecharPagina(); | |
49 | + $scope.isProcessoRelacionado = true; | |
50 | + | |
51 | + $timeout( function () { | |
52 | + angular.element( "#editProcessoRelacionado" ).scope().getProcessoRelacionado(); | |
53 | + } ); | |
54 | + | |
55 | + }; | |
56 | + | |
57 | + $scope.historicoJustificativa = function () { | |
58 | + $scope.fecharPagina(); | |
59 | + $scope.isHistoricoJustificativa = true; | |
60 | + $timeout( function () { | |
61 | + angular.element( "#justificativaAcaoProcessoList" ).scope().inicializarJustificativa(); | |
62 | + } ); | |
63 | + }; | |
64 | + | |
65 | + $scope.abrirJustificativa = function ( acao ) { | |
66 | + $scope.fecharPagina(); | |
67 | + $scope.isCancelarDocumento = true; | |
68 | + }; | |
69 | + | |
70 | + // CRIA NOVO DOCUMENTO | |
71 | + $scope.newDocument = function () { | |
72 | + | |
73 | + $scope.fecharPagina(); | |
74 | + $scope.isDocumentoEdit = true; | |
75 | + $scope.isVersoesDocumento = false; | |
76 | + $timeout( function () { | |
77 | + angular.element( "#editDocumentoGed" ).scope().resetForm(); | |
78 | + } ); | |
79 | + }; | |
80 | + | |
81 | + // Abre a tela de edição do documento | |
82 | + $scope.editDocument = function ( editarDocumento, edit ) { | |
83 | + | |
84 | + $scope.fecharPagina(); | |
85 | + $scope.isDocumentoEdit = true; | |
86 | + $scope.isVersoesDocumento = false; | |
87 | + | |
88 | + $timeout( function () { | |
89 | + angular.element( "#editDocumentoGed" ).scope().getDocumentoGed( editarDocumento.id, edit ); | |
90 | + } ); | |
91 | + }; | |
92 | + | |
93 | + // ABRE ABA PARA CRIAR NOVO PROCESSO | |
94 | + $scope.novoProcesso = function () { | |
95 | + | |
96 | + var workspace = angular.element( '#editProcessoEcm' ).scope().workspace; | |
97 | + if ( workspace ) { | |
98 | + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); | |
99 | + } | |
100 | + | |
101 | + $scope.openWorkspaceIfNotOpen( $translate.instant( 'ECM.LABEL.PROCESSO' ), '/cit-ecm-web/html/processo/processo.html', 'mod-orange' ); | |
102 | + | |
103 | + $timeout( function () { | |
104 | + angular.element( '#editProcessoEcm' ).scope().$showPageEditWorkspace( angular.element( '#editProcessoEcm' ).scope().workspace ); | |
105 | + angular.element( '#editProcessoEcm' ).scope().resetForm(); | |
106 | + | |
107 | + }, 600 ); | |
108 | + | |
109 | + }; | |
110 | + | |
111 | + // Gerenciar as credenciais do processo | |
112 | + $scope.gerenciarCredenciaisProcesso = function () { | |
113 | + | |
114 | + $scope.fecharPagina(); | |
115 | + $scope.isGerenciarCredencialProcesso = true; | |
116 | + | |
117 | + $timeout( function () { | |
118 | + angular.element( "#credencialProcessoEdit" ).scope().iniciarCredencial( $scope.processo.id, $scope.credencialUsuarioProcesso ); | |
119 | + } ); | |
120 | + }; | |
121 | + | |
122 | + // EXECUÇÃO PROCESSO | |
123 | + $scope.executarProcesso = function ( action ) { | |
124 | + $scope.flowAction = action; | |
125 | + | |
126 | + if ( action.requireReason ) { | |
127 | + $scope.fecharPagina(); | |
128 | + $scope.isJustificativaAcaoProcesso = true; | |
129 | + $timeout( function () { | |
130 | + angular.element( "#justificativaAcaoProcesso" ).scope().resetForm(); | |
131 | + } ); | |
132 | + } else { | |
133 | + $scope.closeWidget(); | |
134 | + | |
135 | + DocumentoGedRepository.existeVinculo( { | |
136 | + 'joinClass' : 'processo.id', | |
137 | + 'id' : $scope.processo.id | |
138 | + } ).then( function ( result ) { | |
139 | + if ( !result ) { | |
140 | + var mensagem = $translate.instant( 'ECM.MSG.PROCESSO_SEM_DOCUMENTO' ) + $scope.flowAction.name; | |
141 | + $scope.showAlert( "warning", mensagem ); | |
142 | + } else { | |
143 | + var mensagem = $translate.instant( 'ECM.MSG.CONFIRMA_EXECUCAO_FLUXO' ); | |
144 | + mensagem += $scope.flowAction.name; | |
145 | + $scope.$openModalConfirm( { | |
146 | + message : mensagem, | |
147 | + callback : $scope.avancarFluxo | |
148 | + } ); | |
149 | + } | |
150 | + } ); | |
151 | + | |
152 | + $scope.saveHistoricoProcessoAcao(); | |
153 | + } | |
154 | + }; | |
155 | + | |
156 | + $scope.avancarFluxo = function () { | |
157 | + $scope.$modalConfirmInstance.dismiss( 'cancel' ); | |
158 | + $scope.updateTask( true ); | |
159 | + | |
160 | + }; | |
161 | + | |
162 | + // Salvar Historico Execução Processo | |
163 | + $scope.saveHistoricoProcessoAcao = function () { | |
164 | + | |
165 | + var historicoAlteracaoProcesso = { | |
166 | + descricaoAcao : $translate.instant( 'ECM.MSG_HISTORICO_ECM.ACAO_PROCESSO' ), | |
167 | + processo : $scope.processo, | |
168 | + autor : $scope.usuarioLogado, | |
169 | + acaoAlteracao : "ACAO_PROCESSO", | |
170 | + mapaAtributos : { | |
171 | + "protocolo" : $scope.processo.nup, | |
172 | + "acao" : $scope.flowAction.name | |
185 | 173 | } |
186 | - }else{ | |
187 | - var workspace = angular.element('#editProcessoEcm').scope().workspace; | |
188 | - if (workspace) { | |
189 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
190 | - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); | |
191 | - | |
192 | - angular.element("#citapp-controller").scope().showAlert("success", $translate.instant('MSG.PROCESSO_ENVIADO_SUCESSO')); | |
193 | - } | |
174 | + }; | |
175 | + | |
176 | + HistoricoAlteracaoProcessoRepository.saveParams( historicoAlteracaoProcesso ).then( function ( result ) { | |
177 | + } ); | |
178 | + }; | |
179 | + | |
180 | + // Conclui o proceso | |
181 | + $scope.concluir = function () { | |
182 | + | |
183 | + DocumentoGedRepository.existeVinculo( { | |
184 | + 'joinClass' : 'processo.id', | |
185 | + 'id' : $scope.processo.id | |
186 | + } ).then( function ( result ) { | |
187 | + if ( !result ) { | |
188 | + var mensagem = $translate.instant( 'ECM.MSG.PROCESSO_SEM_DOCUMENTO' ) + " " + $translate.instant( 'ECM.LABEL.CONCLUIR' ); | |
189 | + $scope.showAlert( "warning", mensagem ); | |
190 | + } else { | |
191 | + | |
192 | + $scope.$openModalConfirm( { | |
193 | + message : $translate.instant( 'ECM.MSG.CONFIRMA_CONCLUIR_PROCESSO' ), | |
194 | + callback : $scope.saveConcluir | |
195 | + } ); | |
196 | + } | |
197 | + } ); | |
198 | + }; | |
199 | + | |
200 | + $scope.saveConcluir = function () { | |
201 | + | |
202 | + ProcessoRepository.concluir( { | |
203 | + "idProcesso" : $scope.processo.id, | |
204 | + "idTask" : $scope.task.id | |
205 | + } ).then( function ( result ) { | |
206 | + | |
207 | + // Verifica se foi concluido em todas unidades. | |
208 | + $timeout( function () { | |
209 | + if ( result ) { | |
210 | + if ( $scope.task.flowElement.actions && $scope.task.flowElement.actions.length == 1 ) { | |
211 | + $scope.executarProcesso( $scope.task.flowElement.actions[ 0 ] ); | |
212 | + } | |
213 | + } else { | |
214 | + var workspace = angular.element( '#editProcessoEcm' ).scope().workspace; | |
215 | + if ( workspace ) { | |
216 | + $scope.$modalConfirmInstance.dismiss( 'cancel' ); | |
217 | + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); | |
218 | + | |
219 | + angular.element( "#citapp-controller" ).scope().showAlert( "success", $translate.instant( 'MSG.PROCESSO_ENVIADO_SUCESSO' ) ); | |
220 | + } | |
221 | + } | |
222 | + | |
223 | + }, 100 ); | |
224 | + | |
225 | + $scope.showAlert( "success", $translate.instant( 'ECM.MSG.SUCESSO_CONCLUIR_PROCESSO' ) ); | |
226 | + | |
227 | + $scope.$modalConfirmInstance.dismiss( 'cancel' ); | |
228 | + | |
229 | + $scope.saveHistoricoProcesso(); | |
230 | + } ); | |
231 | + }; | |
232 | + | |
233 | + // Salvar Historico processo UNIDADE | |
234 | + $scope.saveHistoricoProcesso = function ( unidadesProcessoList ) { | |
235 | + | |
236 | + var historicoAlteracaoProcesso = { | |
237 | + descricaoAcao : $translate.instant( 'ECM.MSG_HISTORICO_ECM.CONCLUSAO_PROCESSO_UNIDADE' ), | |
238 | + processo : $scope.processo, | |
239 | + autor : $scope.usuarioLogado, | |
240 | + acaoAlteracao : "CONCLUSAO_PROCESSO_UNIDADE" | |
241 | + }; | |
242 | + | |
243 | + HistoricoAlteracaoProcessoRepository.saveParams( historicoAlteracaoProcesso ).then( function ( result ) { | |
244 | + | |
245 | + } ); | |
246 | + | |
247 | + }; | |
248 | + | |
249 | + // MONTA O EDITAR DO PROCESSO | |
250 | + $scope.editProcessoECM = function () { | |
251 | + | |
252 | + $scope.fecharPagina(); | |
253 | + $scope.isProcessoEdit = true; | |
254 | + $scope.isVersoesDocumento = false; | |
255 | + | |
256 | + $timeout( function () { | |
257 | + angular.element( '#editProcessoEcm' ).scope().getProcesso( $scope.processo, true ); | |
258 | + angular.element( document.querySelector( '#topoMenu' ) ).remove(); | |
259 | + angular.element( document.querySelector( '#cabecalhoProcesso' ) ).remove(); | |
260 | + } ); | |
261 | + | |
262 | + }; | |
263 | + | |
264 | + // ATUALIZAR PADRÃO DE PROCESSO | |
265 | + $scope.atualizaProcesso = function () { | |
266 | + | |
267 | + $timeout( function () { | |
268 | + ProcessoRepository.get( $scope.processo.id ).then( function ( result ) { | |
269 | + $scope.processo = result.originalElement; | |
270 | + } ); | |
271 | + }, 100 ); | |
272 | + | |
273 | + }; | |
274 | + | |
275 | + // VERSOES DO DOCUMENTO | |
276 | + $scope.visualizarVersoes = function ( documento ) { | |
277 | + | |
278 | + $scope.fecharPagina(); | |
279 | + $scope.isVersoesDocumento = true; | |
280 | + $scope.idDocumento = documento.id; | |
281 | + var idRaiz = documento.idRaiz; | |
282 | + if ( !idRaiz ) { | |
283 | + idRaiz = documento.id; | |
194 | 284 | } |
195 | - | |
196 | - }, 100); | |
197 | - | |
198 | - $scope.showAlert("success", $translate.instant('ECM.MSG.SUCESSO_CONCLUIR_PROCESSO')); | |
199 | - | |
200 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
201 | - | |
202 | - $scope.saveHistoricoProcesso(); | |
203 | - }); | |
204 | - }; | |
205 | - | |
206 | - //Salvar Historico processo UNIDADE | |
207 | - $scope.saveHistoricoProcesso = function(unidadesProcessoList){ | |
208 | - | |
209 | - var historicoAlteracaoProcesso = { | |
210 | - descricaoAcao : $translate.instant('ECM.MSG_HISTORICO_ECM.CONCLUSAO_PROCESSO_UNIDADE'), | |
211 | - processo : $scope.processo, | |
212 | - autor : $scope.usuarioLogado, | |
213 | - acaoAlteracao : "CONCLUSAO_PROCESSO_UNIDADE" | |
214 | - }; | |
215 | - | |
216 | - HistoricoAlteracaoProcessoRepository.saveParams(historicoAlteracaoProcesso).then(function(result){ | |
217 | - | |
218 | - }); | |
219 | - | |
220 | - }; | |
221 | - | |
222 | - // MONTA O EDITAR DO PROCESSO | |
223 | - $scope.editProcessoECM = function() { | |
224 | - | |
225 | - $scope.fecharPagina(); | |
226 | - $scope.isProcessoEdit = true; | |
227 | - $scope.isVersoesDocumento = false; | |
228 | - | |
229 | - $timeout(function() { | |
230 | - angular.element('#editProcessoEcm').scope().getProcesso($scope.processo, true); | |
231 | - angular.element(document.querySelector('#topoMenu')).remove(); | |
232 | - angular.element(document.querySelector('#cabecalhoProcesso')).remove(); | |
233 | - }); | |
234 | - | |
235 | - | |
236 | - }; | |
237 | - | |
238 | - //ATUALIZAR PADRÃO DE PROCESSO | |
239 | - $scope.atualizaProcesso = function() { | |
240 | - | |
241 | - $timeout(function(){ | |
242 | - ProcessoRepository.get($scope.processo.id).then(function(result) { | |
243 | - $scope.processo = result.originalElement; | |
244 | - }); | |
245 | - }, 100); | |
246 | - | |
247 | - }; | |
248 | - | |
249 | - //VERSOES DO DOCUMENTO | |
250 | - $scope.visualizarVersoes = function(documento){ | |
251 | - | |
252 | - $scope.fecharPagina(); | |
253 | - $scope.isVersoesDocumento = true; | |
254 | - $scope.idDocumento = documento.id; | |
255 | - var idRaiz = documento.idRaiz; | |
256 | - if(!idRaiz){ | |
257 | - idRaiz = documento.id; | |
258 | - } | |
259 | - DocumentoGedRepository.findByIdDocumentoTodasVersoes(idRaiz).then(function(result) { | |
260 | - $scope.listVersoes = result; | |
261 | - }); | |
262 | - | |
263 | - }; | |
264 | - | |
265 | - //ENVIAR PROCESSO | |
266 | - $scope.enviarProcesso = function(){ | |
267 | - | |
268 | - DocumentoGedRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { | |
269 | - if(result){ | |
285 | + DocumentoGedRepository.findByIdDocumentoTodasVersoes( idRaiz ).then( function ( result ) { | |
286 | + $scope.listVersoes = result; | |
287 | + } ); | |
288 | + | |
289 | + }; | |
290 | + | |
291 | + // ENVIAR PROCESSO | |
292 | + $scope.enviarProcesso = function () { | |
293 | + | |
294 | + DocumentoGedRepository.existeVinculo( { | |
295 | + 'joinClass' : 'processo.id', | |
296 | + 'id' : $scope.processo.id | |
297 | + } ).then( function ( result ) { | |
298 | + if ( result ) { | |
299 | + $scope.fecharPagina(); | |
300 | + $scope.isEnviarProcesso = true; | |
301 | + | |
302 | + $timeout( function () { | |
303 | + angular.element( "#enviarProcessoEdit" ).scope().iniciarEnvio( $scope.processo.id, $scope.task.id ); | |
304 | + } ); | |
305 | + } else { | |
306 | + $scope.showAlert( "warning", $translate.instant( 'ECM.MSG.PROCESSO_SEM_DOCUMENTO_ENVIO_UNIDADE' ) ); | |
307 | + } | |
308 | + } ); | |
309 | + }; | |
310 | + | |
311 | + // ANEXAR PROCESSO | |
312 | + $scope.anexarProcesso = function () { | |
270 | 313 | $scope.fecharPagina(); |
271 | - $scope.isEnviarProcesso = true; | |
272 | - | |
273 | - $timeout(function() { | |
274 | - angular.element("#enviarProcessoEdit").scope().iniciarEnvio($scope.processo.id, $scope.task.id); | |
275 | - }); | |
276 | - }else{ | |
277 | - $scope.showAlert("warning", $translate.instant('ECM.MSG.PROCESSO_SEM_DOCUMENTO_ENVIO_UNIDADE')); | |
278 | - } | |
279 | - }); | |
280 | - }; | |
281 | - | |
282 | - //ANEXAR PROCESSO | |
283 | - $scope.anexarProcesso = function(){ | |
284 | - $scope.fecharPagina(); | |
285 | - $scope.isAnexarProcesso = true; | |
286 | - $timeout(function() { | |
287 | - angular.element("#anexarProcessoEdit").scope().getProcessoAnexado(); | |
288 | - }); | |
289 | - }; | |
290 | - | |
291 | - | |
292 | - //CLASSIFICAR PROCESSO E DOCUMENTO | |
293 | - $scope.classificarDocumentoProceso = function(){ | |
294 | - $scope.fecharPagina(); | |
295 | - $scope.isClassificarProcessoDocumento = true; | |
296 | - $timeout(function() { | |
297 | - angular.element("#classificarDocumento").scope().getProcesso($scope.processo); | |
298 | - }); | |
299 | - }; | |
300 | - | |
301 | - //REMOVER DOCUMENTO | |
302 | - $scope.removeDocumento = function(documento, index){ | |
303 | - $scope.$openModalConfirm({ | |
304 | - message: $translate.instant('MSG.CONFIRMA_EXCLUSAO'), | |
305 | - callback: function () { | |
306 | - DocumentoGedRepository.remove(documento).then(function() { | |
307 | - | |
308 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
309 | - $scope.showAlert("success", $translate.instant('MSG.SUCESSO_EXCLUIR')); | |
310 | - $scope.isDocumentoEdit = false; | |
311 | - $scope.processo.documentos.splice(index , 1); | |
312 | - | |
313 | - var historicoAlteracaoProcesso = { | |
314 | - documentoGed : $scope.documentoGed, | |
315 | - descricaoAcao : $translate.instant('ECM.MSG_HISTORICO_ECM.REMOCAO_DOCUMENTO'), | |
316 | - processo : $scope.processo, | |
317 | - autor : $scope.usuarioLogado, | |
318 | - idTask : $scope.task.id, | |
319 | - acaoAlteracao : "REMOCAO_DOCUMENTO" | |
320 | - }; | |
321 | - HistoricoAlteracaoProcessoRepository.saveParams(historicoAlteracaoProcesso).then(function(result){ | |
322 | - | |
323 | - }); | |
324 | - }); | |
325 | - } | |
326 | - }); | |
327 | - }; | |
328 | - | |
329 | - //Exibir dialog para remover credencial do usuário | |
330 | - $scope.exibirDialogConfirmacaoRemoverCredencial = function(){ | |
331 | - | |
332 | - $scope.$openModalConfirm({message: $translate.instant('ECM.MSG.CONFIRMA_RENUNCIAR_CREDENCIAL'), callback: $scope.removeCredemcial}); | |
333 | - | |
334 | - }; | |
335 | - | |
336 | - //Remover a credencial do usuário | |
337 | - $scope.removeCredemcial = function(){ | |
338 | - | |
339 | - CredencialProcessoRepository.remove($scope.credencialUsuarioProcesso).then(function() { | |
340 | - | |
341 | - $scope.credencialUsuarioProcesso = null; | |
342 | - | |
343 | - $scope.voltarGerenciamentoTarefa(); | |
344 | - | |
345 | - }); | |
346 | - }; | |
347 | - | |
348 | - //Voltar para tela de gerenciamento de tarefa | |
349 | - $scope.voltarGerenciamentoTarefa = function(){ | |
350 | - | |
351 | - var workspace = angular.element('#searchGerenciarProcesso').scope().workspace; | |
352 | - if (workspace) { | |
353 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
354 | - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); | |
355 | - | |
356 | - angular.element("#citapp-controller").scope().showAlert("success", $translate.instant('ECM.MSG.CREDENCIAL_REMOVIDA_SUCESSO')); | |
357 | - } | |
358 | - | |
359 | - $timeout(function(){ | |
360 | - angular.element('#idGerenciamentoTarefas').scope().fetchResult(); | |
361 | - }); | |
362 | - | |
363 | - }; | |
364 | - | |
365 | - //Cancelar documento | |
366 | - $scope.cancelarDocumento = function(documento){ | |
367 | - | |
368 | - $scope.fecharPagina(); | |
369 | - $scope.isCancelarDocumento = true; | |
370 | - $timeout(function() { | |
371 | - angular.element("#cancelarDocumento").scope().resetForm(documento, $scope.task.id); | |
372 | - }); | |
373 | - }; | |
374 | - | |
375 | - $scope.getCancelamentoDocumento = function(documento){ | |
376 | - | |
377 | - $scope.fecharPagina(); | |
378 | - $scope.isCancelarDocumento = true; | |
379 | - $timeout(function() { | |
380 | - angular.element("#cancelarDocumento").scope().getCancelamentoDocumento(documento.cancelamentoDocumentoGed.id); | |
381 | - }); | |
382 | - }; | |
383 | - | |
384 | - // SALVA PROCESSO | |
385 | - $scope.saveOrUpdateProcessoECM = function() { | |
386 | - | |
387 | - // CHAMA GRAVAR DO PROCESSOCONTROLLER.JS | |
388 | - angular.element('#editProcessoEcm').scope().saveOrUpdate(); | |
389 | - | |
390 | - $scope.closeWidget(); | |
391 | - $scope.atualizaProcesso(); | |
392 | - }; | |
393 | - | |
394 | - | |
395 | - // ABRE A VIEW DE GERENCIAR PROCESSO ANEXO | |
396 | - $scope.viewProcessoAnexo = function (processoViewAnexo){ | |
397 | - if(processoViewAnexo != null){ | |
398 | - | |
399 | - var pagina = '/cit-ecm-web/html/gerenciarProcesso/gerenciarProcessoView.html'; | |
400 | - | |
401 | - $scope.openWorkspaceIfNotOpen($translate.instant('ECM.LABEL.PROCESSO'), pagina, 'mod-orange'); | |
402 | - | |
403 | - $timeout(function() { | |
404 | - angular.element('#viewGerenciarProcesso').scope().getProcessoRelacionado(processoViewAnexo); | |
405 | - | |
406 | - }, 400); | |
407 | - } | |
408 | - }; | |
409 | - //FIM | |
410 | - | |
411 | - // FECHA WIDGET E INICIA WIDGET PADRÃO | |
412 | - $scope.closeWidget = function() { | |
413 | - angular.element("#widget-historico").scope().atualizar(); | |
414 | - | |
415 | - $scope.fecharPagina(); | |
416 | - $scope.widgetExemploIsCollapsed = false; | |
417 | - //WIDGET PRADAO | |
418 | - $scope.isHistoricoProcesso = true; | |
419 | - }; | |
420 | - | |
421 | - $scope.tratimitado = function(){ | |
422 | - UnidadeProcessoRepository.existeVinculo({'joinClass' : 'processo.id', 'id': $scope.processo.id}).then(function(result) { | |
423 | - if(result){ | |
424 | - $scope.isTramitado = true; | |
425 | - }else{ | |
426 | - $scope.isTramitado = false; | |
427 | - } | |
428 | - }); | |
429 | - }; | |
430 | - | |
431 | - | |
432 | - | |
433 | - // ------------------------------EXECUTA BPE------------------------------------ | |
434 | - | |
435 | - // ATUALIZAR TASK BPE | |
436 | - $scope.updateTask = function(complete) { | |
437 | - if ($scope.updateAction && (!$scope.flowAction || !$scope.flowAction.id)) { | |
438 | - $scope.showAlert("error", $translate.instant('ESI.MSG.SELECIONE_ACAO')); | |
439 | - return; | |
440 | - } | |
314 | + $scope.isAnexarProcesso = true; | |
315 | + $timeout( function () { | |
316 | + angular.element( "#anexarProcessoEdit" ).scope().getProcessoAnexado(); | |
317 | + } ); | |
318 | + }; | |
441 | 319 | |
320 | + // CLASSIFICAR PROCESSO E DOCUMENTO | |
321 | + $scope.classificarDocumentoProceso = function () { | |
322 | + $scope.fecharPagina(); | |
323 | + $scope.isClassificarProcessoDocumento = true; | |
324 | + $timeout( function () { | |
325 | + angular.element( "#classificarDocumento" ).scope().getProcesso( $scope.processo ); | |
326 | + } ); | |
327 | + }; | |
442 | 328 | |
443 | - // Executa regras criadas | |
444 | - if ($scope.businessRule && $scope.businessRule != '') { | |
445 | - $scope.buildBusinessRuleVariables(); | |
446 | - $scope[$scope.businessRule] = undefined; | |
447 | - RuntimeManagerRepository.executeBusinessRule($scope.businessRule, $scope.businessRuleVariables).then(function(result) { | |
448 | - $scope[$scope.businessRule] = result.originalElement.businessRule; | |
449 | - if ($scope[$scope.businessRule] && $scope[$scope.businessRule].valid) { | |
450 | - $scope.execute(complete); | |
451 | - } | |
452 | - }); | |
453 | - }else{ | |
454 | - $scope.execute(complete); | |
455 | - } | |
456 | - | |
457 | - }; | |
458 | - | |
459 | - // FIM | |
460 | - | |
461 | - $scope.hasTaskVariable = function(name) { | |
462 | - for (var i = 0; i < $scope.taskVariables.length; i++) { | |
463 | - if ($scope.taskVariables[i].name == name) { | |
464 | - return true; | |
465 | - } | |
466 | - } | |
467 | - return false; | |
468 | - }; | |
469 | - | |
470 | - | |
471 | - // EXCUTA TAREFA BPE | |
472 | - $scope.execute = function(complete) { | |
473 | - $scope.setLoading(true,$translate.instant('ESI.EXECUTANDO_TAREFA')+" "+$scope.task.flowElement.name); | |
474 | - $scope.runtimeManagerUtils.executeCode("beforeUpdate"); | |
475 | - | |
476 | - var idRetorno = ESI_RETURN+$scope.flowName; | |
477 | - var idParam = ESI_PARAM+$scope.flowName; | |
478 | - $scope[idParam] = new RuntimeEnvironmentInput($scope.flowName,$scope.taskVariables); | |
479 | - $scope[idParam].workItemId = $scope.task.id; | |
480 | - $scope[idParam].updateFlowAction = $scope.updateAction; | |
481 | - | |
482 | - // ADICIONA ACÃO DO FLUXO NO SCOPO | |
483 | - if ($scope.updateAction) { | |
484 | - $scope[idParam].flowAction = $scope.flowAction; | |
485 | - } | |
329 | + // REMOVER DOCUMENTO | |
330 | + $scope.removeDocumento = function ( documento, index ) { | |
331 | + $scope.$openModalConfirm( { | |
332 | + message : $translate.instant( 'MSG.CONFIRMA_EXCLUSAO' ), | |
333 | + callback : function () { | |
334 | + DocumentoGedRepository.remove( documento ).then( function () { | |
335 | + | |
336 | + $scope.$modalConfirmInstance.dismiss( 'cancel' ); | |
337 | + $scope.showAlert( "success", $translate.instant( 'MSG.SUCESSO_EXCLUIR' ) ); | |
338 | + $scope.isDocumentoEdit = false; | |
339 | + $scope.processo.documentos.splice( index, 1 ); | |
340 | + | |
341 | + var historicoAlteracaoProcesso = { | |
342 | + documentoGed : $scope.documentoGed, | |
343 | + descricaoAcao : $translate.instant( 'ECM.MSG_HISTORICO_ECM.REMOCAO_DOCUMENTO' ), | |
344 | + processo : $scope.processo, | |
345 | + autor : $scope.usuarioLogado, | |
346 | + idTask : $scope.task.id, | |
347 | + acaoAlteracao : "REMOCAO_DOCUMENTO" | |
348 | + }; | |
349 | + HistoricoAlteracaoProcessoRepository.saveParams( historicoAlteracaoProcesso ).then( function ( result ) { | |
350 | + | |
351 | + } ); | |
352 | + } ); | |
353 | + } | |
354 | + } ); | |
355 | + }; | |
486 | 356 | |
487 | - $scope[idRetorno] = new RuntimeEnvironmentOutput(null); | |
488 | - | |
489 | - RuntimeManagerRepository.updateTask($scope[idParam], complete).then(function(result) { | |
490 | - $scope[idRetorno] = new RuntimeEnvironmentOutput(result.originalElement); | |
491 | - $scope.runtimeManagerUtils.setObjectValues($scope[idRetorno]); | |
492 | - | |
493 | - $scope.processInstance = result.originalElement.processInstance; | |
494 | - | |
495 | - $scope.runtimeManagerUtils.saveDocuments($scope[idRetorno].processInstance, $scope.task); | |
496 | - | |
497 | - $scope.runtimeManagerUtils.executeCode("afterUpdate"); | |
498 | - $scope.setLoading(false); | |
499 | - $scope.showExecuteButton = false; | |
500 | - if ($scope.callbackFunction != null) | |
501 | - $scope.callbackFunction(); | |
502 | - $rootScope.controllerScope.fetchResult(); | |
503 | - if ($scope.removeWorkspace) | |
504 | - $scope.close(); | |
505 | - $scope.showAlert("success","ESI.MSG.TAREFA_EXECUTADA",""); | |
506 | - | |
507 | - }); | |
508 | - }; | |
509 | - | |
510 | - // FIM | |
511 | - | |
512 | - $scope.close = function() { | |
513 | - var workspace = angular.element('#searchGerenciarProcesso').scope().workspace; | |
514 | - if (workspace) { | |
515 | - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); | |
516 | - } | |
517 | - }; | |
518 | - | |
519 | - | |
520 | - // RETORNA VARIAVEIS DA TASK BPE | |
521 | - $scope.buildTaskVariables = function() { | |
522 | - if ($scope.task.flowElement.variables) { | |
523 | - for (var i = 0; i < $scope.task.flowElement.variables.length; i++) { | |
524 | - var taskVariable = $scope.task.flowElement.variables[i]; | |
525 | - if (taskVariable.output) { | |
526 | - if ($scope[taskVariable.flowVariable.variable.name] != undefined && !$scope.hasTaskVariable(taskVariable.flowVariable.variable.name)) { | |
527 | - $scope.taskVariables.push(new RuntimeVariable(taskVariable.flowVariable.variable.name , taskVariable.flowVariable.variable.variableType, $scope[taskVariable.flowVariable.variable.name])); | |
357 | + // Exibir dialog para remover credencial do usuário | |
358 | + $scope.exibirDialogConfirmacaoRemoverCredencial = function () { | |
359 | + | |
360 | + $scope.$openModalConfirm( { | |
361 | + message : $translate.instant( 'ECM.MSG.CONFIRMA_RENUNCIAR_CREDENCIAL' ), | |
362 | + callback : $scope.removeCredemcial | |
363 | + } ); | |
364 | + | |
365 | + }; | |
366 | + | |
367 | + // Remover a credencial do usuário | |
368 | + $scope.removeCredemcial = function () { | |
369 | + | |
370 | + CredencialProcessoRepository.remove( $scope.credencialUsuarioProcesso ).then( function () { | |
371 | + | |
372 | + $scope.credencialUsuarioProcesso = null; | |
373 | + | |
374 | + $scope.voltarGerenciamentoTarefa(); | |
375 | + | |
376 | + } ); | |
377 | + }; | |
378 | + | |
379 | + // Voltar para tela de gerenciamento de tarefa | |
380 | + $scope.voltarGerenciamentoTarefa = function () { | |
381 | + | |
382 | + var workspace = angular.element( '#searchGerenciarProcesso' ).scope().workspace; | |
383 | + if ( workspace ) { | |
384 | + $scope.$modalConfirmInstance.dismiss( 'cancel' ); | |
385 | + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); | |
386 | + | |
387 | + angular.element( "#citapp-controller" ).scope().showAlert( "success", $translate.instant( 'ECM.MSG.CREDENCIAL_REMOVIDA_SUCESSO' ) ); | |
388 | + } | |
389 | + | |
390 | + $timeout( function () { | |
391 | + angular.element( '#idGerenciamentoTarefas' ).scope().fetchResult(); | |
392 | + } ); | |
393 | + | |
394 | + }; | |
395 | + | |
396 | + // Cancelar documento | |
397 | + $scope.cancelarDocumento = function ( documento ) { | |
398 | + | |
399 | + $scope.fecharPagina(); | |
400 | + $scope.isCancelarDocumento = true; | |
401 | + $timeout( function () { | |
402 | + angular.element( "#cancelarDocumento" ).scope().resetForm( documento, $scope.task.id ); | |
403 | + } ); | |
404 | + }; | |
405 | + | |
406 | + $scope.getCancelamentoDocumento = function ( documento ) { | |
407 | + | |
408 | + $scope.fecharPagina(); | |
409 | + $scope.isCancelarDocumento = true; | |
410 | + $timeout( function () { | |
411 | + angular.element( "#cancelarDocumento" ).scope().getCancelamentoDocumento( documento.cancelamentoDocumentoGed.id ); | |
412 | + } ); | |
413 | + }; | |
414 | + | |
415 | + // SALVA PROCESSO | |
416 | + $scope.saveOrUpdateProcessoECM = function () { | |
417 | + | |
418 | + // CHAMA GRAVAR DO PROCESSOCONTROLLER.JS | |
419 | + angular.element( '#editProcessoEcm' ).scope().saveOrUpdate(); | |
420 | + | |
421 | + $scope.closeWidget(); | |
422 | + $scope.atualizaProcesso(); | |
423 | + }; | |
424 | + | |
425 | + // ABRE A VIEW DE GERENCIAR PROCESSO ANEXO | |
426 | + $scope.viewProcessoAnexo = function ( processoViewAnexo ) { | |
427 | + if ( processoViewAnexo != null ) { | |
428 | + | |
429 | + var pagina = '/cit-ecm-web/html/gerenciarProcesso/gerenciarProcessoView.html'; | |
430 | + | |
431 | + $scope.openWorkspaceIfNotOpen( $translate.instant( 'ECM.LABEL.PROCESSO' ), pagina, 'mod-orange' ); | |
432 | + | |
433 | + $timeout( function () { | |
434 | + angular.element( '#viewGerenciarProcesso' ).scope().getProcessoRelacionado( processoViewAnexo ); | |
435 | + | |
436 | + }, 400 ); | |
437 | + } | |
438 | + }; | |
439 | + // FIM | |
440 | + | |
441 | + // FECHA WIDGET E INICIA WIDGET PADRÃO | |
442 | + $scope.closeWidget = function () { | |
443 | + angular.element( "#widget-historico" ).scope().atualizar(); | |
444 | + | |
445 | + $scope.fecharPagina(); | |
446 | + $scope.widgetExemploIsCollapsed = false; | |
447 | + // WIDGET PRADAO | |
448 | + $scope.isHistoricoProcesso = true; | |
449 | + }; | |
450 | + | |
451 | + $scope.tratimitado = function () { | |
452 | + UnidadeProcessoRepository.existeVinculo( { | |
453 | + 'joinClass' : 'processo.id', | |
454 | + 'id' : $scope.processo.id | |
455 | + } ).then( function ( result ) { | |
456 | + if ( result ) { | |
457 | + $scope.isTramitado = true; | |
458 | + } else { | |
459 | + $scope.isTramitado = false; | |
460 | + } | |
461 | + } ); | |
462 | + }; | |
463 | + | |
464 | + // ------------------------------EXECUTA BPE------------------------------------ | |
465 | + | |
466 | + // ATUALIZAR TASK BPE | |
467 | + $scope.updateTask = function ( complete ) { | |
468 | + if ( $scope.updateAction && ( !$scope.flowAction || !$scope.flowAction.id ) ) { | |
469 | + $scope.showAlert( "error", $translate.instant( 'ESI.MSG.SELECIONE_ACAO' ) ); | |
470 | + return; | |
471 | + } | |
472 | + | |
473 | + // Executa regras criadas | |
474 | + if ( $scope.businessRule && $scope.businessRule != '' ) { | |
475 | + $scope.buildBusinessRuleVariables(); | |
476 | + $scope[ $scope.businessRule ] = undefined; | |
477 | + RuntimeManagerRepository.executeBusinessRule( $scope.businessRule, $scope.businessRuleVariables ).then( function ( result ) { | |
478 | + $scope[ $scope.businessRule ] = result.originalElement.businessRule; | |
479 | + if ( $scope[ $scope.businessRule ] && $scope[ $scope.businessRule ].valid ) { | |
480 | + $scope.execute( complete ); | |
528 | 481 | } |
482 | + } ); | |
483 | + } else { | |
484 | + $scope.execute( complete ); | |
485 | + } | |
486 | + | |
487 | + }; | |
488 | + | |
489 | + // FIM | |
490 | + | |
491 | + $scope.hasTaskVariable = function ( name ) { | |
492 | + for ( var i = 0; i < $scope.taskVariables.length; i++ ) { | |
493 | + if ( $scope.taskVariables[ i ].name == name ) { | |
494 | + return true; | |
529 | 495 | } |
530 | 496 | } |
497 | + return false; | |
531 | 498 | }; |
532 | - }; | |
533 | - // FIM | |
534 | - | |
535 | - // METODOS DE INICIACAO DO BPE | |
536 | - $scope.initialize = function() { | |
537 | - $scope.setLoading(true); | |
538 | - | |
539 | - RuntimeManagerRepository.initializeUserTask($scope.task.id).then(function(result) { | |
540 | - $scope.task = result.originalElement.workItem; | |
541 | - | |
542 | - //VERIFICA SE A TASK(WORKITEM) JÁ FOI EXECULTADO | |
543 | - if ($scope.task.status == 'CANCELLED' || $scope.task.status == 'COMPLETED') { | |
544 | - $scope.setLoading(false); | |
545 | - $scope.showAlert('error', $translate.instant('ESI.MSG.TAREFA_JA_EXECUTADA')); | |
546 | - return ; | |
499 | + | |
500 | + // EXCUTA TAREFA BPE | |
501 | + $scope.execute = function ( complete ) { | |
502 | + $scope.setLoading( true, $translate.instant( 'ESI.EXECUTANDO_TAREFA' ) + " " + $scope.task.flowElement.name ); | |
503 | + $scope.runtimeManagerUtils.executeCode( "beforeUpdate" ); | |
504 | + | |
505 | + var idRetorno = ESI_RETURN + $scope.flowName; | |
506 | + var idParam = ESI_PARAM + $scope.flowName; | |
507 | + $scope[ idParam ] = new RuntimeEnvironmentInput( $scope.flowName, $scope.taskVariables ); | |
508 | + $scope[ idParam ].workItemId = $scope.task.id; | |
509 | + $scope[ idParam ].updateFlowAction = $scope.updateAction; | |
510 | + | |
511 | + // ADICIONA ACÃO DO FLUXO NO SCOPO | |
512 | + if ( $scope.updateAction ) { | |
513 | + $scope[ idParam ].flowAction = $scope.flowAction; | |
547 | 514 | } |
548 | - | |
549 | - // COLOCA AS VARIAVEIS DE RETORNO NO SCOPO | |
550 | - $scope.runtimeManagerUtils = new RuntimeManagerUtils($scope, $scope, $translate, RuntimeManagerRepository); | |
551 | - var idRetorno = ESI_RETURN+$scope.task.processInstance.id; | |
552 | - $scope[idRetorno] = new RuntimeEnvironmentOutput(result.originalElement); | |
553 | - $scope.runtimeManagerUtils.setObjectValues($scope[idRetorno]); | |
554 | - // FIM | |
555 | - | |
556 | - //VERIFICA SE EXISTE MAIS DE UMA AÇÃO NA EXECUÇÃO DO WORK ITEM | |
557 | - $scope.updateAction = $scope.task.flowElement.actions && $scope.task.flowElement.actions.length > 0; | |
558 | - if ($scope.task.flowElement.actions.length == 1) { | |
559 | - $scope.flowAction = $scope.task.flowElement.actions[0]; | |
515 | + | |
516 | + $scope[ idRetorno ] = new RuntimeEnvironmentOutput( null ); | |
517 | + | |
518 | + RuntimeManagerRepository.updateTask( $scope[ idParam ], complete ).then( function ( result ) { | |
519 | + $scope[ idRetorno ] = new RuntimeEnvironmentOutput( result.originalElement ); | |
520 | + $scope.runtimeManagerUtils.setObjectValues( $scope[ idRetorno ] ); | |
521 | + | |
522 | + $scope.processInstance = result.originalElement.processInstance; | |
523 | + | |
524 | + $scope.runtimeManagerUtils.saveDocuments( $scope[ idRetorno ].processInstance, $scope.task ); | |
525 | + | |
526 | + $scope.runtimeManagerUtils.executeCode( "afterUpdate" ); | |
527 | + $scope.setLoading( false ); | |
528 | + $scope.showExecuteButton = false; | |
529 | + if ( $scope.callbackFunction != null ) | |
530 | + $scope.callbackFunction(); | |
531 | + $rootScope.controllerScope.fetchResult(); | |
532 | + if ( $scope.removeWorkspace ) | |
533 | + $scope.close(); | |
534 | + $scope.showAlert( "success", "ESI.MSG.TAREFA_EXECUTADA", "" ); | |
535 | + | |
536 | + } ); | |
537 | + }; | |
538 | + | |
539 | + // FIM | |
540 | + | |
541 | + $scope.close = function () { | |
542 | + var workspace = angular.element( '#searchGerenciarProcesso' ).scope().workspace; | |
543 | + if ( workspace ) { | |
544 | + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); | |
560 | 545 | } |
561 | - $scope.siglas = []; | |
562 | - | |
563 | - | |
564 | - // CARREGA O PROCESSO VINCULADO A TAREFA | |
565 | - $timeout(function(){ | |
566 | - // console.log('idProcesso:' + $scope.idProcesso); | |
567 | - ProcessoRepository.get($scope.idProcesso).then(function(result) { | |
568 | - $scope.processo = result.originalElement; | |
569 | - | |
570 | - CredencialProcessoRepository.obterCredencialUsuarioLogado($scope.idProcesso).then(function(result) { | |
571 | - $scope.credencialUsuarioProcesso = result.originalElement; | |
572 | - }); | |
573 | - | |
574 | - if ($scope.$parent != undefined) { | |
575 | - $scope.$parent.idProcesso = $scope.idProcesso; | |
576 | - } | |
577 | - | |
578 | - if (angular.element('#viewGerenciarProcesso').scope() != undefined) { | |
579 | - var workspace = angular.element('#viewGerenciarProcesso').scope().workspace; | |
580 | - angular.element("#citapp-controller").scope().removeWorkspace(workspace.id); | |
546 | + }; | |
547 | + | |
548 | + // RETORNA VARIAVEIS DA TASK BPE | |
549 | + $scope.buildTaskVariables = function () { | |
550 | + if ( $scope.task.flowElement.variables ) { | |
551 | + for ( var i = 0; i < $scope.task.flowElement.variables.length; i++ ) { | |
552 | + var taskVariable = $scope.task.flowElement.variables[ i ]; | |
553 | + if ( taskVariable.output ) { | |
554 | + if ( $scope[ taskVariable.flowVariable.variable.name ] != undefined && !$scope.hasTaskVariable( taskVariable.flowVariable.variable.name ) ) { | |
555 | + $scope.taskVariables.push( new RuntimeVariable( taskVariable.flowVariable.variable.name, taskVariable.flowVariable.variable.variableType, | |
556 | + $scope[ taskVariable.flowVariable.variable.name ] ) ); | |
557 | + } | |
581 | 558 | } |
582 | - | |
583 | - $scope.tratimitado(); | |
584 | - | |
585 | - $scope.setLoading(false); | |
586 | - }); | |
587 | - | |
588 | - }, 400); | |
589 | - }); | |
590 | - }; | |
591 | - // FIM EXECUTAR BPE | |
592 | - | |
593 | - if($scope.task != null){ | |
594 | - $scope.initialize(); | |
595 | - } | |
596 | - | |
597 | - $scope.getProcesso = function(processo){ | |
598 | - | |
599 | - $scope.setLoadingGet(true); | |
600 | - | |
601 | - $scope.isHistoricoProcesso = true; | |
602 | - | |
603 | - $scope.processo = processo; | |
604 | - $scope.idProcesso = $scope.processo.id; | |
605 | - | |
606 | - $scope.setLoading(false); | |
607 | - | |
608 | - }; | |
609 | - | |
610 | - | |
611 | -}]); | |
559 | + } | |
560 | + } | |
561 | + ; | |
562 | + }; | |
563 | + // FIM | |
564 | + | |
565 | + // METODOS DE INICIACAO DO BPE | |
566 | + $scope.initialize = function () { | |
567 | + $scope.setLoading( true ); | |
568 | + | |
569 | + RuntimeManagerRepository.initializeUserTask( $scope.task.id ).then( function ( result ) { | |
570 | + $scope.task = result.originalElement.workItem; | |
571 | + | |
572 | + // VERIFICA SE A TASK(WORKITEM) JÁ FOI EXECULTADO | |
573 | + if ( $scope.task.status == 'CANCELLED' || $scope.task.status == 'COMPLETED' ) { | |
574 | + $scope.setLoading( false ); | |
575 | + $scope.showAlert( 'error', $translate.instant( 'ESI.MSG.TAREFA_JA_EXECUTADA' ) ); | |
576 | + return; | |
577 | + } | |
578 | + | |
579 | + // COLOCA AS VARIAVEIS DE RETORNO NO SCOPO | |
580 | + $scope.runtimeManagerUtils = new RuntimeManagerUtils( $scope, $scope, $translate, RuntimeManagerRepository ); | |
581 | + var idRetorno = ESI_RETURN + $scope.task.processInstance.id; | |
582 | + $scope[ idRetorno ] = new RuntimeEnvironmentOutput( result.originalElement ); | |
583 | + $scope.runtimeManagerUtils.setObjectValues( $scope[ idRetorno ] ); | |
584 | + // FIM | |
585 | + | |
586 | + // VERIFICA SE EXISTE MAIS DE UMA AÇÃO NA EXECUÇÃO DO WORK ITEM | |
587 | + $scope.updateAction = $scope.task.flowElement.actions && $scope.task.flowElement.actions.length > 0; | |
588 | + if ( $scope.task.flowElement.actions.length == 1 ) { | |
589 | + $scope.flowAction = $scope.task.flowElement.actions[ 0 ]; | |
590 | + } | |
591 | + $scope.siglas = []; | |
592 | + | |
593 | + // CARREGA O PROCESSO VINCULADO A TAREFA | |
594 | + $timeout( function () { | |
595 | + // console.log('idProcesso:' + $scope.idProcesso); | |
596 | + ProcessoRepository.get( $scope.idProcesso ).then( function ( result ) { | |
597 | + $scope.processo = result.originalElement; | |
598 | + | |
599 | + CredencialProcessoRepository.obterCredencialUsuarioLogado( $scope.idProcesso ).then( function ( result ) { | |
600 | + $scope.credencialUsuarioProcesso = result.originalElement; | |
601 | + } ); | |
602 | + | |
603 | + if ( $scope.$parent != undefined ) { | |
604 | + $scope.$parent.idProcesso = $scope.idProcesso; | |
605 | + } | |
606 | + | |
607 | + if ( angular.element( '#viewGerenciarProcesso' ).scope() != undefined ) { | |
608 | + var workspace = angular.element( '#viewGerenciarProcesso' ).scope().workspace; | |
609 | + angular.element( "#citapp-controller" ).scope().removeWorkspace( workspace.id ); | |
610 | + } | |
611 | + | |
612 | + $scope.tratimitado(); | |
613 | + | |
614 | + $scope.setLoading( false ); | |
615 | + } ); | |
616 | + | |
617 | + }, 400 ); | |
618 | + } ); | |
619 | + }; | |
620 | + // FIM EXECUTAR BPE | |
621 | + | |
622 | + if ( $scope.task != null ) { | |
623 | + $scope.initialize(); | |
624 | + } | |
625 | + | |
626 | + $scope.getProcesso = function ( processo ) { | |
627 | + | |
628 | + $scope.setLoadingGet( true ); | |
629 | + | |
630 | + $scope.isHistoricoProcesso = true; | |
631 | + | |
632 | + $scope.processo = processo; | |
633 | + $scope.idProcesso = $scope.processo.id; | |
634 | + | |
635 | + $scope.setLoading( false ); | |
636 | + | |
637 | + }; | |
638 | + | |
639 | + } | |
640 | +] ); | ... | ... |