diff --git a/.gitignore b/.gitignore index 6c21ed0f..842bcd83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. +# Ignora Hints +.hintrc + # compiled output /dist /tmp diff --git a/package.json b/package.json index 25e5a8c9..65c714c2 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "bootstrap": "^5.2.3", "core-util-is": "^1.0.3", "got": "^12.5.3", + "hammerjs": "^2.0.8", "moment": "^2.29.1", "ng-auto-complete": "^5.0.3", "ngx-mask": "^15.1.0", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 716a1369..75fe2440 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -25,6 +25,7 @@ import { BandejaUpdateComponent } from './components/bandeja/bandeja-update/band import { ColetorCreateComponent } from './components/coletor/coletor-create/coletor-create.component'; import { ColetorDeleteComponent } from './components/coletor/coletor-delete/coletor-delete.component'; import { ColetorUpdateComponent } from './components/coletor/coletor-update/coletor-update.component'; +import { ConvenioComponent } from './components/convenio/convenio.component'; import { ConsultaAmostraShowComponent } from './components/consulta-amostra/consulta-amostra-show/consulta-amostra-show.component'; import { DominioComponent } from './components/dominio/dominio.component'; import { EmpresaCreateComponent } from './components/empresa/empresa-create/empresa-create.component'; @@ -39,6 +40,8 @@ import { ExameCreateComponent } from './components/exame/exame-create/exame-crea import { ExameDeleteComponent } from './components/exame/exame-delete/exame-delete.component'; import { ExameUpdateComponent } from './components/exame/exame-update/exame-update.component'; import { EspecialidadeComponent } from './components/especialidade/especialidade.component'; +import { FornecedorSincronizacaoComponent } from './components/fornecedor-sincronizacao/fornecedor-sincronizacao.component'; +import { GrupoLocalAtendimentoComponent } from './components/grupo-local-atendimento/grupo-local-atendimento.component'; import { HomeComponent } from './views/home/home.component'; import { HibridoClientErrorComponent } from './components/hibrido-client-error/hibrido-client-error.component'; import { LaboratorioCreateComponent } from './components/laboratorio/laboratorio-create/laboratorio-create.component'; @@ -96,8 +99,11 @@ import { TipoExameCreateComponent } from './components/tipo-exame/tipo-exame-cre import { TipoExameDeleteComponent } from './components/tipo-exame/tipo-exame-delete/tipo-exame-delete.component'; import { TipoExameUpdateComponent } from './components/tipo-exame/tipo-exame-update/tipo-exame-update.component'; import { TipoRecursoComponent } from './components/tipo-recurso/tipo-recurso.component'; -import { UploadFileComponent } from './components/upload-file/upload-file.component'; +import { TipoInstrumentoComponent } from './components/tipo-instrumento/tipo-instrumento.component'; import { SuperUserComponent } from './components/super-user/super-user.component'; +import { UnidadeMedidaComponent } from './components/unidade-medida/unidade-medida.component'; +import { UnidadeMedidaLmComponent } from './components/unidade-medida-lm/unidade-medida-lm.component'; +import { UploadFileComponent } from './components/upload-file/upload-file.component'; import { UserComponent } from './components/user/user.component'; import { UsuarioCreateComponent } from './components/usuario/usuario-create/usuario-create.component'; import { UsuarioDeleteComponent } from './components/usuario/usuario-delete/usuario-delete.component'; @@ -142,6 +148,18 @@ const routes: Routes = [ path: 'tipos_recurso', component: TipoRecursoComponent, }, + { + path: 'tipo_instrumentos', + component: TipoInstrumentoComponent, + }, + { + path: 'convenios', + component: ConvenioComponent, + }, + { + path: 'grupos_locais', + component: GrupoLocalAtendimentoComponent, + }, { path: 'hibrido_client_errors', component: HibridoClientErrorComponent, @@ -250,6 +268,14 @@ const routes: Routes = [ path: 'super_users', component: SuperUserComponent, }, + { + path: 'unidades_medida', + component: UnidadeMedidaComponent, + }, + { + path: 'unidades_medidas_lm', + component: UnidadeMedidaLmComponent, + }, { path: 'users', component: UserComponent, @@ -386,6 +412,10 @@ const routes: Routes = [ path: 'coletores/delete/:id', component: ColetorDeleteComponent, }, + { + path: 'fornecedores_sincronizacao', + component: FornecedorSincronizacaoComponent, + }, { path: 'operadoras', component: OperadoraCrudComponent, diff --git a/src/app/components/convenio/convenio-detalhe/convenio-detalhe.component.html b/src/app/components/convenio/convenio-detalhe/convenio-detalhe.component.html new file mode 100644 index 00000000..8e436175 --- /dev/null +++ b/src/app/components/convenio/convenio-detalhe/convenio-detalhe.component.html @@ -0,0 +1,93 @@ +
+
+ + Mascara de Carteirinha + + +
+

Guia:

+ + Relatório de Guia + + + + {{ relatorioGuia.titulo }} + + + + + Mascara da Guia + + +
+ +
+

Fatura:

+ + Nome do Relatório + + + + {{ relatorioFatura.titulo }} + + + + + Qtde. de Vias da Fatura + + +
+ +
+

Exportação de Dados:

