Last active
July 18, 2019 19:47
-
-
Save pmtozzi/c7841f5790fef09044fd2e0a89ac528b to your computer and use it in GitHub Desktop.
ErrosAbrirDetalhes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arguments passed into this controller can be accessed via the `$.args` object directly or: | |
var args = $.args; | |
$.setFatTratamento = function(fatTratamento){ | |
$.fatTratamento.set(fatTratamento); | |
$.fatTratamento.trigger("change"); | |
}; | |
$.getFatTratamento= function(){ | |
return $.fatTratamento; | |
}; | |
function abrirDetalhes(e){ | |
var Win = Alloy.createController("/faturamentoEletronico/tratamentoGTO", { | |
fatTratamento : $.fatTratamento | |
}); | |
Alloy.Globals.Transicao.proxima(Win, Win.init, {}); | |
} | |
function faturar(e){ | |
var mdAuto = $.fatTratamento.getFatTratamento(); | |
mdAuto.verificaAbandono(function(e){ | |
if(e.sucesso){ | |
efetivaFaturar(); | |
} else { | |
Alloy.Globals.showPopup("Falha", e.mensagem); | |
} | |
}); | |
} | |
function finalizar(e){ | |
var mdAuto = $.fatTratamento.getFatTratamento(); | |
finalizarTratamento(); | |
} | |
function abandonar(e){ | |
var md = $.fatTratamento.where({id : e.source.index})[0]; | |
args.fatTratamento = md; | |
var ctrlFormulario = Alloy.createController("/faturamentoEletronico/formularioAbandono", args); | |
Alloy.Globals.Transicao.proxima(ctrlFormulario, ctrlFormulario.init, {}); | |
} | |
function efetivaFaturar(){ | |
var mdAuto = $.fatTratamento.getFatTratamento(); | |
mdAuto.salvarFaturar(function(e){ | |
if(e.sucesso){ | |
args.refresh && args.refresh(); | |
Alloy.Globals.showPopup("Sucesso", "GTO faturada com sucesso."); | |
} else { | |
Alloy.Globals.showPopup("Falha", e.mensagem); | |
} | |
}); | |
} | |
$.setFatTratamento(args.fatTratamento); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- botao detalhes que chama o TratamentoGTO --> | |
<Alloy> | |
<Model src="fatTratamento" id="fatTratamento" instance="true"></Model> | |
<View layout="vertical" class="shadowView containerRow" > | |
<View left="12" right="12" height="Titanium.UI.SIZE" layout="vertical"> | |
<View height="Titanium.UI.SIZE" width="Titanium.UI.FILL" top="12"> | |
<ImageView class="situacaoImagem" image="{$.fatTratamento.imagem}"></ImageView> | |
<View class="corpo" layout="vertical"> | |
<Label class="lblTituloRow" attributedString="{$.fatTratamento.attrCodigoEventoTabela}"></Label> | |
<Label class="lblTituloRow" attributedString="{$.fatTratamento.attrDenteRegiao}"></Label> | |
</View> | |
</View> | |
<View width="Titanium.UI.FILL" height="Titanium.UI.SIZE" > | |
<!--View width="100%" height="Titanium.UI.SIZE" left="0"--> | |
<Widget src="GUI" name="ImgButton" class="btnDetalhe" onClick="abrirDetalhes" /> | |
<!--/View--> | |
</View> | |
<View class="linha" top="5" left="0" right="0" backgroundColor="lightgray" ></View> | |
<View height="Titanium.UI.SIZE" width="Titanium.UI.FILL" top="6" > | |
<View class="corpo" left="0"> | |
<View class="blocoDescricaoTitulo"> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Descrição evento:</Label> | |
</View> | |
<View class="blocoValorTitulo"> | |
<View height="Ti.UI.SIZE" width="Ti.UI.FILL" backgroundColor="#ededed" top="4"> | |
<Label class="lblTituloRow lblTituloRowBold" text="{$.fatTratamento.strDescricao}" top="10" left="10" right="10" bottom="10"></Label> | |
</View> | |
</View> | |
</View> | |
</View> | |
<View width="Titanium.UI.FILL" height="Titanium.UI.SIZE" top="8"> | |
<View width="48%" height="Titanium.UI.SIZE" left="0" > | |
<Widget src="GUI" name="ImgButton" class="btnAbandonar" onClick="abandonar" /> | |
</View> | |
<View width="48%" height="Titanium.UI.SIZE" right="0" top="8"> | |
<Widget src="GUI" name="ImgButton" class="btnFinalizar"/> | |
</View> | |
</View> | |
</View> | |
<View height="10" /> | |
</View> | |
</Alloy> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Controllers | |
// Arguments passed into this controller can be accessed via the `$.args` object directly or: | |
var args = $.args; | |
$.setTratamentoGTO = function(tratamentoGTO){ | |
$.tratamentoGTO.set(args.fatTratamento); | |
$.tratamentoGTO.trigger("change"); | |
}; | |
$.getTratamentoGTO = function(){ | |
return $.tratamentoGTO; | |
}; | |
function abrirPdf(){ | |
/* | |
$.capaLote.gerarPdf(function(e){ | |
if(e.sucesso){ | |
require("/foursys/utils/gui").abrePdf(Ti.Utils.base64decode(e.pdfCapaLote.conteudoArquivo), e.pdfCapaLote.nomeArquivo); | |
} else { | |
Alloy.Globals.showPopup("Falha", e.mensagem); | |
} | |
}); | |
*/ | |
} | |
$.setTratamentoGTO(args.fatTratamento); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.definition = { | |
config: { | |
columns: { | |
"autorizacaoLiberada" : "string", | |
"codigoEventoTabela" : "string", | |
"id" : "number", | |
"idDenteRegiao" : "number", | |
"idEventoTabela" : "number", | |
"idFaceDente" : "number", | |
"idSituacaoTratamento" : "number", | |
"mensagemAbandono" : "string", | |
"motivoAbandono" : "string", | |
"nomeEventoTabela" : "string", | |
"permiteAnexarDocumento" : "bool", | |
"possuiAnexoAutorizacaoEvento" : "bool", | |
"quantidade" : "number", | |
"quantidadeUs" : "number", | |
"somenteLeitura" : "boolean", | |
"tabela" : "number", | |
"valorCoParticipacao" : "number", | |
"valorFranquia" : "number", | |
"valorTratamento" : "number" | |
}, | |
adapter: { | |
type: "properties", | |
collection_name: "fatTratamento" | |
} | |
}, | |
extendModel: function(Model) { | |
_.extend(Model.prototype, { | |
// extended functions and properties go here | |
transform: function() { | |
var md = this.toJSON(); | |
var formatador = require("/foursys/utils/format"); | |
var gui = require('foursys/utils/gui'); | |
md.autorizacaoLiberadaStr = md.autorizacaoLiberadaStr; | |
md.codigoEventoTabelaStr = md.codigoEventoTabela; | |
md.idStr = md.id; | |
md.idDenteRegiaoStr = md.idDenteRegiao; | |
md.idEventoTabelaStr = md.idEventoTabela; | |
md.idFaceDenteStr = md.idFaceDente; | |
md.idSituacaoTratamentoStr = md.idSituacaoTratamento; | |
md.mensagemAbandonoStr = md.mensagemAbandono; | |
md.motivoAbandonoStr = md.motivoAbandono; | |
md.nomeEventoTabelaStr = md.nomeEventoTabela; | |
md.permiteAnexarDocumentoStr = md.permiteAnexarDocumento; | |
md.possuiAnexoAutorizacaoEventoStr = md.possuiAnexoAutorizacaoEvento; | |
md.quantidadeStr = formatador.paraReal(md.quantidade, '.'); | |
md.quantidadeUsStr = formatador.paraReal(md.quantidadeUs, '.'); | |
md.somenteLeituraStr = md.somenteLeitura; | |
md.tabelaStr = md.tabela; | |
md.valorCoParticipacaoStr = formatador.paraReal(md.valorCoParticipacao, '.'); | |
md.valorFranquiaStr = formatador.paraReal(md.valorFranquia, '.'); | |
md.valorTratamentoStr = formatador.paraReal(md.valorTratamento, '.'); | |
md.Imagem = "/images/autorizacao/processo.png"; | |
md.copia = md; | |
return md; | |
}, | |
verificaAbandono: function(cb){ | |
var md = this; | |
//md.get("idAutorizacao"); | |
// Verificar se existe algum tratamento abandonado | |
//Se sim: | |
alerta = "Por favor confirme! Existe(m) evento(s) abandonado(s) na GTO. Você não poderá alterar a situação dos tratamentos posteriormente, deseja continuar? "; | |
cb(alerta); | |
// Verificar resposta do alerta, se ok: | |
// chamar função para salvarFaturar | |
// Se cancelar, voltar para tela | |
}, | |
salvarFaturar: function(cb) { | |
var md = this; | |
// chamar serviço para faturar GTO | |
}, | |
finalizarTratamento: function(cb) { | |
var md = this; | |
// atribuir o valor idSituacao = 2 (finalizado) para o tratamento | |
// desabilitar os botões de finalizar e abandonar para este tratamento | |
}, | |
abandonarTratamento: function(motivoAbandono, cb){ | |
var col = this; | |
var url = Alloy.Globals.enderecoOdontoWS + "rs/bweb/Autorizacao/cancelarEventoAutorizacao"; | |
var webapi = require("foursys/utils/webapi"); | |
webapi.request({ | |
silent: false, | |
metodo: "POST", | |
url: url, | |
args: JSON.stringify({ | |
idMotivoAbandono: idMotivo, | |
motivo: observacao, | |
idsEvento: _.pluck(col.toJSON(), 'idAutorizacaoEvento') | |
}) | |
}, function (retorno) { | |
if (retorno.sucesso == true) { | |
webapi.trataRetornoOdonto(retorno.data, function(ret){ | |
if(ret.sucesso){ | |
cb({sucesso: true, mensagem: ""}); | |
} else { | |
cb(ret); | |
} | |
}); | |
} | |
else { | |
cb(retorno); | |
} | |
} | |
); | |
}, | |
salvarMotivoAbandono: function(motivoAbandono, cb) { | |
var md = this; | |
// Ao clicar no botão "salvar" da tela de motivo do abandono: | |
// Atribuir o valor digitado para o campo de motivoAbandono | |
md.idSituacaoTratamento = 1; | |
md.mensagemAbandono = motivoAbandono; | |
md.idSituacaoTratamentoStr = 1; | |
md.mensagemAbandonoStr = motivoAbandono; | |
// voltar para tela de faturamento Eletronico | |
// Desabilitar botões de abandonar e finalizar para o tratamento | |
// exibir na tela que o tratamento foi abandonado e o motivoAbandono | |
}, | |
gerarPdf: function(cb) { | |
/*var md = this; | |
var urlLogin = Alloy.Globals.enderecoOdontoWS + "rs/bweb/faturamentoPrestadorRs/pdfCapaLote"; | |
urlLogin += "?idCapaLote=" + md.get("idCapaLote"); | |
var webapi = require("foursys/utils/webapi"); | |
webapi.request({ | |
silent: false, | |
metodo: "GET", | |
url: urlLogin | |
}, function(retorno) { | |
if (retorno.sucesso == true) { | |
webapi.trataRetornoOdonto(retorno.data, function(ret) { | |
if (ret.sucesso) { | |
cb({ | |
sucesso: true, | |
mensagem: "", | |
pdfCapaLote: { | |
nomeArquivo: ret.ret.nomeArquivo, | |
conteudoArquivo: ret.ret.conteudoArquivo | |
} | |
}); | |
} else { | |
cb(ret); | |
} | |
}); | |
} else { | |
cb(retorno); | |
} | |
}); */ | |
} | |
}); | |
return Model; | |
}, | |
extendCollection: function(Collection) { | |
_.extend(Collection.prototype, { | |
// extended functions and properties go here | |
// For Backbone v1.1.2, uncomment the following to override the | |
// fetch method to account for a breaking change in Backbone. | |
/* | |
fetch: function(options) { | |
options = options ? _.clone(options) : {}; | |
options.reset = true; | |
return Backbone.Collection.prototype.fetch.call(this, options); | |
} | |
*/ | |
buscar: function(params, cb) { | |
var col = this; | |
var urlLogin = Alloy.Globals.enderecoOdontoWS + "rs/bweb/faturamentoPrestadorRs/gtoDetalhe"; | |
urlLogin += "?idGtoEletronica=2872713"; // + parans.idContratoPrestador; | |
//urlLogin += "&idAutorizacao=" + parans.idAutorizacao; | |
var webapi = require("foursys/utils/webapi"); | |
webapi.request({ | |
silent: false, | |
metodo: "GET", | |
url: urlLogin | |
}, function (retorno) { | |
if (retorno.sucesso == true) { | |
webapi.trataRetornoOdonto(retorno.data, function(ret){ | |
if(ret.sucesso){ | |
col.add(ret.ret.gtoTratamentoDTOs, {silent: true}); | |
col.trigger('change'); | |
cb({sucesso: true, mensagem: "", tratamentoGTO: ret.ret.gtoTratamentoDTOs}); | |
} else { | |
cb(ret); | |
} | |
}); | |
} | |
else { | |
cb(retorno); | |
} | |
} | |
); | |
} | |
}); | |
return Collection; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Models | |
exports.definition = { | |
config: { | |
columns: { | |
"autorizacaoLiberada": "string", | |
"codigoEventoTabela": "number", | |
"id": "number", | |
"idDenteRegiao": "string", | |
"idEventoTabela": "string", | |
"idFaceDente": "string", | |
"idSituacaoTratamento": "string", | |
"mensagemAbandono": "string", | |
"motivoAbandono": "string", | |
"nomeEventoTabela": "string", | |
"permiteAnexarDocumento": "bool", | |
"possuiAnexoAutorizacaoEvento": "bool", | |
"quantidade": "number", | |
"quantidadeUs": "number", | |
"somenteLeitura": "bool", | |
"tabela": "number", | |
"valorCoParticipacao": "number", | |
"valorFranquia": "number", | |
"valorTratamento": "number" | |
}, | |
adapter: { | |
type: "properties", | |
collection_name: "tratamentoGTO" | |
} | |
}, | |
extendModel: function(Model) { | |
_.extend(Model.prototype, { | |
// extended functions and properties go here | |
transform: function() { | |
var md = this.toJSON(); | |
var formatador = require("/foursys/utils/format"); | |
var gui = require('foursys/utils/gui'); | |
md.attrCodigoEventoTabela = gui.configAttributedRowTitle("Evento: " + md.codigoEventoTabela); | |
md.attrDenteRegiao = gui.configAttributedRowTitle("Dente Região: " + md.idDenteRegiao); | |
//md.attrData = gui.configAttributedRowTitle("Data Realização: " + formatador.customFormatData(new Date(md.dataRealizacao), undefined, require("constantes").DateLabelPattern)); | |
md.strDescricao = (md.nomeEventoTabela || ""); | |
md.attrTabela = gui.configAttributedRowInfo("Tabela: " + (md.tabela || "")); | |
md.attrAutorizacaoLiberada = gui.configAttributedRowInfo("Autorizado: " + (md.autorizacaoLiberada || "")); | |
md.strQuantidade = (md.quantidade ? md.quantidade : "-"); | |
md.strQuantidadeUs = (md.quantidadeUs ? md.quantidadeUs : "-"); | |
md.strValorTratamento = (md.valorTratamento ? formatador.paraReal(parseFloat(md.valorTratamento), ".") : "-"); | |
md.strValorCoParticipacao = (md.valorCoParticipacao ? formatador.paraReal(parseFloat(md.valorCoParticipacao), ".") : "-"); | |
md.strValorFranquia = (md.valorFranquia ? formatador.paraReal(parseFloat(md.valorFranquia), ".") : "-"); | |
md.imagem = "/images/faturamentoEletronico/tratamento.png"; | |
md.copia = md; | |
return md; | |
} | |
}); | |
return Model; | |
}, | |
extendCollection: function(Collection) { | |
_.extend(Collection.prototype, { | |
montaCabecalhoColecao: function(dados) { | |
var md = new Object(); | |
var formatador = require("/foursys/utils/format"); | |
var gui = require('foursys/utils/gui'); | |
md.strAutorizacao = dados.codigoAutorizacao; | |
md.strCarteirinha = dados.codigoSegurado; | |
md.attrBeneficiario = dados.nomeSegurado; | |
md.attrDataAutorizacao = formatador.customFormatData(new Date(dados.dataAutorizacao), undefined, require("constantes").DateLabelPattern); | |
md.imagem = "/images/faturamentoEletronico/gto.png"; | |
return md; | |
}, | |
buscar: function(idGtoEletronica, registroAtual, tamanhoPagina, cb) { | |
var col = this; | |
var urlLogin = Alloy.Globals.enderecoOdontoWS + "rs/bweb/faturamentoPrestadorRs/gtoDetalhe"; | |
urlLogin += "?idGtoEletronica=" + idGtoEletronica; | |
urlLogin += "®istroAtual=" + registroAtual; | |
urlLogin += "&tamanhoPagina=" + tamanhoPagina; | |
var webapi = require("foursys/utils/webapi"); | |
webapi.request({ | |
silent: registroAtual != 0, | |
metodo: "GET", | |
url: urlLogin | |
}, function(retorno) { | |
if (retorno.sucesso == true) { | |
webapi.trataRetornoOdonto(retorno.data, function(ret) { | |
if (ret.sucesso) { | |
if (ret.ret.gtoEletronicaDTO.gtoTratamentoDTOs) { | |
col.add(ret.ret.gtoEletronicaDTO.gtoTratamentoDTOs, { | |
silent: true | |
}); | |
col.trigger('change'); | |
} | |
cb({ | |
sucesso: true, | |
mensagem: "", | |
tratamentoGTO: ret.ret.gtoEletronicaDTO.gtoTratamentoDTOs, | |
cabecalhoInfo: col.montaCabecalhoColecao(ret.ret.gtoEletronicaDTO) | |
}); | |
} else { | |
cb(ret); | |
} | |
}); | |
} else { | |
cb(retorno); | |
} | |
}); | |
} | |
}); | |
return Collection; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<Model src="fatTratamento" id="tratamentoGTO" instance="true"></Model> | |
<View layout="vertical" class="shadowView containerRow" > | |
<View left="12" right="12" height="Titanium.UI.SIZE" layout="vertical"> | |
<View height="Titanium.UI.SIZE" width="Titanium.UI.FILL" top="12"> | |
<ImageView class="tratamentoImagem" image="/images/faturamentoEletronico/usuario.png"></ImageView> | |
<View class="corpo"> | |
<View class="blocoDescricaoTitulo"> | |
<Label class="lblTituloRow" width="Titanium.UI.SIZE" left="0" >Evento:</Label> | |
<Label class="lblTituloRow" width="Titanium.UI.SIZE" left="0" >Dente Região:</Label> | |
<Label class="lblTituloRow" width="Titanium.UI.SIZE" left="0" >Faces:</Label> | |
</View> | |
<View class="blocoValorTitulo"> | |
<Label class="lblTituloRow lblTituloRowBold" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.codigoEventoTabelaStr}" /> | |
<Label class="lblTituloRow lblTituloRowBold" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.idDenteRegiaoStr}" /> | |
<Label class="lblTituloRow lblTituloRowBold" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.idFaceDenteStr}" /> | |
</View> | |
</View> | |
</View> | |
<View class="linha" top="5" left="0" right="0" backgroundColor="lightgray" ></View> | |
<View height="Titanium.UI.SIZE" width="Titanium.UI.FILL" top="6"> | |
<View class="corpo" left="0"> | |
<View class="blocoDescricaoTitulo"> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Tabela:</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Autorizado</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Quantidade:</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Quant. US:</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Valor:</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Co. part.:</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Franquia:</Label> | |
<Label class="lblTituloRow lblTituloRowGray" width="Titanium.UI.SIZE" left="0" >Descrição Evento:</Label> | |
</View> | |
<View class="blocoValorTitulo"> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.tabelaStr}"></Label> | |
<ImageView class="tratamentoImagem" image="{$.tratamentoGTO.imagem}"></ImageView> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.quantidadeStr}"></Label> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.quantidadeUsStr}"></Label> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.valorTratamentoStr}"></Label> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.valorCoParticipacaoStr}"></Label> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.valorFranquiaStr}"></Label> | |
<Label class="lblTituloRow lblTituloRowGreen" width="Titanium.UI.SIZE" left="0" text="{$.tratamentoGTO.nomeEventoTabelaStr}"></Label> | |
</View> | |
</View> | |
</View> | |
</View> | |
<View height="10" /> | |
</View> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Erro ao chamar o botão Detalhes:
$.tratamentoGTO.set is not a function