From 1ba2f3d3223644d2eb6081d825db76270c44ff12 Mon Sep 17 00:00:00 2001
From: tony.cheng <chengmingwei_1984122@126.com>
Date: Tue, 17 Mar 2026 13:37:39 +0800
Subject: [PATCH] fix: 修复caseState类型比较问题,使用Number()转换确保字符串和数字类型都能正确匹配
---
web-app/src/components/dashboard/TabContainer.jsx | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/web-app/src/components/dashboard/TabContainer.jsx b/web-app/src/components/dashboard/TabContainer.jsx
index 40b8521..490f498 100644
--- a/web-app/src/components/dashboard/TabContainer.jsx
+++ b/web-app/src/components/dashboard/TabContainer.jsx
@@ -165,6 +165,16 @@
const timeline = caseData || {};
const caseState = timeline.mediation?.state;
+ // 调试日志:输出关键数据
+ useEffect(() => {
+ console.log('===== MediationBoard 数据状态 =====');
+ console.log('caseData:', caseData);
+ console.log('timeline:', timeline);
+ console.log('caseState:', caseState);
+ console.log('mediation:', timeline.mediation);
+ console.log('================================');
+ }, [caseData, caseState, timeline]);
+
// person_type到avatar类型的映射
const getAvatarType = (personType) => {
const typeMap = {
@@ -354,29 +364,35 @@
// 状态控制按钮显示逻辑
const shouldShowControlButton = () => {
- const show = caseState === 0 || caseState === 1 || caseState === 5;
+ // 转换为数字类型进行比较,兼容字符串和数字
+ const stateNum = Number(caseState);
+ const show = stateNum === 0 || stateNum === 1 || stateNum === 5;
console.log('状态控制按钮显示检查:', {
caseState,
+ caseStateType: typeof caseState,
+ stateNum,
show,
conditions: {
- 'caseState === 0': caseState === 0,
- 'caseState === 1': caseState === 1,
- 'caseState === 5': caseState === 5
+ 'stateNum === 0': stateNum === 0,
+ 'stateNum === 1': stateNum === 1,
+ 'stateNum === 5': stateNum === 5
}
});
return show;
};
const getControlButtonProps = () => {
- console.log('获取按钮属性:', { caseState });
+ // 转换为数字类型进行比较
+ const stateNum = Number(caseState);
+ console.log('获取按钮属性:', { caseState, caseStateType: typeof caseState, stateNum });
- if (caseState === 0 || caseState === 1) {
+ if (stateNum === 0 || stateNum === 1) {
return {
text: '终止',
style: 'terminate',
action: 'terminate'
};
- } else if (caseState === 5) {
+ } else if (stateNum === 5) {
return {
text: '恢复',
style: 'resume',
--
Gitblit v1.8.0