@@ -855,12 +855,16 @@ function renderGenHistoryOrder(orderNo){
var infoBody=document.getElementById('genHistoryInfoBody');
var html='';
rec.details.forEach(function(d){
+ var spec=getDishSpecForRecipe(d.foodName);
+ var specLabel=spec.baseGram+'g/'+spec.portion;
html+='
'
+'
'+rec.recipeDate+'
'
+'
'+d.meal+'
'
+'
'+d.foodName+'
'
+'
'+d.dinerCount+'
'
+ +'
'+(parseFloat(d.cookedWeight).toFixed(2))+' kg
'
+'
'+genSeasoningTag(d.needSeasoning)+'
'
+ +'
'+specLabel+'
'
+'
'+d.servings+'
'
+'
'+rec.deliverTime+'
'
+'
'+rec.startTime+'
'
@@ -1441,6 +1445,12 @@ function getDishSpecForRecipe(name){
}
return RECIPE_FALLBACK[name]||{portion:'标准份',baseGram:500,unit:'份'};
}
+/* 食谱餐品可选规格列表:优先总库多规格,无则回退单规格 */
+function getDishSpecOptionsForRecipe(name){
+ var specs=getSpecsByDish(name);
+ if(specs&&specs.length>0)return specs;
+ return [getDishSpecForRecipe(name)];
+}
var MEAL_NAMES=['早餐','午餐','晚餐','加餐'];
function getDefaultDate(){return '2026-05-20';}
@@ -1499,8 +1509,8 @@ function onRecipeDateChange(){
/* ========== 餐品调料配置表(食谱快速创建专用) ========== */
/* recipeSeasoningMap: { 菜名: true|false },跨餐次重复菜品自动合并,状态在重渲时保留 */
var recipeSeasoningMap={};
-/* recipeServingMap: { 菜名: 份数 },餐品明细表份数编辑值,重渲时保留 */
-var recipeServingMap={};
+/* recipeSpecMap: { 菜名: "baseGram|portion|unit" },餐品明细表所选规格,重渲时保留 */
+var recipeSpecMap={};
function renderDishSeasoningTable(){
var section=document.getElementById('dishSeasoningSection');
var tbody=document.getElementById('dishSeasoningBody');
@@ -1533,23 +1543,21 @@ function renderDishSeasoningTable(){
/* 未配置过的菜品默认 false(不需要);已配置的保留 */
if(typeof recipeSeasoningMap[name]!=='boolean')recipeSeasoningMap[name]=false;
var ns=recipeSeasoningMap[name]===true;
- /* 每份生重(克)取系统默认规格;就餐人数为该菜品跨餐次累加值 */
- var sp=getDishSpecForRecipe(name);
- var baseGram=sp.baseGram||500;
- var dinerCount=dishDinerMap[name]||0;
- /* 预测生重(总,克)= 每份生重 × 就餐人数 */
- var predictedRawG=baseGram*dinerCount;
- /* 份数:每份生重>4kg 时按最大包装克重 4kg/份 反算,否则取就餐人数 */
- if(!recipeServingMap[name]){
- recipeServingMap[name]=baseGram>4000?Math.ceil(predictedRawG/4000):dinerCount;
+ /* 规格列表:优先总库多规格,无则回退单规格 */
+ var specs=getDishSpecOptionsForRecipe(name);
+ /* 首次渲染默认选中第一个规格 */
+ if(!recipeSpecMap[name]&&specs.length>0){
+ recipeSpecMap[name]=specs[0].baseGram+'|'+specs[0].portion+'|'+(specs[0].unit||'份');
}
- var servings=recipeServingMap[name];
+ var selVal=recipeSpecMap[name];
html+='
'+name+'
';
- /* 份数:固定单位「份」,输入框编辑份数 */
- html+='
'
- +''
- +'份'
- +'
';
+ /* 规格:下拉选择 规格重量/规格名称 */
+ html+='
';
html+='
';
html+='';
html+='';
@@ -1560,9 +1568,9 @@ function renderDishSeasoningTable(){
function updateRecipeSeasoning(name,val){
recipeSeasoningMap[name]=!!val;
}
-/* 更新食谱餐品份数 */
-function updateRecipeServing(name,val){
- recipeServingMap[name]=parseInt(val,10)||0;
+/* 更新食谱餐品所选规格 */
+function updateRecipeSpec(name,val){
+ recipeSpecMap[name]=val;
}
/* 校验所选餐次是否都已填写就餐人数,并返回缺失餐次名 */
@@ -1628,15 +1636,25 @@ function submitRecipeOrder(){
for(var name in dishMap){
var item=dishMap[name];
var sp=item.spec;
- /* 包装规格固定为「份」,份数优先取餐品明细表编辑值,未编辑回退就餐人数 */
var baseGram=sp.baseGram||500;
- var unit='份';
- var servings=recipeServingMap[name]||item.dinerCount;
+ var portion=sp.portion||'标准份';
+ var unit=sp.unit||'份';
+ /* 采用餐品明细表所选规格 */
+ if(recipeSpecMap[name]){
+ var spParts=recipeSpecMap[name].split('|');
+ if(spParts.length>=2){
+ baseGram=parseFloat(spParts[0])||baseGram;
+ portion=spParts[1]||portion;
+ unit=spParts[2]||'份';
+ }
+ }
+ /* 份数按所选规格自动计算:每份生重>4kg 时按 4kg/份 反算,否则=就餐人数 */
+ var servings=baseGram>4000?Math.ceil(baseGram*item.dinerCount/4000):item.dinerCount;
newLines.push({
id:'L'+(Date.now()+di),
ncType:'cp',foodName:name,
spec:baseGram+'g/'+unit,
- portion:sp.portion,baseGram:baseGram,unit:unit,
+ portion:portion,baseGram:baseGram,unit:unit,
qty:servings,
dinerCount:item.dinerCount,
weight:parseFloat((baseGram*item.dinerCount/1000).toFixed(2)),
@@ -1670,7 +1688,7 @@ function sanitizeIntegerInput(el){el.value=el.value.replace(/[^\d]/g,'');}
document.getElementById('recipeDeliveryTime').value=getDefaultDeliveryTime();
document.getElementById('dailyMenuSection').style.display='none';
recipeSeasoningMap={};
- recipeServingMap={};
+ recipeSpecMap={};
onRecipeDateChange();
}
if(id==='modal-gen-history'){document.getElementById('ghDate').value='';renderGenHistory();}