84 lines
4.9 KiB
PHP
84 lines
4.9 KiB
PHP
<x-app-layout :active="'pumps.index'" title="SoftSPM 2 - Nowa pompa">
|
|
@php $factors = [0, 0.25, 0.55, 0.7, 1.0, 1.22, 1.35, 1.42]; @endphp
|
|
|
|
<div class="max-w-3xl space-y-stack-gap">
|
|
|
|
<div class="flex items-center gap-2">
|
|
<a href="{{ route('pumps.index') }}" class="font-body-sm text-body-sm text-on-surface-variant hover:text-primary">← Wróć</a>
|
|
<h1 class="font-headline-lg text-headline-lg text-on-surface">Nowa pompa</h1>
|
|
</div>
|
|
|
|
@if ($errors->any())
|
|
<div class="status-chip-alert px-3 py-2 rounded-lg font-body-sm text-body-sm">{{ $errors->first() }}</div>
|
|
@endif
|
|
|
|
<form method="POST" action="{{ route('pumps.store') }}"
|
|
class="bg-surface-container-lowest border border-outline-variant/40 rounded-lg shadow-card p-card-inner-padding space-y-6">
|
|
@csrf
|
|
|
|
{{-- Dane podstawowe --}}
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<x-well-field name="name" label="Typ pompy" :value="old('name')" required class="sm:col-span-2" />
|
|
<x-well-select name="manufacturer_id" label="Producent" :options="$manufacturers" :selected="old('manufacturer_id')" required placeholder="- wybierz -" class="sm:col-span-2" />
|
|
<x-well-field name="q_n" label="Qₙ [m³/h]" :value="old('q_n')" required />
|
|
<x-well-field name="length" label="Długość [mm]" :value="old('length')" />
|
|
<x-well-field name="diameter" label="Średnica [mm]" :value="old('diameter')" />
|
|
<x-well-field name="weight" label="Masa [kg]" :value="old('weight')" />
|
|
</div>
|
|
|
|
{{-- 8 punktów krzywych - Q liczone z Qₙ, użytkownik podaje H i η --}}
|
|
<div>
|
|
<h2 class="font-title-sm text-title-sm text-tertiary mb-1">Parametry energetyczne (8 punktów)</h2>
|
|
<p class="font-body-sm text-body-sm text-on-surface-variant mb-2">
|
|
Wartości Q wyliczane automatycznie z Qₙ. Podaj H i η dla każdego punktu.
|
|
</p>
|
|
<table class="w-full text-left border border-outline-variant/40 rounded-lg overflow-hidden">
|
|
<thead class="bg-secondary/10">
|
|
<tr class="font-data-label text-data-label text-on-surface-variant tracking-wide">
|
|
<th class="px-3 py-2 w-10">Lp.</th>
|
|
<th class="px-3 py-2 text-right">Q [m³/h]</th>
|
|
<th class="px-3 py-2">H [m]</th>
|
|
<th class="px-3 py-2">η [-]</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-outline-variant/30">
|
|
@foreach ($factors as $i => $f)
|
|
<tr>
|
|
<td class="px-3 py-1.5 font-data-label text-on-surface-variant">{{ $i + 1 }}.</td>
|
|
<td class="px-3 py-1.5 text-right font-data-label" data-qcell>0,000</td>
|
|
<td class="px-3 py-1.5">
|
|
<input type="text" name="h[{{ $i }}]" value="{{ old('h.'.$i) }}" required
|
|
class="w-28 bg-surface-container-low border border-outline-variant px-2 py-1 rounded font-data-label text-on-surface">
|
|
</td>
|
|
<td class="px-3 py-1.5">
|
|
<input type="text" name="eta[{{ $i }}]" value="{{ old('eta.'.$i) }}" required
|
|
class="w-28 bg-surface-container-low border border-outline-variant px-2 py-1 rounded font-data-label text-on-surface">
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-2">
|
|
<button type="submit" class="bg-primary text-on-primary px-6 py-2.5 rounded-full font-title-sm text-title-sm hover:bg-primary-container transition-all active:scale-95 shadow-card">Zapisz</button>
|
|
<a href="{{ route('pumps.index') }}" class="px-5 py-2.5 rounded-full font-title-sm text-title-sm text-on-surface-variant hover:bg-surface-container transition-all">Anuluj</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
(function () {
|
|
const factors = @json($factors);
|
|
const qn = document.getElementById('q_n');
|
|
const cells = document.querySelectorAll('[data-qcell]');
|
|
function recalc() {
|
|
const v = parseFloat((qn.value || '').replace(',', '.')) || 0;
|
|
cells.forEach((el, i) => { el.textContent = (factors[i] * v).toFixed(3).replace('.', ','); });
|
|
}
|
|
qn.addEventListener('input', recalc);
|
|
recalc();
|
|
})();
|
|
</script>
|
|
</x-app-layout>
|