Explorar el Código

修复作业节点更新报错问题

pm hace 3 meses
padre
commit
ad5f445dd5
Se han modificado 1 ficheros con 29 adiciones y 8 borrados
  1. 29 8
      src/components/IsolationWork.tsx

+ 29 - 8
src/components/IsolationWork.tsx

@@ -1801,7 +1801,7 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
       if (!config.isolationType || config.isolationType === '') {
         return false;
       }
-      if (config.isolationPoints.length === 0) {
+      if (!config.isolationPoints || !Array.isArray(config.isolationPoints) || config.isolationPoints.length === 0) {
         return false;
       }
       // 字典值:0=盲板,1=上锁挂牌,2=拆除
@@ -1983,6 +1983,7 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
               (item.type === 'isolation' || item.type === '隔离' || item.type === '隔离/方案')
           )
         : null;
+      // 解除隔离节点:仅从隔离/方案携带「隔离方式」及以下数据;节点名称、业务表单保持解除隔离节点自身不变
       const dataSource = isolationNodeDO ?? nodeDO;
       let nodeData: any = {};
       if (dataSource.data) {
@@ -1993,6 +1994,13 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
         }
       }
       const source = nodeData || node.data || {};
+      // 解除隔离节点自身的 data(仅用于 nodeName、submitForm 保持本节点)
+      let releaseNodeData: any = {};
+      if (isReleaseIsolation && isolationNodeDO && nodeDO.data) {
+        try {
+          releaseNodeData = typeof nodeDO.data === 'string' ? JSON.parse(nodeDO.data) : nodeDO.data;
+        } catch (_) {}
+      }
       
       let lockPersonId: string | number = '';
       const coLockPersonIds: (string | number)[] = [];
@@ -2021,8 +2029,11 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
         isolationPoints = source.isolationPoints || [];
       }
       
+      const fromIsolationOnly = isReleaseIsolation && isolationNodeDO;
       const nodeConfig = {
-        nodeName: dataSource.nodeName || source.label || config?.label || '',
+        nodeName: fromIsolationOnly
+          ? (nodeDO.nodeName || releaseNodeData.label || node.data?.label || config?.label || '')
+          : (dataSource.nodeName || source.label || config?.label || ''),
         nodeIcon: (isolationNodeDO ? nodeDO.nodeIcon : dataSource.nodeIcon) || source.icon || '',
         responsible: (dataSource.workerUserId !== null && dataSource.workerUserId !== undefined && dataSource.workerUserId !== 0)
           ? (typeof dataSource.workerUserId === 'number' ? dataSource.workerUserId : Number(dataSource.workerUserId))
@@ -2030,7 +2041,9 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
             ? (typeof source.workerUserId === 'number' ? source.workerUserId : Number(source.workerUserId))
             : undefined,
         remark: source.remark || '',
-        submitForm: dataSource.formId ? (typeof dataSource.formId === 'number' ? dataSource.formId : Number(dataSource.formId)) : (source.submitForm ? (typeof source.submitForm === 'number' ? source.submitForm : Number(source.submitForm)) : undefined),
+        submitForm: fromIsolationOnly
+          ? (nodeDO.formId != null && nodeDO.formId !== '' ? (typeof nodeDO.formId === 'number' ? nodeDO.formId : Number(nodeDO.formId)) : (releaseNodeData.submitForm != null ? (typeof releaseNodeData.submitForm === 'number' ? releaseNodeData.submitForm : Number(releaseNodeData.submitForm)) : undefined))
+          : (dataSource.formId ? (typeof dataSource.formId === 'number' ? dataSource.formId : Number(dataSource.formId)) : (source.submitForm ? (typeof source.submitForm === 'number' ? source.submitForm : Number(source.submitForm)) : undefined)),
         isolationType: (dataSource.isolationType !== null && dataSource.isolationType !== undefined) ? String(dataSource.isolationType) : (source.isolationType || ''),
         isolationPoints,
         isolationNode: source.isolationNode || [],
@@ -4412,8 +4425,16 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
 
                 {workJobStep === 1 && (
                   <div className="flex gap-4" style={{ height: 'calc(80vh - 250px)' }}>
-                      {/* 左侧:流程设计渲染区域(面积大一些) */}
-                      <div className="flex-1 border border-gray-200 rounded-lg overflow-hidden bg-gray-50" style={{ minWidth: 0 }}>
+                      {/* 左侧:流程设计渲染区域(面积大一些),带点状网状背景 */}
+                      <div
+                        className="flex-1 border border-gray-200 rounded-lg overflow-hidden"
+                        style={{
+                          minWidth: 0,
+                          backgroundColor: '#f8fafc',
+                          backgroundImage: 'radial-gradient(circle at center, #cbd5e1 1.2px, transparent 1.2px)',
+                          backgroundSize: '14px 14px',
+                        }}
+                      >
                       {workflowNodes.length > 0 ? (
                         <div className="h-full" ref={workflowReactFlowWrapper}>
                           <style>{`
@@ -4504,7 +4525,7 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
                             edgesUpdatable={!isViewMode}
                           >
                             <Controls className="!bg-white !border !border-gray-200 !rounded-lg !shadow-md" />
-                            <Background variant={BackgroundVariant.Dots} gap={16} size={1} color="#e5e7eb" />
+                            <Background variant={BackgroundVariant.Dots} gap={12} size={1.5} color="#cbd5e1" />
                           </ReactFlow>
                         </div>
                       ) : (
@@ -5170,7 +5191,7 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
                                         formId: formId,
                                         workerUserId: workflowNodeConfig.responsible ? Number(workflowNodeConfig.responsible) : undefined,
                                         isolationType: workflowNodeConfig.isolationType || undefined,
-                                        isolationPoints: workflowNodeConfig.isolationPoints && workflowNodeConfig.isolationPoints.length > 0 
+                                        isolationPoints: workflowNodeConfig.isolationPoints && Array.isArray(workflowNodeConfig.isolationPoints) && workflowNodeConfig.isolationPoints.length > 0 
                                           ? JSON.stringify(workflowNodeConfig.isolationPoints) 
                                           : undefined,
                                         // 如果是解除隔离节点,传递选中的隔离节点UUID
@@ -5179,7 +5200,7 @@ export default function IsolationWork({ subMenu }: IsolationWorkProps) {
                                           : undefined,
                                         nodeUserDOList: nodeUserDOList.length > 0 ? nodeUserDOList : undefined,
                                         lockPerson,
-                                        colockPersons: colockPersons.length > 0 ? colockPersons : undefined,
+                                        colockPersons: (colockPersons != null && colockPersons.length > 0) ? colockPersons : undefined,
                                         // 如果获取到了表单数据,将整个对象内容转换成字符串传递给 formData 字段
                                         formData: formData,
                                         // 根据选中值传递模板代码参数(字符串类型的 'true' 或 'false')