zhangwencui
6 天以前 dab35bff798cfce2ddf7e8a67e4e1cdb144f5b4c
fix(bpm): 修复 App 发起流程表单加载异常
已修改1个文件
26 ■■■■■ 文件已修改
src/pages/bpm/process-instance/create/form.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/bpm/process-instance/create/form.vue
@@ -34,6 +34,19 @@
  import type { SheetOption } from "../../../mes/process-design/shared";
  const { state } = useAuth();
  /**
   * App 端 onLoad 可能保留 navigateTo 参数中的百分号编码,H5 则通常已自动解码。
   * 流程定义 id 含冒号,未解码会导致缓存匹配失败并把错误 id 传给后端。
   */
  function decodeRouteParam(value: unknown) {
    const raw = value === undefined || value === null ? "" : String(value);
    try {
      return decodeURIComponent(raw);
    } catch {
      return raw;
    }
  }
  const SELECTED_DEFINITION_KEY = "bpm_create_selected_definition";
  const selectedDefinition = ref<BpmProcessDefinition>();
@@ -348,6 +361,7 @@
      return;
    }
    loading.value = true;
    loadError.value = "";
    try {
      let preset: Record<string, any> | undefined;
      /** 流程实例所属流程定义的 key(重新发起时用于取「最新版本」定义) */
@@ -491,11 +505,17 @@
  }
  onLoad(query => {
    explicitDefinitionId.value = query?.id ? String(query.id) : "";
    explicitDefinitionId.value = decodeRouteParam(query?.id);
    definitionId.value = explicitDefinitionId.value;
    processInstanceId.value = query?.processInstanceId ? String(query.processInstanceId) : "";
    processInstanceId.value = decodeRouteParam(query?.processInstanceId);
    try {
      const cached = uni.getStorageSync(SELECTED_DEFINITION_KEY) as BpmProcessDefinition | undefined;
      const cachedValue = uni.getStorageSync(SELECTED_DEFINITION_KEY) as
        | BpmProcessDefinition
        | string
        | undefined;
      const cached = typeof cachedValue === "string"
        ? (JSON.parse(cachedValue) as BpmProcessDefinition)
        : cachedValue;
      if (cached?.id && String(cached.id) === explicitDefinitionId.value) {
        selectedDefinition.value = cached;
      }