From 9f05c76d32b68bf6935cddc289cd1d4ea1376e58 Mon Sep 17 00:00:00 2001 From: wangli <274027703@qq.com> Date: Wed, 19 Nov 2025 14:51:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(REQ-5965)=20-=20=E5=A2=9E=E5=8A=A0ctx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/templates/form.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/workflow-engine-server/src/main/resources/templates/form.html b/workflow-engine-server/src/main/resources/templates/form.html index cd72e6268..988e2db51 100644 --- a/workflow-engine-server/src/main/resources/templates/form.html +++ b/workflow-engine-server/src/main/resources/templates/form.html @@ -30,7 +30,11 @@ } } - + + + + + @@ -178,7 +179,7 @@

- 授权码有效期为1分钟,请及时使用 + 授权码有效期为30分钟,请及时使用

@@ -280,6 +281,9 @@ 提交 + + + @@ -349,6 +353,7 @@ const copyToast = document.getElementById('copyToast'); const submitMask = document.getElementById('submitMask'); const maskMessage = document.getElementById('maskMessage'); + const operationMessage = document.getElementById('operationMessage'); // 错误提示元素 const processInstanceIdError = document.getElementById('processInstanceIdError'); @@ -528,7 +533,7 @@ async function getAuthCode() { const password = authPassword.value.trim(); if (!password) { - getAuthError.textContent = '请输入管理员密码'; + getAuthError.innerHTML = '请输入管理员密码'; getAuthError.classList.remove('hidden'); return; } @@ -538,16 +543,15 @@ getAuthError.classList.add('hidden'); try { - // 构造带查询参数的URL(POST方式但参数通过URL传递) + // 使用全局上下文路径变量拼接URL const url = `${ctx}web/process/get-auth-code?password=${encodeURIComponent(password)}`; // 保持POST请求方式,参数通过URL查询参数传递 const response = await fetch(url, { - method: 'POST', // 保持POST请求方式 + method: 'POST', headers: { - 'Accept': 'application/json' // 只保留接收JSON的头 + 'Accept': 'application/json' } - // 移除body,参数通过URL传递 }); const result = await response.json(); @@ -563,7 +567,7 @@ // }, 1000); } else { // 显示错误信息 - getAuthError.innerHTML = '' + (result.message || '密码错误,无法获取授权码'); + getAuthError.innerHTML = '' + (result.msg || '密码错误,无法获取授权码'); getAuthError.classList.remove('hidden'); } } catch (error) { @@ -606,6 +610,7 @@ }; try { + // 使用全局上下文路径变量 const response = await fetch(this.action, { method: this.method, headers: { @@ -615,18 +620,28 @@ body: JSON.stringify(formData) }); - if (response.ok) { - showSuccessToast(); - processForm.reset(); - updateFormFields(); + const result = await response.json(); + + // 显示消息区域 + operationMessage.classList.remove('hidden'); + + if (response.ok && result.code === 200) { + // 成功消息 - 绿色背景 + operationMessage.className = 'mt-4 p-4 rounded-lg bg-green-50 border border-green-200 text-green-700'; + operationMessage.innerHTML = `${result.msg || '操作已成功提交'}`; } else { - alert('提交失败,请重试'); + // 错误消息 - 红色背景 + operationMessage.className = 'mt-4 p-4 rounded-lg bg-red-50 border border-red-200 text-red-700'; + operationMessage.innerHTML = `${result.msg || '操作失败,请重试'}`; } } catch (error) { console.error('请求错误:', error); - alert('网络错误,请稍后重试'); + // 网络错误消息 + operationMessage.className = 'mt-4 p-4 rounded-lg bg-red-50 border border-red-200 text-red-700'; + operationMessage.innerHTML = `网络错误,请稍后重试`; + operationMessage.classList.remove('hidden'); } finally { - // 无论成功或失败,都隐藏遮罩层 + // 隐藏遮罩层 hideMask(); } }); @@ -655,10 +670,26 @@ updateFormFields(); } - // 如果有授权错误,显示错误信息 - if (authError && authError.textContent.trim() !== '') { - authError.classList.remove('hidden'); - } + // 页面加载时检查后端消息 + document.addEventListener('DOMContentLoaded', function () { + // 检查流程操作的后端消息(使用 Thymeleaf JS 内联语法) + /*[[#{ + if (${message != null}) { + operationMessage.classList.remove('hidden'); + if (${message.startsWith('操作成功')}) { + operationMessage.className = 'mt-4 p-4 rounded-lg bg-green-50 border border-green-200 text-green-700'; + } else { + operationMessage.className = 'mt-4 p-4 rounded-lg bg-red-50 border border-red-200 text-red-700'; + } + operationMessage.innerHTML = '' + '${message}'; + } + }]]*/ + + // 显示授权错误(如果有) + if (authError && authError.textContent.trim() !== '') { + authError.classList.remove('hidden'); + } + }); \ No newline at end of file