对齐补餐屏接口文档:统一字段命名、简化预警逻辑、调整轮询策略

- API路径、请求头X-DEVICE-CODE、响应字段名全部对齐新接口规范
- 移除客户端三级预警计算,改用服务端lowStock二态判定
- 移除重量单位转换(接口直接返回kg)
- 成功轮询10s,失败轮询5s快速恢复

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 18:31:35 +08:00
co-authored by Claude Opus 4.7
parent 19d015c598
commit 69fd56f631
@@ -3,21 +3,21 @@
<div class="header">
<div class="times">{{ times }}</div>
<div class="title">餐厅后厨智能看板</div>
<div class="meal">当前餐次{{ dinnerType }}&emsp;{{ mealTime }}</div>
<div class="meal">当前餐次{{ mealTypeName }}&emsp;{{ mealTime }}</div>
</div>
<div class="content">
<div class="content_l">
<template v-for="item in nutritionFoodList">
<div :class="['content_l_list', item.class]">
<template v-for="item in nutritionList">
<div :class="['content_l_list', item.lowStock ? 'danger' : 'normal']">
<div class="content_l_list_name">
<div></div>
<div>{{ item.foodName }}</div>
<div :class="'content_l_list_name_' + item.class"></div>
<div>{{ item.dishName }}</div>
<div :class="'content_l_list_name_' + (item.lowStock ? 'danger' : 'normal')"></div>
</div>
<div class="content_l_list_margin">
当前余量
<countTo
:endVal="item.marginWeight_kg"
:endVal="item.remainWeightKg"
separator=""
:decimals="2"
:duration="300"
@@ -25,12 +25,12 @@
kg
</div>
<div class="content_l_list_status">
<template v-if="item.class === 'normal'">
<template v-if="!item.lowStock">
<div class="content_l_list_status_">
<div class="content_l_list_status_text">累计制作</div>
<div class="content_l_list_status_text">{{ item.serveTypeName }}</div>
<div class="content_l_list_status_value">
<countTo
:endVal="item.foodWeight_kg"
:endVal="item.totalServeKg"
separator=""
:decimals="2"
:duration="300"
@@ -39,16 +39,10 @@
</div>
</div>
</template>
<template v-if="item.class === 'warning'">
<template v-if="item.lowStock">
<div class="content_l_list_status_">
<div class="content_l_list_status_icon"></div>
<div class="content_l_list_status_text">低于预警值备菜</div>
</div>
</template>
<template v-if="item.class === 'danger'">
<div class="content_l_list_status_">
<div class="content_l_list_status_icon"></div>
<div class="content_l_list_status_text">低于警告值请补餐</div>
<div class="content_l_list_status_text">低于预警值补餐</div>
</div>
</template>
</div>
@@ -57,7 +51,7 @@
</div>
</div>
</template>
<template v-for="item in 16 - nutritionFoodList.length">
<template v-for="item in 16 - nutritionList.length">
<div class="content_l_list noData">
<div></div>
<div>无开餐数据</div>
@@ -73,13 +67,13 @@
<div class="content_r_content_table">
<div class="content_r_content_table_head">
<div>未制作</div>
<div style="color: #F8A45A">{{ recipeFoodNotMadeList.length }}</div>
<div style="color: #F8A45A">{{ unmadeList.length }}</div>
</div>
<div class="content_r_content_table_body">
<template v-for="item in recipeFoodNotMadeList">
<template v-for="item in unmadeList">
<div style="color: #FFFFFF">
<div>{{ item.foodName }}</div>
<div>{{ item.foodWeight_kg }}kg</div>
<div>{{ item.dishName }}</div>
<div>{{ item.needQuantity }}kg</div>
</div>
</template>
</div>
@@ -87,13 +81,13 @@
<div class="content_r_content_table">
<div class="content_r_content_table_head">
<div>已制作</div>
<div style="color: #5AF186">{{ recipeFoodProducedList.length }}</div>
<div style="color: #5AF186">{{ madeList.length }}</div>
</div>
<div class="content_r_content_table_body">
<template v-for="item in recipeFoodProducedList">
<template v-for="item in madeList">
<div style="color: #869CC5">
<div>{{ item.foodName }}</div>
<div>{{ item.foodWeight_kg }}kg</div>
<div>{{ item.dishName }}</div>
<div>{{ item.madeQuantity }}kg</div>
</div>
</template>
</div>
@@ -119,12 +113,12 @@ export default {
timer: null,
times: getCurrentTime(),
dinnerType: "", // 餐次
mealTime: "", // 餐次的时间
mealTypeName: "", // 餐次名称
mealTime: "", // 餐次的时间
nutritionFoodList: [], // 菜品数据
recipeFoodNotMadeList: [], // 食谱菜品未制作
recipeFoodProducedList: [], // 食谱菜品已制作
nutritionList: [], // 营养秤实时数据
unmadeList: [], // 未制作列表
madeList: [], // 已制作列表
}
},
created() {
@@ -135,67 +129,50 @@ export default {
var params = {};
var _this = this;
httpRequest("GET", "http://me.dm.yixiong-tech.com/terminal/neglect/large-screen/kitchen/info", params, {
httpRequest("GET", "https://dev.yixiong-tech.com:8081/nutrition/neglect/large-screen/kitchen", params, {
"X-DEVICE-CODE": "XIAOMI-00999",
"authorization": "57ee87183f2a4fa59683ec9ef41c8f5d"
}).then(function(res) {
_this.dinnerType = "";
_this.mealTypeName = "";
_this.mealTime = "";
_this.nutritionFoodList = [];
_this.recipeFoodNotMadeList = [];
_this.recipeFoodProducedList = [];
_this.nutritionList = [];
_this.unmadeList = [];
_this.madeList = [];
if (res && res.code === "00000" && res.data) {
_this.dinnerType = res.data.dinnerType;
_this.mealTypeName = res.data.mealTypeName || "";
if (res.data.mealTimeStart && res.data.mealTimeEnd) {
_this.mealTime = res.data.mealTimeStart + ' - ' + res.data.mealTimeEnd;
}
// 处理营养菜品列表
if (res.data.nutritionFoodList && res.data.nutritionFoodList.length) {
res.data.nutritionFoodList.map(function(item) {
if (item.marginWeight >= item.warningWeight) {
item.class = "normal";
} else if (item.marginWeight >= item.dangerWeight) {
item.class = "warning";
} else {
item.class = "danger";
}
item.foodWeight_kg = Math.round(item.foodWeight / 10) / 100;
item.marginWeight_kg = Math.round(item.marginWeight / 10) / 100;
item.progress = (1 - item.marginWeight / item.foodWeight) * 100 + '%';
// 营养秤实时数据
if (res.data.nutritionList && res.data.nutritionList.length) {
res.data.nutritionList.map(function(item) {
item.progress = item.madeWeightKg ? ((1 - item.remainWeightKg / item.madeWeightKg) * 100) + '%' : '0%';
return item;
});
_this.nutritionFoodList = res.data.nutritionFoodList;
_this.nutritionList = res.data.nutritionList;
}
// 处理已出菜品列表
if (res.data.recipeFoodNotMadeList && res.data.recipeFoodNotMadeList.length) {
res.data.recipeFoodNotMadeList.map(function(item) {
item.foodWeight_kg = Math.round(item.foodWeight / 10) / 100;
return item;
});
_this.recipeFoodNotMadeList = res.data.recipeFoodNotMadeList;
// 未制作列表
if (res.data.unmadeList && res.data.unmadeList.length) {
_this.unmadeList = res.data.unmadeList;
}
if (res.data.recipeFoodProducedList && res.data.recipeFoodProducedList.length) {
res.data.recipeFoodProducedList.map(function(item) {
item.foodWeight_kg = Math.round(item.foodWeight / 10) / 100;
return item;
});
_this.recipeFoodProducedList = res.data.recipeFoodProducedList;
// 已制作列表
if (res.data.madeList && res.data.madeList.length) {
_this.madeList = res.data.madeList;
}
}
// 模拟 finally 效果:成功时触发下一次轮询
setTimeout(function() {
_this.getKitchenInfo();
}, 10000);
}).catch(function(err) {
console.error("H5 Log: 请求出错", err);
// 模拟 finally 效果:失败时也触发下一次轮询,保证页面不卡死
setTimeout(function() {
_this.getKitchenInfo();
}, 10000);
}, 5000);
});
}
},
@@ -423,54 +400,6 @@ export default {
}
}
&.warning {
background-color: #402200;
border: 2px solid #5E4728;
.content_l_list_name {
> div:nth-of-type(1) {
background-color: #F8A45A;
}
> div:nth-of-type(2) {
color: #F6BD9E;
}
.content_l_list_name_warning {
background-image: url("@/assets/images/mealSurplusInformation/warning_name_icon.png");
}
}
.content_l_list_margin {
color: #F6BD9E;
span {
color: #F8A45A;
}
}
.content_l_list_status_ {
width: 200px;
background-color: #5A2F00;
.content_l_list_status_icon {
background-image: url("@/assets/images/mealSurplusInformation/warning_status_icon.png");
}
.content_l_list_status_text {
color: #F6BD9E;
}
}
.content_l_list_progress {
background-color: rgba(248, 164, 90, .3);
> div {
background-color: #F8A45A;
}
}
}
&.danger {
background-color: #220203;
border: 2px solid #FF3232;