Refactor: Ajuste na logica de busca por cliente, paginacao e layout do header

This commit is contained in:
Eduardo 2025-12-22 17:43:36 -03:00
parent 14128cce99
commit d9af2da0eb
3 changed files with 691 additions and 430 deletions

View File

@ -11,6 +11,7 @@
</div> </div>
<section class="geral-page" (click)="closeClientDropdown()"> <section class="geral-page" (click)="closeClientDropdown()">
<span class="page-blob blob-1" aria-hidden="true"></span> <span class="page-blob blob-1" aria-hidden="true"></span>
<span class="page-blob blob-2" aria-hidden="true"></span> <span class="page-blob blob-2" aria-hidden="true"></span>
<span class="page-blob blob-3" aria-hidden="true"></span> <span class="page-blob blob-3" aria-hidden="true"></span>
@ -20,14 +21,19 @@
<div class="geral-card" data-animate> <div class="geral-card" data-animate>
<div class="geral-header"> <div class="geral-header">
<div class="header-row-top"> <div class="header-row-top">
<div class="header-spacer d-none d-md-block"></div>
<div class="title-badge" data-animate>
<i class="bi bi-grid-1x2"></i> Gestão centralizada
</div>
<div class="header-title" data-animate> <div class="header-title" data-animate>
<div class="title-badge"><i class="bi bi-grid-1x2"></i> Gestão centralizada</div>
<h5 class="title mb-0">Geral</h5> <h5 class="title mb-0">Geral</h5>
<small class="subtitle">Tabela de linhas e dados de telefonia</small> <small class="subtitle">Tabela de linhas e dados de telefonia</small>
</div> </div>
<div class="header-actions d-flex gap-2 justify-content-center justify-content-md-end" data-animate>
<div class="header-actions d-flex gap-2 justify-content-end" data-animate>
<button type="button" class="btn btn-glass btn-sm" (click)="onImportExcel()" [disabled]="loading"> <button type="button" class="btn btn-glass btn-sm" (click)="onImportExcel()" [disabled]="loading">
<i class="bi bi-file-earmark-excel me-1"></i> Importar <i class="bi bi-file-earmark-excel me-1"></i> Importar
</button> </button>
@ -39,7 +45,6 @@
</div> </div>
<div class="filters-row mt-4" data-animate> <div class="filters-row mt-4" data-animate>
<div class="filter-tabs"> <div class="filter-tabs">
<button type="button" class="filter-tab" [class.active]="filterSkil === 'ALL'" (click)="setFilter('ALL')" [disabled]="loading"> <button type="button" class="filter-tab" [class.active]="filterSkil === 'ALL'" (click)="setFilter('ALL')" [disabled]="loading">
Todos Todos
@ -50,71 +55,57 @@
<button type="button" class="filter-tab" [class.active]="filterSkil === 'PJ'" (click)="setFilter('PJ')" [disabled]="loading"> <button type="button" class="filter-tab" [class.active]="filterSkil === 'PJ'" (click)="setFilter('PJ')" [disabled]="loading">
<i class="bi bi-building me-1"></i> Pessoa Jurídica <i class="bi bi-building me-1"></i> Pessoa Jurídica
</button> </button>
<button type="button" class="filter-tab" [class.active]="filterSkil === 'RESERVA'" (click)="setFilter('RESERVA')" [disabled]="loading">
<i class="bi bi-archive me-1"></i> Reservas
</button>
</div> </div>
<div class="client-filter-wrap" (click)="$event.stopPropagation()"> <div class="client-filter-wrap" (click)="$event.stopPropagation()">
<button <button type="button" class="btn-client-filter" [class.active]="selectedClient" (click)="toggleClientMenu()" [disabled]="loading">
type="button"
class="btn-client-filter"
[class.active]="selectedClient"
(click)="toggleClientMenu()"
[disabled]="loading"
>
<i class="bi bi-people-fill me-2" *ngIf="!selectedClient"></i> <i class="bi bi-people-fill me-2" *ngIf="!selectedClient"></i>
<span class="text-truncate" style="max-width: 150px;"> <span class="text-truncate" style="max-width: 150px;">
{{ selectedClient ? selectedClient : 'Clientes' }} {{ selectedClient ? selectedClient : 'Clientes' }}
</span> </span>
<i class="bi bi-chevron-down ms-2 small"></i> <i class="bi bi-chevron-down ms-2 small"></i>
</button> </button>
<div class="client-dropdown" *ngIf="showClientMenu"> <div class="client-dropdown" *ngIf="showClientMenu">
<div class="dropdown-header-search"> <div class="dropdown-header-search">
<input <input type="text" class="form-control form-control-sm" placeholder="Buscar na lista..." [(ngModel)]="clientSearchTerm" autofocus>
type="text"
class="form-control form-control-sm"
placeholder="Buscar na lista..."
[(ngModel)]="clientSearchTerm"
autofocus
>
</div> </div>
<div class="dropdown-list"> <div class="dropdown-list">
<div <div class="dropdown-item-custom" [class.selected]="!selectedClient" (click)="selectClient(null)">
class="dropdown-item-custom"
[class.selected]="!selectedClient"
(click)="selectClient(null)"
>
<i class="bi bi-grid me-2"></i> Todos os Clientes <i class="bi bi-grid me-2"></i> Todos os Clientes
</div> </div>
<ng-container *ngFor="let client of filteredClientsList"> <ng-container *ngFor="let client of filteredClientsList">
<div <div class="dropdown-item-custom" [class.selected]="client === selectedClient" (click)="selectClient(client)">
class="dropdown-item-custom"
[class.selected]="client === selectedClient"
(click)="selectClient(client)"
>
{{ client }} {{ client }}
</div> </div>
</ng-container> </ng-container>
<div class="p-3 text-center text-muted small" *ngIf="filteredClientsList.length === 0"> <div class="p-3 text-center text-muted small" *ngIf="filteredClientsList.length === 0">
Nenhum cliente encontrado. Nenhum cliente encontrado.
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="controls mt-3" data-animate *ngIf="!isGroupMode"> <div class="controls mt-3" data-animate>
<div class="input-group input-group-sm search-group"> <div class="input-group input-group-sm search-group">
<span class="input-group-text"><i class="bi bi-search"></i></span> <span class="input-group-text">
<input class="form-control" placeholder="Pesquisar..." [(ngModel)]="searchTerm" (ngModelChange)="onSearch()" [disabled]="loading" /> <i class="bi" [class.bi-search]="!loading" [class.bi-hourglass-split]="loading" [class.text-brand]="loading"></i>
</span>
<input class="form-control"
placeholder="Pesquisar..."
[(ngModel)]="searchTerm"
(ngModelChange)="onSearch()" />
<button class="btn btn-outline-secondary btn-clear" type="button" (click)="clearSearch()" *ngIf="searchTerm"> <button class="btn btn-outline-secondary btn-clear" type="button" (click)="clearSearch()" *ngIf="searchTerm">
<i class="bi bi-x-lg"></i> <i class="bi bi-x-lg"></i>
</button> </button>
</div> </div>
<div class="page-size"> <div class="page-size">
<span class="text-muted small fw-bold">Itens por página</span> <span class="text-muted small fw-bold">Itens:</span>
<select class="form-select form-select-sm select-glass" [(ngModel)]="pageSize" (change)="onPageSizeChange()" [disabled]="loading"> <select class="form-select form-select-sm select-glass" [(ngModel)]="pageSize" (change)="onPageSizeChange()" [disabled]="loading">
<option [ngValue]="10">10</option> <option [ngValue]="10">10</option>
<option [ngValue]="20">20</option> <option [ngValue]="20">20</option>
@ -145,14 +136,14 @@
<span class="badge-pill blocked" *ngIf="group.bloqueados > 0">{{ group.bloqueados }} Bloq.</span> <span class="badge-pill blocked" *ngIf="group.bloqueados > 0">{{ group.bloqueados }} Bloq.</span>
</div> </div>
</div> </div>
<div class="group-toggle-icon"> <div class="group-toggle-icon"><i class="bi bi-chevron-down"></i></div>
<i class="bi bi-chevron-down"></i>
</div>
</div> </div>
<div class="group-body" *ngIf="expandedGroup === group.cliente"> <div class="group-body" *ngIf="expandedGroup === group.cliente">
<div class="table-wrap inner-table-wrap"> <div class="table-wrap inner-table-wrap">
<div *ngIf="loadingLines" class="p-4 text-center text-muted"><span class="spinner-border spinner-border-sm me-2"></span> Carregando linhas...</div> <div *ngIf="loadingLines" class="p-4 text-center text-muted">
<span class="spinner-border spinner-border-sm me-2"></span> Carregando linhas...
</div>
<table class="table table-modern align-middle text-center mb-0" *ngIf="!loadingLines"> <table class="table table-modern align-middle text-center mb-0" *ngIf="!loadingLines">
<thead> <thead>
@ -183,7 +174,10 @@
</table> </table>
</div> </div>
</div> </div>
</div>
<div class="text-center text-muted mt-5" *ngIf="clientGroups.length === 0">
<i class="bi bi-inbox fs-1 d-block mb-2 opacity-50"></i> Nenhum grupo encontrado.
</div> </div>
</div> </div>
</div> </div>
@ -203,34 +197,22 @@
<thead> <thead>
<tr> <tr>
<th class="sortable text-center" (click)="setSort('item')"> <th class="sortable text-center" (click)="setSort('item')">
<div class="th-content justify-content-center"> <div class="th-content justify-content-center">ITEM <span class="sort-caret" [class.active]="sortKey==='item'">{{ sortKey==='item' && sortDir==='desc' ? '▼' : '▲' }}</span></div>
ITEM <span class="sort-caret" [class.active]="sortKey==='item'">{{ sortKey==='item' && sortDir==='desc' ? '▼' : '▲' }}</span>
</div>
</th> </th>
<th class="sortable text-center" (click)="setSort('linha')"> <th class="sortable text-center" (click)="setSort('linha')">
<div class="th-content justify-content-center"> <div class="th-content justify-content-center">LINHA <span class="sort-caret" [class.active]="sortKey==='linha'">{{ sortKey==='linha' && sortDir==='desc' ? '▼' : '▲' }}</span></div>
LINHA <span class="sort-caret" [class.active]="sortKey==='linha'">{{ sortKey==='linha' && sortDir==='desc' ? '▼' : '▲' }}</span>
</div>
</th> </th>
<th class="sortable text-center" (click)="setSort('cliente')"> <th class="sortable text-center" (click)="setSort('cliente')">
<div class="th-content justify-content-center"> <div class="th-content justify-content-center">CLIENTE <span class="sort-caret" [class.active]="sortKey==='cliente'">{{ sortKey==='cliente' && sortDir==='desc' ? '▼' : '▲' }}</span></div>
CLIENTE <span class="sort-caret" [class.active]="sortKey==='cliente'">{{ sortKey==='cliente' && sortDir==='desc' ? '▼' : '▲' }}</span>
</div>
</th> </th>
<th class="sortable text-center" (click)="setSort('status')"> <th class="sortable text-center" (click)="setSort('status')">
<div class="th-content justify-content-center"> <div class="th-content justify-content-center">STATUS <span class="sort-caret" [class.active]="sortKey==='status'">{{ sortKey==='status' && sortDir==='desc' ? '▼' : '▲' }}</span></div>
STATUS <span class="sort-caret" [class.active]="sortKey==='status'">{{ sortKey==='status' && sortDir==='desc' ? '▼' : '▲' }}</span>
</div>
</th> </th>
<th class="sortable text-center" (click)="setSort('skil')"> <th class="sortable text-center" (click)="setSort('skil')">
<div class="th-content justify-content-center"> <div class="th-content justify-content-center">SKIL <span class="sort-caret" [class.active]="sortKey==='skil'">{{ sortKey==='skil' && sortDir==='desc' ? '▼' : '▲' }}</span></div>
SKIL <span class="sort-caret" [class.active]="sortKey==='skil'">{{ sortKey==='skil' && sortDir==='desc' ? '▼' : '▲' }}</span>
</div>
</th> </th>
<th class="sortable text-center" (click)="setSort('contrato')"> <th class="sortable text-center" (click)="setSort('contrato')">
<div class="th-content justify-content-center"> <div class="th-content justify-content-center">VENCIMENTO <span class="sort-caret" [class.active]="sortKey==='contrato'">{{ sortKey==='contrato' && sortDir==='desc' ? '▼' : '▲' }}</span></div>
VENCIMENTO <span class="sort-caret" [class.active]="sortKey==='contrato'">{{ sortKey==='contrato' && sortDir==='desc' ? '▼' : '▲' }}</span>
</div>
</th> </th>
<th class="text-center">AÇÕES</th> <th class="text-center">AÇÕES</th>
</tr> </tr>
@ -253,7 +235,7 @@
<button type="button" class="btn-icon" (click)="onDetalhes(r)" title="Detalhes"><i class="bi bi-eye"></i></button> <button type="button" class="btn-icon" (click)="onDetalhes(r)" title="Detalhes"><i class="bi bi-eye"></i></button>
<button type="button" class="btn-icon success" (click)="onFinanceiro(r)" title="Financeiro"><i class="bi bi-cash-coin"></i></button> <button type="button" class="btn-icon success" (click)="onFinanceiro(r)" title="Financeiro"><i class="bi bi-cash-coin"></i></button>
<button type="button" class="btn-icon primary" (click)="onEditar(r)" title="Editar"><i class="bi bi-pencil-square"></i></button> <button type="button" class="btn-icon primary" (click)="onEditar(r)" title="Editar"><i class="bi bi-pencil-square"></i></button>
<button type="button" class="btn-icon danger" (click)="onRemover(r)" title="Remover"><i class="bi bi-trash"></i></button> <button type="button" class="btn-icon danger" (click)="onRemover(r)"><i class="bi bi-trash"></i></button>
</div> </div>
</td> </td>
</tr> </tr>
@ -267,7 +249,7 @@
</div> </div>
<div class="geral-footer" *ngIf="!isGroupMode"> <div class="geral-footer">
<div class="small text-muted fw-bold">Mostrando {{ pageStart }}{{ pageEnd }} de {{ filteredCount }}</div> <div class="small text-muted fw-bold">Mostrando {{ pageStart }}{{ pageEnd }} de {{ filteredCount }}</div>
<nav> <nav>
<ul class="pagination pagination-sm mb-0 pagination-modern"> <ul class="pagination pagination-sm mb-0 pagination-modern">
@ -281,17 +263,14 @@
</div> </div>
</section> </section>
<div class="modal-backdrop-custom" *ngIf="detailOpen" (click)="closeDetail()"></div> <div class="modal-backdrop-custom" *ngIf="detailOpen || financeOpen || editOpen" (click)="closeDetail(); closeFinance(); closeEdit()"></div>
<div class="modal-custom" *ngIf="detailOpen"> <div class="modal-custom" *ngIf="detailOpen">
<div class="modal-card modal-responsive" (click)="$event.stopPropagation()"> <div class="modal-card modal-responsive" (click)="$event.stopPropagation()">
<div class="modal-header"> <div class="modal-header">
<div class="modal-title"> <div class="modal-title"><span class="icon-bg primary-soft"><i class="bi bi-sim"></i></span> Detalhes da Linha</div>
<span class="icon-bg primary-soft"><i class="bi bi-sim"></i></span>
Detalhes da Linha
</div>
<button type="button" class="btn btn-sm btn-icon" (click)="closeDetail()"><i class="bi bi-x-lg"></i></button> <button type="button" class="btn btn-sm btn-icon" (click)="closeDetail()"><i class="bi bi-x-lg"></i></button>
</div> </div>
<div class="modal-body modern-body bg-light-gray" *ngIf="detailData; else detailLoading"> <div class="modal-body modern-body bg-light-gray" *ngIf="detailData; else detailLoading">
<div class="details-dashboard"> <div class="details-dashboard">
<div class="dashboard-column"> <div class="dashboard-column">
@ -344,7 +323,6 @@
</div> </div>
</div> </div>
<div class="modal-backdrop-custom" *ngIf="financeOpen" (click)="closeFinance()"></div>
<div class="modal-custom" *ngIf="financeOpen"> <div class="modal-custom" *ngIf="financeOpen">
<div class="modal-card modal-lg" (click)="$event.stopPropagation()"> <div class="modal-card modal-lg" (click)="$event.stopPropagation()">
<div class="modal-header"> <div class="modal-header">
@ -388,7 +366,6 @@
</div> </div>
</div> </div>
<div class="modal-backdrop-custom" *ngIf="editOpen" (click)="closeEdit()"></div>
<div class="modal-custom" *ngIf="editOpen"> <div class="modal-custom" *ngIf="editOpen">
<div class="modal-card modal-edit" (click)="$event.stopPropagation()"> <div class="modal-card modal-edit" (click)="$event.stopPropagation()">
<div class="modal-header"> <div class="modal-header">
@ -404,8 +381,7 @@
<div class="modal-body modern-body bg-light-gray"> <div class="modal-body modern-body bg-light-gray">
<ng-container *ngIf="editModel; else editLoadingTpl"> <ng-container *ngIf="editModel; else editLoadingTpl">
<div class="edit-sections"> <div class="edit-sections">
<details open class="edit-section"> <details open class="edit-section"><summary><i class="bi bi-person-badge me-2"></i>Identificação</summary>
<summary><i class="bi bi-person-badge me-2"></i>Identificação</summary>
<div class="edit-grid"> <div class="edit-grid">
<div class="form-field"><label>Item</label><input class="form-control form-control-sm" type="number" [(ngModel)]="editModel.item" name="edit_item" /></div> <div class="form-field"><label>Item</label><input class="form-control form-control-sm" type="number" [(ngModel)]="editModel.item" name="edit_item" /></div>
<div class="form-field"><label>Conta</label><input class="form-control form-control-sm" [(ngModel)]="editModel.conta" name="edit_conta" /></div> <div class="form-field"><label>Conta</label><input class="form-control form-control-sm" [(ngModel)]="editModel.conta" name="edit_conta" /></div>
@ -433,6 +409,32 @@
<div class="form-field"><label>Solicitante</label><input class="form-control form-control-sm" [(ngModel)]="editModel.solicitante" name="edit_solicitante" /></div> <div class="form-field"><label>Solicitante</label><input class="form-control form-control-sm" [(ngModel)]="editModel.solicitante" name="edit_solicitante" /></div>
</div> </div>
</details> </details>
<details class="edit-section"><summary><i class="bi bi-telephone-fill me-2"></i>Vivo</summary>
<div class="edit-grid">
<div class="form-field"><label>Franquia Vivo</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.franquiaVivo" name="edit_franquiaVivo" /></div>
<div class="form-field"><label>Valor Plano Vivo</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.valorPlanoVivo" name="edit_valorPlanoVivo" /></div>
<div class="form-field"><label>Gestão Voz/Dados</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.gestaoVozDados" name="edit_gestaoVozDados" /></div>
<div class="form-field"><label>Skeelo</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.skeelo" name="edit_skeelo" /></div>
<div class="form-field"><label>Vivo News+</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.vivoNewsPlus" name="edit_vivoNewsPlus" /></div>
<div class="form-field"><label>Vivo Travel Mundo</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.vivoTravelMundo" name="edit_vivoTravelMundo" /></div>
<div class="form-field"><label>Vivo Gestão Dispositivo</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.vivoGestaoDispositivo" name="edit_vivoGestaoDispositivo" /></div>
<div class="form-field"><label>Valor Contrato Vivo</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.valorContratoVivo" name="edit_valorContratoVivo" /></div>
</div>
</details>
<details class="edit-section"><summary><i class="bi bi-hdd-network-fill me-2"></i>Line Móvel</summary>
<div class="edit-grid">
<div class="form-field"><label>Franquia Line</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.franquiaLine" name="edit_franquiaLine" /></div>
<div class="form-field"><label>Franquia Gestão</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.franquiaGestao" name="edit_franquiaGestao" /></div>
<div class="form-field"><label>Locação Ap.</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.locacaoAp" name="edit_locacaoAp" /></div>
<div class="form-field"><label>Valor Contrato Line</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.valorContratoLine" name="edit_valorContratoLine" /></div>
</div>
</details>
<details class="edit-section"><summary><i class="bi bi-graph-up-arrow me-2"></i>Resultado</summary>
<div class="edit-grid">
<div class="form-field"><label>Desconto</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.desconto" name="edit_desconto" /></div>
<div class="form-field"><label>Lucro</label><input class="form-control form-control-sm" type="number" step="0.01" [(ngModel)]="editModel.lucro" name="edit_lucro" /></div>
</div>
</details>
</div> </div>
</ng-container> </ng-container>
<ng-template #editLoadingTpl><div class="p-5 text-center text-muted"><span class="spinner-border spinner-border-sm me-2"></span> Carregando...</div></ng-template> <ng-template #editLoadingTpl><div class="p-5 text-center text-muted"><span class="spinner-border spinner-border-sm me-2"></span> Carregando...</div></ng-template>

