瀏覽代碼

重新提交流程设计相关tsx文件

wyn 1 周之前
父節點
當前提交
ad679dcc2e
共有 2 個文件被更改,包括 159 次插入0 次删除
  1. 96 0
      src/utils/workflowNodePanelUi.ts
  2. 63 0
      src/utils/workflowNodeTypes.ts

+ 96 - 0
src/utils/workflowNodePanelUi.ts

@@ -0,0 +1,96 @@
+/**
+ * 流程节点右侧面板共用 UI:节点图标资源与说明文案(与 ProcessDesigner 保持一致)
+ */
+
+const iconCategories: Record<string, { start: number; end: number }> = {
+  审核: { start: 1000, end: 1011 },
+  开始: { start: 2000, end: 2016 },
+  录入: { start: 3000, end: 3028 },
+  确认: { start: 4000, end: 4024 },
+  结束: { start: 5000, end: 5018 },
+  能量隔离: { start: 6000, end: 6027 },
+  解除隔离: { start: 7000, end: 7021 },
+};
+
+const iconModules = import.meta.glob('../assets/节点图标/**/*.png', { eager: true, as: 'url' });
+
+export function generateIconPaths(category: string): Array<{ id: string; fileName: string; path: string }> {
+  const config = iconCategories[category];
+  if (!config) return [];
+
+  const paths: Array<{ id: string; fileName: string; path: string }> = [];
+  const allKeys = Object.keys(iconModules);
+
+  if (allKeys.length > 0) {
+    for (let i = config.start; i <= config.end; i++) {
+      const fileName = `${i}.png`;
+      const matchingKey = allKeys.find((k) => {
+        const normalizedKey = k.replace(/\\/g, '/').toLowerCase();
+        const normalizedCategory = category.toLowerCase();
+        const normalizedFileName = fileName.toLowerCase();
+        return normalizedKey.includes(normalizedCategory) && normalizedKey.endsWith(normalizedFileName);
+      });
+      if (matchingKey) {
+        paths.push({ id: `${category}_${i}`, fileName, path: iconModules[matchingKey] as string });
+      }
+    }
+  } else {
+    for (let i = config.start; i <= config.end; i++) {
+      try {
+        const fileName = `${i}.png`;
+        const iconPath = new URL(`../assets/节点图标/${category}/${fileName}`, import.meta.url).href;
+        paths.push({ id: `${category}_${i}`, fileName, path: iconPath });
+      } catch {
+        /* skip */
+      }
+    }
+  }
+  return paths;
+}
+
+export function getIconPathByFileName(fileName: string | undefined): string | null {
+  if (!fileName) return null;
+  let actualFileName = fileName;
+  if (fileName.includes('/') || fileName.includes('\\')) {
+    const pathParts = fileName.replace(/\\/g, '/').split('/');
+    actualFileName = pathParts[pathParts.length - 1];
+  }
+  const match = actualFileName.match(/^(\d+)\.png$/);
+  if (!match) return null;
+  const iconNumber = parseInt(match[1], 10);
+  let category = '';
+  if (iconNumber >= 1000 && iconNumber <= 1011) category = '审核';
+  else if (iconNumber >= 2000 && iconNumber <= 2016) category = '开始';
+  else if (iconNumber >= 3000 && iconNumber <= 3028) category = '录入';
+  else if (iconNumber >= 4000 && iconNumber <= 4024) category = '确认';
+  else if (iconNumber >= 5000 && iconNumber <= 5018) category = '结束';
+  else if (iconNumber >= 6000 && iconNumber <= 6027) category = '能量隔离';
+  else if (iconNumber >= 7000 && iconNumber <= 7021) category = '解除隔离';
+  if (!category) return null;
+  const allKeys = Object.keys(iconModules);
+  const matchingKey = allKeys.find((k) => {
+    const normalizedKey = k.replace(/\\/g, '/').toLowerCase();
+    return normalizedKey.includes(category.toLowerCase()) && normalizedKey.endsWith(actualFileName.toLowerCase());
+  });
+  if (matchingKey) return iconModules[matchingKey] as string;
+  return null;
+}
+
+/** 与 ProcessDesigner 中 getNodeDescription 文案一致 */
+export function getWorkflowNodeDescription(type: string): string {
+  const descriptions: Record<string, string> = {
+    createJob: '该节点为作业创建人员创建作业录入信息开始节点。',
+    confirm: '该节点为作业确认,为"上一节点"操作分配确认模式及确认人员权限',
+    review: '该节点为作业审核,为"上一节点"操作分配审核模式及审核人员权限',
+    inputInfo: '该节点为作业录入提交,可提交信息或图片,主要为"信息确认"',
+    lock: '该节点为作业隔离类型选择,主要包括盲板,上锁挂牌,拆除等。',
+    unlock: '该节点在解锁时与所选上锁节点保持隔离方式等信息一致。',
+    coLock: '该节点需选择流程中的上锁任务并配置共锁人;隔离信息随所选上锁任务一致。',
+    unlockCoLock: '该节点在解除共锁时与所选共锁节点保持隔离方式等信息一致。',
+    isolation: '该节点为作业隔离类型选择,主要包括盲板,上锁挂牌,拆除等。',
+    releaseIsolation: '该节点为作业隔离类型选择,主要包括盲板,上锁挂牌,拆除等。',
+    returnLock: '该节点为还锁操作,归还钥匙,确认隔离操作完成',
+    complete: '该节点为流程结束点',
+  };
+  return descriptions[type] || '该节点的功能描述。';
+}

