доработка компоненты вывода клиентов: вывел поиск по жк
This commit is contained in:
parent
42bc369227
commit
a2a4b4710d
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
class ClientsTable extends Component
|
class ClientsTable extends Component
|
||||||
{
|
{
|
||||||
use WithPagination, WithoutUrlPagination;
|
|
||||||
|
|
||||||
public $status;
|
public $status;
|
||||||
public $count;
|
public $count;
|
||||||
public $mode;//short || full
|
public $mode;//short || full
|
||||||
@ -76,6 +74,15 @@ public function getDeals()
|
|||||||
if (array_key_exists('status', $this->filter)) {
|
if (array_key_exists('status', $this->filter)) {
|
||||||
$deals->where('status', $this->filter['status']);
|
$deals->where('status', $this->filter['status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('complexes', $this->filter)) {
|
||||||
|
$complexes = [];
|
||||||
|
foreach ($this->filter['complexes'] as $selectedComplex) {
|
||||||
|
$complexes[] = $selectedComplex['id'];
|
||||||
|
}
|
||||||
|
$deals->whereIn('complex_id', $complexes);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$deals) {
|
if (!$deals) {
|
||||||
return Client::where('id', 0);
|
return Client::where('id', 0);
|
||||||
}
|
}
|
||||||
@ -115,11 +122,10 @@ function getClients()
|
|||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$clients = $this->getClients();
|
$clients = $this->getClients();
|
||||||
|
|
||||||
if ($this->clientsCount != $clients->count()) {
|
if ($this->clientsCount != $clients->count()) {
|
||||||
$this->clientsCount = $clients->count();
|
$this->clientsCount = $clients->count();
|
||||||
$this->currentPage = 1;
|
$this->currentPage = 1;
|
||||||
}
|
};
|
||||||
$clients = $clients->skip(($this->currentPage - 1) * $this->count)->take($this->count)->get();
|
$clients = $clients->skip(($this->currentPage - 1) * $this->count)->take($this->count)->get();
|
||||||
return view(
|
return view(
|
||||||
'livewire.clients-table',
|
'livewire.clients-table',
|
||||||
|
|||||||
@ -9,9 +9,10 @@
|
|||||||
class ClientSearchInputLivewire extends Component
|
class ClientSearchInputLivewire extends Component
|
||||||
{
|
{
|
||||||
public $filter = [];
|
public $filter = [];
|
||||||
|
public $complexes;
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$this->complexes = GetAvailableComplexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStatus($status)
|
public function setStatus($status)
|
||||||
@ -23,10 +24,37 @@ public function setStatus($status)
|
|||||||
$this->filter['status'] = $status;
|
$this->filter['status'] = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updated($propertyName)
|
public function toggleComplex($complexId)
|
||||||
|
{
|
||||||
|
if (!array_key_exists('complexes', $this->filter)) {
|
||||||
|
$this->filter['complexes'] = [];
|
||||||
|
}
|
||||||
|
$disabled = false;
|
||||||
|
foreach ($this->filter['complexes'] as $selectedKey=>$selectedComplex) {
|
||||||
|
if ($selectedComplex['id'] == $complexId) {
|
||||||
|
unset($this->filter['complexes'][$selectedKey]);
|
||||||
|
$disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$disabled) {
|
||||||
|
foreach ($this->complexes as $complex) {
|
||||||
|
if($complex['id'] == $complexId) {
|
||||||
|
$this->filter['complexes'][] = ['id' => $complexId, 'name' => $complex['name']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->filter['complexes'] = array_values($this->filter['complexes']);
|
||||||
|
if (!count($this->filter['complexes'])) {
|
||||||
|
unset($this->filter['complexes']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updated();
|
||||||
|
}
|
||||||
|
public function updated()
|
||||||
{
|
{
|
||||||
$this->dispatch('clientsTableFilterUpdated', filter: $this->filter);
|
$this->dispatch('clientsTableFilterUpdated', filter: $this->filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('main::clients.livewire.search.input', [
|
return view('main::clients.livewire.search.input', [
|
||||||
|
|||||||
@ -3,15 +3,52 @@
|
|||||||
?>
|
?>
|
||||||
<div class="d-flex gap-2 flex-column flex-lg-row">
|
<div class="d-flex gap-2 flex-column flex-lg-row">
|
||||||
<div class="d-flex flex-row col-12 col-lg-auto border rounded-3 border-1 p-1 bg-white" style="">
|
<div class="d-flex flex-row col-12 col-lg-auto border rounded-3 border-1 p-1 bg-white" style="">
|
||||||
<input wire:model.live="filter.status" type="radio" class="btn-check" name="status" value="{{ DealStatus::MODERATION }}" id="option5" autocomplete="off"
|
<input wire:model.live="filter.status" type="radio" class="btn-check" name="status"
|
||||||
{{ (array_key_exists('status', $filter) && $filter['status'] == DealStatus::MODERATION) ? 'checked' : '' }}>
|
value="{{ DealStatus::MODERATION }}" id="option5" autocomplete="off" {{ (array_key_exists('status', $filter) && $filter['status'] == DealStatus::MODERATION) ? 'checked' : '' }}>
|
||||||
<label class="btn p-2 fs-5 text-truncate" for="option5">На проверке</label>
|
<label class="btn p-2 fs-5 text-truncate" for="option5">На проверке</label>
|
||||||
<input wire:model.live="filter.status" type="radio" class="btn-check" name="status" value="{{ DealStatus::UNIQUE }}" id="option6" autocomplete="off"
|
<input wire:model.live="filter.status" type="radio" class="btn-check" name="status"
|
||||||
{{ (array_key_exists('status', $filter) && $filter['status'] == DealStatus::UNIQUE) ? 'checked' : '' }}>
|
value="{{ DealStatus::UNIQUE }}" id="option6" autocomplete="off" {{ (array_key_exists('status', $filter) && $filter['status'] == DealStatus::UNIQUE) ? 'checked' : '' }}>
|
||||||
<label class="btn p-2 fs-5 text-truncate" for="option6">Уникальные</label>
|
<label class="btn p-2 fs-5 text-truncate" for="option6">Уникальные</label>
|
||||||
<input wire:model.live="filter.status" type="radio" class="btn-check" name="status" value="{{ DealStatus::NOT_UNIQUE }}" id="option7" autocomplete="off"
|
<input wire:model.live="filter.status" type="radio" class="btn-check" name="status"
|
||||||
{{ (array_key_exists('status', $filter) && $filter['status'] == DealStatus::NOT_UNIQUE) ? 'checked' : '' }}>
|
value="{{ DealStatus::NOT_UNIQUE }}" id="option7" autocomplete="off" {{ (array_key_exists('status', $filter) && $filter['status'] == DealStatus::NOT_UNIQUE) ? 'checked' : '' }}>
|
||||||
<label class="btn p-2 fs-5 text-truncate" for="option7">Не уникальные</label>
|
<label class="btn p-2 fs-5 text-truncate" for="option7">Не уникальные</label>
|
||||||
</div>
|
</div>
|
||||||
<input wire:model.live="filter.search" class="flex-fill col-12 col-md-auto form-control form-control-lg" type="text" placeholder="Поиск по имени, телефону, электронной почте">
|
<input wire:model.live="filter.search" class="flex-fill col-12 col-md-auto form-control form-control-lg" type="text"
|
||||||
|
placeholder="Поиск по имени, телефону, электронной почте">
|
||||||
|
<!-- Выбор ЖК-->
|
||||||
|
<div class="btn-group bg-light d-flex rounded-4">
|
||||||
|
<button type="button" class="btn bg-light text-primary border overflow-hidden w-100 rounded-start-3 pe-0"
|
||||||
|
style="mask-image: linear-gradient(to right, black, black 90%, transparent);">
|
||||||
|
<div class="m-2 text-truncate">
|
||||||
|
@if(array_key_exists('complexes', $filter))
|
||||||
|
<div class="">
|
||||||
|
<span class="text-truncate">{{ $filter['complexes'][0]['name'] }}</span>
|
||||||
|
@if(count($filter['complexes']) > 1)
|
||||||
|
+ {{ count($filter['complexes']) - 1 }}
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@else
|
||||||
|
<div class="m-2">Выберите жилой комплекс</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<button type="button" style="width:30px" class="btn btn-secondary dropdown-toggle dropdown-toggle-split show"
|
||||||
|
data-bs-toggle="dropdown" aria-expanded="true" data-bs-reference="parent">
|
||||||
|
<span class="visually-hidden">Toggle Dropdown</span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
|
@foreach ($complexes as $complex)
|
||||||
|
<li>
|
||||||
|
<div class="dropdown-item">
|
||||||
|
<input wire:change="toggleComplex({{ $complex['id'] }})" class="form-check-input"
|
||||||
|
type="checkbox" id="complex_selector_{{ $complex['id'] }}">
|
||||||
|
<label class="form-check-label" for="complex_selector_{{ $complex['id'] }}">
|
||||||
|
{{ $complex['name'] }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Loading…
Reference in New Issue
Block a user