diff --git a/other-module/canteen-device/clean-veg-ratio-scale/01-accept.html b/other-module/canteen-device/clean-veg-ratio-scale/01-accept.html
index e9a6286..d0014ce 100644
--- a/other-module/canteen-device/clean-veg-ratio-scale/01-accept.html
+++ b/other-module/canteen-device/clean-veg-ratio-scale/01-accept.html
@@ -360,7 +360,7 @@
-
+
@@ -428,7 +428,8 @@
var currentUser = null;
var acceptedFoods = [];
- var pendingWeightFood = null; // 待确认重量的净菜引用
+ var pendingWeightFood = null;
+ var foodIdCounter = 0; // 唯一ID计数器
// ---- URL 参数 ----
function getUrlParam(name) {
@@ -447,22 +448,25 @@
// 初始化净菜列表(带累计已加工重量)
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, icon: f.icon };
});
renderFoodCards();
})();
- // ---- 渲染净菜卡片列表 ----
+ // ---- 渲染净菜卡片列表(隐藏已完成的) ----
function renderFoodCards() {
var container = document.getElementById('foodCards');
var html = '';
- acceptedFoods.forEach(function(f, idx) {
+ // 只渲染未完成的(processed < target)
+ acceptedFoods.forEach(function(f) {
+ if (f.processed >= f.target) return; // 已完成则隐藏
var pct = f.target > 0 ? Math.min(100, (f.processed / f.target) * 100) : 0;
html += '
'
+ ''
+ '
' + f.size + ' · ' + f.shape + ' · ' + f.blade + ''
+ '
'
@@ -477,19 +481,42 @@
+ '
';
});
if (html === '') {
- html = '
暂无加工净菜,点击右上角「刷新」获取
';
+ html = '
暂无加工净菜,点击上方「获取任务」添加
';
}
container.innerHTML = html;
}
// ---- 删除净菜 ----
- function removeFood(idx) {
- acceptedFoods.splice(idx, 1);
+ function removeFood(id) {
+ for (var i = 0; i < acceptedFoods.length; i++) {
+ if (acceptedFoods[i].id === id) { acceptedFoods.splice(i, 1); break; }
+ }
renderFoodCards();
showToast('已删除', 1000);
}
- // ---- 刷新:模拟获取加工任务最新重量 ----
+ // ---- 获取任务:新增一个未完成的净菜加工任务 ----
+ function handleFetchTask() {
+ showToast('正在获取加工任务...', 800);
+ setTimeout(function() {
+ // 从食材库随机选一个,排除已在列表中未完成的同名净菜
+ var existingNames = acceptedFoods.filter(function(f) { return f.processed < f.target; }).map(function(f) { return f.name; });
+ var available = foodDatabase.filter(function(f) { return existingNames.indexOf(f.name) === -1; });
+ if (available.length === 0) {
+ showToast('暂无可获取的净菜任务', 1200, 'warn');
+ return;
+ }
+ var food = available[Math.floor(Math.random() * available.length)];
+ var target = parseFloat((Math.random() * 5 + 1.5).toFixed(1));
+ var processed = parseFloat((Math.random() * target * 0.7).toFixed(1)); // 0~70%进度,确保未完成
+ foodIdCounter++;
+ acceptedFoods.push({ id: foodIdCounter, name: food.name, size: food.size, shape: food.shape, blade: food.blade, target: target, processed: processed, icon: food.icon });
+ renderFoodCards();
+ showToast('已获取:' + food.name + '(应加工 ' + target.toFixed(1) + '斤)', 1500);
+ }, 800);
+ }
+
+ // ---- 刷新:模拟获取加工任务最新重量 ----(顶部刷新按钮)
function handleRefresh() {
showToast('正在获取加工数据...', 800);
setTimeout(function() {