Merge branch 'feature/REQ-5965' into dev
This commit is contained in:
commit
d1833584b2
@ -1,5 +1,6 @@
|
||||
package cn.axzo.workflow.server.controller.web;
|
||||
|
||||
import cn.axzo.framework.domain.data.AssertUtil;
|
||||
import cn.axzo.infra.xxl220to250.XxlJobLogger;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceAbortDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCancelDTO;
|
||||
@ -16,7 +17,7 @@ import cn.axzo.workflow.server.xxljob.DangerSuperOperationJobHandler;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -33,6 +34,7 @@ import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.workflow.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
|
||||
@ -104,8 +106,9 @@ public class DangerOperationController {
|
||||
}
|
||||
|
||||
// 处理表单提交
|
||||
@PostMapping(value = "/web/process/handle", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public String handleProcess(@Validated @RequestBody DangerSuperOperationJobHandler.DangerOperationJobParam jobParam, Model model) {
|
||||
@PostMapping(value = "/web/process/handle")
|
||||
@ResponseBody
|
||||
public CommonResponse<String> handleProcess(@Validated @RequestBody DangerSuperOperationJobHandler.DangerOperationJobParam jobParam, Model model) {
|
||||
|
||||
// 处理表单提交的逻辑
|
||||
log.info("操作类型: {}", jobParam.getOperationType());
|
||||
@ -113,6 +116,9 @@ public class DangerOperationController {
|
||||
log.info("自然人ID: {}", jobParam.getPersonId());
|
||||
log.info("意见: {}", jobParam.getComment());
|
||||
|
||||
try {
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(jobParam.getProcessInstanceId()).singleResult();
|
||||
AssertUtil.notNull(processInstance, PROCESS_INSTANCE_NOT_EXISTS);
|
||||
// 这里可以添加实际的业务逻辑,如调用流程引擎API等
|
||||
switch (jobParam.getOperationType()) {
|
||||
case CANCEL:
|
||||
@ -133,10 +139,14 @@ public class DangerOperationController {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 可以将处理结果添加到模型中返回给页面
|
||||
model.addAttribute("message", "操作已成功提交");
|
||||
return "form"; // 处理完成后返回表单页面
|
||||
return CommonResponse.success("操作已成功提交");
|
||||
} catch (Exception e) {
|
||||
model.addAttribute("message", "操作失败: " + e.getMessage());
|
||||
return CommonResponse.error("操作失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -62,6 +62,11 @@
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 全局上下文路径变量 -->
|
||||
<script th:inline="javascript">
|
||||
const ctx = [[@{/}]]; // 自动获取servlet.context.path
|
||||
</script>
|
||||
</head>
|
||||
<body class="bg-gray-50 font-inter min-h-screen flex flex-col">
|
||||
<!-- 顶部导航 -->
|
||||
@ -174,7 +179,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-gray-500">
|
||||
<i class="fa fa-clock-o mr-1"></i>授权码有效期为1分钟,请及时使用
|
||||
<i class="fa fa-clock-o mr-1"></i>授权码有效期为30分钟,请及时使用
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@ -276,6 +281,9 @@
|
||||
<i class="fa fa-check mr-2"></i>提交
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 操作消息显示区域 -->
|
||||
<div id="operationMessage" class="mt-4 p-4 rounded-lg hidden"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -345,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');
|
||||
@ -524,7 +533,7 @@
|
||||
async function getAuthCode() {
|
||||
const password = authPassword.value.trim();
|
||||
if (!password) {
|
||||
getAuthError.textContent = '<i class="fa fa-exclamation-circle mr-1"></i>请输入管理员密码';
|
||||
getAuthError.innerHTML = '<i class="fa fa-exclamation-circle mr-1"></i>请输入管理员密码';
|
||||
getAuthError.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
@ -534,16 +543,15 @@
|
||||
getAuthError.classList.add('hidden');
|
||||
|
||||
try {
|
||||
// 构造带查询参数的URL(POST方式但参数通过URL传递)
|
||||
const url = `/web/process/get-auth-code?password=${encodeURIComponent(password)}`;
|
||||
// 使用全局上下文路径变量拼接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();
|
||||
@ -559,7 +567,7 @@
|
||||
// }, 1000);
|
||||
} else {
|
||||
// 显示错误信息
|
||||
getAuthError.innerHTML = '<i class="fa fa-exclamation-circle mr-1"></i>' + (result.message || '密码错误,无法获取授权码');
|
||||
getAuthError.innerHTML = '<i class="fa fa-exclamation-circle mr-1"></i>' + (result.msg || '密码错误,无法获取授权码');
|
||||
getAuthError.classList.remove('hidden');
|
||||
}
|
||||
} catch (error) {
|
||||
@ -602,6 +610,7 @@
|
||||
};
|
||||
|
||||
try {
|
||||
// 使用全局上下文路径变量
|
||||
const response = await fetch(this.action, {
|
||||
method: this.method,
|
||||
headers: {
|
||||
@ -611,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 = `<i class="fa fa-check-circle mr-2"></i>${result.msg || '操作已成功提交'}`;
|
||||
} else {
|
||||
alert('提交失败,请重试');
|
||||
// 错误消息 - 红色背景
|
||||
operationMessage.className = 'mt-4 p-4 rounded-lg bg-red-50 border border-red-200 text-red-700';
|
||||
operationMessage.innerHTML = `<i class="fa fa-exclamation-circle mr-2"></i>${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 = `<i class="fa fa-exclamation-circle mr-2"></i>网络错误,请稍后重试`;
|
||||
operationMessage.classList.remove('hidden');
|
||||
} finally {
|
||||
// 无论成功或失败,都隐藏遮罩层
|
||||
// 隐藏遮罩层
|
||||
hideMask();
|
||||
}
|
||||
});
|
||||
@ -651,10 +670,26 @@
|
||||
updateFormFields();
|
||||
}
|
||||
|
||||
// 如果有授权错误,显示错误信息
|
||||
// 页面加载时检查后端消息
|
||||
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 = '<i class="fa ' + (${message.startsWith('操作成功')} ? 'fa-check-circle' : 'fa-exclamation-circle') + ' mr-2"></i>' + '${message}';
|
||||
}
|
||||
}]]*/
|
||||
|
||||
// 显示授权错误(如果有)
|
||||
if (authError && authError.textContent.trim() !== '') {
|
||||
authError.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user