Explorar el Código

修复作业管理和任务管理对紧急程度的渲染调整

pm hace 4 meses
padre
commit
d790809921
Se han modificado 3 ficheros con 57 adiciones y 150 borrados
  1. 19 50
      src/components/IsolationWork.tsx
  2. 19 50
      src/components/MyTask.tsx
  3. 19 50
      src/components/TaskManagement.tsx

+ 19 - 50
src/components/IsolationWork.tsx

@@ -3132,9 +3132,9 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
     };
   };
 
-  // 获取紧急程度图标和样式
-  const getUrgencyLevelIconAndStyle = (urgencyText: string): { icon: React.ReactNode; style: React.CSSProperties } => {
-    if (!urgencyText || urgencyText === '-') {
+  // 获取紧急程度图标和样式(根据字典 value 判断:0=一般,1=紧急,2=非常紧急)
+  const getUrgencyLevelIconAndStyle = (urgencyValue: string | number | undefined): { icon: React.ReactNode; style: React.CSSProperties } => {
+    if (urgencyValue === null || urgencyValue === undefined || urgencyValue === '') {
       return {
         icon: null,
         style: {
@@ -3144,15 +3144,15 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
       };
     }
     
-    const urgencyTextLower = urgencyText.toLowerCase();
+    const value = Number(urgencyValue);
     
-    // 正常:使用 urgecy1.png 图标 + "正常"文字(黑色)
-    if (urgencyTextLower.includes('正常') || urgencyTextLower.includes('normal') || urgencyTextLower.includes('普通')) {
+    // 0 = 一般:使用 urgecy1.png 图标 + 黑色文字
+    if (value === 0) {
       return {
         icon: (
           <img 
             src={urgecy1Icon} 
-            alt="正常" 
+            alt="一般" 
             className="w-5 h-5 flex-shrink-0 mr-1.5"
             style={{ objectFit: 'contain' }}
           />
@@ -3164,39 +3164,27 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
       };
     }
     
-    // 已处理:使用 urgecy1.png 图标 + "已处理"文字(黑色)
-    if (urgencyTextLower.includes('已处理') || urgencyTextLower.includes('processed') || urgencyTextLower.includes('handled')) {
+    // 1 = 紧急:使用 urgecy2.png 图标 + 橙色加粗文字
+    if (value === 1) {
       return {
         icon: (
           <img 
-            src={urgecy1Icon} 
-            alt="已处理" 
+            src={urgecy2Icon} 
+            alt="紧急" 
             className="w-5 h-5 flex-shrink-0 mr-1.5"
             style={{ objectFit: 'contain' }}
           />
         ),
         style: {
           backgroundColor: 'transparent',
-          color: '#000000',
-        },
-      };
-    }
-    
-    // 警示线:橙色三角形警告图标 + "警示线"文字(先判断,避免与紧急混淆)
-    if (urgencyTextLower.includes('警示线') || urgencyTextLower.includes('warning line') || urgencyTextLower.includes('alert line')) {
-      return {
-        icon: (
-          <WarningOutlined className="text-orange-500" style={{ fontSize: '16px' }} />
-        ),
-        style: {
-          backgroundColor: 'transparent',
-          color: '#333333',
+          color: '#fa8c16',
+          fontWeight: 'bold',
         },
       };
     }
     
-    // 非常紧急:使用 urgecy3.png 图标 + "非常紧急"文字(红色加粗,先判断,避免与紧急混淆)
-    if (urgencyTextLower.includes('非常紧急') || urgencyTextLower.includes('very urgent') || urgencyTextLower.includes('特急')) {
+    // 2 = 非常紧急:使用 urgecy3.png 图标 + 红色加粗文字
+    if (value === 2) {
       return {
         icon: (
           <img 
@@ -3214,25 +3202,6 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
       };
     }
     
-    // 紧急:使用 urgecy2.png 图标 + "紧急"文字(橙色加粗)
-    if (urgencyTextLower.includes('紧急') || urgencyTextLower.includes('urgent')) {
-      return {
-        icon: (
-          <img 
-            src={urgecy2Icon} 
-            alt="紧急" 
-            className="w-5 h-5 flex-shrink-0 mr-1.5"
-            style={{ objectFit: 'contain' }}
-          />
-        ),
-        style: {
-          backgroundColor: 'transparent',
-          color: '#fa8c16',
-          fontWeight: 'bold',
-        },
-      };
-    }
-    
     // 如果没有匹配到,默认灰色
     return {
       icon: null,
@@ -3244,8 +3213,8 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
   };
 
   // 获取紧急程度样式(保留用于向后兼容)
-  const getUrgencyLevelStyle = (urgencyText: string): React.CSSProperties => {
-    return getUrgencyLevelIconAndStyle(urgencyText).style;
+  const getUrgencyLevelStyle = (urgencyValue: string | number | undefined): React.CSSProperties => {
+    return getUrgencyLevelIconAndStyle(urgencyValue).style;
   };
 
   // 作业管理表格列配置
@@ -3358,11 +3327,11 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
         const urgencyItem = urgencyLevelDictList.find(item => String(item.value) === String(urgencyValue));
         const urgencyText = urgencyItem ? (urgencyItem.label || '') : (urgencyValue ? String(urgencyValue) : '-');
         
-        if (!urgencyValue || urgencyText === '-') {
+        if (!urgencyValue || urgencyValue === null || urgencyValue === undefined || urgencyValue === '') {
           return <span>-</span>;
         }
         
-        const { icon, style } = getUrgencyLevelIconAndStyle(urgencyText);
+        const { icon, style } = getUrgencyLevelIconAndStyle(urgencyValue);
         
         return (
           <span 

+ 19 - 50
src/components/MyTask.tsx

@@ -1459,9 +1459,9 @@ export default function MyTask() {
   };
 
   // 获取紧急程度样式
-  // 获取紧急程度图标和样式
-  const getUrgencyLevelIconAndStyle = (urgencyText: string): { icon: React.ReactNode; style: React.CSSProperties } => {
-    if (!urgencyText || urgencyText === '-') {
+  // 获取紧急程度图标和样式(根据字典 value 判断:0=一般,1=紧急,2=非常紧急)
+  const getUrgencyLevelIconAndStyle = (urgencyValue: string | number | undefined): { icon: React.ReactNode; style: React.CSSProperties } => {
+    if (urgencyValue === null || urgencyValue === undefined || urgencyValue === '') {
       return {
         icon: null,
         style: {
@@ -1471,15 +1471,15 @@ export default function MyTask() {
       };
     }
     
-    const urgencyTextLower = urgencyText.toLowerCase();
+    const value = Number(urgencyValue);
     
-    // 正常:使用 urgecy1.png 图标 + "正常"文字(黑色)
-    if (urgencyTextLower.includes('正常') || urgencyTextLower.includes('normal') || urgencyTextLower.includes('普通')) {
+    // 0 = 一般:使用 urgecy1.png 图标 + 黑色文字
+    if (value === 0) {
       return {
         icon: (
           <img 
             src={urgecy1Icon} 
-            alt="正常" 
+            alt="一般" 
             className="w-5 h-5 flex-shrink-0 mr-1.5"
             style={{ objectFit: 'contain' }}
           />
@@ -1491,39 +1491,27 @@ export default function MyTask() {
       };
     }
     
-    // 已处理:使用 urgecy1.png 图标 + "已处理"文字(黑色)
-    if (urgencyTextLower.includes('已处理') || urgencyTextLower.includes('processed') || urgencyTextLower.includes('handled')) {
+    // 1 = 紧急:使用 urgecy2.png 图标 + 橙色加粗文字
+    if (value === 1) {
       return {
         icon: (
           <img 
-            src={urgecy1Icon} 
-            alt="已处理" 
+            src={urgecy2Icon} 
+            alt="紧急" 
             className="w-5 h-5 flex-shrink-0 mr-1.5"
             style={{ objectFit: 'contain' }}
           />
         ),
         style: {
           backgroundColor: 'transparent',
-          color: '#000000',
-        },
-      };
-    }
-    
-    // 警示线:橙色三角形警告图标 + "警示线"文字(先判断,避免与紧急混淆)
-    if (urgencyTextLower.includes('警示线') || urgencyTextLower.includes('warning line') || urgencyTextLower.includes('alert line')) {
-      return {
-        icon: (
-          <WarningOutlined className="text-orange-500" style={{ fontSize: '16px' }} />
-        ),
-        style: {
-          backgroundColor: 'transparent',
-          color: '#333333',
+          color: '#fa8c16',
+          fontWeight: 'bold',
         },
       };
     }
     
-    // 非常紧急:使用 urgecy3.png 图标 + "非常紧急"文字(红色加粗,先判断,避免与紧急混淆)
-    if (urgencyTextLower.includes('非常紧急') || urgencyTextLower.includes('very urgent') || urgencyTextLower.includes('特急')) {
+    // 2 = 非常紧急:使用 urgecy3.png 图标 + 红色加粗文字
+    if (value === 2) {
       return {
         icon: (
           <img 
@@ -1541,25 +1529,6 @@ export default function MyTask() {
       };
     }
     
-    // 紧急:使用 urgecy2.png 图标 + "紧急"文字(橙色加粗)
-    if (urgencyTextLower.includes('紧急') || urgencyTextLower.includes('urgent')) {
-      return {
-        icon: (
-          <img 
-            src={urgecy2Icon} 
-            alt="紧急" 
-            className="w-5 h-5 flex-shrink-0 mr-1.5"
-            style={{ objectFit: 'contain' }}
-          />
-        ),
-        style: {
-          backgroundColor: 'transparent',
-          color: '#fa8c16',
-          fontWeight: 'bold',
-        },
-      };
-    }
-    
     // 如果没有匹配到,默认灰色
     return {
       icon: null,
@@ -1571,8 +1540,8 @@ export default function MyTask() {
   };
 
   // 获取紧急程度样式(保留用于向后兼容)
-  const getUrgencyLevelStyle = (urgencyText: string): React.CSSProperties => {
-    return getUrgencyLevelIconAndStyle(urgencyText).style;
+  const getUrgencyLevelStyle = (urgencyValue: string | number | undefined): React.CSSProperties => {
+    return getUrgencyLevelIconAndStyle(urgencyValue).style;
   };
 
   // 表格列配置
@@ -1673,11 +1642,11 @@ export default function MyTask() {
         const urgencyItem = urgencyLevelDictList.find(item => String(item.value) === String(urgencyValue));
         const urgencyText = urgencyItem ? (urgencyItem.label || '') : (urgencyValue ? String(urgencyValue) : '-');
         
-        if (!urgencyValue || urgencyText === '-') {
+        if (!urgencyValue || urgencyValue === null || urgencyValue === undefined || urgencyValue === '') {
           return <span>-</span>;
         }
         
-        const { icon, style } = getUrgencyLevelIconAndStyle(urgencyText);
+        const { icon, style } = getUrgencyLevelIconAndStyle(urgencyValue);
         
         return (
           <span 

+ 19 - 50
src/components/TaskManagement.tsx

@@ -1458,9 +1458,9 @@ export default function TaskManagement() {
   };
 
   // 获取紧急程度样式
-  // 获取紧急程度图标和样式
-  const getUrgencyLevelIconAndStyle = (urgencyText: string): { icon: React.ReactNode; style: React.CSSProperties } => {
-    if (!urgencyText || urgencyText === '-') {
+  // 获取紧急程度图标和样式(根据字典 value 判断:0=一般,1=紧急,2=非常紧急)
+  const getUrgencyLevelIconAndStyle = (urgencyValue: string | number | undefined): { icon: React.ReactNode; style: React.CSSProperties } => {
+    if (urgencyValue === null || urgencyValue === undefined || urgencyValue === '') {
       return {
         icon: null,
         style: {
@@ -1470,15 +1470,15 @@ export default function TaskManagement() {
       };
     }
     
-    const urgencyTextLower = urgencyText.toLowerCase();
+    const value = Number(urgencyValue);
     
-    // 正常:使用 urgecy1.png 图标 + "正常"文字(黑色)
-    if (urgencyTextLower.includes('正常') || urgencyTextLower.includes('normal') || urgencyTextLower.includes('普通')) {
+    // 0 = 一般:使用 urgecy1.png 图标 + 黑色文字
+    if (value === 0) {
       return {
         icon: (
           <img 
             src={urgecy1Icon} 
-            alt="正常" 
+            alt="一般" 
             className="w-5 h-5 flex-shrink-0 mr-1.5"
             style={{ objectFit: 'contain' }}
           />
@@ -1490,39 +1490,27 @@ export default function TaskManagement() {
       };
     }
     
-    // 已处理:使用 urgecy1.png 图标 + "已处理"文字(黑色)
-    if (urgencyTextLower.includes('已处理') || urgencyTextLower.includes('processed') || urgencyTextLower.includes('handled')) {
+    // 1 = 紧急:使用 urgecy2.png 图标 + 橙色加粗文字
+    if (value === 1) {
       return {
         icon: (
           <img 
-            src={urgecy1Icon} 
-            alt="已处理" 
+            src={urgecy2Icon} 
+            alt="紧急" 
             className="w-5 h-5 flex-shrink-0 mr-1.5"
             style={{ objectFit: 'contain' }}
           />
         ),
         style: {
           backgroundColor: 'transparent',
-          color: '#000000',
-        },
-      };
-    }
-    
-    // 警示线:橙色三角形警告图标 + "警示线"文字(先判断,避免与紧急混淆)
-    if (urgencyTextLower.includes('警示线') || urgencyTextLower.includes('warning line') || urgencyTextLower.includes('alert line')) {
-      return {
-        icon: (
-          <WarningOutlined className="text-orange-500" style={{ fontSize: '16px' }} />
-        ),
-        style: {
-          backgroundColor: 'transparent',
-          color: '#333333',
+          color: '#fa8c16',
+          fontWeight: 'bold',
         },
       };
     }
     
-    // 非常紧急:使用 urgecy3.png 图标 + "非常紧急"文字(红色加粗,先判断,避免与紧急混淆)
-    if (urgencyTextLower.includes('非常紧急') || urgencyTextLower.includes('very urgent') || urgencyTextLower.includes('特急')) {
+    // 2 = 非常紧急:使用 urgecy3.png 图标 + 红色加粗文字
+    if (value === 2) {
       return {
         icon: (
           <img 
@@ -1540,25 +1528,6 @@ export default function TaskManagement() {
       };
     }
     
-    // 紧急:使用 urgecy2.png 图标 + "紧急"文字(橙色加粗)
-    if (urgencyTextLower.includes('紧急') || urgencyTextLower.includes('urgent')) {
-      return {
-        icon: (
-          <img 
-            src={urgecy2Icon} 
-            alt="紧急" 
-            className="w-5 h-5 flex-shrink-0 mr-1.5"
-            style={{ objectFit: 'contain' }}
-          />
-        ),
-        style: {
-          backgroundColor: 'transparent',
-          color: '#fa8c16',
-          fontWeight: 'bold',
-        },
-      };
-    }
-    
     // 如果没有匹配到,默认灰色
     return {
       icon: null,
@@ -1570,8 +1539,8 @@ export default function TaskManagement() {
   };
 
   // 获取紧急程度样式(保留用于向后兼容)
-  const getUrgencyLevelStyle = (urgencyText: string): React.CSSProperties => {
-    return getUrgencyLevelIconAndStyle(urgencyText).style;
+  const getUrgencyLevelStyle = (urgencyValue: string | number | undefined): React.CSSProperties => {
+    return getUrgencyLevelIconAndStyle(urgencyValue).style;
   };
 
   // 表格列配置
@@ -1672,11 +1641,11 @@ export default function TaskManagement() {
         const urgencyItem = urgencyLevelDictList.find(item => String(item.value) === String(urgencyValue));
         const urgencyText = urgencyItem ? (urgencyItem.label || '') : (urgencyValue ? String(urgencyValue) : '-');
         
-        if (!urgencyValue || urgencyText === '-') {
+        if (!urgencyValue || urgencyValue === null || urgencyValue === undefined || urgencyValue === '') {
           return <span>-</span>;
         }
         
-        const { icon, style } = getUrgencyLevelIconAndStyle(urgencyText);
+        const { icon, style } = getUrgencyLevelIconAndStyle(urgencyValue);
         
         return (
           <span