Jelajahi Sumber

调整执行人的界面渲染

pm 4 bulan lalu
induk
melakukan
f9c8cbc41c
3 mengubah file dengan 52 tambahan dan 21 penghapusan
  1. 2 2
      .env
  2. 9 1
      src/api/executorHome/index.ts
  3. 41 18
      src/components/ExecutorDashboard.tsx

+ 2 - 2
.env

@@ -4,8 +4,8 @@ VITE_APP_TITLE=能量隔离系统
 # 项目本地运行端口号
 VITE_PORT=81
 # 请求路径
-VITE_BASE_URL='http://192.168.0.10:48080'
-# VITE_BASE_URL='http://120.27.232.27:9292'
+# VITE_BASE_URL='http://192.168.0.10:48080'
+VITE_BASE_URL='http://120.27.232.27:9292'
 # open 运行 npm run dev 时自动打开浏览器
 VITE_OPEN=true
 

+ 9 - 1
src/api/executorHome/index.ts

@@ -29,7 +29,7 @@ export interface ExecutorNodeVO {
   messageTemplateCode?: number;
   emailTemplateCode?: number;
   appTemplateCode?: number;
-  approvalStatus?: number; // 审批状态:1-待执行,2-进行中,3-已完成等
+  approvalStatus?: number | string; // 审批状态:1-待执行,2-进行中,3-已完成等,或字符串如 "running"
   approvalOpinion?: string;
   isolationType?: number;
   isolationPoints?: string;
@@ -42,6 +42,14 @@ export interface ExecutorNodeVO {
   startTime?: string; // 开始时间
   endTime?: string;
   createTime?: string;
+  workTime?: number | string; // 工作时间(时间戳或字符串)
+  nodeId?: number | string; // 节点ID
+  currentNodeId?: number | string; // 当前节点ID
+  currentNodeName?: string; // 当前节点名称
+  name?: string; // 作业名称
+  cancellationReason?: string | null; // 取消原因
+  cancellationTime?: string | number | null; // 取消时间
+  completionTime?: string | number | null; // 完成时间
   nodeUserList?: Array<{
     id?: number;
     workNodeId?: number;

+ 41 - 18
src/components/ExecutorDashboard.tsx

@@ -254,16 +254,17 @@ export default function ExecutorDashboard() {
     return nodeList.map((node) => ({
       ...node,
       // 映射字段以兼容表格显示
-      id: node.id,
-      nodeId: node.id || node.uuid,
-      orderNo: node.workId ? `#${node.workId}` : `#${node.id || ''}`,
-      name: node.nodeName || node.description || '未知任务',
-      currentNodeName: node.nodeName || '',
+      id: (typeof node.id === 'number' ? node.id : undefined) || (typeof node.nodeId === 'number' ? node.nodeId : undefined),
+      nodeId: node.nodeId || node.id || node.uuid,
+      orderNo: node.orderNo || (node.workId ? String(node.workId) : String(node.id || '')),
+      name: node.name || '未知任务',
+      currentNodeName: node.currentNodeName || node.nodeName || '',
+      currentNodeId: node.currentNodeId || node.nodeId,
       approvalStatus: node.approvalStatus,
       taskStatus: node.approvalStatus,
       status: node.approvalStatus,
-      workTime: node.startTime,
-      taskStartTime: node.startTime,
+      workTime: node.workTime || node.startTime,
+      startTime: node.startTime || (node.workTime ? String(node.workTime) : undefined), // 使用 workTime 作为开始时间(转换为字符串)
       workerUserName: node.workerUserName || node.initiatorName || '',
       urgencyLevel: node.urgencyLevel !== undefined && node.urgencyLevel !== null ? node.urgencyLevel : '', // 从接口数据中获取(保留0值)
       workType: node.workType !== undefined && node.workType !== null ? node.workType : '', // 从接口数据中获取(保留0值)
@@ -287,7 +288,7 @@ export default function ExecutorDashboard() {
     if (statusStr === 'pending' || statusStr === '待执行' || statusStr === '待开始' || statusStr === '未开始' || statusStr === 'unaudited' || statusStr === '1') {
       return '待执行';
     }
-    if (statusStr === '进行中' || statusStr === 'in_progress' || statusStr === '执行中' || statusStr === '2') {
+    if (statusStr === 'running' || statusStr === '进行中' || statusStr === 'in_progress' || statusStr === '执行中' || statusStr === '2') {
       return '进行中';
     }
     if (statusStr === 'completed' || statusStr === '已完成' || statusStr === 'approved' || statusStr === '已通过' || statusStr === '3') {
@@ -1336,13 +1337,23 @@ export default function ExecutorDashboard() {
       key: 'orderNo',
       width: 120,
       render: (_: any, record: ExecutorNodeVO) => {
-        return record.workId ? String(record.workId) : String(record.id || '');
+        return record.orderNo || '-';
+      },
+    },
+    {
+      title: '作业名称',
+      dataIndex: 'name',
+      key: 'name',
+      width: 200,
+      ellipsis: true,
+      render: (text: string) => {
+        return text || '-';
       },
     },
     {
       title: '任务名称',
-      dataIndex: 'nodeName',
-      key: 'nodeName',
+      dataIndex: 'currentNodeName',
+      key: 'currentNodeName',
       width: 200,
       ellipsis: true,
       render: (text: string, record: ExecutorNodeVO) => {
@@ -1364,9 +1375,11 @@ export default function ExecutorDashboard() {
           return { color: '#6b7280' }; // 一般:灰色
         };
         
+        const nodeName = text || record.currentNodeName || record.nodeName || record.description || '未知任务';
+        
         return (
           <div>
-            <div>{text || record.description || '未知任务'}</div>
+            <div>{nodeName}</div>
             {urgencyValue !== undefined && urgencyValue !== null && urgencyValue !== '' && (
               <div className="text-xs mt-1" style={getPriorityStyle(urgencyValue)}>
                 优先级:{priorityText}
@@ -1389,15 +1402,25 @@ export default function ExecutorDashboard() {
     },
     {
       title: '开始时间',
-      dataIndex: 'startTime',
-      key: 'startTime',
+      dataIndex: 'workTime',
+      key: 'workTime',
       width: 180,
-      render: (text: any) => {
-        if (!text) return '-';
+      render: (text: any, record: ExecutorNodeVO) => {
+        const timeValue = text || record.workTime || record.startTime;
+        if (!timeValue) return '-';
         try {
-          return formatDateWithFormat(text, 'YYYY-MM-DD HH:mm:ss');
+          // 如果是数字(时间戳),需要处理
+          if (typeof timeValue === 'number') {
+            // 如果是秒级时间戳,转换为毫秒
+            let timestamp = timeValue;
+            if (timestamp < 10000000000) {
+              timestamp = timestamp * 1000;
+            }
+            return formatDateWithFormat(timestamp, 'YYYY-MM-DD HH:mm:ss');
+          }
+          return formatDateWithFormat(timeValue, 'YYYY-MM-DD HH:mm:ss');
         } catch (e) {
-          return String(text);
+          return String(timeValue);
         }
       },
     },