+ + Nome do Objeto + + + + {{ relatorioExportacao.titulo }} + + + + + Versão do Layout + + + + Registro ANS + + +
+
+
diff --git a/src/app/components/convenio/convenio-detalhe/convenio-detalhe.component.ts b/src/app/components/convenio/convenio-detalhe/convenio-detalhe.component.ts new file mode 100644 index 00000000..2d63506d --- /dev/null +++ b/src/app/components/convenio/convenio-detalhe/convenio-detalhe.component.ts @@ -0,0 +1,143 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { Convenio } from '../../model/convenio.model'; +import { Relatorio } from '../../model/relatorio.model'; +import { TipoRelatorio } from '../../model/tipo-relatorio.model'; +import { RelatorioGuiaService } from '../../service/relatorio-guia.service'; +import { RelatorioFaturaService } from '../../service/relatorio-fatura.service'; +import { RelatorioExportacaoService } from '../../service/relatorio-exportacao.service'; +import { Query } from 'src/app/components/model/query.model'; +import { Subject } from 'rxjs'; +import { MatSelectModule } from '@angular/material/select'; +import { MatOptionModule } from '@angular/material/core'; +import { NgFor, JsonPipe } from '@angular/common'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { FormsModule } from '@angular/forms'; + +@Component({ + selector: 'app-convenio-detalhe', + standalone: true, + templateUrl: './convenio-detalhe.component.html', + imports: [ FormsModule, MatFormFieldModule, MatInputModule, JsonPipe, + MatAutocompleteModule, NgFor, MatOptionModule, MatSelectModule, + ] +}) +export class ConvenioDetalheComponent implements OnInit { + @Input('convenio') convenio: Convenio; + @Input('relatoriosGuia') relatoriosGuia: Relatorio[] = []; + @Input('relatoriosFatura') relatoriosFatura: Relatorio[] = []; + @Input('relatoriosExportacao') relatoriosExportacao: Relatorio[] = []; + + tipo_relatorio: TipoRelatorio; + relatorio: Relatorio; + queries: Query[] = []; + + subjectRelatorioGuia: Subject = new Subject(); + subjectRelatorioFatura: Subject = new Subject(); + subjectRelatorioExportacao: Subject = new Subject(); + + constructor( + private relatorioFaturaService: RelatorioFaturaService, + private relatorioGuiaService: RelatorioGuiaService, + private relatorioExportacaoService: RelatorioExportacaoService, + ) { + this.convenio ||= new Convenio({}); + this.relatorio ||= new Relatorio({}); + this.tipo_relatorio ||= new TipoRelatorio({}); + } + + ngOnInit(): void { + const query = new Query({ key: '', value: '', isNumeric: false }); + + this.subjectRelatorioGuia.subscribe(() => { + this.relatorioGuiaService + .find('id', 'asc', 0, 60, this.queries) + .subscribe((relatoriosGuia: any) => { + this.relatoriosGuia = relatoriosGuia; + }); + }); + this.subjectRelatorioGuia.next(null); + + this.subjectRelatorioFatura.subscribe(() => { + this.relatorioFaturaService + .find('id', 'asc', 0, 60, this.queries) + .subscribe((relatoriosFatura: any) => { + this.relatoriosFatura = relatoriosFatura; + }); + }); + this.subjectRelatorioFatura.next(null); + + this.subjectRelatorioExportacao.subscribe(() => { + this.relatorioExportacaoService + .find('id', 'asc', 0, 60, this.queries) + .subscribe((relatoriosExportacao: any) => { + this.relatoriosExportacao = relatoriosExportacao; + }); + }); + this.subjectRelatorioExportacao.next(null); + } + + searchRelatorioGuia(): void { + const query_string = this.convenio.idrelatorioguia as unknown as string; + const query = new Query({ + key: 'titulo', + value: query_string, + isNumeric: false, + }); + this.queries = []; + this.queries.push(query); + this.subjectRelatorioGuia.next(null); + } + + displayFnRelatorioGuia(options: Relatorio[]): (id: any) => any { + return (id: any) => { + const correspondingOption = Array.isArray(options) + ? options.find((option) => option.id === id) + : null; + return correspondingOption ? correspondingOption.titulo : ''; + }; + } + + searchRelatorioFatura(): void { + const query_string = this.convenio.idrelatoriofatura as unknown as string; + const query = new Query({ + key: 'titulo', + value: query_string, + isNumeric: false, + }); + this.queries = []; + this.queries.push(query); + this.subjectRelatorioFatura.next(null); + } + + displayFnRelatorioFatura(options: Relatorio[]): (id: any) => any { + return (id: any) => { + const correspondingOption = Array.isArray(options) + ? options.find((option) => option.id === id) + : null; + return correspondingOption ? correspondingOption.titulo : ''; + }; + } + + searchRelatorioExportacao(): void { + const query_string = this.convenio.idrelatorioexportacao as unknown as string; + const query = new Query({ + key: 'titulo', + value: query_string, + isNumeric: false, + }); + this.queries = []; + this.queries.push(query); + this.subjectRelatorioExportacao.next(null); + } + + displayFnRelatorioExportacao(options: Relatorio[]): (id: any) => any { + return (id: any) => { + const correspondingOption = Array.isArray(options) + ? options.find((option) => option.id === id) + : null; + return correspondingOption ? correspondingOption.titulo : ''; + }; + } +} diff --git a/src/app/components/convenio/convenio.component.html b/src/app/components/convenio/convenio.component.html new file mode 100644 index 00000000..d1618893 --- /dev/null +++ b/src/app/components/convenio/convenio.component.html @@ -0,0 +1,233 @@ +
+ + + +
+ +
+
+
+
+
+ + Nome: + + +
+ +
+ + Email: + + +
+
+
+
+ +
+
+
+ + + Nome: + + + + O campo é obrigatório! + + + + + + Email: + + + + O campo é obrigatório! + + + + + + Chave Publicação: + + + + O campo é obrigatório! + + + + + + Operadora + + + + O campo é obrigatório! + + + + + {{operadora?.empresa?.nome_fantasia}} + + + + + + + + + + + +
+ + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Nome{{ row?.nome }}Email{{ row?.email }}Chave Publicação{{ row?.chave_web }}Operadora{{ row?.operadora?.empresa?.nome_fantasia }} Ações +
+ +
+ +
+ +
+ +
+ + + + Deseja apagar esse registro? + + + + + + +
+
+ + +
+ diff --git a/src/app/components/convenio/convenio.component.ts b/src/app/components/convenio/convenio.component.ts new file mode 100644 index 00000000..fd4f6ff0 --- /dev/null +++ b/src/app/components/convenio/convenio.component.ts @@ -0,0 +1,228 @@ +import { Component, OnInit, AfterViewInit, + ViewChild, TemplateRef, ElementRef, Input } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { Convenio } from '../model/convenio.model'; +import { ConvenioService } from '../service/convenio.service'; +import { Operadora } from '../model/operadora.model'; +import { OperadoraService } from '../service/operadora.service'; +import { Empresa } from '../model/empresa.model'; +import { MatDialog, MatDialogModule } from '@angular/material/dialog'; +import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; +import { MatSort, MatSortModule } from '@angular/material/sort'; +import { MatTableDataSource, MatTableModule } from '@angular/material/table'; +import { merge } from 'rxjs'; +import { Query } from '../model/query.model'; +import { Subject, forkJoin } from 'rxjs'; +import { tap } from 'rxjs/operators'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTabsModule } from '@angular/material/tabs'; +import { MatSelectModule } from '@angular/material/select'; +import { MatOptionModule } from '@angular/material/core'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; +import { FormsModule } from '@angular/forms'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { NgIf, NgFor } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; +import { MatDatepickerModule } from '@angular/material/datepicker'; +import { ConvenioDetalheComponent } from './convenio-detalhe/convenio-detalhe.component'; +import { RelatorioGuiaService } from '../service/relatorio-guia.service'; +import { RelatorioFaturaService } from '../service/relatorio-fatura.service'; +import { RelatorioExportacaoService } from '../service/relatorio-exportacao.service'; +import { Relatorio } from '../model/relatorio.model'; + +@Component({ + selector: 'app-convenio', + standalone: true, + templateUrl: './convenio.component.html', + imports: [ + CommonModule, MatIconModule, NgIf, MatFormFieldModule, MatInputModule, FormsModule, + MatAutocompleteModule, NgIf, NgFor, MatOptionModule, MatSelectModule, MatTabsModule, + MatButtonModule, MatTableModule, MatSortModule, MatDialogModule, MatPaginatorModule, + MatDatepickerModule, ConvenioDetalheComponent + ] +}) +export class ConvenioComponent implements OnInit, AfterViewInit { + @Input('operadoras') operadoras: Operadora[] = []; + @Input('relatoriosGuia') relatoriosGuia: Relatorio[] = []; + @Input('relatoriosFatura') relatoriosFatura: Relatorio[] = []; + @Input('relatoriosExportacao') relatoriosExportacao: Relatorio[] = []; + + operadora: Operadora; + empresa: Empresa; + + datasource = new MatTableDataSource([]); + records: any[] = []; + record!: any; + oldRecord: any; + currentRecord: any; + deletedRecords: any[] = []; + query: Query[] = []; + id!: number; + totalCount!: number; + + @ViewChild('operadora_id') operadora_id!: ElementRef; + @ViewChild('empresa_id') empresa_id!: ElementRef; + @ViewChild('deleteDialog') deleteDialog: TemplateRef | any; + @ViewChild(MatSort) sort: MatSort | any; + @ViewChild(MatPaginator) paginator: MatPaginator | any; + + queries: Query[] = []; + subjectOperadora: Subject = new Subject(); + + onEdit = false; + onCreate = false; + + displayedColumns = [ + 'nome', + 'email', + 'chave_web', + 'operadora_id', + 'action' + ]; + + constructor( + public dialog: MatDialog, + private recordService: ConvenioService, + private operadoraService: OperadoraService, + private relatorioFaturaService: RelatorioFaturaService, + private relatorioGuiaService: RelatorioGuiaService, + private relatorioExportacaoService: RelatorioExportacaoService, + ) { + this.currentRecord = new Convenio({}); + this.record ||= new Convenio({}); + this.operadora ||= new Operadora({}); + this.empresa ||= new Empresa({}); + } + + ngOnInit(): void { + this.recordService.count().subscribe((totalCount) => { + this.totalCount = totalCount; + }); + + const query = new Query({ key: '', value: '', isNumeric: false }); + + this.subjectOperadora.subscribe(() => { + this.operadoraService + .find('id', 'asc', 0, 90, []) + .subscribe((operadoras) => { + console.table(this.queries); + this.operadoras = operadoras; + }); + }); + this.subjectOperadora.next(null); + } + + ngAfterViewInit() { + this.loadPage(); + this.sort.sortChange.subscribe(() => (this.paginator.pageIndex = 0)); // reseta o paginador depois de ordenar + + merge(this.sort.sortChange, this.paginator.page) // Na ordenação ou paginação, carrega uma nova página + .pipe(tap(() => this.loadPage())) + .subscribe(); + } + + loadPage() { + forkJoin({ + guias: this.relatorioGuiaService.find('id', 'asc', 0, 60, this.queries), + faturas: this.relatorioFaturaService.find('id', 'asc', 0, 60, this.queries), + exportacoes: this.relatorioExportacaoService.find('id', 'asc', 0, 60, this.queries), + convenios: this.recordService + .find(this.sort.active, + this.sort.direction, + this.paginator.pageIndex, + this.paginator.pageSize, this.query) + }).subscribe( resultado => { + this.relatoriosFatura = resultado.faturas; + this.relatoriosExportacao = resultado.exportacoes; + this.relatoriosGuia = resultado.guias; + this.records = resultado.convenios; + this.datasource.data = [...this.records]; + }) + } + + new(): void { + this.onCreate = true; + } + + addGridData(): void { + this.onCreate = false; + this.onEdit = false; + this.recordService.create(this.currentRecord).subscribe((record) => { + this.records.unshift(record); + this.datasource.data = [...this.records]; + this.recordService.showMessage('Convênio cadastrado com sucesso!'); + this.loadPage(); + }); + this.currentRecord = new Convenio({}); + } + + updateGridData(): void { + this.onCreate = false; + this.onEdit = false; + this.recordService.update(this.currentRecord).subscribe((recurso) => { + this.recordService.showMessage('Convênio atualizado com sucesso!'); + this.loadPage(); + }); + this.currentRecord = new Convenio({}); + } + + atualizar(row: Convenio): void { + this.currentRecord = row; + this.onCreate = false; + this.onEdit = true; + } + + cancelar(): void { + this.onCreate = false; + this.onEdit = false; + Object.assign(this.currentRecord, this.oldRecord); + this.currentRecord = new Convenio({}); + } + + deleteGridData(id: number): void { + const dialogRef = this.dialog.open(this.deleteDialog); + + dialogRef.afterClosed().subscribe((result) => { + if (result) { + this.recordService.delete(id).subscribe((record) => { + this.recordService.showMessage('Convênio apagado com sucesso!'); + // Carrega os dados do backend e faz refresh do datasource + this.loadPage(); + this.datasource.data = [...this.records]; + }); + } + }); + } + + search(key: string, value: string, isNumeric: boolean = false): void { + const query = new Query({ key, value, isNumeric }); + this.query = this.query.filter((q) => q.key !== key); + this.query.push(query); + this.paginator.pageIndex = 0; + this.loadPage(); + } + + searchOperadora(): void { + const query_string = this.currentRecord + .operadora_id as unknown as string; + const query = new Query({ + key: 'empresa.nome_fantasia', + value: query_string, + isNumeric: false, + }); + console.warn(query_string); + this.queries = []; + this.queries.push(query); + this.subjectOperadora.next(null); + } + + displayFnOperadora(options: Operadora[]): (id: any) => any { + return (id: any) => { + const correspondingOption = Array.isArray(options) + ? options.find((option) => option.id === id) + : null; + return correspondingOption ? correspondingOption.empresa?.nome_fantasia : ''; + }; + } +} diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component.html b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component.html new file mode 100644 index 00000000..fcbdad7a --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component.html @@ -0,0 +1,33 @@ +
+
+
+ + Telefone + + + + + Fax + + + + + Contato + + + + + E-mail + + +
+
+
diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component.ts b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component.ts new file mode 100644 index 00000000..8e58c967 --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component.ts @@ -0,0 +1,29 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { Empresa } from 'src/app/components/model/empresa.model'; +import { FornecedorSincronizacao } from '../../model/fornecedor-sincronizacao.model'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { FormsModule } from '@angular/forms'; + +@Component({ + selector: 'app-fornecedor-sincronizacao-contato', + templateUrl: './fornecedor-sincronizacao-contato.component.html', + standalone: true, + imports: [CommonModule, FormsModule, MatFormFieldModule, MatInputModule] +}) +export class FornecedorSincronizacaoContatoComponent implements OnInit { + @Input('fornecedorSincronizacao') fornecedorSincronizacao: FornecedorSincronizacao; + @Input('empresa') empresa: Empresa; + + constructor() { + this.fornecedorSincronizacao = new FornecedorSincronizacao({}); + this.empresa ||= new Empresa({}); + // console.table(this.empresa); + this.fornecedorSincronizacao.empresa = this.empresa; + } + ngOnInit(): void { + this.empresa ||= new Empresa({}); + } + +} diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component.html b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component.html new file mode 100644 index 00000000..2acade27 --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component.html @@ -0,0 +1,58 @@ +
+
+ + Razão Social + + + + Nome Fantasia + + +
+
+ + CNPJ + + + + Inscrição Estadual + + + + Alvará + + + + Alvará UF + + +
+
diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component.ts b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component.ts new file mode 100644 index 00000000..94f778d5 --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component.ts @@ -0,0 +1,29 @@ +import { JsonPipe } from '@angular/common'; +import { Component, OnInit, Input } from '@angular/core'; +import { Empresa } from 'src/app/components/model/empresa.model'; +import { FornecedorSincronizacao } from '../../model/fornecedor-sincronizacao.model'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { FormsModule } from '@angular/forms'; + +@Component({ + selector: 'app-fornecedor-sincronizacao-empresa', + templateUrl: './fornecedor-sincronizacao-empresa.component.html', + standalone: true, + imports: [FormsModule, MatFormFieldModule, MatInputModule, JsonPipe] + +}) +export class FornecedorSincronizacaoEmpresaComponent implements OnInit { + @Input('fornecedor') fornecedor: FornecedorSincronizacao; + @Input('empresa') empresa: Empresa; + + constructor() { + this.fornecedor = new FornecedorSincronizacao({}); + this.empresa ||= new Empresa({}); + this.fornecedor.empresa = this.empresa; + } + ngOnInit(): void { + this.empresa ||= new Empresa({}); + } + +} diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component.html b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component.html new file mode 100644 index 00000000..352ebb81 --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component.html @@ -0,0 +1,80 @@ +
+
+
+ + CEP: + + +
+ +
+ + Cidade: + + +
+ +
+ + UF: + + +
+ +
+ + Logradouro: + + +
+ +
+ + N°: + + +
+ +
+ + Bairro: + + +
+ +

Dados para o TISS

+
+ + Tipo de Logradouro + + + + Cod. IBGE do Município + + +
+
+
diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component.ts b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component.ts new file mode 100644 index 00000000..1dd79a08 --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component.ts @@ -0,0 +1,50 @@ +import { JsonPipe } from '@angular/common'; +import { Component, OnInit, Input } from '@angular/core'; +import { Empresa } from 'src/app/components/model/empresa.model'; +import { FornecedorSincronizacao } from '../../model/fornecedor-sincronizacao.model'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { FormsModule } from '@angular/forms'; +import { Cep } from '../../model/cep.model'; +import { CepService } from '../../service/cep.service'; + +@Component({ + selector: 'app-fornecedor-sincronizacao-endereco', + templateUrl: './fornecedor-sincronizacao-endereco.component.html', + standalone: true, + imports: [FormsModule, MatFormFieldModule, MatInputModule, JsonPipe] +}) +export class FornecedorSincronizacaoEnderecoComponent implements OnInit { + @Input('fornecedor') fornecedor: FornecedorSincronizacao; + @Input('empresa') empresa: Empresa; + cep: Cep; + + constructor( + private cepService: CepService + ) { + this.fornecedor = new FornecedorSincronizacao({}); + this.empresa ||= new Empresa({}); + this.fornecedor.empresa = this.empresa; + this.cep = new Cep(); + } + + ngOnInit(): void { + this.empresa ||= new Empresa({}); + } + + consulta(): void{ + // consulta o cep informado na variavel cep + // Chama serviço + this.cepService + .consultar(this.empresa.cep as unknown as string) + .subscribe((cep: any) => { + // subscreve os campos + Object.assign(this.cep, cep); + this.empresa.cidade = this.cep.localidade; + this.empresa.uf = this.cep.uf; + this.empresa.endereco = this.cep.logradouro; + this.empresa.bairro = this.cep.bairro; + }); + } + +} diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao.component.html b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao.component.html new file mode 100644 index 00000000..b28b021b --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao.component.html @@ -0,0 +1,137 @@ +
+ + + +
+ +
+
+
+
+
+ + Nome: + + +
+
+
+
+ +
+
+
+ + Nome: + + + + O campo é obrigatório! + + + +
+ + + + + + + + + + + + + + +
+ + + +
+
+
+
+ +
+ + + + + + + + + + + + + + + +
Nome{{ row?.nome }} Ações +
+ +
+ +
+ +
+ +
+ + + + Deseja apagar esse registro? + + + + + + +
+
+ + +
diff --git a/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao.component.ts b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao.component.ts new file mode 100644 index 00000000..a880b254 --- /dev/null +++ b/src/app/components/fornecedor-sincronizacao/fornecedor-sincronizacao.component.ts @@ -0,0 +1,218 @@ +import { ActivatedRoute, Router } from '@angular/router'; +import { Component, OnInit, AfterViewInit, + ViewChild, TemplateRef, ElementRef, Input } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FornecedorSincronizacao } from '../model/fornecedor-sincronizacao.model'; +import { FornecedorSincronizacaoService } from '../service/fornecedor-sincronizacao.service'; +import { Empresa } from '../model/empresa.model'; +import { EmpresaService } from '../service/empresa.service'; +import { MatDialog, MatDialogModule } from '@angular/material/dialog'; +import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; +import { MatSort, MatSortModule } from '@angular/material/sort'; +import { MatTableDataSource, MatTableModule } from '@angular/material/table'; +import { merge } from 'rxjs'; +import { Query } from '../model/query.model'; +import { Subject, forkJoin } from 'rxjs'; +import { tap } from 'rxjs/operators'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTabsModule } from '@angular/material/tabs'; +import { MatSelectModule } from '@angular/material/select'; +import { MatOptionModule } from '@angular/material/core'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; +import { FormsModule } from '@angular/forms'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { NgIf, NgFor } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; +import { MatDatepickerModule } from '@angular/material/datepicker'; +import { FornecedorSincronizacaoEmpresaComponent } from './fornecedor-sincronizacao-empresa/fornecedor-sincronizacao-empresa.component'; +import { FornecedorSincronizacaoEnderecoComponent } from './fornecedor-sincronizacao-endereco/fornecedor-sincronizacao-endereco.component'; +import { FornecedorSincronizacaoContatoComponent } from './fornecedor-sincronizacao-contato/fornecedor-sincronizacao-contato.component'; + +@Component({ + selector: 'app-fornecedor-sincronizacao', + standalone: true, + templateUrl: './fornecedor-sincronizacao.component.html', + imports: [ + CommonModule, MatIconModule, NgIf, MatFormFieldModule, MatInputModule, FormsModule, + MatAutocompleteModule, NgIf, NgFor, MatOptionModule, MatSelectModule, MatTabsModule, + MatButtonModule, MatTableModule, MatSortModule, MatDialogModule, MatPaginatorModule, + MatDatepickerModule, FornecedorSincronizacaoEmpresaComponent, + FornecedorSincronizacaoEnderecoComponent, FornecedorSincronizacaoContatoComponent + ] +}) +export class FornecedorSincronizacaoComponent implements OnInit, AfterViewInit { + empresa!: Empresa; + datasource = new MatTableDataSource([]); + records: any[] = []; + record!: any; + oldRecord: any; + currentRecord: any; + deletedRecords: any[] = []; + query: Query[] = []; + id!: number; + totalCount!: number; + + @ViewChild('empresa_id') empresa_id!: ElementRef; + @ViewChild('deleteDialog') deleteDialog: TemplateRef | any; + @ViewChild(MatSort) sort: MatSort | any; + @ViewChild(MatPaginator) paginator: MatPaginator | any; + + queries: Query[] = []; + subjectEmpresa: Subject = new Subject(); + + onEdit = false; + onCreate = false; + + displayedColumns = [ + 'nome', + 'action' + ]; + + constructor( + private router: Router, + private route: ActivatedRoute, + public dialog: MatDialog, + private recordService: FornecedorSincronizacaoService, + private empresaService: EmpresaService + ) { + this.currentRecord = new FornecedorSincronizacao({}); + this.currentRecord.empresa ||= new Empresa({}); + this.record ||= new FornecedorSincronizacao({}); + + this.id = this.route.snapshot.paramMap.get('id') as unknown as number; + if (this.id > 0) { + this.load(this.id); + } + } + + load(id: number): void { + this.recordService.readById(id).subscribe((currentRecord) => { + this.empresaService + .readById(this.currentRecord.empresa_id as number) // relacao empresa local + .subscribe ((empresa) => { + // TODO: Revisar + this.currentRecord.empresa = empresa; + this.currentRecord.empresa_id = empresa.id + }); + }); + } + + ngOnInit(): void { + this.recordService.count().subscribe((totalCount) => { + this.totalCount = totalCount; + }); + + const query = new Query({ key: '', value: '', isNumeric: false }); + + this.currentRecord ||= new FornecedorSincronizacao({}); + + const empresa_id = this.currentRecord.empresa_id || 0 + + if (empresa_id > 0) { + this.empresaService.readById(this.currentRecord.empresa_id as number).subscribe( + (empresa) => { + this.currentRecord.empresa = empresa; + this.currentRecord.empresa_id = empresa.id + }); + } + + } + + ngAfterViewInit() { + this.loadPage(); + this.sort.sortChange.subscribe(() => (this.paginator.pageIndex = 0)); // reseta o paginador depois de ordenar + + merge(this.sort.sortChange, this.paginator.page) // Na ordenação ou paginação, carrega uma nova página + .pipe(tap(() => this.loadPage())) + .subscribe(); + } + + loadPage() { + forkJoin({ + fornecedores: this.recordService + .find(this.sort.active, + this.sort.direction, + this.paginator.pageIndex, + this.paginator.pageSize, this.query) + }).subscribe( resultado => { + this.records = resultado.fornecedores; + this.datasource.data = [...this.records]; + }) + } + + new(): void { + this.onCreate = true; + } + + addGridData(): void { + this.onCreate = false; + this.onEdit = false; + + if(this.id > 0){ + console.warn(this.id); + this.updateGridData(); + }else{ + this.empresaService.create(this.currentRecord.empresa).subscribe((empresa) => { + this.currentRecord.empresa = empresa; + this.currentRecord.empresa_id = empresa.id; + this.recordService.create(this.currentRecord).subscribe(() => { + this.records.unshift(this.record); + this.datasource.data = [...this.records]; + this.recordService.showMessage('Fornecedor cadastrado com sucesso!'); + this.loadPage(); + }); + this.currentRecord = new FornecedorSincronizacao({}); + }); + } + } + + updateGridData(): void { + this.onCreate = false; + this.onEdit = false; + + this.empresaService.update(this.currentRecord.empresa).subscribe((empresa) => { + this.recordService.update(this.currentRecord).subscribe(() => { + this.recordService.showMessage('Fornecedor atualizado com sucesso!'); + this.loadPage(); + }); + }); + this.currentRecord ||= new FornecedorSincronizacao({}); + } + + atualizar(row: FornecedorSincronizacao): void { + this.currentRecord = row; + this.onCreate = false; + this.onEdit = true; + } + + cancelar(): void { + this.onCreate = false; + this.onEdit = false; + Object.assign(this.currentRecord, this.oldRecord); + this.currentRecord = new FornecedorSincronizacao({}); + } + + deleteGridData(id: number): void { + const dialogRef = this.dialog.open(this.deleteDialog); + + dialogRef.afterClosed().subscribe((result) => { + if (result) { + this.recordService.delete(id).subscribe((record) => { + this.recordService.showMessage('Fornecedor apagado com sucesso!'); + // Carrega os dados do backend e faz refresh do datasource + this.loadPage(); + this.datasource.data = [...this.records]; + }); + } + }); + } + + search(key: string, value: string, isNumeric: boolean = false): void { + const query = new Query({ key, value, isNumeric }); + this.query = this.query.filter((q) => q.key !== key); + this.query.push(query); + this.paginator.pageIndex = 0; + this.loadPage(); + } +} diff --git a/src/app/components/grupo-local-atendimento/grupo-local-atendimento.component.html b/src/app/components/grupo-local-atendimento/grupo-local-atendimento.component.html new file mode 100644 index 00000000..97278aba --- /dev/null +++ b/src/app/components/grupo-local-atendimento/grupo-local-atendimento.component.html @@ -0,0 +1,127 @@ +
+ + + +
+ +
+
+
+
+
+ + Nome: + + +
+
+
+
+ +
+
+
+ + + Nome: + + + + O campo é obrigatório! + + + + +
+ + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Nome{{ row?.nome }} Ações +
+ +
+ +
+ +
+ +
+ + + + Deseja apagar esse registro? + + + + + + +
+
+ + +
+ diff --git a/src/app/components/grupo-local-atendimento/grupo-local-atendimento.component.ts b/src/app/components/grupo-local-atendimento/grupo-local-atendimento.component.ts new file mode 100644 index 00000000..02218e8d --- /dev/null +++ b/src/app/components/grupo-local-atendimento/grupo-local-atendimento.component.ts @@ -0,0 +1,175 @@ +import { CommonModule } from '@angular/common'; +import { + Component, + OnInit, + AfterViewInit, + ViewChild, + TemplateRef, + ElementRef, + Input +} from '@angular/core'; +import { GrupoLocalAtendimento } from '../model/grupo-local-atendimento.model'; +import { GrupoLocalAtendimentoService } from '../service/grupo-local-atendimento.service'; +import { MatDialog, MatDialogModule } from '@angular/material/dialog'; +import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator'; +import { MatSort, MatSortModule } from '@angular/material/sort'; +import { MatTableDataSource, MatTableModule } from '@angular/material/table'; +import { merge } from 'rxjs'; +import { Query } from '../model/query.model'; +import { Subject, timer } from 'rxjs'; +import { tap, debounceTime } from 'rxjs/operators'; +import { MatButtonModule } from '@angular/material/button'; +import { MatTabsModule } from '@angular/material/tabs'; +import { MatSelectModule } from '@angular/material/select'; +import { MatOptionModule } from '@angular/material/core'; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; +import { FormsModule } from '@angular/forms'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { NgIf, NgFor } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; +import { MatDatepickerModule } from '@angular/material/datepicker'; + +@Component({ + selector: 'app-grupo-local-atendimento', + templateUrl: './grupo-local-atendimento.component.html', + standalone: true, + imports: [ + CommonModule, MatIconModule, NgIf, MatFormFieldModule, MatInputModule, FormsModule, + MatAutocompleteModule, NgFor, MatOptionModule, MatSelectModule, MatTabsModule, + MatButtonModule, MatTableModule, MatSortModule, MatDialogModule, MatPaginatorModule, + MatDatepickerModule + ] +}) +export class GrupoLocalAtendimentoComponent { + gruposLocaisAtendimento: GrupoLocalAtendimento[] =[]; + datasource = new MatTableDataSource([]); + records: any[] = []; + record!: any; + oldRecord: any; + currentRecord: any; + deletedRecords: any[] = []; + query: Query[] = []; + id!: number; + totalCount!: number; + + @ViewChild('deleteDialog') deleteDialog: TemplateRef | any; + @ViewChild(MatSort) sort: MatSort | any; + @ViewChild(MatPaginator) paginator: MatPaginator | any; + + queries: Query[] = []; + subjectEspecialidade: Subject = new Subject(); + subjectOperadoraTelefonia: Subject = new Subject(); + + onEdit = false; + onCreate = false; + + displayedColumns = [ + 'nome', + 'action' + ]; + + constructor( + public dialog: MatDialog, + private recordService: GrupoLocalAtendimentoService + ) { + this.currentRecord = new GrupoLocalAtendimento({}); + this.record ||= new GrupoLocalAtendimento({}); + } + + ngOnInit(): void { + this.recordService.count().subscribe((totalCount) => { + this.totalCount = totalCount; + }); + + const query = new Query({ key: '', value: '', isNumeric: false }); + } + + ngAfterViewInit() { + this.loadPage(); + this.sort.sortChange.subscribe(() => (this.paginator.pageIndex = 0)); // reseta o paginador depois de ordenar + + merge(this.sort.sortChange, this.paginator.page) // Na ordenação ou paginação, carrega uma nova página + .pipe(tap(() => this.loadPage())) + .subscribe(); + } + + loadPage() { + this.recordService + .find(this.sort.active, + this.sort.direction, + this.paginator.pageIndex, + this.paginator.pageSize, this.query + ).subscribe((records: any[]) => { + this.records = records; + this.datasource.data = [...this.records]; + }); + } + + new(): void { + this.onCreate = true; + } + + addGridData(): void { + this.onCreate = false; + this.onEdit = false; + this.recordService.create(this.currentRecord).subscribe((record) => { + // this.records.unshift(record); + // this.datasource.data = [...this.records]; + this.recordService.showMessage('Grupo local de atendimento cadastrado com sucesso!'); + this.loadPage(); + }); + + this.currentRecord = new GrupoLocalAtendimento({}); + } + + updateGridData(): void { + this.onCreate = false; + this.onEdit = false; + this.recordService.update(this.currentRecord).subscribe((recurso) => { + this.recordService.showMessage('Grupo local de atendimento atualizado com sucesso!'); + this.loadPage(); + }); + this.currentRecord = new GrupoLocalAtendimento({}); + } + + atualizar(row: GrupoLocalAtendimento): void { + console.warn('Passou no atualizar!!!!!!!') + console.table(row); + this.currentRecord = row; + this.onCreate = false; + this.onEdit = true; + } + + cancelar(): void { + this.onCreate = false; + this.onEdit = false; + Object.assign(this.currentRecord, this.oldRecord); + this.currentRecord = new GrupoLocalAtendimento({}); + } + + deleteGridData(id: number): void { + const dialogRef = this.dialog.open(this.deleteDialog); + dialogRef.afterClosed().subscribe((result) => { + if (result) { + this.recordService.delete(id) + .subscribe((record) => { + this.recordService.showMessage('Grupo local de atendimento apagado com sucesso!'); + + // Carrega os dados do backend e faz refresh do datasource + this.loadPage(); + this.datasource.data = [...this.records]; + }); + } + }); + } + + search(key: string, value: string, isNumeric: boolean = false): void { + const query = new Query({ key, value, isNumeric }); + this.query = this.query.filter((q) => q.key !== key); + this.query.push(query); + this.paginator.pageIndex = 0; + this.loadPage(); + } + +} diff --git a/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-contato/local-de-atendimento-contato.component.html b/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-contato/local-de-atendimento-contato.component.html new file mode 100644 index 00000000..0c20d15e --- /dev/null +++ b/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-contato/local-de-atendimento-contato.component.html @@ -0,0 +1,33 @@ +
+
+
+ + Telefone + + + + + Celular + + + + + E-mail + + + + + E-mail Secundario + + +
+
+
diff --git a/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-contato/local-de-atendimento-contato.component.ts b/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-contato/local-de-atendimento-contato.component.ts new file mode 100644 index 00000000..65bcbfbf --- /dev/null +++ b/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-contato/local-de-atendimento-contato.component.ts @@ -0,0 +1,28 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { Empresa } from 'src/app/components/model/empresa.model'; +import { LocalDeAtendimento } from 'src/app/components/model/local-de-atendimento.model'; +import { MatInputModule } from '@angular/material/input'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { FormsModule } from '@angular/forms'; + +@Component({ + selector: 'app-local-de-atendimento-contato', + standalone: true, + templateUrl: './local-de-atendimento-contato.component.html', + imports: [CommonModule, FormsModule, MatFormFieldModule, MatInputModule] +}) +export class LocalDeAtendimentoContatoComponent implements OnInit { + @Input('localdeatendimento') localdeatendimento: LocalDeAtendimento; + @Input('empresa') empresa: Empresa; + + constructor() { + this.localdeatendimento = new LocalDeAtendimento({}); + this.empresa ||= new Empresa({}); + // console.table(this.empresa); + this.localdeatendimento.empresa = this.empresa; + } + ngOnInit(): void { + this.empresa ||= new Empresa({}); + } +} diff --git a/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-create.component.html b/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-create.component.html index f7a7ab9b..212149c4 100644 --- a/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-create.component.html +++ b/src/app/components/local-de-atendimento/local-de-atendimento-create/local-de-atendimento-create.component.html @@ -1,118 +1,171 @@
+

Cadastro de Local de Atendimento:

-
- - Local de Atendimento: - + + Local de Atendimento + - - CNES: - + + CNES + - - Grupo: - + + Grupo + + + + O campo é obrigatório! + + + + + {{grupo_local.nome}} + + + + + + Grupo Histórico no Laudo + -
-
- - Chave de Publicação: - - +
- - Local de Impressão: - - +
+ + Chave de Publicação + + - - Grupo Histórico no Laudo: - - + + Utiliza Registro de Coleta: + + Sim + Não + + -
+ + Local de Impressão: + + Recepção + Coleta + Nenhum + + -
- - Coleta Interna - Coleta Externa - -
+
+
+ + Coleta Interna + Coleta Externa + +
-
- -
+
+
+
-