creo que pude instalar select2, create sales y crud client o casi crud
This commit is contained in:
@@ -1,223 +1,289 @@
|
||||
<x-layout>
|
||||
<div class="py-12 bg-gray-100 min-h-screen">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-6">
|
||||
<div class="mb-6 border-b pb-2">
|
||||
<h2 class="text-2xl font-bold text-gray-800">Nueva Venta en Mostrador</h2>
|
||||
</div>
|
||||
|
||||
@if (session('success'))
|
||||
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4">
|
||||
<strong class="font-bold">¡Éxito!</strong> {{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (session('error'))
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4">
|
||||
<strong class="font-bold">Error:</strong> {{ session('error') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="bg-red-50 text-red-600 p-4 mb-4 rounded border border-red-200">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>• {{ $error }}</li>
|
||||
<x-layout title="Lauck - Nueva Venta">
|
||||
@push('styles')
|
||||
<style>
|
||||
/* Select2 adaptado al Tema 'Lauck' (Neutral + Neon Lime) */
|
||||
.select2-container--default .select2-selection--single {
|
||||
background-color: #262626 !important; /* neutral-800 */
|
||||
border-color: #404040 !important; /* neutral-700 */
|
||||
color: white !important;
|
||||
height: 42px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 0.5rem; /* rounded-lg */
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
||||
color: white !important;
|
||||
line-height: 42px;
|
||||
padding-left: 12px;
|
||||
}
|
||||
.select2-dropdown {
|
||||
background-color: #262626 !important; /* neutral-800 */
|
||||
border-color: #404040 !important; /* neutral-700 */
|
||||
color: white !important;
|
||||
}
|
||||
/* Color de resalto al pasar el mouse u opción seleccionada */
|
||||
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
|
||||
background-color: #ccff00 !important; /* neon-lime */
|
||||
color: #171717 !important; /* neutral-900 */
|
||||
font-weight: bold;
|
||||
}
|
||||
/* Ajuste del placeholder */
|
||||
.select2-container--default .select2-selection--single .select2-selection__placeholder {
|
||||
color: #9ca3af !important; /* gray-400 */
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
<x-section-header subtitle="Punto de Venta" title="Nueva " highlight="Venta" />
|
||||
|
||||
<div class="w-full max-w-5xl mx-auto bg-panel-bg border border-neutral-800 rounded-xl p-8 shadow-lg">
|
||||
|
||||
@if(session('success'))
|
||||
<div class="bg-green-900/50 border border-green-500 text-green-300 px-4 py-3 rounded-lg mb-6 shadow-sm">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
@if(session('error'))
|
||||
<div class="bg-red-900/50 border border-red-500 text-red-300 px-4 py-3 rounded-lg mb-6 shadow-sm">
|
||||
{{ session('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@if($errors->any())
|
||||
<div class="bg-red-900/50 border border-red-500 text-red-300 px-4 py-3 rounded-lg mb-6 shadow-sm">
|
||||
<ul class="list-disc list-inside">
|
||||
@foreach($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form action="{{ route('sales.store') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-12 gap-6 mb-8 border-b border-neutral-800 pb-8">
|
||||
<div class="md:col-span-10">
|
||||
<x-forms.label for="client_id" value="Cliente" />
|
||||
<div class="relative">
|
||||
<select name="client_id" class="w-full select2-basic">
|
||||
<option value="">-- Consumidor Final (Anónimo) --</option>
|
||||
@foreach($clients as $client)
|
||||
<option value="{{ $client->id }}">{{ $client->name }}</option>
|
||||
@endforeach
|
||||
</ul>
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
<form action="{{ route('sales.store') }}" method="POST" id="sale-form">
|
||||
@csrf
|
||||
|
||||
<div class="mb-6 bg-gray-50 p-4 rounded-lg border border-gray-200">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Cliente</label>
|
||||
<div class="flex gap-2">
|
||||
<select name="client_id" class="select2-enable w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2 px-3 border">
|
||||
<option value="">-- Consumidor Final (Anónimo) --</option>
|
||||
@foreach($clients as $client)
|
||||
<option value="{{ $client->id }}">{{ $client->name }} ({{ $client->phone }})</option>
|
||||
</div>
|
||||
<div class="md:col-span-2 flex items-end">
|
||||
<a href="{{ route('clients.create', ['origin' => 'sales']) }}" target="_blank" class="bg-indigo-100 text-indigo-700 hover:bg-indigo-200 px-4 py-2 rounded-md font-bold flex items-center border border-indigo-200" title="Crear nuevo cliente">
|
||||
+
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-8">
|
||||
<div class="flex justify-between items-end mb-4">
|
||||
<x-forms.label value="Detalle de Productos" />
|
||||
<div class="text-sm text-gray-400">
|
||||
Total Items: <span class="text-white font-mono" id="item-count">1</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="items-container" class="space-y-3">
|
||||
|
||||
<div class="item-row grid grid-cols-1 md:grid-cols-12 gap-4 items-start bg-neutral-800/50 p-4 rounded-xl border border-neutral-800">
|
||||
|
||||
<div class="md:col-span-6">
|
||||
<label class="block text-gray-400 text-xs mb-1.5 uppercase tracking-wider font-semibold">Producto</label>
|
||||
<select name="items[0][product_id]" class="w-full select2-product product-select">
|
||||
<option value="" data-price="0" selected disabled>Buscar producto...</option>
|
||||
@foreach($products as $product)
|
||||
<option value="{{ $product->id }}" data-price="{{ $product->price }}">
|
||||
{{ $product->sku }} - {{ $product->name }} (Stock: {{ $product->stock_quantity }})
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<a href="{{ route('clients.create') }}" target="_blank" class="bg-indigo-100 text-indigo-700 hover:bg-indigo-200 px-4 py-2 rounded-md font-bold flex items-center border border-indigo-200" title="Crear nuevo cliente">
|
||||
+
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="items-container" class="space-y-4">
|
||||
<div class="item-row grid grid-cols-1 md:grid-cols-12 gap-4 items-end bg-gray-50 p-4 rounded-lg border border-gray-200">
|
||||
<div class="md:col-span-6">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Producto</label>
|
||||
<select name="items[0][product_id]" class="product-select select2-enable w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2 px-3 border" required onchange="calcularTotal()">
|
||||
<option value="" data-price="0" selected disabled>Seleccione...</option>
|
||||
@foreach($products as $product)
|
||||
<option value="{{ $product->id }}" data-price="{{ $product->price }}">
|
||||
{{ $product->sku }} - {{ $product->name }} (${{ $product->price }})
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-3">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Cantidad</label>
|
||||
<input type="number" name="items[0][quantity]" value="1" min="1" class="quantity-input w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2 px-3 border" required oninput="calcularTotal()">
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2 text-right font-mono text-gray-600 self-center pt-6">
|
||||
$<span class="row-subtotal">0.00</span>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-1 text-right">
|
||||
<button type="button" class="text-gray-400 cursor-not-allowed" disabled>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 inline">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-gray-400 text-xs mb-1.5 uppercase tracking-wider font-semibold">Cant.</label>
|
||||
<input type="number" name="items[0][quantity]" value="1" min="1"
|
||||
class="quantity-input bg-neutral-800 border-neutral-700 text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5 h-[42px]">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<button type="button" onclick="agregarFila()" class="flex items-center text-indigo-600 hover:text-indigo-800 font-semibold">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 mr-1">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
||||
</svg>
|
||||
Agregar otro producto
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end mt-6 border-t pt-4">
|
||||
<div class="text-2xl font-bold text-gray-800">
|
||||
Total a Pagar: <span class="text-indigo-600">$<span id="total-display">0.00</span></span>
|
||||
|
||||
<div class="md:col-span-3 text-right flex flex-col justify-center h-[42px] mt-6">
|
||||
<span class="text-xs text-gray-500">Subtotal</span>
|
||||
<span class="row-total text-lg font-bold text-neon-lime">$0.00</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 grid grid-cols-1 md:grid-cols-2 gap-6 items-center">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Método de Pago</label>
|
||||
<select name="payment_method" class="w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2 px-3 border">
|
||||
<option value="Efectivo">Efectivo</option>
|
||||
<option value="Tarjeta de Débito">Tarjeta de Débito</option>
|
||||
<option value="Tarjeta de Crédito">Tarjeta de Crédito</option>
|
||||
<option value="Transferencia">Transferencia</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex items-end gap-4 justify-end">
|
||||
<a href="{{ route('sales.create') }}" class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow">
|
||||
Cancelar
|
||||
</a>
|
||||
<button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded shadow-lg">
|
||||
Confirmar Venta
|
||||
|
||||
<div class="md:col-span-1 flex items-end justify-end h-[42px] mt-6">
|
||||
<button type="button" class="btn-remove text-neutral-500 hover:text-red-500 transition-colors p-2" title="Quitar item">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<button type="button" id="btn-add-row" class="inline-flex items-center text-neon-lime hover:text-[#b3e600] font-bold text-sm transition-colors">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
Agregar otro producto
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 flex justify-end items-center border-t border-neutral-700 pt-6">
|
||||
<div class="text-right">
|
||||
<span class="block text-gray-400 text-sm mb-1">Monto Total a Pagar</span>
|
||||
<span id="grand-total" class="text-3xl font-bold text-white">$0.00</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 items-end border-t border-neutral-800 pt-6">
|
||||
|
||||
<div>
|
||||
<x-forms.label for="payment_method" value="Método de Pago" />
|
||||
<select name="payment_method" class="bg-neutral-800 border-neutral-700 text-white text-sm rounded-lg focus:ring-neon-lime focus:border-neon-lime block w-full p-2.5">
|
||||
<option value="Efectivo">Efectivo</option>
|
||||
<option value="Tarjeta de Débito">Tarjeta de Débito</option>
|
||||
<option value="Tarjeta de Crédito">Tarjeta de Crédito</option>
|
||||
<option value="Transferencia">Transferencia</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-4">
|
||||
<a href="{{ route('sales.create') }}" class="px-6 py-2.5 text-gray-400 hover:text-white font-medium text-sm transition-colors flex items-center">
|
||||
Cancelar
|
||||
</a>
|
||||
<button type="submit" class="px-8 py-2.5 bg-neon-lime text-neutral-900 font-bold rounded-lg hover:bg-[#b3e600] transition-colors shadow-lg shadow-neon-lime/20 transform hover:scale-105">
|
||||
Confirmar Venta
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</x-layout>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
let itemIndex = 0;
|
||||
<script type="module">
|
||||
let rowCount = 0;
|
||||
|
||||
$(document).ready(function() {
|
||||
inicializarSelect2();
|
||||
});
|
||||
$(document).ready(function() {
|
||||
initSelect2();
|
||||
actualizarBloqueos(); // Bloqueo inicial
|
||||
|
||||
function inicializarSelect2() {
|
||||
$('.select2-enable').select2({
|
||||
width: '100%',
|
||||
placeholder: "Escribe para buscar...",
|
||||
allowClear: true
|
||||
});
|
||||
}
|
||||
// --- AGREGAR FILA ---
|
||||
$('#btn-add-row').click(function() {
|
||||
rowCount++;
|
||||
const container = $('#items-container');
|
||||
const firstRow = container.find('.item-row').first();
|
||||
|
||||
function agregarFila() {
|
||||
itemIndex++;
|
||||
const container = document.getElementById('items-container');
|
||||
const firstRow = container.querySelector('.item-row');
|
||||
$('.select2-product').select2('destroy'); // Destruir
|
||||
|
||||
// 1. Destruimos Select2 temporalmente para clonar limpio
|
||||
$('.select2-enable').select2('destroy');
|
||||
const newRow = firstRow.clone(); // Clonar
|
||||
|
||||
// 2. Clonamos
|
||||
const newRow = firstRow.cloneNode(true);
|
||||
initSelect2(); // Reactivar originales
|
||||
|
||||
// 3. Reactivamos en los originales
|
||||
inicializarSelect2();
|
||||
// Limpiar nueva fila
|
||||
newRow.find('input').val(1);
|
||||
newRow.find('.row-total').text('$0.00');
|
||||
|
||||
// Actualizar atributos
|
||||
newRow.find('select').attr('name', `items[${rowCount}][product_id]`).val('');
|
||||
newRow.find('input').attr('name', `items[${rowCount}][quantity]`);
|
||||
|
||||
// Limpiamos valores de la copia
|
||||
const select = newRow.querySelector('select');
|
||||
const input = newRow.querySelector('input');
|
||||
const subtotal = newRow.querySelector('.row-subtotal');
|
||||
|
||||
select.name = `items[${itemIndex}][product_id]`;
|
||||
select.value = "";
|
||||
|
||||
input.name = `items[${itemIndex}][quantity]`;
|
||||
input.value = 1;
|
||||
|
||||
subtotal.innerText = "0.00";
|
||||
// Desbloquear opciones en la nueva fila (vital)
|
||||
newRow.find('option').prop('disabled', false);
|
||||
|
||||
// Botón Eliminar
|
||||
const deleteBtnDiv = newRow.querySelector('div:last-child');
|
||||
deleteBtnDiv.innerHTML = `
|
||||
<button type="button" onclick="eliminarFila(this)" class="text-red-500 hover:text-red-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 inline">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
|
||||
</svg>
|
||||
</button>
|
||||
`;
|
||||
container.append(newRow);
|
||||
initSelect2(); // Activar nueva
|
||||
actualizarBloqueos(); // Recalcular bloqueos
|
||||
actualizarContadorItems();
|
||||
});
|
||||
|
||||
container.appendChild(newRow);
|
||||
|
||||
// 4. Inicializamos en el nuevo
|
||||
inicializarSelect2();
|
||||
|
||||
// Evento extra para Select2
|
||||
$(select).on('select2:select', function (e) {
|
||||
calcularTotal();
|
||||
});
|
||||
}
|
||||
// --- ELIMINAR FILA ---
|
||||
$(document).on('click', '.btn-remove', function() {
|
||||
if ($('.item-row').length > 1) {
|
||||
$(this).closest('.item-row').remove();
|
||||
recalcularTodo();
|
||||
actualizarBloqueos();
|
||||
actualizarContadorItems();
|
||||
} else {
|
||||
alert("Debe haber al menos un producto.");
|
||||
}
|
||||
});
|
||||
|
||||
function eliminarFila(button) {
|
||||
const row = button.closest('.item-row');
|
||||
row.remove();
|
||||
calcularTotal();
|
||||
}
|
||||
|
||||
function calcularTotal() {
|
||||
let total = 0;
|
||||
const rows = document.querySelectorAll('.item-row');
|
||||
|
||||
rows.forEach(row => {
|
||||
const select = row.querySelector('.product-select');
|
||||
const input = row.querySelector('.quantity-input');
|
||||
const subtotalSpan = row.querySelector('.row-subtotal');
|
||||
|
||||
const selectedOption = $(select).find(':selected');
|
||||
const price = parseFloat(selectedOption.attr('data-price')) || 0;
|
||||
const quantity = parseInt(input.value) || 0;
|
||||
|
||||
const subtotal = price * quantity;
|
||||
subtotalSpan.innerText = subtotal.toFixed(2);
|
||||
|
||||
total += subtotal;
|
||||
// --- EVENTOS ---
|
||||
$(document).on('select2:select input', '.product-select, .quantity-input', function() {
|
||||
let row = $(this).closest('.item-row');
|
||||
calcularFila(row);
|
||||
recalcularTodo();
|
||||
|
||||
if ($(this).hasClass('product-select')) {
|
||||
actualizarBloqueos();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('total-display').innerText = total.toFixed(2);
|
||||
}
|
||||
// --- FUNCIONES ---
|
||||
function initSelect2() {
|
||||
$('.select2-basic').select2({ width: '100%' });
|
||||
$('.select2-product').select2({
|
||||
width: '100%',
|
||||
placeholder: "Buscar producto...",
|
||||
language: { noResults: () => "Sin resultados" }
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('select2:select', '.product-select', function (e) {
|
||||
calcularTotal();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
function calcularFila(row) {
|
||||
let select = row.find('.product-select');
|
||||
let input = row.find('.quantity-input');
|
||||
let option = select.find(':selected');
|
||||
let price = parseFloat(option.data('price')) || 0;
|
||||
let qty = parseInt(input.val()) || 0;
|
||||
let subtotal = price * qty;
|
||||
row.find('.row-total').text('$' + subtotal.toFixed(2));
|
||||
}
|
||||
|
||||
function recalcularTodo() {
|
||||
let grandTotal = 0;
|
||||
$('.item-row').each(function() {
|
||||
let row = $(this);
|
||||
let price = parseFloat(row.find('.product-select').find(':selected').data('price')) || 0;
|
||||
let qty = parseInt(row.find('.quantity-input').val()) || 0;
|
||||
grandTotal += (price * qty);
|
||||
});
|
||||
$('#grand-total').text('$' + grandTotal.toFixed(2));
|
||||
}
|
||||
|
||||
function actualizarContadorItems() {
|
||||
$('#item-count').text($('.item-row').length);
|
||||
}
|
||||
|
||||
function actualizarBloqueos() {
|
||||
let seleccionados = [];
|
||||
$('.product-select').each(function() {
|
||||
let valor = $(this).val();
|
||||
if (valor) seleccionados.push(valor);
|
||||
});
|
||||
|
||||
$('.product-select').each(function() {
|
||||
let selectActual = $(this);
|
||||
let miValor = selectActual.val();
|
||||
selectActual.find('option').each(function() {
|
||||
let opcion = $(this);
|
||||
let valorOpcion = opcion.val();
|
||||
if (!valorOpcion) return;
|
||||
|
||||
if (seleccionados.includes(valorOpcion) && valorOpcion != miValor) {
|
||||
opcion.prop('disabled', true);
|
||||
} else {
|
||||
opcion.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</x-layout>
|
||||
Reference in New Issue
Block a user