+ 63 - 0
src/utils/workflowNodeTypes.ts

@@ -0,0 +1,63 @@
+/**
+ * 流程节点 type 判定(含历史数据:isolation / releaseIsolation 及中文旧值)
+ */
+
+export function isWorkflowLockSchemeType(t: string | undefined | null): boolean {
+  return t === 'lock' || t === 'isolation' || t === '隔离' || t === '隔离/方案';
+}
+
+export function isWorkflowUnlockSchemeType(t: string | undefined | null): boolean {
+  return t === 'unlock' || t === 'releaseIsolation' || t === '解除隔离';
+}
+
+export function isWorkflowCoLockType(t: string | undefined | null): boolean {
+  return t === 'coLock' || t === '共锁';
+}
+
+export function isWorkflowUnlockCoLockType(t: string | undefined | null): boolean {
+  return t === 'unlockCoLock' || t === '解除共锁';
+}
+
+/** 与「上锁」节点相同的校验与配置结构(含共锁) */
+export function isWorkflowLockLikeValidationType(t: string | undefined | null): boolean {
+  return isWorkflowLockSchemeType(t) || isWorkflowCoLockType(t);
+}
+
+/** 与「解锁」节点相同的校验结构(含解除共锁) */
+export function isWorkflowUnlockLikeValidationType(t: string | undefined | null): boolean {
+  return isWorkflowUnlockSchemeType(t) || isWorkflowUnlockCoLockType(t);
+}
+
+/** 右侧配置:隔离方式、隔离点、关联方案节点等整块 UI */
+export function isWorkflowIsolationSchemePanelType(t: string | undefined | null): boolean {
+  return (
+    isWorkflowLockSchemeType(t) ||
+    isWorkflowUnlockSchemeType(t) ||
+    isWorkflowCoLockType(t) ||
+    isWorkflowUnlockCoLockType(t)
+  );
+}
+
+/** 画布/持久化中的 type 映射到当前左侧模板节点 type(用于 nodeConfigs 来查找) */
+export function resolveWorkflowPaletteType(t: string | undefined | null): string {
+  if (!t) return '';
+  if (t === 'isolation' || t === '隔离' || t === '隔离/方案') return 'lock';
+  if (t === 'releaseIsolation' || t === '解除隔离') return 'unlock';
+  if (t === '共锁') return 'coLock';
+  if (t === '解除共锁') return 'unlockCoLock';
+  return t;
+}
+
+/** 解除类节点关联的「方案源」节点 type 是否匹配 */
+export function isWorkflowUnlockParentMatch(
+  unlockNodeType: string | undefined | null,
+  parentNodeType: string | undefined | null
+): boolean {
+  if (isWorkflowUnlockCoLockType(unlockNodeType)) {
+    return isWorkflowCoLockType(parentNodeType);
+  }
+  if (isWorkflowUnlockSchemeType(unlockNodeType)) {
+    return isWorkflowLockSchemeType(parentNodeType);
+  }
+  return false;
+}