| | |
| | | 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>(); |
| | | |
| | | const definitionId = ref(""); |
| | | /** 调用方显式传入的流程定义 id(从列表页选择 / 重新发起时解析出的最新版本) */ |
| | |
| | | return; |
| | | } |
| | | loading.value = true; |
| | | loadError.value = ""; |
| | | try { |
| | | let preset: Record<string, any> | undefined; |
| | | /** 流程实例所属流程定义的 key(重新发起时用于取「最新版本」定义) */ |
| | |
| | | |
| | | // 定义优先级:调用方显式指定的 id(已是最新版本) |
| | | // > 实例 key 对应的最新版本 > 实例绑定的定义 id |
| | | let def: BpmProcessDefinition | undefined; |
| | | if (explicitDefinitionId.value) { |
| | | let def: BpmProcessDefinition | undefined = selectedDefinition.value; |
| | | if (!def?.id && explicitDefinitionId.value) { |
| | | def = await getProcessDefinition(state.accessToken, { id: explicitDefinitionId.value }); |
| | | } |
| | | if (!def?.id && instanceKey) { |
| | |
| | | } |
| | | |
| | | 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 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; |
| | | } |
| | | uni.removeStorageSync(SELECTED_DEFINITION_KEY); |
| | | } catch { |
| | | selectedDefinition.value = undefined; |
| | | } |
| | | initForm(); |
| | | }); |
| | | |
| | |
| | | .footer{position:fixed;z-index:20;right:0;bottom:0;left:0;display:flex;gap:20rpx;padding:16rpx 30rpx calc(20rpx + env(safe-area-inset-bottom));background:#fff;border-top:1rpx solid #e9eef5;box-shadow:0 -6rpx 20rpx rgba(43,69,107,.06)} |
| | | .btn{flex:1;font-size:29rpx;border-radius:14rpx} |
| | | .btn.ghost{color:#3d5069;background:#fff;border:1rpx solid #dbe4ef} |
| | | .btn.primary{color:#fff;background:#1769d8} |
| | | .btn.primary{color:#fff;background:var(--color-primary, #1769d8)} |
| | | .state{flex:1;padding:60rpx 20rpx;color:#8795a8;font-size:25rpx;text-align:center} |
| | | .state.error{color:#c65050} |
| | | </style> |