View File

@ -1,29 +1,39 @@
/* ========================================================== */
/* 1. VARIÁVEIS E CONFIGURAÇÕES GERAIS */
/* ========================================================== */
:host { :host {
/* ================= PALETA DE CORES ================= */ /* Paleta de Cores */
--brand: #E33DCF; --brand: #E33DCF; /* Rosa da marca */
--blue: #030FAA; --blue: #030FAA; /* Azul da marca */
--text: #111214; --text: #111214; /* Texto principal */
--muted: rgba(17, 18, 20, 0.65); --muted: rgba(17, 18, 20, 0.65); /* Texto secundário */
/* Cores Específicas (Financeiro) */ /* Cores Específicas (Financeiro/Status) */
--bg-vivo: #fbf5fc; --bg-vivo: #fbf5fc;
--text-vivo: #8a2be2; --text-vivo: #8a2be2;
--bg-line: #f5f6ff; --bg-line: #f5f6ff;
--text-line: #030FAA; --text-line: #030FAA;
--success-bg: rgba(25, 135, 84, 0.1);
--success-text: #198754;
--danger-bg: rgba(220, 53, 69, 0.1);
--danger-text: #dc3545;
/* Dimensões & Bordas */ /* Dimensões & Bordas */
--radius-xl: 22px; --radius-xl: 22px;
--radius-lg: 16px; --radius-lg: 16px;
--radius-md: 12px; --radius-md: 12px;
--shadow-card: 0 22px 46px rgba(17, 18, 20, 0.10);
--glass-bg: rgba(255, 255, 255, 0.82);
--glass-border: 1px solid rgba(227, 61, 207, 0.16);
display: block; display: block;
font-family: 'Inter', sans-serif; font-family: 'Inter', sans-serif;
color: var(--text); color: var(--text);
} }
/* ========================================= */ /* ========================================================== */
/* 1. LAYOUT DA PÁGINA & BACKGROUND */ /* 2. LAYOUT DA PÁGINA & BACKGROUND */
/* ========================================= */ /* ========================================================== */
.geral-page { .geral-page {
min-height: 100vh; min-height: 100vh;
padding: 24px 12px 90px; padding: 24px 12px 90px;
@ -32,25 +42,23 @@
position: relative; position: relative;
overflow: hidden; overflow: hidden;
/* Fundo com Gradientes Suaves */ /* Fundo com Gradientes Suaves e modernos */
background: background:
radial-gradient(900px 420px at 20% 10%, rgba(227, 61, 207, 0.14), transparent 60%), radial-gradient(900px 420px at 20% 10%, rgba(227, 61, 207, 0.14), transparent 60%),
radial-gradient(820px 380px at 80% 30%, rgba(227, 61, 207, 0.08), transparent 60%), radial-gradient(820px 380px at 80% 30%, rgba(227, 61, 207, 0.08), transparent 60%),
linear-gradient(180deg, #ffffff 0%, #f5f5f7 70%); linear-gradient(180deg, #ffffff 0%, #f5f5f7 70%);
/* Overlay sutil de ruído/textura (opcional) */ /* Overlay sutil de ruído/textura (opcional, aqui usado como clareador) */
&::after { &::after {
content: ''; content: ''; position: absolute; inset: 0; pointer-events: none;
position: absolute;
inset: 0;
pointer-events: none;
background: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.25);
} }
} }
/* Blobs Flutuantes (Animação de Fundo) */ /* Blobs Flutuantes (Animação de fundo) */
.page-blob { .page-blob {
position: fixed; pointer-events: none; border-radius: 999px; filter: blur(34px); opacity: 0.55; z-index: 0; position: fixed; pointer-events: none; border-radius: 999px;
filter: blur(34px); opacity: 0.55; z-index: 0;
background: radial-gradient(circle at 30% 30%, rgba(227,61,207,0.55), rgba(227,61,207,0.06)); background: radial-gradient(circle at 30% 30%, rgba(227,61,207,0.55), rgba(227,61,207,0.06));
animation: floaty 10s ease-in-out infinite; animation: floaty 10s ease-in-out infinite;
@ -67,41 +75,39 @@
} }
.container-geral { .container-geral {
width: 100%; width: 100%; max-width: 1180px; position: relative; z-index: 1;
max-width: 1180px;
position: relative;
z-index: 1;
} }
/* Card Principal (Efeito de Vidro) */ /* Card Principal (Container da Aplicação) */
.geral-card { .geral-card {
border-radius: var(--radius-xl); border-radius: var(--radius-xl);
overflow: hidden; /* Importante para conter tabelas */ overflow: hidden;
background: rgba(255, 255, 255, 0.82); background: var(--glass-bg);
border: 1px solid rgba(227, 61, 207, 0.16); border: var(--glass-border);
backdrop-filter: blur(12px); backdrop-filter: blur(12px);
box-shadow: 0 22px 46px rgba(17, 18, 20, 0.10); box-shadow: var(--shadow-card);
position: relative; position: relative;
display: flex; display: flex; flex-direction: column;
flex-direction: column; max-height: 85vh; /* Limita altura para scroll interno */
max-height: 85vh; /* Limita altura total do card na tela */
/* Borda interna brilhante */
&::before { &::before {
content: ''; position: absolute; inset: 1px; border-radius: calc(var(--radius-xl) - 1px); content: ''; position: absolute; inset: 1px; border-radius: calc(var(--radius-xl) - 1px);
pointer-events: none; border: 1px solid rgba(255, 255, 255, 0.65); opacity: 0.75; pointer-events: none; border: 1px solid rgba(255, 255, 255, 0.65); opacity: 0.75;
} }
} }
/* ========================================= */ /* ========================================================== */
/* 2. HEADER & AÇÕES */ /* 3. HEADER (GRID LAYOUT) */
/* ========================================= */ /* ========================================================== */
.geral-header { .geral-header {
padding: 16px 24px; padding: 16px 24px;
border-bottom: 1px solid rgba(17, 18, 20, 0.06); border-bottom: 1px solid rgba(17, 18, 20, 0.06);
background: linear-gradient(180deg, rgba(227,61,207,0.06), rgba(255,255,255,0.2)); background: linear-gradient(180deg, rgba(227,61,207,0.06), rgba(255,255,255,0.2));
flex-shrink: 0; /* Header não encolhe */ flex-shrink: 0;
} }
/* GRID: Esquerda (1fr) | Centro (auto) | Direita (1fr) */
.header-row-top { .header-row-top {
display: grid; display: grid;
grid-template-columns: 1fr auto 1fr; grid-template-columns: 1fr auto 1fr;
@ -112,14 +118,15 @@
grid-template-columns: 1fr; grid-template-columns: 1fr;
text-align: center; text-align: center;
gap: 16px; gap: 16px;
.title-badge { justify-self: center; margin-bottom: 8px; }
.header-actions { justify-self: center; }
} }
} }
.header-title { /* 1. Badge à esquerda */
display: flex; flex-direction: column; align-items: center; text-align: center;
}
.title-badge { .title-badge {
justify-self: start;
display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px;
border-radius: 999px; background: rgba(255, 255, 255, 0.78); border-radius: 999px; background: rgba(255, 255, 255, 0.78);
border: 1px solid rgba(227, 61, 207, 0.22); backdrop-filter: blur(10px); border: 1px solid rgba(227, 61, 207, 0.22); backdrop-filter: blur(10px);
@ -127,10 +134,20 @@
i { color: var(--brand); } i { color: var(--brand); }
} }
/* 2. Título Centralizado */
.header-title {
justify-self: center;
display: flex; flex-direction: column; align-items: center; text-align: center;
}
.title { font-size: 26px; font-weight: 950; letter-spacing: -0.3px; color: var(--text); margin-top: 10px; margin-bottom: 0; } .title { font-size: 26px; font-weight: 950; letter-spacing: -0.3px; color: var(--text); margin-top: 10px; margin-bottom: 0; }
.subtitle { color: rgba(17, 18, 20, 0.65); font-weight: 700; } .subtitle { color: rgba(17, 18, 20, 0.65); font-weight: 700; }
/* Botões de Ação Principais */ /* 3. Ações à Direita */
.header-actions {
justify-self: end;
}
/* Botões do Header */
.btn-brand { .btn-brand {
background-color: var(--brand); border-color: var(--brand); color: #fff; background-color: var(--brand); border-color: var(--brand); color: #fff;
font-weight: 900; border-radius: 12px; transition: transform 0.2s, box-shadow 0.2s; font-weight: 900; border-radius: 12px; transition: transform 0.2s, box-shadow 0.2s;
@ -144,46 +161,31 @@
&:hover { transform: translateY(-2px); border-color: var(--brand); background: #fff; } &:hover { transform: translateY(-2px); border-color: var(--brand); background: #fff; }
} }
/* ========================================= */ /* ========================================================== */
/* 3. FILTROS (TABS E DROPDOWN) */ /* 4. FILTROS E DROPDOWN */
/* ========================================= */ /* ========================================================== */
.filters-row { .filters-row {
display: flex; display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap;
justify-content: center;
align-items: center;
gap: 12px;
flex-wrap: wrap;
} }
/* Tabs (Todos / PF / PJ) */
.filter-tabs { .filter-tabs {
display: flex; gap: 4px; padding: 4px; display: flex; gap: 4px; padding: 4px;
background: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.6);
border: 1px solid rgba(17, 18, 20, 0.08); border: 1px solid rgba(17, 18, 20, 0.08);
border-radius: 12px; border-radius: 12px; backdrop-filter: blur(8px);
backdrop-filter: blur(8px);
} }
.filter-tab { .filter-tab {
border: none; background: transparent; padding: 8px 16px; border-radius: 8px; border: none; background: transparent; padding: 8px 16px; border-radius: 8px;
font-size: 0.85rem; font-weight: 700; color: var(--muted); font-size: 0.85rem; font-weight: 700; color: var(--muted);
transition: all 0.2s ease; transition: all 0.2s ease; display: flex; align-items: center; gap: 6px;
display: flex; align-items: center; gap: 6px;
&:hover { color: var(--text); background: rgba(255, 255, 255, 0.5); } &:hover { color: var(--text); background: rgba(255, 255, 255, 0.5); }
&.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(227, 61, 207, 0.15); }
&.active {
background: #fff; color: var(--brand);
box-shadow: 0 2px 8px rgba(227, 61, 207, 0.15);
}
&:disabled { opacity: 0.5; cursor: not-allowed; } &:disabled { opacity: 0.5; cursor: not-allowed; }
} }
/* Dropdown de Clientes */ /* Dropdown de Clientes */
.client-filter-wrap { .client-filter-wrap { position: relative; }
position: relative;
}
.btn-client-filter { .btn-client-filter {
display: flex; align-items: center; gap: 8px; display: flex; align-items: center; gap: 8px;
@ -191,14 +193,9 @@
border: 1px solid rgba(17, 18, 20, 0.08); border: 1px solid rgba(17, 18, 20, 0.08);
background: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.6);
color: var(--muted); font-weight: 700; font-size: 0.85rem; color: var(--muted); font-weight: 700; font-size: 0.85rem;
backdrop-filter: blur(8px); transition: all 0.2s; backdrop-filter: blur(8px); transition: all 0.2s; white-space: nowrap;
&:hover { background: #fff; border-color: var(--blue); color: var(--blue); } &:hover { background: #fff; border-color: var(--blue); color: var(--blue); }
&.active { background: var(--blue); color: #fff; border-color: var(--blue); i { color: #fff; } }
&.active {
background: var(--blue); color: #fff; border-color: var(--blue);
i { color: #fff; }
}
} }
.client-dropdown { .client-dropdown {
@ -207,184 +204,163 @@
background: #fff; border-radius: 12px; background: #fff; border-radius: 12px;
box-shadow: 0 10px 30px rgba(0,0,0,0.15); box-shadow: 0 10px 30px rgba(0,0,0,0.15);
border: 1px solid rgba(17,18,20,0.08); border: 1px solid rgba(17,18,20,0.08);
z-index: 50; z-index: 50; display: flex; flex-direction: column; overflow: hidden;
display: flex; flex-direction: column;
overflow: hidden;
animation: fadeIn 0.2s ease; animation: fadeIn 0.2s ease;
} }
@keyframes fadeIn { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { .dropdown-header-search { padding: 8px; border-bottom: 1px solid rgba(0,0,0,0.05); background: #f9fafb; }
from { opacity:0; transform:translateY(-10px); } .dropdown-list { overflow-y: auto; max-height: 300px; }
to { opacity:1; transform:translateY(0); }
}
.dropdown-header-search {
padding: 8px; border-bottom: 1px solid rgba(0,0,0,0.05); background: #f9fafb;
}
.dropdown-list {
overflow-y: auto; max-height: 300px;
}
.dropdown-item-custom { .dropdown-item-custom {
padding: 10px 16px; font-size: 0.85rem; color: var(--text); padding: 10px 16px; font-size: 0.85rem; color: var(--text); cursor: pointer; border-bottom: 1px solid rgba(0,0,0,0.03); transition: background 0.1s;
cursor: pointer; border-bottom: 1px solid rgba(0,0,0,0.03);
transition: background 0.1s;
&:hover { background: rgba(227,61,207,0.05); color: var(--brand); font-weight: 600; } &:hover { background: rgba(227,61,207,0.05); color: var(--brand); font-weight: 600; }
&.selected { background: rgba(3,15,170,0.08); color: var(--blue); font-weight: 700; } &.selected { background: rgba(3,15,170,0.08); color: var(--blue); font-weight: 700; }
} }
/* Inputs de Busca e Paginação */ /* ========================================================== */
/* 5. CONTROLES (SEARCH BAR) */
/* ========================================================== */
.controls { .controls {
display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
} }
/* Estilo Moderno da Busca */
.search-group { .search-group {
max-width: 340px; border-radius: 14px; overflow: hidden; max-width: 225px;
.input-group-text { background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(17, 18, 20, 0.1); color: var(--brand); } border-radius: 12px;
.form-control { border: 1px solid rgba(17, 18, 20, 0.1); background: rgba(255, 255, 255, 0.6); &:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(227,61,207,0.1); } }
.btn-clear { background: rgba(255,255,255,0.6); border: 1px solid rgba(17,18,20,0.1); }
}
.select-glass {
border-radius: 12px; background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(17, 18, 20, 0.1); width: auto; cursor: pointer;
}
/* ========================================= */
/* 4. ÁREA DE CONTEÚDO (BODY) */
/* ========================================= */
.geral-body {
padding: 0;
background: transparent;
flex: 1; /* Ocupa espaço restante do card */
overflow: hidden; /* Scroll interno na tabela/grupos */
display: flex; flex-direction: column;
}
/* ========================================= */
/* 5. MODO GRUPO (ACCORDION) */
/* ========================================= */
.groups-container {
padding: 16px;
overflow-y: auto;
height: 100%;
}
.group-list {
display: flex; flex-direction: column; gap: 12px;
}
.client-group-card {
background: #fff;
border-radius: 16px;
border: 1px solid rgba(17,18,20,0.08);
overflow: hidden; overflow: hidden;
display: flex;
align-items: stretch;
background: #fff; /* Fundo Branco Sólido */
border: 1px solid rgba(17, 18, 20, 0.15); /* Borda Visível */
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
transition: all 0.2s ease;
&:focus-within {
border-color: var(--brand);
box-shadow: 0 4px 12px rgba(227, 61, 207, 0.15);
transform: translateY(-1px);
}
.input-group-text {
background: transparent;
border: none;
color: var(--muted);
padding-left: 14px;
padding-right: 8px;
display: flex; align-items: center;
i { font-size: 1rem; }
}
.form-control {
border: none;
background: transparent;
padding: 10px 0;
font-size: 0.9rem;
color: var(--text);
box-shadow: none;
&::placeholder { color: rgba(17, 18, 20, 0.4); font-weight: 500; }
&:focus { outline: none; }
}
.btn-clear {
background: transparent;
border: none;
color: var(--muted);
padding: 0 12px;
display: flex; align-items: center; cursor: pointer;
transition: color 0.2s;
&:hover { color: #dc3545; }
i { font-size: 1rem; }
}
}
/* Select de Paginação */
.select-glass {
border-radius: 12px;
background: #fff;
border: 1px solid rgba(17, 18, 20, 0.15);
color: var(--text);
font-weight: 600;
box-shadow: 0 2px 6px rgba(0,0,0,0.04);
padding: 8px 32px 8px 12px;
cursor: pointer;
transition: all 0.2s;
width: auto;
&:focus {
border-color: var(--brand);
box-shadow: 0 4px 12px rgba(227, 61, 207, 0.15);
outline: none;
}
}
/* ========================================================== */
/* 6. CORPO, GRUPOS (ACCORDION) & TABELA */
/* ========================================================== */
.geral-body {
padding: 0; background: transparent; flex: 1; overflow: hidden; display: flex; flex-direction: column;
}
.groups-container { padding: 16px; overflow-y: auto; height: 100%; }
.group-list { display: flex; flex-direction: column; gap: 12px; }
/* Cards de Grupo */
.client-group-card {
background: #fff; border-radius: 16px;
border: 1px solid rgba(17,18,20,0.08); overflow: hidden;
transition: all 0.3s ease; transition: all 0.3s ease;
&:hover { border-color: var(--brand); box-shadow: 0 4px 12px rgba(227,61,207,0.1); }
&:hover { &.expanded { border-color: var(--brand); box-shadow: 0 8px 24px rgba(227,61,207,0.12); }
border-color: var(--brand);
box-shadow: 0 4px 12px rgba(227,61,207,0.1);
}
&.expanded {
border-color: var(--brand);
box-shadow: 0 8px 24px rgba(227,61,207,0.12);
}
} }
.group-header { .group-header {
padding: 16px 24px; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center;
display: flex; justify-content: space-between; align-items: center; cursor: pointer; background: linear-gradient(180deg, #fff, #fdfdfd);
cursor: pointer;
background: linear-gradient(180deg, #fff, #fdfdfd);
&:hover .group-toggle-icon { color: var(--brand); } &:hover .group-toggle-icon { color: var(--brand); }
} }
.group-info { .group-info { display: flex; flex-direction: column; gap: 6px; }
display: flex; flex-direction: column; gap: 6px; .group-badges { display: flex; gap: 8px; flex-wrap: wrap; }
}
.group-badges {
display: flex; gap: 8px; flex-wrap: wrap;
}
.badge-pill { .badge-pill {
font-size: 0.7rem; padding: 4px 10px; border-radius: 99px; font-weight: 800; text-transform: uppercase; font-size: 0.7rem; padding: 4px 10px; border-radius: 99px; font-weight: 800; text-transform: uppercase;
&.total { background: rgba(3,15,170,0.1); color: var(--blue); } &.total { background: rgba(3,15,170,0.1); color: var(--blue); }
&.active { background: rgba(25,135,84,0.1); color: #198754; } &.active { background: var(--success-bg); color: var(--success-text); }
&.blocked { background: rgba(220,53,69,0.1); color: #dc3545; } &.blocked { background: var(--danger-bg); color: var(--danger-text); }
} }
.group-toggle-icon { .group-toggle-icon { font-size: 1.2rem; color: var(--muted); transition: transform 0.3s ease; }
font-size: 1.2rem; color: var(--muted); transition: transform 0.3s ease; .client-group-card.expanded .group-toggle-icon { transform: rotate(180deg); color: var(--brand); }
}
.client-group-card.expanded .group-toggle-icon {
transform: rotate(180deg); color: var(--brand);
}
.group-body { .group-body {
border-top: 1px solid rgba(17,18,20,0.06); border-top: 1px solid rgba(17,18,20,0.06); background: #fbfbfc;
background: #fbfbfc;
animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1); animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
} }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { .inner-table-wrap { max-height: 450px; overflow-y: auto; }
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
.inner-table-wrap {
max-height: 450px;
overflow-y: auto;
}
/* ========================================= */
/* 6. MODO TABELA (CENTRALIZADA) */
/* ========================================= */
.table-wrap {
overflow-x: auto;
overflow-y: auto;
height: 100%;
}
/* Tabela */
.table-wrap { overflow-x: auto; overflow-y: auto; height: 100%; }
.table-modern { .table-modern {
width: 100%; min-width: 1000px; border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1000px; border-collapse: separate; border-spacing: 0;
thead th { thead th {
position: sticky; top: 0; z-index: 10; position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px);
background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px); border-bottom: 2px solid rgba(227, 61, 207, 0.15); padding: 12px;
border-bottom: 2px solid rgba(227, 61, 207, 0.15);
padding: 12px;
color: rgba(17, 18, 20, 0.7); font-size: 0.8rem; font-weight: 950; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(17, 18, 20, 0.7); font-size: 0.8rem; font-weight: 950; letter-spacing: 0.05em; text-transform: uppercase;
white-space: nowrap; cursor: pointer; transition: color 0.2s; white-space: nowrap; cursor: pointer; transition: color 0.2s; text-align: center !important;
/* Centralização Forçada */
text-align: center !important;
&:hover { color: var(--brand); } &:hover { color: var(--brand); }
} }
tbody tr { tbody tr {
transition: background-color 0.2s; transition: background-color 0.2s; border-bottom: 1px solid rgba(17,18,20,0.05);
border-bottom: 1px solid rgba(17,18,20,0.05);
&:hover { background-color: rgba(227, 61, 207, 0.05); } &:hover { background-color: rgba(227, 61, 207, 0.05); }
td { border-bottom: 1px solid rgba(17,18,20,0.04); } td { border-bottom: 1px solid rgba(17,18,20,0.04); }
} }
td { padding: 12px; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.875rem; color: var(--text); text-align: center !important; }
td {
padding: 12px; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
font-size: 0.875rem; color: var(--text);
/* Centralização Forçada */
text-align: center !important;
}
} }
.th-content { display: flex; align-items: center; justify-content: center; gap: 4px; } .th-content { display: flex; align-items: center; justify-content: center; gap: 4px; }
.sort-caret { display: inline-block; width: 14px; text-align: center; opacity: 0.3; &.active { opacity: 1; color: var(--brand); } } .sort-caret { display: inline-block; width: 14px; text-align: center; opacity: 0.3; &.active { opacity: 1; color: var(--brand); } }
.text-brand { color: var(--brand) !important; } .text-brand { color: var(--brand) !important; }
.text-blue { color: var(--blue) !important; } .text-blue { color: var(--blue) !important; }
@ -392,24 +368,34 @@
.td-clip { overflow: hidden; text-overflow: ellipsis; max-width: 250px; } .td-clip { overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.empty-state { background: rgba(255,255,255,0.4); } .empty-state { background: rgba(255,255,255,0.4); }
/* Ações */ .status-pill {
display: inline-block; vertical-align: middle; max-width: 100%; padding: 6px 14px;
border-radius: 999px; font-weight: 950; font-size: 0.75rem; letter-spacing: 0.3px; text-align: center; text-transform: uppercase;
border: 1px solid rgba(17,18,20,0.1); background: rgba(17,18,20,0.05); color: rgba(17,18,20,0.7);
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
&.is-active { background: rgba(25, 135, 84, 0.15); border-color: rgba(25, 135, 84, 0.25); color: #157347; }
&.is-blocked { background: rgba(220, 53, 69, 0.15); border-color: rgba(220, 53, 69, 0.25); color: #b02a37; }
}
/* Botões de Ação na Tabela */
.action-group { display: flex; justify-content: center; gap: 6px; } .action-group { display: flex; justify-content: center; gap: 6px; }
.btn-icon { .btn-icon {
width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px; width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px;
display: flex; align-items: center; justify-content: center; color: rgba(17,18,20,0.5); transition: all 0.2s; display: flex; align-items: center; justify-content: center; color: rgba(17,18,20,0.5); transition: all 0.2s;
&:hover { background: rgba(17,18,20,0.05); color: var(--text); transform: translateY(-1px); } &:hover { background: rgba(17,18,20,0.05); color: var(--text); transform: translateY(-1px); }
&.success:hover { color: #198754; background: rgba(25,135,84,0.1); } &.success:hover { color: var(--success-text); background: var(--success-bg); }
&.primary:hover { color: var(--blue); background: rgba(3,15,170,0.1); } &.primary:hover { color: var(--blue); background: rgba(3,15,170,0.1); }
&.danger:hover { color: #dc3545; background: rgba(220,53,69,0.1); } &.danger:hover { color: var(--danger-text); background: var(--danger-bg); }
} }
/* Footer */ /* ========================================================== */
/* 7. FOOTER (PAGINAÇÃO) */
/* ========================================================== */
.geral-footer { .geral-footer {
padding: 14px 24px; border-top: 1px solid rgba(17, 18, 20, 0.06); padding: 14px 24px; border-top: 1px solid rgba(17, 18, 20, 0.06);
display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0;
@media (max-width: 768px) { justify-content: center; text-align: center; } @media (max-width: 768px) { justify-content: center; text-align: center; }
} }
.pagination-modern .page-link { .pagination-modern .page-link {
color: var(--blue); font-weight: 900; border-radius: 10px; border: 1px solid rgba(17,18,20,0.1); color: var(--blue); font-weight: 900; border-radius: 10px; border: 1px solid rgba(17,18,20,0.1);
background: rgba(255,255,255,0.6); margin: 0 2px; background: rgba(255,255,255,0.6); margin: 0 2px;
@ -417,9 +403,9 @@
} }
.pagination-modern .page-item.active .page-link { background-color: var(--blue); border-color: var(--blue); color: #fff; } .pagination-modern .page-item.active .page-link { background-color: var(--blue); border-color: var(--blue); color: #fff; }
/* ========================================= */ /* ========================================================== */
/* 7. MODAIS (Geral) */ /* 8. MODAIS (Z-INDEX ALTO) */
/* ========================================= */ /* ========================================================== */
.modal-backdrop-custom { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 9990; backdrop-filter: blur(4px); } .modal-backdrop-custom { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 9990; backdrop-filter: blur(4px); }
.modal-custom { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 9995; padding: 16px; } .modal-custom { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 9995; padding: 16px; }
@ -427,41 +413,26 @@
background: #ffffff; border: 1px solid rgba(255,255,255,0.8); border-radius: 20px; background: #ffffff; border: 1px solid rgba(255,255,255,0.8); border-radius: 20px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); overflow: hidden; display: flex; flex-direction: column;
animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
width: min(850px, 100%); max-height: 90vh;
/* Tamanho Padrão */
width: min(850px, 100%);
max-height: 90vh;
} }
@keyframes modalPop { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } } @keyframes modalPop { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { .modal-header {
padding: 16px 24px; border-bottom: 1px solid rgba(0,0,0,0.06); background: #fff; display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid rgba(0,0,0,0.06); background: #fff; display: flex; justify-content: space-between; align-items: center;
.modal-title { font-size: 1.1rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 12px; } .modal-title { font-size: 1.1rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 12px; }
.icon-bg { width: 32px; height: 32px; border-radius: 10px; background: rgba(3, 15, 170, 0.1); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 16px; &.success { background: rgba(25, 135, 84, 0.1); color: #198754; } &.primary-soft { background: rgba(3, 15, 170, 0.1); color: var(--blue); } } .icon-bg { width: 32px; height: 32px; border-radius: 10px; background: rgba(3, 15, 170, 0.1); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 16px; &.success { background: var(--success-bg); color: var(--success-text); } &.primary-soft { background: rgba(3, 15, 170, 0.1); color: var(--blue); } }
.btn-icon { color: var(--muted); background: transparent; font-size: 1.2rem; &:hover { color: var(--brand); transform: rotate(90deg); } } .btn-icon { color: var(--muted); background: transparent; font-size: 1.2rem; &:hover { color: var(--brand); transform: rotate(90deg); } }
} }
.modal-body { padding: 24px; overflow-y: auto; &.bg-light-gray { background-color: #f8f9fa; } } .modal-body { padding: 24px; overflow-y: auto; &.bg-light-gray { background-color: #f8f9fa; } }
/* ========================================= */ /* Estilos de conteúdo dos modais (Detalhes, Financeiro, Edit) - Mantidos para garantir consistência */
/* 8. MODAL DETALHES (Responsivo Inteligente) */
/* ========================================= */
/* Regra apenas para telas GRANDES (>1440px) */
@media (min-width: 1441px) { @media (min-width: 1441px) {
.modal-card.modal-responsive { .modal-card.modal-responsive { width: min(1200px, 95%); height: 85vh; max-height: none; }
width: min(1200px, 95%);
height: 85vh;
max-height: none;
}
.detail-box .box-header { padding: 8px 16px; } .detail-box .box-header { padding: 8px 16px; }
.detail-box .box-body.compact { padding: 10px 14px; } .detail-box .box-body.compact { padding: 10px 14px; }
.box-body.compact .row-item { margin-bottom: 4px; font-size: 0.85rem; } .box-body.compact .row-item { margin-bottom: 4px; font-size: 0.85rem; }
.details-dashboard { gap: 16px; } .details-dashboard { gap: 16px; }
} }
.details-dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; @media(max-width: 700px) { grid-template-columns: 1fr; } } .details-dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; @media(max-width: 700px) { grid-template-columns: 1fr; } }
.detail-box { background: #fff; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06); overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.02); height: 100%; .box-header { padding: 10px 16px; font-weight: 800; font-size: 0.85rem; background: #fdfdfd; border-bottom: 1px solid rgba(0,0,0,0.04); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; i { color: var(--blue); } } .box-body { padding: 16px; } .box-body.compact { padding: 12px 14px; } } .detail-box { background: #fff; border-radius: 12px; border: 1px solid rgba(0,0,0,0.06); overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.02); height: 100%; .box-header { padding: 10px 16px; font-weight: 800; font-size: 0.85rem; background: #fdfdfd; border-bottom: 1px solid rgba(0,0,0,0.04); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; i { color: var(--blue); } } .box-body { padding: 16px; } .box-body.compact { padding: 12px 14px; } }
.row-item { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 0.9rem; color: var(--muted); .lbl { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px; } .val { color: var(--text); font-weight: 700; text-align: right; } } .row-item { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 0.9rem; color: var(--muted); .lbl { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px; } .val { color: var(--text); font-weight: 700; text-align: right; } }
@ -471,28 +442,16 @@
.divider { height: 1px; background: rgba(0,0,0,0.06); margin: 12px 0; } .divider { height: 1px; background: rgba(0,0,0,0.06); margin: 12px 0; }
.divider.small { margin: 8px 0; } .divider.small { margin: 8px 0; }
/* ========================================= */
/* 9. MODAL FINANCEIRO */
/* ========================================= */
.finance-dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; @media(max-width: 700px) { grid-template-columns: 1fr; } } .finance-dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; @media(max-width: 700px) { grid-template-columns: 1fr; } }
.finance-card { background: #fff; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.04); overflow: hidden; &.vivo-card { border-top: 4px solid var(--brand); .card-header-f { color: var(--brand); background: var(--bg-vivo); } } &.line-card { border-top: 4px solid var(--blue); .card-header-f { color: var(--blue); background: var(--bg-line); } } } .finance-card { background: #fff; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid rgba(0,0,0,0.04); overflow: hidden; &.vivo-card { border-top: 4px solid var(--brand); .card-header-f { color: var(--brand); background: var(--bg-vivo); } } &.line-card { border-top: 4px solid var(--blue); .card-header-f { color: var(--blue); background: var(--bg-line); } } }
.card-header-f { padding: 12px 16px; font-weight: 800; font-size: 0.95rem; display: flex; align-items: center; } .card-header-f { padding: 12px 16px; font-weight: 800; font-size: 0.95rem; display: flex; align-items: center; }
.card-body-f { padding: 16px; .row-item { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.85rem; color: var(--muted); strong { color: var(--text); font-weight: 700; } &.total { font-size: 1rem; color: var(--text); margin-top: 8px; margin-bottom: 0; strong { color: var(--text); font-weight: 900; } } } .divider { height: 1px; background: rgba(0,0,0,0.06); margin: 12px 0; } } .card-body-f { padding: 16px; .row-item { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.85rem; color: var(--muted); strong { color: var(--text); font-weight: 700; } &.total { font-size: 1rem; color: var(--text); margin-top: 8px; margin-bottom: 0; strong { color: var(--text); font-weight: 900; } } } .divider { height: 1px; background: rgba(0,0,0,0.06); margin: 12px 0; } }
.finance-summary { background: #fff; border-radius: 16px; padding: 16px 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.03); display: flex; align-items: center; justify-content: space-around; .summary-item { display: flex; flex-direction: column; align-items: center; .lbl { font-size: 0.75rem; text-transform: uppercase; font-weight: 800; color: var(--muted); } .val { font-size: 1.25rem; font-weight: 900; } } .vertical-line { width: 1px; height: 40px; background: rgba(0,0,0,0.08); } } .finance-summary { background: #fff; border-radius: 16px; padding: 16px 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.03); display: flex; align-items: center; justify-content: space-around; .summary-item { display: flex; flex-direction: column; align-items: center; .lbl { font-size: 0.75rem; text-transform: uppercase; font-weight: 800; color: var(--muted); } .val { font-size: 1.25rem; font-weight: 900; } } .vertical-line { width: 1px; height: 40px; background: rgba(0,0,0,0.08); } }
.text-success { color: #198754 !important; } .text-success { color: var(--success-text) !important; }
/* ========================================= */
/* 10. MODAL EDITAR */
/* ========================================= */
.modal-card.modal-edit { width: min(1100px, 100%); } .modal-card.modal-edit { width: min(1100px, 100%); }
.edit-sections { display: grid; gap: 12px; } .edit-sections { display: grid; gap: 12px; }
.edit-section { .edit-section { background: #fff; border: 1px solid rgba(0,0,0,0.06); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.03); summary { cursor: pointer; user-select: none; padding: 12px 16px; font-weight: 950; color: rgba(17,18,20,0.75); display: flex; align-items: center; background: linear-gradient(180deg, rgba(227,61,207,0.06), rgba(255,255,255,0.6)); border-bottom: 1px solid rgba(0,0,0,0.06); i { color: var(--blue); } } }
background: #fff; border: 1px solid rgba(0,0,0,0.06); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.03);
summary {
cursor: pointer; user-select: none; padding: 12px 16px; font-weight: 950; color: rgba(17,18,20,0.75); display: flex; align-items: center; background: linear-gradient(180deg, rgba(227,61,207,0.06), rgba(255,255,255,0.6)); border-bottom: 1px solid rgba(0,0,0,0.06);
i { color: var(--blue); }
}
}
.edit-grid { padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; @media (max-width: 700px) { grid-template-columns: 1fr; } } .edit-grid { padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; @media (max-width: 700px) { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 6px; label { font-size: 0.75rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(17,18,20,0.65); } } .form-field { display: flex; flex-direction: column; gap: 6px; label { font-size: 0.75rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(17,18,20,0.65); } }
.form-field.span-2 { grid-column: span 2; @media (max-width: 700px) { grid-column: span 1; } } .form-field.span-2 { grid-column: span 2; @media (max-width: 700px) { grid-column: span 1; } }

View File

@ -3,36 +3,81 @@ import { isPlatformBrowser, CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { HttpClient, HttpClientModule, HttpParams, HttpErrorResponse } from '@angular/common/http'; import { HttpClient, HttpClientModule, HttpParams, HttpErrorResponse } from '@angular/common/http';
// Tipos e Interfaces
type SortDir = 'asc' | 'desc'; type SortDir = 'asc' | 'desc';
// ✅ CORREÇÃO: Adicionado 'usuario' aqui interface LineRow {
type LineRow = {
id: string; id: string;
item: string; item: string;
linha: string; linha: string;
cliente: string; cliente: string;
usuario: string; // <--- NOVO CAMPO usuario: string;
status: string; status: string;
skil: string; skil: string;
contrato: string; contrato: string;
}; }
type ApiPagedResult<T> = { page: number; pageSize: number; total: number; items: T[]; }; interface ApiPagedResult<T> {
// ✅ CORREÇÃO: Adicionado 'usuario' no DTO de listagem também, caso não tivesse page: number;
type ApiLineList = { pageSize: number;
total: number;
items: T[];
}
interface ApiLineList {
id: string; id: string;
item: number; item: number;
linha: string | null; linha: string | null;
cliente: string | null; cliente: string | null;
usuario: string | null; // <--- NOVO CAMPO usuario: string | null;
vencConta: string | null; vencConta: string | null;
status?: string | null; status?: string | null;
skil?: string | null; skil?: string | null;
}; }
// Interface completa para Edição/Detalhes
interface ApiLineDetail {
id: string;
item: number;
conta?: string | null;
linha?: string | null;
chip?: string | null;
cliente?: string | null;
usuario?: string | null;
planoContrato?: string | null;
status?: string | null;
skil?: string | null;
modalidade?: string | null;
dataBloqueio?: string | null;
cedente?: string | null;
solicitante?: string | null;
dataEntregaOpera?: string | null;
dataEntregaCliente?: string | null;
vencConta?: string | null;
franquiaVivo?: number | null;
valorPlanoVivo?: number | null;
gestaoVozDados?: number | null;
skeelo?: number | null;
vivoNewsPlus?: number | null;
vivoTravelMundo?: number | null;
vivoGestaoDispositivo?: number | null;
valorContratoVivo?: number | null;
franquiaLine?: number | null;
franquiaGestao?: number | null;
locacaoAp?: number | null;
valorContratoLine?: number | null;
desconto?: number | null;
lucro?: number | null;
}
type ApiLineDetail = { /* ... campos detalhe (mantenha os mesmos) ... */ id: string; item: number; conta?: string | null; linha?: string | null; chip?: string | null; cliente?: string | null; usuario?: string | null; planoContrato?: string | null; status?: string | null; skil?: string | null; modalidade?: string | null; dataBloqueio?: string | null; cedente?: string | null; solicitante?: string | null; dataEntregaOpera?: string | null; dataEntregaCliente?: string | null; vencConta?: string | null; franquiaVivo?: number | null; valorPlanoVivo?: number | null; gestaoVozDados?: number | null; skeelo?: number | null; vivoNewsPlus?: number | null; vivoTravelMundo?: number | null; vivoGestaoDispositivo?: number | null; valorContratoVivo?: number | null; franquiaLine?: number | null; franquiaGestao?: number | null; locacaoAp?: number | null; valorContratoLine?: number | null; desconto?: number | null; lucro?: number | null; };
type UpdateMobileLineRequest = Omit<ApiLineDetail, 'id'>; type UpdateMobileLineRequest = Omit<ApiLineDetail, 'id'>;
type ClientGroupDto = { cliente: string; totalLinhas: number; ativos: number; bloqueados: number; };
interface ClientGroupDto {
cliente: string;
totalLinhas: number;
ativos: number;
bloqueados: number;
}
@Component({ @Component({
standalone: true, standalone: true,
@ -41,57 +86,86 @@ type ClientGroupDto = { cliente: string; totalLinhas: number; ativos: number; bl
styleUrls: ['./geral.scss'] styleUrls: ['./geral.scss']
}) })
export class Geral implements AfterViewInit { export class Geral implements AfterViewInit {
// Toast & Upload
toastMessage = ''; toastMessage = '';
@ViewChild('successToast', { static: false }) successToast!: ElementRef; @ViewChild('successToast', { static: false }) successToast!: ElementRef;
@ViewChild('excelInput') excelInput!: ElementRef<HTMLInputElement>; @ViewChild('excelInput') excelInput!: ElementRef<HTMLInputElement>;
constructor(@Inject(PLATFORM_ID) private platformId: object, private http: HttpClient, private cdr: ChangeDetectorRef) {} constructor(
@Inject(PLATFORM_ID) private platformId: object,
private http: HttpClient,
private cdr: ChangeDetectorRef
) {}
private readonly apiBase = 'https://localhost:7205/api/lines'; private readonly apiBase = 'https://localhost:7205/api/lines';
loading = false; loading = false;
// Dados
rows: LineRow[] = []; rows: LineRow[] = [];
clientGroups: ClientGroupDto[] = []; clientGroups: ClientGroupDto[] = []; // Cards de Clientes
groupLines: LineRow[] = []; groupLines: LineRow[] = []; // Linhas internas do Card (Accordion)
// Controle de Estado
expandedGroup: string | null = null; expandedGroup: string | null = null;
loadingLines = false; loadingLines = false;
// Filtros
searchTerm = ''; searchTerm = '';
filterSkil: 'ALL' | 'PF' | 'PJ' = 'ALL'; filterSkil: 'ALL' | 'PF' | 'PJ' | 'RESERVA' = 'ALL';
// Dropdown de Clientes
clientsList: string[] = []; clientsList: string[] = [];
selectedClient: string | null = null; selectedClient: string | null = null;
showClientMenu = false; showClientMenu = false;
clientSearchTerm = ''; clientSearchTerm = '';
// Modo de Visualização: 'GROUPS' (Cards) ou 'TABLE' (Linhas)
viewMode: 'GROUPS' | 'TABLE' = 'GROUPS';
// Paginação e Ordenação
sortKey: keyof LineRow = 'item'; sortKey: keyof LineRow = 'item';
sortDir: SortDir = 'asc'; sortDir: SortDir = 'asc';
page = 1; page = 1;
pageSize = 10; pageSize = 10;
total = 0; total = 0;
detailOpen = false; financeOpen = false; editOpen = false; editSaving = false; // Modais
detailData: any = null; financeData: any = null; editModel: any = null; detailOpen = false;
financeOpen = false;
editOpen = false;
editSaving = false;
detailData: any = null;
financeData: any = null;
editModel: any = null;
private editingId: string | null = null; private editingId: string | null = null;
private searchTimer: any = null; private searchTimer: any = null;
// Getter auxiliar para o HTML saber se exibe os grupos
get isGroupMode(): boolean { get isGroupMode(): boolean {
return this.filterSkil === 'ALL' && !this.selectedClient && !this.searchTerm; return this.viewMode === 'GROUPS';
} }
async ngAfterViewInit() { async ngAfterViewInit() {
if (!isPlatformBrowser(this.platformId)) return; if (!isPlatformBrowser(this.platformId)) return;
this.initAnimations(); this.initAnimations();
setTimeout(() => {
this.refreshData(); this.refreshData();
this.loadClients(); this.loadClients();
// Verifica se houve redirecionamento com mensagem de toast
const state = history.state; const state = history.state;
if (state && state.toastMessage) { if (state && state.toastMessage) {
const msg = String(state.toastMessage); const msg = String(state.toastMessage);
const newState = { ...state }; delete newState.toastMessage; const newState = { ...state };
delete newState.toastMessage;
history.replaceState(newState, '', location.href); history.replaceState(newState, '', location.href);
setTimeout(() => this.showToast(msg), 500); this.showToast(msg);
} }
});
} }
private initAnimations() { private initAnimations() {
@ -102,19 +176,86 @@ export class Geral implements AfterViewInit {
}, 100); }, 100);
} }
// ==========================================================
// LÓGICA PRINCIPAL DE DADOS
// ==========================================================
refreshData() { refreshData() {
if (this.isGroupMode) { // Se um cliente específico foi selecionado no dropdown, força modo TABELA
if (this.selectedClient) {
this.viewMode = 'TABLE';
this.loadFromApi();
return;
}
// Se não, respeita o modo definido pela busca ou padrão
if (this.viewMode === 'GROUPS') {
this.loadGroups(); this.loadGroups();
} else { } else {
this.loadFromApi(); this.loadFromApi();
} }
} }
/**
* Lógica de Pesquisa Inteligente:
* - Se contém números -> Busca Linha/Chip -> Modo TABELA
* - Se é texto -> Busca Nome Cliente -> Modo GRUPOS (Cards)
*/
onSearch() {
if (this.searchTimer) clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(() => {
this.page = 1; // Reseta paginação ao pesquisar
const s = this.searchTerm.trim();
if (!s) {
// Busca vazia -> Volta para o padrão (Grupos)
this.viewMode = 'GROUPS';
this.loadGroups();
return;
}
// Verifica se tem números (busca específica)
if (/\d/.test(s)) {
this.viewMode = 'TABLE';
this.loadFromApi();
} else {
// Texto -> Busca por cliente nos Grupos
this.viewMode = 'GROUPS';
this.loadGroups();
}
}, 300); // Debounce de 300ms
}
// Carrega os Cards (Grupos)
private loadGroups() { private loadGroups() {
this.loading = true; this.loading = true;
this.http.get<ClientGroupDto[]>(`${this.apiBase}/groups`).subscribe({
next: (data) => { let params = new HttpParams()
this.clientGroups = data || []; .set('page', String(this.page))
.set('pageSize', String(this.pageSize));
// Filtros de Aba
if (this.filterSkil === 'PF') params = params.set('skil', 'PESSOA FÍSICA');
else if (this.filterSkil === 'PJ') params = params.set('skil', 'PESSOA JURÍDICA');
else if (this.filterSkil === 'RESERVA') params = params.set('skil', 'RESERVA');
// Filtro de Busca Textual (Nome do Cliente)
if (this.searchTerm) params = params.set('search', this.searchTerm);
this.http.get<ApiPagedResult<ClientGroupDto>>(`${this.apiBase}/groups`, { params }).subscribe({
next: (res) => {
// Fallback: Se buscou texto, mas não retornou nenhum grupo de cliente,
// pode ser que o usuário esteja buscando o nome de um "Usuário da Linha".
// Nesse caso, tentamos buscar na tabela.
if (this.searchTerm && res.total === 0 && !/\d/.test(this.searchTerm)) {
this.viewMode = 'TABLE';
this.loadFromApi();
return;
}
this.clientGroups = res.items || [];
this.total = res.total; // Total de Grupos para paginação
this.loading = false; this.loading = false;
}, },
error: () => { error: () => {
@ -124,31 +265,37 @@ export class Geral implements AfterViewInit {
}); });
} }
// Expandir o Card do Cliente (Accordion)
toggleGroup(clientName: string) { toggleGroup(clientName: string) {
if (this.expandedGroup === clientName) { if (this.expandedGroup === clientName) {
this.expandedGroup = null; this.expandedGroup = null; // Fecha se já estiver aberto
return; return;
} }
this.expandedGroup = clientName; this.expandedGroup = clientName;
this.groupLines = []; this.groupLines = [];
this.loadingLines = true; this.loadingLines = true;
const params = new HttpParams() // Busca as linhas desse cliente específico
let params = new HttpParams()
.set('client', clientName) .set('client', clientName)
.set('page', '1') .set('page', '1')
.set('pageSize', '500') .set('pageSize', '500') // Carrega até 500 linhas na expansão
.set('sortBy', 'item') .set('sortBy', 'item')
.set('sortDir', 'asc'); .set('sortDir', 'asc');
// ✅ IMPORTANTE: Passa o filtro Skil ativo (Ex: Reserva)
if (this.filterSkil === 'PF') params = params.set('skil', 'PESSOA FÍSICA');
else if (this.filterSkil === 'PJ') params = params.set('skil', 'PESSOA JURÍDICA');
else if (this.filterSkil === 'RESERVA') params = params.set('skil', 'RESERVA');
this.http.get<ApiPagedResult<ApiLineList>>(this.apiBase, { params }).subscribe({ this.http.get<ApiPagedResult<ApiLineList>>(this.apiBase, { params }).subscribe({
next: (res) => { next: (res) => {
// ✅ CORREÇÃO: Mapeando 'usuario' corretamente aqui
this.groupLines = (res.items ?? []).map(x => ({ this.groupLines = (res.items ?? []).map(x => ({
id: x.id, id: x.id,
item: String(x.item ?? ''), item: String(x.item ?? ''),
linha: x.linha ?? '', linha: x.linha ?? '',
cliente: x.cliente ?? '', cliente: x.cliente ?? '',
usuario: x.usuario ?? '', // <--- Mapeado usuario: x.usuario ?? '',
status: x.status ?? '', status: x.status ?? '',
skil: x.skil ?? '', skil: x.skil ?? '',
contrato: x.vencConta ?? '' contrato: x.vencConta ?? ''
@ -162,6 +309,7 @@ export class Geral implements AfterViewInit {
}); });
} }
// Carrega a Tabela Plana (Modo Tabela)
private loadFromApi() { private loadFromApi() {
this.loading = true; this.loading = true;
let params = new HttpParams() let params = new HttpParams()
@ -173,19 +321,19 @@ export class Geral implements AfterViewInit {
if (this.filterSkil === 'PF') params = params.set('skil', 'PESSOA FÍSICA'); if (this.filterSkil === 'PF') params = params.set('skil', 'PESSOA FÍSICA');
else if (this.filterSkil === 'PJ') params = params.set('skil', 'PESSOA JURÍDICA'); else if (this.filterSkil === 'PJ') params = params.set('skil', 'PESSOA JURÍDICA');
else if (this.filterSkil === 'RESERVA') params = params.set('skil', 'RESERVA');
if (this.selectedClient) params = params.set('client', this.selectedClient); if (this.selectedClient) params = params.set('client', this.selectedClient);
this.http.get<ApiPagedResult<ApiLineList>>(this.apiBase, { params }).subscribe({ this.http.get<ApiPagedResult<ApiLineList>>(this.apiBase, { params }).subscribe({
next: (res) => { next: (res) => {
this.total = res.total ?? 0; this.total = res.total ?? 0; // Total de Linhas para paginação
// ✅ CORREÇÃO: Mapeando 'usuario' corretamente aqui também
this.rows = (res.items ?? []).map(x => ({ this.rows = (res.items ?? []).map(x => ({
id: x.id, id: x.id,
item: String(x.item ?? ''), item: String(x.item ?? ''),
linha: x.linha ?? '', linha: x.linha ?? '',
cliente: x.cliente ?? '', cliente: x.cliente ?? '',
usuario: x.usuario ?? '', // <--- Mapeado usuario: x.usuario ?? '',
status: x.status ?? '', status: x.status ?? '',
skil: x.skil ?? '', skil: x.skil ?? '',
contrato: x.vencConta ?? '' contrato: x.vencConta ?? ''
@ -199,20 +347,17 @@ export class Geral implements AfterViewInit {
}); });
} }
setFilter(type: 'ALL' | 'PF' | 'PJ') { // Troca de Abas (Todos, PF, PJ, Reserva)
setFilter(type: 'ALL' | 'PF' | 'PJ' | 'RESERVA') {
if (this.filterSkil === type) return; if (this.filterSkil === type) return;
this.filterSkil = type; this.filterSkil = type;
this.page = 1; this.page = 1;
this.refreshData(); this.refreshData();
} }
onSearch() { // ==========================================================
if (this.searchTimer) clearTimeout(this.searchTimer); // UX & FILTROS DE CLIENTE
this.searchTimer = setTimeout(() => { // ==========================================================
this.page = 1;
this.refreshData();
}, 300);
}
clearSearch() { clearSearch() {
this.searchTerm = ''; this.searchTerm = '';
@ -220,47 +365,182 @@ export class Geral implements AfterViewInit {
this.refreshData(); this.refreshData();
} }
private loadClients() { this.http.get<string[]>(`${this.apiBase}/clients`).subscribe({ next: (data) => this.clientsList = data || [] }); } private loadClients() {
toggleClientMenu() { this.showClientMenu = !this.showClientMenu; this.clientSearchTerm = ''; } this.http.get<string[]>(`${this.apiBase}/clients`).subscribe({
closeClientDropdown() { this.showClientMenu = false; } next: (data) => this.clientsList = data || []
});
}
toggleClientMenu() {
this.showClientMenu = !this.showClientMenu;
this.clientSearchTerm = '';
}
closeClientDropdown() {
this.showClientMenu = false;
}
selectClient(client: string | null) { selectClient(client: string | null) {
this.selectedClient = client; this.selectedClient = client;
this.showClientMenu = false; this.showClientMenu = false;
this.page = 1; this.page = 1;
this.refreshData(); this.refreshData();
} }
get filteredClientsList(): string[] { get filteredClientsList(): string[] {
if (!this.clientSearchTerm) return this.clientsList; if (!this.clientSearchTerm) return this.clientsList;
const s = this.clientSearchTerm.toLowerCase(); const s = this.clientSearchTerm.toLowerCase();
return this.clientsList.filter(c => c.toLowerCase().includes(s)); return this.clientsList.filter(c => c.toLowerCase().includes(s));
} }
// ==========================================================
// PAGINAÇÃO E ORDENAÇÃO
// ==========================================================
setSort(key: keyof LineRow) { setSort(key: keyof LineRow) {
if (this.sortKey === key) this.sortDir = this.sortDir === 'asc' ? 'desc' : 'asc'; if (this.sortKey === key) {
else { this.sortKey = key; this.sortDir = 'asc'; } this.sortDir = this.sortDir === 'asc' ? 'desc' : 'asc';
this.page = 1; this.loadFromApi(); } else {
this.sortKey = key;
this.sortDir = 'asc';
} }
onPageSizeChange() { this.page = 1; this.loadFromApi(); } this.page = 1;
goToPage(p: number) { this.page = Math.max(1, Math.min(this.totalPages, p)); this.loadFromApi(); } this.loadFromApi(); // Ordenação só faz sentido visualmente na tabela
}
onPageSizeChange() {
this.page = 1;
this.refreshData();
}
goToPage(p: number) {
this.page = Math.max(1, Math.min(this.totalPages, p));
this.refreshData();
}
trackById(_: number, row: LineRow) { return row.id; } trackById(_: number, row: LineRow) { return row.id; }
get pagedRows() { return this.rows; }
get pagedRows() { return this.rows; } // Dados já vêm paginados do back
get totalPages() { return Math.ceil((this.total || 0) / this.pageSize) || 1; } get totalPages() { return Math.ceil((this.total || 0) / this.pageSize) || 1; }
get filteredCount() { return this.total || 0; } get filteredCount() { return this.total || 0; }
get pageStart() { return this.filteredCount === 0 ? 0 : (this.page - 1) * this.pageSize + 1; }
get pageEnd() { return this.filteredCount === 0 ? 0 : Math.min((this.page - 1) * this.pageSize + this.rows.length, this.filteredCount); }
get pageNumbers() { const total = this.totalPages; const current = this.page; const max = 5; let start = Math.max(1, current - 2); let end = Math.min(total, start + (max - 1)); start = Math.max(1, end - (max - 1)); const pages = []; for (let i = start; i <= end; i++) pages.push(i); return pages; }
private getById(id: string, cb: (d: any) => void) { this.http.get(`${this.apiBase}/${id}`).subscribe({ next: cb }); } get pageStart() { return this.filteredCount === 0 ? 0 : (this.page - 1) * this.pageSize + 1; }
onDetalhes(r: LineRow) { this.detailOpen = true; this.detailData = null; this.getById(r.id, d => this.detailData = d); }
onFinanceiro(r: LineRow) { this.financeOpen = true; this.financeData = null; this.getById(r.id, d => this.financeData = d); } get pageEnd() {
return this.filteredCount === 0 ? 0 : Math.min((this.page - 1) * this.pageSize + (this.isGroupMode ? this.clientGroups.length : this.rows.length), this.filteredCount);
}
get pageNumbers() {
const total = this.totalPages;
const current = this.page;
const max = 5;
let start = Math.max(1, current - 2);
let end = Math.min(total, start + (max - 1));
start = Math.max(1, end - (max - 1));
const pages = [];
for (let i = start; i <= end; i++) pages.push(i);
return pages;
}
// ==========================================================
// IMPORTAÇÃO / AÇÕES
// ==========================================================
async onImportExcel() {
if (!this.excelInput?.nativeElement) return;
this.excelInput.nativeElement.value = '';
this.excelInput.nativeElement.click();
}
onExcelSelected(ev: Event) {
const file = (ev.target as HTMLInputElement).files?.[0];
if (!file) return;
const form = new FormData();
form.append('file', file);
this.loading = true;
this.http.post<{ imported: number }>(`${this.apiBase}/import-excel`, form).subscribe({
next: async (r) => {
await this.showToast(`Sucesso! ${r?.imported ?? 0} registros importados.`);
this.page = 1;
this.refreshData();
},
error: async () => {
this.loading = false;
await this.showToast('Falha ao importar planilha.');
}
});
}
async onCadastrarLinha() {
await this.showToast('Em breve.');
}
// ==========================================================
// MODAIS E HELPERS
// ==========================================================
private async showToast(message: string) {
if (!isPlatformBrowser(this.platformId)) return;
this.toastMessage = message;
this.cdr.detectChanges();
if (!this.successToast?.nativeElement) return;
try {
const bs = await import('bootstrap');
const toastInstance = bs.Toast.getOrCreateInstance(this.successToast.nativeElement, { autohide: true, delay: 3000 });
toastInstance.show();
} catch (error) {
console.error(error);
}
}
private getById(id: string, cb: (d: any) => void) {
this.http.get(`${this.apiBase}/${id}`).subscribe({
next: cb,
error: () => this.showToast('Erro ao carregar detalhes.')
});
}
onDetalhes(r: LineRow) {
this.detailOpen = true;
this.detailData = null;
this.getById(r.id, d => this.detailData = d);
}
onFinanceiro(r: LineRow) {
this.financeOpen = true;
this.financeData = null;
this.getById(r.id, d => this.financeData = d);
}
closeDetail() { this.detailOpen = false; this.detailData = null; } closeDetail() { this.detailOpen = false; this.detailData = null; }
closeFinance() { this.financeOpen = false; this.financeData = null; } closeFinance() { this.financeOpen = false; this.financeData = null; }
// Edição
async onEditar(r: LineRow) { async onEditar(r: LineRow) {
this.editOpen = true; this.editSaving = false; this.editModel = null; this.editingId = r.id; this.editOpen = true;
this.http.get<ApiLineDetail>(`${this.apiBase}/${r.id}`).subscribe({ next: (d) => this.editModel = this.toEditModel(d) }); this.editSaving = false;
this.editModel = null;
this.editingId = r.id;
this.http.get<ApiLineDetail>(`${this.apiBase}/${r.id}`).subscribe({
next: (d) => { this.editModel = this.toEditModel(d); },
error: async () => {
this.editOpen = false;
await this.showToast('Erro ao carregar dados para edição.');
}
});
}
closeEdit() {
this.editOpen = false;
this.editSaving = false;
this.editModel = null;
this.editingId = null;
} }
closeEdit() { this.editOpen = false; this.editSaving = false; this.editModel = null; this.editingId = null; }
async saveEdit() { async saveEdit() {
if (!this.editingId || !this.editModel) return; if (!this.editingId || !this.editModel) return;
@ -296,12 +576,25 @@ export class Geral implements AfterViewInit {
locacaoAp: this.toNullableNumber(this.editModel.locacaoAp), locacaoAp: this.toNullableNumber(this.editModel.locacaoAp),
valorContratoLine: this.toNullableNumber(this.editModel.valorContratoLine), valorContratoLine: this.toNullableNumber(this.editModel.valorContratoLine),
desconto: this.toNullableNumber(this.editModel.desconto), desconto: this.toNullableNumber(this.editModel.desconto),
lucro: this.toNullableNumber(this.editModel.lucro), lucro: this.toNullableNumber(this.editModel.lucro)
}; };
this.http.put(`${this.apiBase}/${this.editingId}`, payload).subscribe({ this.http.put(`${this.apiBase}/${this.editingId}`, payload).subscribe({
next: async () => { this.editSaving = false; this.closeEdit(); await this.showToast('Registro atualizado!'); if(this.isGroupMode && this.expandedGroup) { this.toggleGroup(this.expandedGroup); } else { this.refreshData(); } }, next: async () => {
error: async () => { this.editSaving = false; await this.showToast('Erro ao salvar.'); } this.editSaving = false;
this.closeEdit();
await this.showToast('Registro atualizado!');
// Se estiver em grupo e ele estiver aberto, recarrega o grupo
if(this.isGroupMode && this.expandedGroup) {
this.toggleGroup(this.expandedGroup);
} else {
this.refreshData();
}
},
error: async (err: HttpErrorResponse) => {
this.editSaving = false;
await this.showToast('Erro ao salvar.');
}
}); });
} }
@ -309,27 +602,34 @@ export class Geral implements AfterViewInit {
if (!confirm(`Remover linha ${r.linha}?`)) return; if (!confirm(`Remover linha ${r.linha}?`)) return;
this.loading = true; this.loading = true;
this.http.delete(`${this.apiBase}/${r.id}`).subscribe({ this.http.delete(`${this.apiBase}/${r.id}`).subscribe({
next: async () => { await this.showToast('Removido com sucesso.'); if(fromGroup && this.expandedGroup) { this.toggleGroup(this.expandedGroup); } else { this.refreshData(); } }, next: async () => {
error: async () => { this.loading = false; await this.showToast('Erro ao remover.'); } await this.showToast('Removido com sucesso.');
if(fromGroup && this.expandedGroup) {
this.toggleGroup(this.expandedGroup);
} else {
this.refreshData();
}
},
error: async () => {
this.loading = false;
await this.showToast('Erro ao remover.');
}
}); });
} }
async onCadastrarLinha() { await this.showToast('Em breve.'); } // Formatters
private async showToast(message: string) { if (!isPlatformBrowser(this.platformId)) return; this.toastMessage = message; this.cdr.detectChanges(); if (!this.successToast?.nativeElement) return; try { const bs = await import('bootstrap'); const toastInstance = bs.Toast.getOrCreateInstance(this.successToast.nativeElement, { autohide: true, delay: 3000 }); toastInstance.show(); } catch (error) { console.error(error); } }
formatMoney(v: any): string { if (v == null || Number.isNaN(v)) return '-'; return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(v); } formatMoney(v: any): string { if (v == null || Number.isNaN(v)) return '-'; return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(v); }
formatNumber(v: any): string { if (v == null || Number.isNaN(v)) return '-'; return new Intl.NumberFormat('pt-BR').format(v); } formatNumber(v: any): string { if (v == null || Number.isNaN(v)) return '-'; return new Intl.NumberFormat('pt-BR').format(v); }
formatFranquia(v: any): string { if (v == null || Number.isNaN(v)) return '-'; return `${new Intl.NumberFormat('pt-BR').format(v)} GB`; } formatFranquia(v: any): string { if (v == null || Number.isNaN(v)) return '-'; return `${new Intl.NumberFormat('pt-BR').format(v)} GB`; }
formatDateBr(iso: any): string { if (!iso) return '-'; const d = new Date(iso); return Number.isNaN(d.getTime()) ? '-' : new Intl.DateTimeFormat('pt-BR').format(d); } formatDateBr(iso: any): string { if (!iso) return '-'; const d = new Date(iso); return Number.isNaN(d.getTime()) ? '-' : new Intl.DateTimeFormat('pt-BR').format(d); }
statusClass(s: any): string { const n = (s??'').toLowerCase(); if(n.includes('bloq')||n.includes('perda')) return 'is-blocked'; if(n.includes('ativo')) return 'is-active'; return ''; } statusClass(s: any): string { const n = (s??'').toLowerCase(); if(n.includes('bloq')||n.includes('perda')) return 'is-blocked'; if(n.includes('ativo')) return 'is-active'; return ''; }
statusLabel(s: any): string { return s || '-'; } statusLabel(s: any): string { return s || '-'; }
// Mappers
private mapSortKeyToApi(sortKey: keyof LineRow): string { const map: Record<string, string> = { item: 'item', linha: 'linha', cliente: 'cliente', status: 'status', skil: 'skil', contrato: 'vencConta' }; return map[String(sortKey)] ?? 'item'; } private mapSortKeyToApi(sortKey: keyof LineRow): string { const map: Record<string, string> = { item: 'item', linha: 'linha', cliente: 'cliente', status: 'status', skil: 'skil', contrato: 'vencConta' }; return map[String(sortKey)] ?? 'item'; }
private isoToDateInput(iso: string | null | undefined): string { if (!iso) return ''; const dt = new Date(iso); return Number.isNaN(dt.getTime()) ? '' : dt.toISOString().slice(0, 10); } private isoToDateInput(iso: string | null | undefined): string { if (!iso) return ''; const dt = new Date(iso); return Number.isNaN(dt.getTime()) ? '' : dt.toISOString().slice(0, 10); }
private dateInputToIso(dateStr: string | null | undefined): string | null { const s = (dateStr ?? '').trim(); return s ? new Date(`${s}T00:00:00.000Z`).toISOString() : null; } private dateInputToIso(dateStr: string | null | undefined): string | null { const s = (dateStr ?? '').trim(); return s ? new Date(`${s}T00:00:00.000Z`).toISOString() : null; }
private toNullableNumber(v: any): number | null { if (v === null || v === undefined || v === '') return null; const n = Number(String(v).trim().replace(',', '.')); return Number.isFinite(n) ? n : null; } private toNullableNumber(v: any): number | null { if (v === null || v === undefined || v === '') return null; const n = Number(String(v).trim().replace(',', '.')); return Number.isFinite(n) ? n : null; }
private toInt(v: any): number { const n = parseInt(String(v ?? '0'), 10); return Number.isFinite(n) ? n : 0; } private toInt(v: any): number { const n = parseInt(String(v ?? '0'), 10); return Number.isFinite(n) ? n : 0; }
private toEditModel(d: ApiLineDetail) { return { ...d, dataBloqueio: this.isoToDateInput(d.dataBloqueio), dataEntregaOpera: this.isoToDateInput(d.dataEntregaOpera), dataEntregaCliente: this.isoToDateInput(d.dataEntregaCliente) }; } private toEditModel(d: ApiLineDetail) { return { ...d, dataBloqueio: this.isoToDateInput(d.dataBloqueio), dataEntregaOpera: this.isoToDateInput(d.dataEntregaOpera), dataEntregaCliente: this.isoToDateInput(d.dataEntregaCliente) }; }
async onImportExcel() { if (!this.excelInput?.nativeElement) return; this.excelInput.nativeElement.value = ''; this.excelInput.nativeElement.click(); }
onExcelSelected(ev: Event) { const file = (ev.target as HTMLInputElement).files?.[0]; if (!file) return; const form = new FormData(); form.append('file', file); this.loading = true; this.http.post<{ imported: number }>(`${this.apiBase}/import-excel`, form).subscribe({ next: async (r) => { await this.showToast(`Sucesso! ${r?.imported ?? 0} registros importados.`); this.page = 1; this.loadFromApi(); }, error: async () => { this.loading = false; await this.showToast('Falha ao importar planilha.'); } }); }
} }