Spaces:
Running
Running
Download index.html from FactoryTex/almacen: direct link, hf CLI and curl.
- Browser
- Download file 27.1 kB
-
https://huggingface.co/spaces/FactoryTex/almacen/resolve/main/index.html
- Command line
-
hf download hf://spaces/FactoryTex/almacen/index.html
-
curl -L -o index.html https://huggingface.co/spaces/FactoryTex/almacen/resolve/main/index.html
27.1 kB
| <html lang="es"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Sistema de Gestión de Almacén</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .fade-in { | |
| animation: fadeIn 0.3s ease-in-out; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .product-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 20px rgba(0,0,0,0.1); | |
| } | |
| .modal { | |
| transition: all 0.3s ease; | |
| } | |
| .modal.active { | |
| opacity: 1; | |
| visibility: visible; | |
| } | |
| .modal:not(.active) { | |
| opacity: 0; | |
| visibility: hidden; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 font-sans"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <header class="mb-8"> | |
| <h1 class="text-3xl font-bold text-indigo-700 flex items-center"> | |
| <i class="fas fa-warehouse mr-3"></i> Gestión de Almacén | |
| </h1> | |
| <p class="text-gray-600">Control de entradas y salidas de productos</p> | |
| </header> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-6"> | |
| <!-- Panel de control --> | |
| <div class="lg:col-span-1 bg-white rounded-lg shadow p-6"> | |
| <h2 class="text-xl font-semibold mb-4 text-indigo-600 flex items-center"> | |
| <i class="fas fa-tachometer-alt mr-2"></i> Panel de Control | |
| </h2> | |
| <div class="mb-6"> | |
| <button id="addProductBtn" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-4 rounded-lg flex items-center justify-center transition"> | |
| <i class="fas fa-plus-circle mr-2"></i> Agregar Producto | |
| </button> | |
| </div> | |
| <div class="mb-6"> | |
| <h3 class="font-medium text-gray-700 mb-2">Filtrar productos</h3> | |
| <input type="text" id="searchInput" placeholder="Buscar producto..." class="w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-indigo-400 focus:border-indigo-400"> | |
| </div> | |
| <div class="bg-indigo-50 p-4 rounded-lg"> | |
| <h3 class="font-medium text-indigo-700 mb-2">Resumen de stock</h3> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div class="bg-white p-3 rounded-lg shadow-sm"> | |
| <p class="text-sm text-gray-500">Productos totales</p> | |
| <p id="totalProducts" class="text-2xl font-bold text-indigo-600">0</p> | |
| </div> | |
| <div class="bg-white p-3 rounded-lg shadow-sm"> | |
| <p class="text-sm text-gray-500">Valor total</p> | |
| <p id="totalValue" class="text-2xl font-bold text-green-600">$0</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Lista de productos --> | |
| <div class="lg:col-span-2 bg-white rounded-lg shadow overflow-hidden"> | |
| <div class="p-4 border-b"> | |
| <h2 class="text-xl font-semibold text-indigo-600 flex items-center"> | |
| <i class="fas fa-boxes mr-2"></i> Inventario Actual | |
| </h2> | |
| </div> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-200"> | |
| <thead class="bg-gray-50"> | |
| <tr> | |
| <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Código</th> | |
| <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Producto</th> | |
| <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Precio</th> | |
| <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stock</th> | |
| <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th> | |
| </tr> | |
| </thead> | |
| <tbody id="productTableBody" class="bg-white divide-y divide-gray-200"> | |
| <!-- Los productos se cargarán aquí dinámicamente --> | |
| </tbody> | |
| </table> | |
| </div> | |
| <div class="p-4 border-t"> | |
| <div class="flex justify-between items-center"> | |
| <div> | |
| <p class="text-sm text-gray-600">Mostrando <span id="showingCount">0</span> de <span id="totalCount">0</span> productos</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Gráfico de stock --> | |
| <div class="mt-8 bg-white rounded-lg shadow p-6"> | |
| <h2 class="text-xl font-semibold mb-4 text-indigo-600 flex items-center"> | |
| <i class="fas fa-chart-bar mr-2"></i> Gráfico de Stock | |
| </h2> | |
| <div class="h-80"> | |
| <canvas id="stockChart"></canvas> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Modal para agregar/editar producto --> | |
| <div id="productModal" class="modal fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50"> | |
| <div class="bg-white rounded-lg shadow-xl w-full max-w-md fade-in"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 id="modalTitle" class="text-xl font-semibold text-indigo-600">Agregar Nuevo Producto</h3> | |
| <button id="closeModalBtn" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <form id="productForm" class="space-y-4"> | |
| <input type="hidden" id="productId"> | |
| <div> | |
| <label for="productName" class="block text-sm font-medium text-gray-700">Nombre del Producto</label> | |
| <input type="text" id="productName" required class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"> | |
| </div> | |
| <div> | |
| <label for="barcode" class="block text-sm font-medium text-gray-700">Código de Barras</label> | |
| <div class="flex"> | |
| <input type="text" id="barcode" required class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"> | |
| <button type="button" id="generateBarcode" class="mt-1 px-3 py-2 bg-gray-200 border border-l-0 border-gray-300 rounded-r-md hover:bg-gray-300"> | |
| <i class="fas fa-barcode"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="productPrice" class="block text-sm font-medium text-gray-700">Precio Unitario</label> | |
| <div class="relative mt-1"> | |
| <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> | |
| <span class="text-gray-500">$</span> | |
| </div> | |
| <input type="number" id="productPrice" min="0" step="0.01" required class="pl-7 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="initialStock" class="block text-sm font-medium text-gray-700">Stock Inicial</label> | |
| <input type="number" id="initialStock" min="0" value="0" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"> | |
| </div> | |
| <div class="flex justify-end space-x-3 pt-4"> | |
| <button type="button" id="cancelBtn" class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> | |
| Cancelar | |
| </button> | |
| <button type="submit" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> | |
| Guardar | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Modal para movimiento de stock --> | |
| <div id="movementModal" class="modal fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50"> | |
| <div class="bg-white rounded-lg shadow-xl w-full max-w-md fade-in"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 id="movementModalTitle" class="text-xl font-semibold text-indigo-600">Movimiento de Stock</h3> | |
| <button id="closeMovementModalBtn" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <form id="movementForm" class="space-y-4"> | |
| <input type="hidden" id="movementProductId"> | |
| <div> | |
| <p class="text-sm font-medium text-gray-700">Producto: <span id="movementProductName" class="font-semibold"></span></p> | |
| <p class="text-sm text-gray-500">Stock actual: <span id="currentStock" class="font-medium"></span></p> | |
| </div> | |
| <div> | |
| <label for="movementType" class="block text-sm font-medium text-gray-700">Tipo de Movimiento</label> | |
| <select id="movementType" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 rounded-md"> | |
| <option value="in">Entrada (Ingreso)</option> | |
| <option value="out">Salida (Egreso)</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label for="movementQuantity" class="block text-sm font-medium text-gray-700">Cantidad</label> | |
| <input type="number" id="movementQuantity" min="1" value="1" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"> | |
| </div> | |
| <div> | |
| <label for="movementNotes" class="block text-sm font-medium text-gray-700">Notas (Opcional)</label> | |
| <textarea id="movementNotes" rows="2" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"></textarea> | |
| </div> | |
| <div class="flex justify-end space-x-3 pt-4"> | |
| <button type="button" id="cancelMovementBtn" class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> | |
| Cancelar | |
| </button> | |
| <button type="submit" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> | |
| Confirmar | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Base de datos simulada | |
| let products = [ | |
| { id: 1, name: "Laptop HP 15", barcode: "123456789012", price: 899.99, stock: 15 }, | |
| { id: 2, name: "Mouse Inalámbrico", barcode: "234567890123", price: 24.99, stock: 42 }, | |
| { id: 3, name: "Teclado Mecánico", barcode: "345678901234", price: 59.99, stock: 23 }, | |
| { id: 4, name: "Monitor 24\" Full HD", barcode: "456789012345", price: 199.99, stock: 8 }, | |
| { id: 5, name: "Disco SSD 500GB", barcode: "567890123456", price: 79.99, stock: 31 } | |
| ]; | |
| // Elementos del DOM | |
| const productTableBody = document.getElementById('productTableBody'); | |
| const searchInput = document.getElementById('searchInput'); | |
| const totalProducts = document.getElementById('totalProducts'); | |
| const totalValue = document.getElementById('totalValue'); | |
| const showingCount = document.getElementById('showingCount'); | |
| const totalCount = document.getElementById('totalCount'); | |
| // Elementos del modal | |
| const productModal = document.getElementById('productModal'); | |
| const modalTitle = document.getElementById('modalTitle'); | |
| const productForm = document.getElementById('productForm'); | |
| const productId = document.getElementById('productId'); | |
| const productName = document.getElementById('productName'); | |
| const barcode = document.getElementById('barcode'); | |
| const productPrice = document.getElementById('productPrice'); | |
| const initialStock = document.getElementById('initialStock'); | |
| const generateBarcode = document.getElementById('generateBarcode'); | |
| const addProductBtn = document.getElementById('addProductBtn'); | |
| const closeModalBtn = document.getElementById('closeModalBtn'); | |
| const cancelBtn = document.getElementById('cancelBtn'); | |
| // Elementos del modal de movimiento | |
| const movementModal = document.getElementById('movementModal'); | |
| const movementModalTitle = document.getElementById('movementModalTitle'); | |
| const movementForm = document.getElementById('movementForm'); | |
| const movementProductId = document.getElementById('movementProductId'); | |
| const movementProductName = document.getElementById('movementProductName'); | |
| const currentStock = document.getElementById('currentStock'); | |
| const movementType = document.getElementById('movementType'); | |
| const movementQuantity = document.getElementById('movementQuantity'); | |
| const movementNotes = document.getElementById('movementNotes'); | |
| const closeMovementModalBtn = document.getElementById('closeMovementModalBtn'); | |
| const cancelMovementBtn = document.getElementById('cancelMovementBtn'); | |
| // Gráfico | |
| let stockChart; | |
| // Inicializar la aplicación | |
| document.addEventListener('DOMContentLoaded', () => { | |
| renderProducts(); | |
| updateSummary(); | |
| initChart(); | |
| // Event listeners | |
| addProductBtn.addEventListener('click', () => openProductModal()); | |
| closeModalBtn.addEventListener('click', () => closeProductModal()); | |
| cancelBtn.addEventListener('click', () => closeProductModal()); | |
| closeMovementModalBtn.addEventListener('click', () => closeMovementModal()); | |
| cancelMovementBtn.addEventListener('click', () => closeMovementModal()); | |
| productForm.addEventListener('submit', handleProductSubmit); | |
| movementForm.addEventListener('submit', handleMovementSubmit); | |
| searchInput.addEventListener('input', () => { | |
| renderProducts(); | |
| }); | |
| generateBarcode.addEventListener('click', generateRandomBarcode); | |
| }); | |
| // Renderizar la lista de productos | |
| function renderProducts() { | |
| const searchTerm = searchInput.value.toLowerCase(); | |
| const filteredProducts = products.filter(product => | |
| product.name.toLowerCase().includes(searchTerm) || | |
| product.barcode.includes(searchTerm) | |
| ); | |
| productTableBody.innerHTML = ''; | |
| filteredProducts.forEach(product => { | |
| const row = document.createElement('tr'); | |
| row.className = 'hover:bg-gray-50'; | |
| row.innerHTML = ` | |
| <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${product.barcode}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${product.name}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">$${product.price.toFixed(2)}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm ${product.stock < 5 ? 'text-red-600 font-bold' : 'text-gray-500'}"> | |
| ${product.stock} | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> | |
| <div class="flex space-x-2"> | |
| <button onclick="openMovementModal(${product.id}, 'in')" class="text-green-600 hover:text-green-800" title="Entrada"> | |
| <i class="fas fa-arrow-down"></i> | |
| </button> | |
| <button onclick="openMovementModal(${product.id}, 'out')" class="text-red-600 hover:text-red-800" title="Salida"> | |
| <i class="fas fa-arrow-up"></i> | |
| </button> | |
| <button onclick="editProduct(${product.id})" class="text-blue-600 hover:text-blue-800" title="Editar"> | |
| <i class="fas fa-edit"></i> | |
| </button> | |
| <button onclick="deleteProduct(${product.id})" class="text-red-600 hover:text-red-800" title="Eliminar"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| </div> | |
| </td> | |
| `; | |
| productTableBody.appendChild(row); | |
| }); | |
| showingCount.textContent = filteredProducts.length; | |
| totalCount.textContent = products.length; | |
| updateChart(); | |
| } | |
| // Actualizar el resumen | |
| function updateSummary() { | |
| totalProducts.textContent = products.length; | |
| const total = products.reduce((sum, product) => sum + (product.price * product.stock), 0); | |
| totalValue.textContent = `$${total.toFixed(2)}`; | |
| } | |
| // Inicializar el gráfico | |
| function initChart() { | |
| const ctx = document.getElementById('stockChart').getContext('2d'); | |
| stockChart = new Chart(ctx, { | |
| type: 'bar', | |
| data: { | |
| labels: [], | |
| datasets: [{ | |
| label: 'Stock de Productos', | |
| data: [], | |
| backgroundColor: 'rgba(79, 70, 229, 0.7)', | |
| borderColor: 'rgba(79, 70, 229, 1)', | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| scales: { | |
| y: { | |
| beginAtZero: true | |
| } | |
| }, | |
| plugins: { | |
| legend: { | |
| position: 'top', | |
| }, | |
| tooltip: { | |
| callbacks: { | |
| label: function(context) { | |
| return `Stock: ${context.raw}`; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| // Actualizar el gráfico | |
| function updateChart() { | |
| const topProducts = [...products] | |
| .sort((a, b) => b.stock - a.stock) | |
| .slice(0, 8); | |
| stockChart.data.labels = topProducts.map(p => p.name); | |
| stockChart.data.datasets[0].data = topProducts.map(p => p.stock); | |
| stockChart.update(); | |
| } | |
| // Abrir modal de producto | |
| function openProductModal(product = null) { | |
| if (product) { | |
| modalTitle.textContent = 'Editar Producto'; | |
| productId.value = product.id; | |
| productName.value = product.name; | |
| barcode.value = product.barcode; | |
| productPrice.value = product.price; | |
| initialStock.value = product.stock; | |
| } else { | |
| modalTitle.textContent = 'Agregar Nuevo Producto'; | |
| productForm.reset(); | |
| productId.value = ''; | |
| } | |
| productModal.classList.add('active'); | |
| } | |
| // Cerrar modal de producto | |
| function closeProductModal() { | |
| productModal.classList.remove('active'); | |
| } | |
| // Abrir modal de movimiento | |
| function openMovementModal(productId, type = 'in') { | |
| const product = products.find(p => p.id === productId); | |
| if (!product) return; | |
| movementProductId.value = product.id; | |
| movementProductName.textContent = product.name; | |
| currentStock.textContent = product.stock; | |
| movementType.value = type; | |
| movementQuantity.value = 1; | |
| movementNotes.value = ''; | |
| movementModalTitle.textContent = type === 'in' ? 'Registrar Entrada' : 'Registrar Salida'; | |
| movementModal.classList.add('active'); | |
| } | |
| // Cerrar modal de movimiento | |
| function closeMovementModal() { | |
| movementModal.classList.remove('active'); | |
| } | |
| // Manejar el envío del formulario de producto | |
| function handleProductSubmit(e) { | |
| e.preventDefault(); | |
| const productData = { | |
| name: productName.value, | |
| barcode: barcode.value, | |
| price: parseFloat(productPrice.value), | |
| stock: parseInt(initialStock.value) || 0 | |
| }; | |
| if (productId.value) { | |
| // Editar producto existente | |
| const index = products.findIndex(p => p.id === parseInt(productId.value)); | |
| if (index !== -1) { | |
| products[index] = { ...products[index], ...productData }; | |
| } | |
| } else { | |
| // Agregar nuevo producto | |
| const newId = products.length > 0 ? Math.max(...products.map(p => p.id)) + 1 : 1; | |
| products.push({ id: newId, ...productData }); | |
| } | |
| renderProducts(); | |
| updateSummary(); | |
| closeProductModal(); | |
| } | |
| // Manejar el envío del formulario de movimiento | |
| function handleMovementSubmit(e) { | |
| e.preventDefault(); | |
| const productId = parseInt(movementProductId.value); | |
| const quantity = parseInt(movementQuantity.value); | |
| const type = movementType.value; | |
| const notes = movementNotes.value; | |
| const productIndex = products.findIndex(p => p.id === productId); | |
| if (productIndex === -1) return; | |
| if (type === 'in') { | |
| products[productIndex].stock += quantity; | |
| } else { | |
| if (products[productIndex].stock < quantity) { | |
| alert('No hay suficiente stock para esta salida'); | |
| return; | |
| } | |
| products[productIndex].stock -= quantity; | |
| } | |
| // Aquí podrías guardar el movimiento en un historial si lo deseas | |
| renderProducts(); | |
| updateSummary(); | |
| closeMovementModal(); | |
| } | |
| // Editar producto | |
| function editProduct(id) { | |
| const product = products.find(p => p.id === id); | |
| if (product) { | |
| openProductModal(product); | |
| } | |
| } | |
| // Eliminar producto | |
| function deleteProduct(id) { | |
| if (confirm('¿Estás seguro de que deseas eliminar este producto?')) { | |
| products = products.filter(p => p.id !== id); | |
| renderProducts(); | |
| updateSummary(); | |
| } | |
| } | |
| // Generar código de barras aleatorio | |
| function generateRandomBarcode() { | |
| const randomBarcode = Math.floor(100000000000 + Math.random() * 900000000000).toString(); | |
| barcode.value = randomBarcode; | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=FactoryTex/almacen" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |