完善MES审批流设计功能,新增审批可选回调动作、发起人撤销及催办接口,支持审批状态恢复与联动回退,提升审批流程的灵活性与用户体验。
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
/**
|
||||
* 审批流「回调接口」录制器。
|
||||
*
|
||||
* 审批流设计器是覆盖在业务页面之上的(同一前端应用、同一个 defHttp 实例),
|
||||
* 录制时全局拦截器会把每次业务请求的 url/method/参数 上报到这里,
|
||||
* 捕获用户点击目标按钮所触发的真实请求,自动回填到节点的回调接口配置。
|
||||
*
|
||||
* @author GHT
|
||||
* @date 2026-05-29 for:【QH-MES审批流设计】可视化录制业务按钮接口
|
||||
*/
|
||||
|
||||
export interface FlowCapturedApi {
|
||||
/** 请求路径(servlet 内路径,如 /xslmes/xxx/approve) */
|
||||
url: string;
|
||||
/** 请求方法 GET/POST/PUT/DELETE */
|
||||
method: string;
|
||||
/** 请求体(POST/PUT 时) */
|
||||
data?: any;
|
||||
/** 查询参数 */
|
||||
params?: any;
|
||||
}
|
||||
|
||||
/** 录制中状态(供设计器隐藏遮罩、显示录制条) */
|
||||
export const flowApiRecording = ref(false);
|
||||
|
||||
let resolver: ((c: FlowCapturedApi | null) => void) | null = null;
|
||||
|
||||
/** 开始录制,返回 Promise;捕获到请求或取消时 resolve(取消为 null) */
|
||||
export function startFlowApiRecord(): Promise<FlowCapturedApi | null> {
|
||||
// 若已有未完成的录制,先取消
|
||||
cancelFlowApiRecord();
|
||||
flowApiRecording.value = true;
|
||||
return new Promise((resolve) => {
|
||||
resolver = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
/** 取消录制 */
|
||||
export function cancelFlowApiRecord() {
|
||||
if (resolver) {
|
||||
const r = resolver;
|
||||
resolver = null;
|
||||
flowApiRecording.value = false;
|
||||
r(null);
|
||||
} else {
|
||||
flowApiRecording.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 由全局请求拦截器调用,上报每次请求。
|
||||
* 仅在录制中生效,默认只捕获「非 GET」业务请求(按钮动作通常是写操作),
|
||||
* 并跳过审批流自身接口,避免误捕获。
|
||||
*/
|
||||
export function notifyFlowApiRecorder(config: any) {
|
||||
if (!flowApiRecording.value || !resolver) {
|
||||
return;
|
||||
}
|
||||
const method = String(config?.method || 'get').toUpperCase();
|
||||
if (method === 'GET') {
|
||||
return;
|
||||
}
|
||||
const url = config?.url;
|
||||
if (!url || typeof url !== 'string') {
|
||||
return;
|
||||
}
|
||||
// 跳过审批流/审批办理自身接口
|
||||
if (url.includes('/approvalFlow') || url.includes('/approvalHandle') || url.includes('/sys/dict')) {
|
||||
return;
|
||||
}
|
||||
const captured: FlowCapturedApi = {
|
||||
url,
|
||||
method,
|
||||
data: safeClone(config?.data),
|
||||
params: safeClone(config?.params),
|
||||
};
|
||||
const r = resolver;
|
||||
resolver = null;
|
||||
flowApiRecording.value = false;
|
||||
r(captured);
|
||||
}
|
||||
|
||||
function safeClone(v: any) {
|
||||
if (v == null || typeof v !== 'object') {
|
||||
return v;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(JSON.stringify(v));
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,6 @@ import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { joinTimestamp, formatRequestDate } from './helper';
|
||||
import { useUserStoreWithOut } from '/@/store/modules/user';
|
||||
import { cloneDeep } from "lodash-es";
|
||||
//update-begin---author:GHT ---date:2026-05-29 for:【QH-MES审批流设计】回调接口录制-----
|
||||
import { notifyFlowApiRecorder } from '/@/utils/flowApiRecorder';
|
||||
//update-end---author:GHT ---date:2026-05-29 for:【QH-MES审批流设计】回调接口录制-----
|
||||
const globSetting = useGlobSetting();
|
||||
const urlPrefix = globSetting.urlPrefix;
|
||||
const { createMessage, createErrorModal } = useMessage();
|
||||
@@ -93,9 +90,6 @@ const transform: AxiosTransform = {
|
||||
|
||||
// 请求之前处理config
|
||||
beforeRequestHook: (config, options) => {
|
||||
//update-begin---author:GHT ---date:2026-05-29 for:【QH-MES审批流设计】录制时捕获原始servlet路径(未加前缀/上下文)-----
|
||||
notifyFlowApiRecorder({ url: config.url, method: config.method, data: config.data, params: config.params });
|
||||
//update-end---author:GHT ---date:2026-05-29 for:【QH-MES审批流设计】录制时捕获原始servlet路径(未加前缀/上下文)-----
|
||||
const { apiUrl, joinPrefix, joinParamsToUrl, formatDate, joinTime = true, urlPrefix } = options;
|
||||
|
||||
// http开头的请求url,不加前缀
|
||||
|
||||
Reference in New Issue
Block a user