селектор помещений из апи

This commit is contained in:
developer 2026-04-02 11:49:13 +08:00
parent 97a48aa657
commit b2a11b212b
2 changed files with 156 additions and 118 deletions

View File

@ -14,7 +14,7 @@ class Plan7SelectorLivewire extends Component
public $types; public $types;
public $access; public $access;
public $summary; public $summary;
public $room; public $room = false;
public $objects = []; public $objects = [];
private $apiSummary = 'https://plan7.ru/catalog/exp/json/summary/?token=0754c5e6a3824322&zk=614'; private $apiSummary = 'https://plan7.ru/catalog/exp/json/summary/?token=0754c5e6a3824322&zk=614';
private $apiAll = 'https://plan7.ru/catalog/exp/json/?token=0754c5e6a3824322&zk=614'; private $apiAll = 'https://plan7.ru/catalog/exp/json/?token=0754c5e6a3824322&zk=614';
@ -63,7 +63,10 @@ public function setHouse($id)
public function setRoom($id) public function setRoom($id)
{ {
$this->room = $this->allObjects['data'][$id]; $this->room = $this->allObjects['data'][$id];
$this->filter['id'] = $id; //$this->filter['id'] = $id;
}
public function unsetRoom() {
$this->room = false;
} }
public function resetFilter() { public function resetFilter() {
$this->filter = []; $this->filter = [];
@ -71,6 +74,7 @@ public function resetFilter() {
public function start() { public function start() {
$this->mode = 'select'; $this->mode = 'select';
$this->filter = []; $this->filter = [];
//$this->room = false;
$this->getData(); $this->getData();
} }
public function done() { public function done() {
@ -83,19 +87,19 @@ public function render()
if (count($this->filter)) { if (count($this->filter)) {
foreach ($this->allObjects['data'] as $key => $room) { foreach ($this->allObjects['data'] as $key => $room) {
if ($room['access'] != 0) { if ($room['access'] != 0) {
if (array_key_exists('id', $this->filter) && $this->filter['id'] !== null && $room['id'] != $this->filter['id']) { if (array_key_exists('id', $this->filter) && $this->filter['id'] != null && $room['id'] != $this->filter['id']) {
continue; continue;
} }
if (array_key_exists('bs', $this->filter) && $this->filter['bs'] !== null && $room['bs'] != $this->filter['bs']) { if (array_key_exists('bs', $this->filter) && $this->filter['bs'] != null && $room['bs'] != $this->filter['bs']) {
continue; continue;
} }
if (array_key_exists('type', $this->filter) && $this->filter['type'] !== null && $room['type'] != $this->filter['type']) { if (array_key_exists('type', $this->filter) && $this->filter['type'] != null && $room['type'] != $this->filter['type']) {
continue; continue;
} }
if (array_key_exists('min_area', $this->filter) && $this->filter['min_area'] !== null && $room['area'] < $this->filter['min_area']) { if (array_key_exists('min_area', $this->filter) && $this->filter['min_area'] != null && $room['area'] < $this->filter['min_area']) {
continue; continue;
} }
if (array_key_exists('max_area', $this->filter) && $this->filter['max_area'] !== null && $room['area'] > $this->filter['max_area']) { if (array_key_exists('max_area', $this->filter) && $this->filter['max_area'] != null && $room['area'] > $this->filter['max_area']) {
continue; continue;
} }
$room['mode'] = 'room'; $room['mode'] = 'room';

View File

@ -13,7 +13,8 @@
</div> </div>
</div> </div>
@endif @endif
<button type="button" wire:click="start()" class="btn btn-primary" onclick="plan7SelectorModal = new bootstrap.Modal(document.getElementById('plan7_selector_modal'), {});plan7SelectorModal.show()"> <button type="button" wire:click="start()" class="btn btn-primary"
onclick="plan7SelectorModal = new bootstrap.Modal(document.getElementById('plan7_selector_modal'), {});plan7SelectorModal.show()">
@if($room) @if($room)
Изменить Изменить
@else @else
@ -34,10 +35,40 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
@if($room)
<div class="d-flex">
<div class="col-12 col-md-7">
<img src="{{ array_key_exists($room['pla'], $allObjects['pla']) ? $allObjects['pla'][$room['pla']]['pla'] : '...' }}"
class="img-fluid rounded-start" alt="...">
</div>
<div class="col px-3">
<h3 class="fw-bold mb-3 text-uppercase">
{{ (($room['type'] == 0) ? $room['room'] . ' комн. ' . mb_strtolower($this->types[$room['type']]) : $this->types[$room['type']]) }}
</h3>
<div class="d-flex flex-wrap gap-3">
<div class="hstack gap-3 w-100">
<div class="d-flex flex-column w-50 p-2 bg-light border border-1 rounded-4">
<span class="text-secondary">Помещение</span><span class="fs-3">{{ $room['name'] }}</span>
</div>
<div class="d-flex flex-column w-50 p-2 bg-light border border-1 rounded-4">
<span class="text-secondary">Этаж</span><span class="fs-3">{{ $room['level'] }}</span>
</div>
</div>
<div class="d-flex flex-column w-100 p-2 bg-light border border-1 rounded-4">
<span class="text-secondary">Площадь</span><span class="fs-3">{{ $room['area'] }} м<sup>2</sup></span>
</div>
<div class="d-flex flex-column w-100 p-2 bg-light border border-1 rounded-4">
<span class="text-secondary">Стоимость</span><span class="fs-3">{{ ($room['summ']) ? number_format($room['summ'], 0, '', ' ') . ' р.' : '' }}</span>
</div>
</div>
</div>
</div>
@endif
@if(!$room)
<div class="d-flex gap-2"> <div class="d-flex gap-2">
<div class="col-4 p-2 rounded-4 mb-3 bg-light border d-flex gap-2"> <div class="col-4 p-2 rounded-4 mb-3 bg-light border d-flex gap-2">
<div class="flex-fill"> <div class="flex-fill">
<label>Дом/секция:</label> <label>Дом/строение:</label>
<div> <div>
<select wire:loading.attr="disabled" class="form-select" <select wire:loading.attr="disabled" class="form-select"
wire:model.change="filter.bs"> wire:model.change="filter.bs">
@ -110,6 +141,7 @@ class="form-control w-25"
@if(count($filter) && count($objs)) @if(count($filter) && count($objs))
<div>Всего помещений: {{ count($objs) }}</div> <div>Всего помещений: {{ count($objs) }}</div>
@endif @endif
<? print_r($filter) ?>
@if(!count($objs)) @if(!count($objs))
<div wire:loading.remove class="p-5 text-secondary w-100 text-center fs-3"> <div wire:loading.remove class="p-5 text-secondary w-100 text-center fs-3">
Нет помещений для отображения по выбранным параметрам Нет помещений для отображения по выбранным параметрам
@ -155,9 +187,11 @@ class="img-fluid rounded-start" alt="...">
</div> </div>
@endforeach @endforeach
</div> </div>
@endif
</div> </div>
@if(array_key_exists('id', $filter)) @if($room)
<div class="modal-footer"> <div class="modal-footer">
<button wire:click="unsetRoom()" type="button" class="btn btn-secondary">Выбрать другое</button>
<button wire:click="done()" type="button" class="btn btn-primary" data-bs-dismiss="modal">Выбрать и <button wire:click="done()" type="button" class="btn btn-primary" data-bs-dismiss="modal">Выбрать и
закрыть</button> закрыть</button>
</div> </div>