智慧水务管理系统 - 精河县供水工程综合管理平台

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>库存管理</title>
  7. <script src="https://cdn.tailwindcss.com"></script>
  8. </head>
  9. <body class="bg-gray-50 min-h-screen">
  10. <nav class="bg-blue-600 text-white shadow-lg">
  11. <div class="container mx-auto px-4 py-4">
  12. <div class="flex justify-between items-center">
  13. <div class="flex items-center space-x-3"><span class="text-2xl">📦</span><h1 class="text-xl font-bold">电商库存管理系统</h1></div>
  14. <div class="flex space-x-4">
  15. <a href="/" class="hover:bg-blue-500 px-3 py-2 rounded">首页</a>
  16. <a href="/shops" class="hover:bg-blue-500 px-3 py-2 rounded">店铺</a>
  17. <a href="/products" class="hover:bg-blue-500 px-3 py-2 rounded">商品</a>
  18. <a href="/inventory" class="bg-blue-500 px-3 py-2 rounded">库存</a>
  19. <a href="/orders" class="hover:bg-blue-500 px-3 py-2 rounded">订单</a>
  20. </div>
  21. </div>
  22. </div>
  23. </nav>
  24. <main class="container mx-auto px-4 py-8">
  25. <div class="flex justify-between items-center mb-8">
  26. <div><h2 class="text-3xl font-bold text-gray-800">📊 库存管理</h2><p class="text-gray-600 mt-2">多平台库存同步</p></div>
  27. <button onclick="syncInventory()" class="bg-purple-600 text-white px-6 py-3 rounded-lg">🔄 同步库存</button>
  28. </div>
  29. <div id="inventoryList" class="bg-white rounded-lg shadow overflow-hidden"></div>
  30. </main>
  31. <script>
  32. async function loadInventory() {
  33. const res = await fetch('/api/inventory');
  34. const data = await res.json();
  35. const container = document.getElementById('inventoryList');
  36. if (data.success && data.data.length > 0) {
  37. container.innerHTML = '<table class="min-w-full"><thead class="bg-gray-50"><tr><th class="px-6 py-3">商品</th><th class="px-6 py-3">店铺</th><th class="px-6 py-3">平台</th><th class="px-6 py-3">库存</th><th class="px-6 py-3">安全库存</th><th class="px-6 py-3">状态</th></tr></thead><tbody>' +
  38. data.data.map(i => `<tr class="border-t"><td class="px-6 py-4">${i.product_name}</td><td class="px-6 py-4">${i.shop_name}</td><td class="px-6 py-4">${i.platform}</td><td class="px-6 py-4 ${i.is_low_stock ? 'text-red-600 font-bold' : ''}>${i.quantity}</td><td class="px-6 py-4">${i.safe_stock}</td><td class="px-6 py-4">${i.is_low_stock ? '<span class="text-red-600">⚠️ 预警</span>' : '<span class="text-green-600">✅ 充足</span>'}</td></tr>`).join('') + '</tbody></table>';
  39. } else {
  40. container.innerHTML = '<div class="p-8 text-center text-gray-500">暂无库存数据,请先添加商品和店铺</div>';
  41. }
  42. }
  43. async function syncInventory() {
  44. if(!confirm('确定同步库存?')) return;
  45. const res = await fetch('/api/inventory/sync', {method:'POST'});
  46. const result = await res.json();
  47. if(result.success) { alert('✅ '+result.message); loadInventory(); }
  48. else alert('❌ '+result.error);
  49. }
  50. document.addEventListener('DOMContentLoaded', loadInventory);
  51. </script>
  52. </body>
  53. </html>