@yugu-ui/flow-ui 0.1.29 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -259,3 +259,10 @@ export interface WflowUndoResult {
259
259
  export declare function fetchWflowUndoApprove(data: WflowUndoApproveParams): Promise<import('..').FlowUIResponse<WflowUndoResult>>;
260
260
  /** 审批驳回(POST /wflow/undo/reject:驳回到发起人=终止流程,驳回到历史审批节点=该节点起重置重审;路径可经注入 endpoints.undoReject 覆盖) */
261
261
  export declare function fetchWflowUndoReject(data: WflowUndoRejectParams): Promise<import('..').FlowUIResponse<WflowUndoResult>>;
262
+ /** 流程撤回请求参数(仅发起人可撤回:处理中需开启允许撤回,已通过需开启允许通过后撤销) */
263
+ export interface WflowUndoRecallParams {
264
+ /** 流程实例 ID(待办详情/实例详情返回的 instance_id) */
265
+ instance_id: number;
266
+ }
267
+ /** 流程撤回(POST /wflow/undo/recall:撤回后流程状态置为撤销(0),仅发起人可撤回;路径可经注入 endpoints.undoRecall 覆盖) */
268
+ export declare function fetchWflowUndoRecall(data: WflowUndoRecallParams): Promise<import('..').FlowUIResponse<WflowUndoResult>>;
package/dist/index.js CHANGED
@@ -49,7 +49,8 @@ var DEFAULT_ENDPOINTS = {
49
49
  flowNodes: "/wflow/flow/nodes",
50
50
  flowLaunch: "/wflow/flow/launch",
51
51
  undoApprove: "/wflow/undo/approve",
52
- undoReject: "/wflow/undo/reject"
52
+ undoReject: "/wflow/undo/reject",
53
+ undoRecall: "/wflow/undo/recall"
53
54
  };
54
55
  /** 未注入兜底配置:可渲染、可告警,能力调用统一走 error 分支 */
55
56
  var fallbackConfig = {
@@ -6111,18 +6112,21 @@ function isLatestRowsReject(rows) {
6111
6112
  const latest = rows.reduce((acc, cur) => (cur.assertion_time ?? 0) >= (acc.assertion_time ?? 0) ? cur : acc, rows[0]);
6112
6113
  return latest.result === 3 || latest.is_reject === 1;
6113
6114
  }
6114
- /** display 模式审批时间线映射:节点快照直接映射 FlowNodeItem——发起人节点独立判定:一律完成绿色(不随流程被驳回到发起人变化,驳回到发起人(finished=1 且 status=-1)也不再标红);其余节点按实例 finished、节点自带 finished(1=已完成)推导:进行中节点优先取第一个「未完成且 status=1 待处理」的节点,无激活节点时兜底认第一个存在待处理任务行(users.records 中 result=0 且 finished=0)的节点为当前节点,仍无则回退第一个未完成节点,有激活/兜底节点时其后节点一律待开始(剥离上一轮残留),流程被驳回终止时其余节点一律灰色待开始;人员状态按本人最新一条操作记录展示(已处理记录 result=2/3 或 is_reject=1 中 assertion_time 最新一条:驳回标红、同意标绿;发起人节点人员固定成功绿色),无操作记录随节点状态(进行中节点淡黄、其余灰色未处理) */
6115
+ /** display 模式审批时间线映射:节点快照直接映射 FlowNodeItem——发起人节点独立判定:一律完成绿色(不随流程被驳回到发起人变化,驳回到发起人(finished=1 且 status=-1)也不再标红);其余节点按实例 finished、节点自带 finished(1=已完成)推导:进行中节点优先取第一个「未完成且 status=1 待处理」的节点,无激活节点时兜底认第一个存在待处理任务行(users.records 中 result=0 且 finished=0)的节点为当前节点,仍无则回退第一个未完成节点,有激活/兜底节点时其后节点一律待开始(剥离上一轮残留),流程被驳回终止时其余节点一律灰色待开始;人员状态按本人最新一条操作记录展示(已处理记录 result=2/3 或 is_reject=1 中 assertion_time 最新一条:驳回标红、同意标绿;发起人节点人员固定成功绿色),无操作记录随节点状态(进行中节点淡黄、其余灰色未处理);流程撤回终止(finished=1 且 status=0)时未留下已处理记录的节点保持待处理,不随实例结束标为已完成 */
6115
6116
  function mapTimelineNodes(data) {
6116
6117
  const d = data;
6117
6118
  if (!d?.nodes?.length) return [];
6118
6119
  const instanceFinished = d.finished === 1;
6119
6120
  const instanceRejected = instanceFinished && d.status === -1;
6121
+ /** 撤回终止识别:finished=1 且 status=0(已撤销)——流程在审批中途撤回,未处理的节点不应被当作已完成 */
6122
+ const instanceCancelled = instanceFinished && d.status === 0;
6120
6123
  const activeIndex = d.nodes.findIndex((item) => item.status === 1 && item.finished !== 1);
6121
6124
  const pendingIndex = !instanceFinished && activeIndex < 0 ? d.nodes.findIndex((item) => item.users.some((user) => (Array.isArray(user.records) ? user.records : []).some((record) => record.result === 0 && record.finished === 0))) : -1;
6122
6125
  const currentIndex = activeIndex > -1 ? activeIndex : pendingIndex > -1 ? pendingIndex : instanceFinished ? -1 : d.nodes.findIndex((item) => item.finished !== 1);
6123
6126
  return d.nodes.map((node, index) => {
6124
6127
  const forcePending = !instanceFinished && (activeIndex > -1 || pendingIndex > -1) && index > currentIndex;
6125
- const nodeStatus = node.type === "start" ? "done" : instanceRejected ? "pending" : forcePending ? "pending" : !instanceFinished && index === currentIndex ? "doing" : instanceFinished || node.finished === 1 || currentIndex > -1 && index < currentIndex ? "done" : "pending";
6128
+ const nodeHasProcessed = node.users.some((user) => (Array.isArray(user.records) ? user.records : []).some((record) => record.result === 2 || record.result === 3 || record.is_reject === 1));
6129
+ const nodeStatus = node.type === "start" ? "done" : instanceRejected ? "pending" : instanceCancelled ? nodeHasProcessed ? "done" : "pending" : forcePending ? "pending" : !instanceFinished && index === currentIndex ? "doing" : instanceFinished || node.finished === 1 || currentIndex > -1 && index < currentIndex ? "done" : "pending";
6126
6130
  const users = node.users.map((user) => {
6127
6131
  const records = toUserRecords(user, instanceRejected);
6128
6132
  const rawRows = Array.isArray(user.records) ? user.records : [];
@@ -6512,6 +6516,14 @@ function fetchWflowUndoReject(data) {
6512
6516
  data
6513
6517
  });
6514
6518
  }
6519
+ /** 流程撤回(POST /wflow/undo/recall:撤回后流程状态置为撤销(0),仅发起人可撤回;路径可经注入 endpoints.undoRecall 覆盖) */
6520
+ function fetchWflowUndoRecall(data) {
6521
+ return getFlowUIConfig().request({
6522
+ url: getFlowUIConfig().endpoints.undoRecall,
6523
+ method: "post",
6524
+ data
6525
+ });
6526
+ }
6515
6527
  //#endregion
6516
6528
  //#region src/timeline/FlowActions.vue
6517
6529
  var FlowActions_default = /* @__PURE__ */ defineComponent({
@@ -6559,15 +6571,24 @@ var FlowActions_default = /* @__PURE__ */ defineComponent({
6559
6571
  approvalType.value = type;
6560
6572
  approvalVisible.value = true;
6561
6573
  }
6562
- /** 撤回:二次确认(反馈 API 经 getFlowUIFeedback:注入 feedback 优先,回落宿主 app-provider 挂载的 window.$dialog);撤回接口待接入,确认后暂仅提示成功 */
6574
+ /** 撤回:二次确认(反馈 API 经 getFlowUIFeedback:注入 feedback 优先,回落宿主 app-provider 挂载的 window.$dialog)→ 调用 /wflow/undo/recall → 成功提示并通知页面刷新 */
6563
6575
  function handleWithdraw() {
6576
+ const instanceId = props.data?.instance_id;
6577
+ if (!instanceId) {
6578
+ getFlowUIFeedback().message?.error("未获取到流程实例ID,无法撤回");
6579
+ return;
6580
+ }
6564
6581
  getFlowUIFeedback().dialog?.warning({
6565
6582
  title: "撤回确认",
6566
6583
  content: "确定撤回当前流程吗?",
6567
6584
  positiveText: "确定",
6568
6585
  negativeText: "取消",
6569
- onPositiveClick: () => {
6586
+ onPositiveClick: async () => {
6587
+ const { error } = await fetchWflowUndoRecall({ instance_id: instanceId });
6588
+ if (error) return false;
6570
6589
  getFlowUIFeedback().message?.success("流程已撤回");
6590
+ emit("success");
6591
+ return true;
6571
6592
  }
6572
6593
  });
6573
6594
  }
@@ -64,6 +64,8 @@ export interface FlowUIEndpoints {
64
64
  undoApprove: string;
65
65
  /** 审批驳回,默认 '/wflow/undo/reject' */
66
66
  undoReject: string;
67
+ /** 流程撤回,默认 '/wflow/undo/recall' */
68
+ undoRecall: string;
67
69
  }
68
70
  /** 注入选项(宿主 app.use(createFlowUI(options)) 传入) */
69
71
  export interface FlowUIOptions {
@@ -5,7 +5,7 @@ type __VLS_Props = {
5
5
  data?: FlowApprovalData;
6
6
  /** 是否审批处理模式(默认 true):false=纯查看,不渲染操作按钮与审批弹窗 */
7
7
  approval?: boolean;
8
- /** 是否展示撤回按钮(默认 true):撤回接口待接入期间可传 false 隐藏 */
8
+ /** 是否展示撤回按钮(默认 true):撤回接口已接入 /wflow/undo/recall,仅在宿主需要隐藏撤回入口时传 false */
9
9
  showWithdraw?: boolean;
10
10
  };
11
11
  declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
@@ -3,7 +3,7 @@ import { WflowTodoDetail, WflowTodoRecord } from '../adapter/wflow';
3
3
  /** display 模式原始详情数据:节点快照自带任务状态与每人处理结果 + status/finished 实例状态 */
4
4
  export type FlowTimelineData = Pick<WflowTodoDetail, 'nodes' | 'finished' | 'status'>;
5
5
  /** FlowActions 审批操作数据:FlowTimelineData 基础上补充 undo_id(同意/驳回接口入参)与 undo_finished(操作按钮显隐)——待办详情接口整份数据可直接传入 */
6
- export type FlowApprovalData = FlowTimelineData & Pick<WflowTodoDetail, 'undo_id' | 'undo_finished' | 'can_handle' | 'can_recall'>;
6
+ export type FlowApprovalData = FlowTimelineData & Pick<WflowTodoDetail, 'instance_id' | 'undo_id' | 'undo_finished' | 'can_handle' | 'can_recall'>;
7
7
  /** 流程状态枚举(接口 status:-1 已驳回 / 0 已撤销 / 1 审批中 / 2 已通过) */
8
8
  export declare enum FlowStatus {
9
9
  Rejected = -1,
@@ -42,7 +42,7 @@ export declare function toUserRecords(user: {
42
42
  }, flowRejected?: boolean): FlowNodeUserRecord[];
43
43
  /** 已处理记录(result=2/3 或 is_reject=1,与 toUserRecords 口径一致)中处理时间(assertion_time 毫秒时间戳)最新的一条是否为驳回(result=3 或 is_reject=1);空集合返回 false,records 数组顺序不可靠必须按时间数值比较 */
44
44
  export declare function isLatestRowsReject(rows: WflowTodoRecord[]): boolean;
45
- /** display 模式审批时间线映射:节点快照直接映射 FlowNodeItem——发起人节点独立判定:一律完成绿色(不随流程被驳回到发起人变化,驳回到发起人(finished=1 且 status=-1)也不再标红);其余节点按实例 finished、节点自带 finished(1=已完成)推导:进行中节点优先取第一个「未完成且 status=1 待处理」的节点,无激活节点时兜底认第一个存在待处理任务行(users.records 中 result=0 且 finished=0)的节点为当前节点,仍无则回退第一个未完成节点,有激活/兜底节点时其后节点一律待开始(剥离上一轮残留),流程被驳回终止时其余节点一律灰色待开始;人员状态按本人最新一条操作记录展示(已处理记录 result=2/3 或 is_reject=1 中 assertion_time 最新一条:驳回标红、同意标绿;发起人节点人员固定成功绿色),无操作记录随节点状态(进行中节点淡黄、其余灰色未处理) */
45
+ /** display 模式审批时间线映射:节点快照直接映射 FlowNodeItem——发起人节点独立判定:一律完成绿色(不随流程被驳回到发起人变化,驳回到发起人(finished=1 且 status=-1)也不再标红);其余节点按实例 finished、节点自带 finished(1=已完成)推导:进行中节点优先取第一个「未完成且 status=1 待处理」的节点,无激活节点时兜底认第一个存在待处理任务行(users.records 中 result=0 且 finished=0)的节点为当前节点,仍无则回退第一个未完成节点,有激活/兜底节点时其后节点一律待开始(剥离上一轮残留),流程被驳回终止时其余节点一律灰色待开始;人员状态按本人最新一条操作记录展示(已处理记录 result=2/3 或 is_reject=1 中 assertion_time 最新一条:驳回标红、同意标绿;发起人节点人员固定成功绿色),无操作记录随节点状态(进行中节点淡黄、其余灰色未处理);流程撤回终止(finished=1 且 status=0)时未留下已处理记录的节点保持待处理,不随实例结束标为已完成 */
46
46
  export declare function mapTimelineNodes(data?: FlowTimelineData): FlowNodeItem[];
47
47
  /** 组装完整节点链:有数据统一追加 END 结束节点,无数据为空数组走空态;display(非 form)流程全部完成时 END 状态同步 done;末节点已是 end(后端快照自带 end、或调用方传入已组装过 END 的节点链,如 FlowLayout → FlowNodesPanel)时幂等跳过,防止结束节点重复渲染 */
48
48
  export declare function withEndNode(baseNodes: FlowNodeItem[], mode?: 'display' | 'form'): FlowNodeItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yugu-ui/flow-ui",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "堉古商城流程组件库:流程设计器(config)/ 审批时间线(timeline)/ 流程列表(FlowList)",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",