From dab35bff798cfce2ddf7e8a67e4e1cdb144f5b4c Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 02 十一月 2026 16:08:32 +0800
Subject: [PATCH] fix(bpm): 修复 App 发起流程表单加载异常
---
src/pages/bpm/process-instance/create/form.vue | 41 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/pages/bpm/process-instance/create/form.vue b/src/pages/bpm/process-instance/create/form.vue
index 7013fe3..507cc08 100644
--- a/src/pages/bpm/process-instance/create/form.vue
+++ b/src/pages/bpm/process-instance/create/form.vue
@@ -34,6 +34,21 @@
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锛堜粠鍒楄〃椤甸�夋嫨 / 閲嶆柊鍙戣捣鏃惰В鏋愬嚭鐨勬渶鏂扮増鏈級 */
@@ -346,6 +361,7 @@
return;
}
loading.value = true;
+ loadError.value = "";
try {
let preset: Record<string, any> | undefined;
/** 娴佺▼瀹炰緥鎵�灞炴祦绋嬪畾涔夌殑 key锛堥噸鏂板彂璧锋椂鐢ㄤ簬鍙栥�屾渶鏂扮増鏈�嶅畾涔夛級 */
@@ -367,8 +383,8 @@
// 瀹氫箟浼樺厛绾э細璋冪敤鏂规樉寮忔寚瀹氱殑 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) {
@@ -489,9 +505,24 @@
}
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();
});
@@ -586,7 +617,7 @@
.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>
--
Gitblit v1.9.3