diff --git a/package-lock.json b/package-lock.json index 0ba49cc..20889c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,5 @@ { -<<<<<<< Updated upstream - "name": "Review2", -======= "name": "boss", ->>>>>>> Stashed changes "lockfileVersion": 3, "requires": true, "packages": { @@ -15,7 +11,8 @@ "cors": "^2.8.5", "express": "^5.1.0", "mysql2": "^3.15.3", - "sharp": "^0.34.5" + "sharp": "^0.34.5", + "ws": "^8.19.0" }, "devDependencies": { "chai": "^6.2.1", @@ -56,7 +53,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1300,7 +1296,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -5173,6 +5168,27 @@ "dev": true, "license": "ISC" }, + "node_modules/ws": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", + "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/xml2js": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", diff --git a/supply.html b/supply.html index 51a5c1e..fe53180 100644 --- a/supply.html +++ b/supply.html @@ -1142,6 +1142,28 @@ + + +
+
+
+

选择新鲜程度

+ +
+ +
+
+ +
+
+ +
+
@@ -2265,7 +2287,29 @@ startAutoOfflineCheck(); // 启动定期刷新数据,确保label字段变化能实时显示 - timers.loadSupplies = setInterval(loadSupplies, 5000); // 每5秒刷新一次 + timers.loadSupplies = setInterval(() => { + console.log('定期刷新数据,检查label字段变化'); + loadSupplies(); + }, 5000); // 每5秒刷新一次 + + // 增强WebSocket消息处理,确保所有相关消息都能触发数据刷新 + console.log('增强WebSocket消息处理'); + if (ws) { + // 添加额外的消息监听器,确保所有相关消息都能触发数据刷新 + ws.addEventListener('message', function(event) { + try { + const data = JSON.parse(event.data); + console.log('增强的WebSocket消息处理:', data); + // 对于任何类型的WebSocket消息,都重新加载数据,确保label字段实时更新 + if (data.type !== 'ping' && data.type !== 'pong') { + console.log('收到相关WebSocket消息,刷新数据'); + loadSupplies(); + } + } catch (error) { + console.error('解析WebSocket消息失败:', error); + } + }); + } }; // 页面卸载时清理资源 @@ -5606,8 +5650,8 @@ const userInfo = checkLogin(); if (!userInfo) return; - // 获取规格和件数数据 - const pairs = document.querySelectorAll('.spec-quantity-pair'); + // 获取规格和件数数据 - 只获取创建货源表单中的规格和件数对 + const pairs = document.querySelectorAll('#specQuantityContainer .spec-quantity-pair'); const specifications = []; const quantities = []; @@ -6282,6 +6326,11 @@ document.getElementById('editCostprice').value = supply.costprice || ''; document.getElementById('editGrossWeight').value = supply.grossWeight || ''; + // 新鲜程度 + document.getElementById('editFreshnessDisplayText').textContent = supply.freshness || '请选择新鲜程度'; + document.getElementById('editFreshness').value = supply.freshness || ''; + editSelectedFreshness = supply.freshness || ''; + // 自动下架时间(将小时转换为分钟) const autoOfflineMinutes = (parseFloat(supply.autoOfflineHours) || 24) * 60; document.getElementById('editAutoOfflineMinutes').value = Math.round(autoOfflineMinutes);