feat: 卡片按上游期望到货时间排序,新增到达时间展示

- mockFoods/foodDatabase 全部食材新增 arrivalTime 字段
- renderFoodCards 按到达时间升序排列
- 每张卡片新增「期望到货 HH:MM」信息展示
- 获取任务/搜索/候选添加均携带到达时间

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zhangyan
2026-06-17 09:46:53 +08:00
co-authored by Claude Opus 4.6
parent 80a81175c9
commit ae12cd3710
@@ -397,33 +397,33 @@
<script>
// ---- 模拟数据(累计模式) ----
var mockFoods = [
{ name: '土豆丝', size: '35mm*1mm*1mm', shape: '长条', blade: '平刀', target: 5.0, processed: 3.2, icon: '\u{1F954}' },
{ name: '胡萝卜丝', size: '20mm*1mm*1mm', shape: '细丝', blade: '平刀', target: 2.0, processed: 1.5, icon: '\u{1F955}' },
{ name: '黄瓜片', size: '30mm*30mm*3mm', shape: '圆片', blade: '平刀', target: 4.0, processed: 2.8, icon: '\u{1F952}' }
{ name: '土豆丝', size: '35mm*1mm*1mm', shape: '长条', blade: '平刀', target: 5.0, processed: 3.2, arrivalTime: '08:30', icon: '\u{1F954}' },
{ name: '胡萝卜丝', size: '20mm*1mm*1mm', shape: '细丝', blade: '平刀', target: 2.0, processed: 1.5, arrivalTime: '09:15', icon: '\u{1F955}' },
{ name: '黄瓜片', size: '30mm*30mm*3mm', shape: '圆片', blade: '平刀', target: 4.0, processed: 2.8, arrivalTime: '10:00', icon: '\u{1F952}' }
];
// 净菜食材数据库(供搜索用)
var foodDatabase = [
{ name: '土豆丝', size: '35mm*1mm*1mm', shape: '长条', blade: '平刀', icon: '\u{1F954}' },
{ name: '土豆块', size: '20mm*20mm*20mm', shape: '方丁', blade: '平刀', icon: '\u{1F954}' },
{ name: '土豆片', size: '30mm*30mm*3mm', shape: '圆片', blade: '平刀', icon: '\u{1F954}' },
{ name: '胡萝卜丝', size: '20mm*1mm*1mm', shape: '细丝', blade: '平刀', icon: '\u{1F955}' },
{ name: '胡萝卜片', size: '25mm*25mm*2mm', shape: '圆片', blade: '平刀', icon: '\u{1F955}' },
{ name: '黄瓜片', size: '30mm*30mm*3mm', shape: '圆片', blade: '平刀', icon: '\u{1F952}' },
{ name: '黄瓜条', size: '40mm*8mm*8mm', shape: '长条', blade: '平刀', icon: '\u{1F952}' },
{ name: '大白菜段', size: '50mm*30mm*30mm', shape: '宽段', blade: '平刀', icon: '\u{1F96C}' },
{ name: '大白菜丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', icon: '\u{1F96C}' },
{ name: '西红柿块', size: '25mm*25mm*20mm', shape: '楔形块', blade: '平刀', icon: '\u{1F345}' },
{ name: '西红柿片', size: '30mm*30mm*5mm', shape: '圆片', blade: '平刀', icon: '\u{1F345}' },
{ name: '青椒丝', size: '30mm*3mm*3mm', shape: '长条', blade: '平刀', icon: '\u{1FAD1}' },
{ name: '青椒块', size: '20mm*20mm*20mm', shape: '方丁', blade: '平刀', icon: '\u{1FAD1}' },
{ name: '洋葱丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', icon: '\u{1F9C5}' },
{ name: '洋葱块', size: '15mm*15mm*15mm', shape: '方丁', blade: '平刀', icon: '\u{1F9C5}' },
{ name: '芹菜段', size: '40mm*10mm*10mm', shape: '宽段', blade: '平刀', icon: '\u{1F96C}' },
{ name: '芹菜丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', icon: '\u{1F96C}' },
{ name: '莲藕片', size: '35mm*35mm*3mm', shape: '圆片', blade: '平刀', icon: '\u{1FAD1}' },
{ name: '莴笋丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', icon: '\u{1F96C}' },
{ name: '豆角段', size: '40mm*10mm*10mm', shape: '宽段', blade: '平刀', icon: '\u{1FAD8}' }
{ name: '土豆丝', size: '35mm*1mm*1mm', shape: '长条', blade: '平刀', arrivalTime: '08:30', icon: '\u{1F954}' },
{ name: '土豆块', size: '20mm*20mm*20mm', shape: '方丁', blade: '平刀', arrivalTime: '08:30', icon: '\u{1F954}' },
{ name: '土豆片', size: '30mm*30mm*3mm', shape: '圆片', blade: '平刀', arrivalTime: '08:30', icon: '\u{1F954}' },
{ name: '胡萝卜丝', size: '20mm*1mm*1mm', shape: '细丝', blade: '平刀', arrivalTime: '09:15', icon: '\u{1F955}' },
{ name: '胡萝卜片', size: '25mm*25mm*2mm', shape: '圆片', blade: '平刀', arrivalTime: '09:15', icon: '\u{1F955}' },
{ name: '黄瓜片', size: '30mm*30mm*3mm', shape: '圆片', blade: '平刀', arrivalTime: '10:00', icon: '\u{1F952}' },
{ name: '黄瓜条', size: '40mm*8mm*8mm', shape: '长条', blade: '平刀', arrivalTime: '10:00', icon: '\u{1F952}' },
{ name: '大白菜段', size: '50mm*30mm*30mm', shape: '宽段', blade: '平刀', arrivalTime: '10:30', icon: '\u{1F96C}' },
{ name: '大白菜丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', arrivalTime: '10:30', icon: '\u{1F96C}' },
{ name: '西红柿块', size: '25mm*25mm*20mm', shape: '楔形块', blade: '平刀', arrivalTime: '11:00', icon: '\u{1F345}' },
{ name: '西红柿片', size: '30mm*30mm*5mm', shape: '圆片', blade: '平刀', arrivalTime: '11:00', icon: '\u{1F345}' },
{ name: '青椒丝', size: '30mm*3mm*3mm', shape: '长条', blade: '平刀', arrivalTime: '11:30', icon: '\u{1FAD1}' },
{ name: '青椒块', size: '20mm*20mm*20mm', shape: '方丁', blade: '平刀', arrivalTime: '11:30', icon: '\u{1FAD1}' },
{ name: '洋葱丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', arrivalTime: '13:00', icon: '\u{1F9C5}' },
{ name: '洋葱块', size: '15mm*15mm*15mm', shape: '方丁', blade: '平刀', arrivalTime: '13:00', icon: '\u{1F9C5}' },
{ name: '芹菜段', size: '40mm*10mm*10mm', shape: '宽段', blade: '平刀', arrivalTime: '13:30', icon: '\u{1F96C}' },
{ name: '芹菜丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', arrivalTime: '13:30', icon: '\u{1F96C}' },
{ name: '莲藕片', size: '35mm*35mm*3mm', shape: '圆片', blade: '平刀', arrivalTime: '14:00', icon: '\u{1FAD1}' },
{ name: '莴笋丝', size: '30mm*2mm*2mm', shape: '细丝', blade: '平刀', arrivalTime: '14:00', icon: '\u{1F96C}' },
{ name: '豆角段', size: '40mm*10mm*10mm', shape: '宽段', blade: '平刀', arrivalTime: '14:30', icon: '\u{1FAD8}' }
];
var currentUser = null;
@@ -449,18 +449,23 @@
// 初始化净菜列表(带累计已加工重量)
acceptedFoods = mockFoods.map(function(f) {
foodIdCounter++;
return { id: foodIdCounter, name: f.name, size: f.size, shape: f.shape, blade: f.blade, target: f.target, processed: f.processed, icon: f.icon };
return { id: foodIdCounter, name: f.name, size: f.size, shape: f.shape, blade: f.blade, target: f.target, processed: f.processed, arrivalTime: f.arrivalTime, icon: f.icon };
});
renderFoodCards();
startAutoPoll();
})();
// ---- 渲染净菜卡片列表(隐藏已完成的) ----
// ---- 渲染净菜卡片列表(隐藏已完成的,按到达时间排序 ----
function renderFoodCards() {
var container = document.getElementById('foodCards');
var html = '';
// 只渲染未完成的(processed < target
acceptedFoods.forEach(function(f) {
// 按上游期望到货时间升序排列
var sorted = acceptedFoods.slice().sort(function(a, b) {
if (a.arrivalTime < b.arrivalTime) return -1;
if (a.arrivalTime > b.arrivalTime) return 1;
return 0;
});
sorted.forEach(function(f) {
if (f.processed >= f.target) return; // 已完成则隐藏
var pct = f.target > 0 ? Math.min(100, (f.processed / f.target) * 100) : 0;
html += '<div class="food-card">'
@@ -470,6 +475,9 @@
+ '<button class="food-card__delete" onclick="removeFood(' + f.id + ')" title="删除">&#x2715;</button>'
+ '</div>'
+ '<span class="food-card__spec">' + f.size + ' · ' + f.shape + ' · ' + f.blade + '</span>'
+ '<div style="display:flex;justify-content:space-between;align-items:center;">'
+ '<span style="font-size:11px;color:rgba(255,255,255,0.35);">期望到货 ' + f.arrivalTime + '</span>'
+ '</div>'
+ '<div class="food-card__progress">'
+ '<div style="display:flex;justify-content:space-between;">'
+ '<span class="food-card__progress-label">处理进度(斤)</span>'
@@ -526,7 +534,7 @@
var target = parseFloat((Math.random() * 5 + 1.5).toFixed(1));
var processed = parseFloat((Math.random() * target * 0.7).toFixed(1));
foodIdCounter++;
acceptedFoods.push({ id: foodIdCounter, name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: target, processed: processed, icon: food.icon });
acceptedFoods.push({ id: foodIdCounter, name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: target, processed: processed, arrivalTime: food.arrivalTime, icon: food.icon });
renderFoodCards();
showToast('已获取:' + food.name + '(应加工 ' + target.toFixed(1) + '斤)', 1500);
}, 800);
@@ -550,7 +558,8 @@
if (acceptedFoods.length === 0) {
// 无数据时重新初始化
acceptedFoods = mockFoods.map(function(f) {
return { name: f.name, size: f.size, shape: f.shape, blade: f.blade, target: f.target, processed: f.processed, icon: f.icon };
foodIdCounter++;
return { id: foodIdCounter, name: f.name, size: f.size, shape: f.shape, blade: f.blade, target: f.target, processed: f.processed, arrivalTime: f.arrivalTime, icon: f.icon };
});
renderFoodCards();
showToast('加工任务已刷新', 1200);
@@ -608,7 +617,7 @@
} else {
// 新净菜,添加到列表并弹窗
var food = foodDatabase.find(function(f) { return f.name === name; });
var newFood = { name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: 3.0, processed: 0, icon: food.icon };
var newFood = { name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: 3.0, processed: 0, arrivalTime: food.arrivalTime, icon: food.icon };
acceptedFoods.push(newFood);
renderFoodCards();
showWeightModal(newFood, detectedWeight);
@@ -656,7 +665,7 @@
var food = foodDatabase.find(function(f) { return f.name === name; });
if (!food) return;
var detectedWeight = parseFloat((Math.random() * 2 + 0.3).toFixed(1));
var newFood = { name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: 3.0, processed: 0, icon: food.icon };
var newFood = { name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: 3.0, processed: 0, arrivalTime: food.arrivalTime, icon: food.icon };
acceptedFoods.push(newFood);
renderFoodCards();
document.getElementById('searchInput').value = '';
@@ -718,7 +727,8 @@
function handleSaveContinue() {
showToast('保存成功', 1500);
acceptedFoods = mockFoods.map(function(f) {
return { name: f.name, size: f.size, shape: f.shape, blade: f.blade, target: f.target, processed: f.processed, icon: f.icon };
foodIdCounter++;
return { id: foodIdCounter, name: f.name, size: f.size, shape: f.shape, blade: f.blade, target: f.target, processed: f.processed, arrivalTime: f.arrivalTime, icon: f.icon };
});
renderFoodCards();
document.getElementById('candidateEmpty').style.display = 'flex';