@yugu-ui/flow-ui 0.1.21 → 0.1.22

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.
package/dist/index.d.ts CHANGED
@@ -3,7 +3,8 @@ export { default as FlowConfigField } from './config/FlowConfigField';
3
3
  export { default as FlowConfigMore } from './config/FlowConfigMore';
4
4
  export { default as FlowNodesPanel } from './timeline/FlowNodesPanel';
5
5
  export { default as FlowActions } from './timeline/FlowActions';
6
- export type { FlowTimelineData, FlowStatusTag, FlowApprovalData } from './timeline/timeline-mapping';
6
+ export type { FlowTimelineData, FlowStatusTag, FlowApprovalData, FlowStatusInfo, FlowStatusType } from './timeline/timeline-mapping';
7
+ export { FLOW_STATUS_MAP, FLOW_STATUS_OPTIONS, getFlowStatusInfo } from './timeline/timeline-mapping';
7
8
  export { default as FlowNode } from './timeline/FlowNode';
8
9
  export { default as FlowAvatar } from './timeline/FlowAvatar';
9
10
  export { default as ApprovalModal } from './timeline/ApprovalModal';
package/dist/index.js CHANGED
@@ -6016,6 +6016,42 @@ function formatTime(value, format = "YYYY-MM-DD HH:mm:ss") {
6016
6016
  }
6017
6017
  //#endregion
6018
6018
  //#region src/timeline/timeline-mapping.ts
6019
+ /** 流程状态字典(单一来源,key=接口 status:-1 已驳回 / 0 已撤销 / 1 审批中 / 2 已通过) */
6020
+ var FLOW_STATUS_MAP = {
6021
+ [-1]: {
6022
+ label: "已驳回",
6023
+ type: "error"
6024
+ },
6025
+ 0: {
6026
+ label: "已撤销",
6027
+ type: "default"
6028
+ },
6029
+ 1: {
6030
+ label: "审批中",
6031
+ type: "warning"
6032
+ },
6033
+ 2: {
6034
+ label: "已通过",
6035
+ type: "success"
6036
+ }
6037
+ };
6038
+ /** 流程状态下拉选项(筛选表单直接用,value 对齐接口 status) */
6039
+ var FLOW_STATUS_OPTIONS = Object.entries(FLOW_STATUS_MAP).map(([value, info]) => ({
6040
+ label: info.label,
6041
+ value: Number(value)
6042
+ }));
6043
+ /**
6044
+ * 解析流程状态展示信息:
6045
+ * - status 明确为 -1/0/2 时直接取字典(已驳回/已撤销/已通过);
6046
+ * - status=1 或缺失时结合 finished 判断——已结束按已通过兜底,未结束=审批中;
6047
+ * - 无数据时默认审批中。
6048
+ */
6049
+ function getFlowStatusInfo(data) {
6050
+ if (!data) return FLOW_STATUS_MAP[1];
6051
+ const status = Number(data.status);
6052
+ if (status === -1 || status === 0 || status === 2) return FLOW_STATUS_MAP[status];
6053
+ return data.finished === 1 ? FLOW_STATUS_MAP[2] : FLOW_STATUS_MAP[1];
6054
+ }
6019
6055
  /** 固定尾节点:节点有数据时渲染追加(display 下状态按流程是否走完覆盖),接口返回与提交数据均不包含 */
6020
6056
  var END_NODE = {
6021
6057
  type: "end",
@@ -6113,26 +6149,13 @@ function withEndNode(baseNodes, mode) {
6113
6149
  status: allDone ? "done" : "pending"
6114
6150
  }];
6115
6151
  }
6116
- /** 折叠面板标题流程状态标签:仅 display 模式且有详情数据时推导——finished=1 且 status=-1 已驳回(驳回到发起人终止)、finished=1 且 status=0 已撤销、finished=1 已通过、未结束审批中;form 发起模式无实例状态不展示,数据未返回前隐藏避免先展示「审批中」再跳变 */
6152
+ /** 折叠面板标题流程状态标签:仅 display 模式且有详情数据时推导(判断口径见 getFlowStatusInfo);form 发起模式无实例状态不展示,数据未返回前隐藏避免先展示「审批中」再跳变 */
6117
6153
  function getFlowStatusTag(mode, data) {
6118
6154
  if (mode === "form" || !data) return void 0;
6119
- if (data.finished === 1) {
6120
- if (data.status === -1) return {
6121
- text: "已驳回",
6122
- type: "error"
6123
- };
6124
- if (data.status === 0) return {
6125
- text: "已撤销",
6126
- type: "default"
6127
- };
6128
- return {
6129
- text: "已通过",
6130
- type: "success"
6131
- };
6132
- }
6155
+ const info = getFlowStatusInfo(data);
6133
6156
  return {
6134
- text: "审批中",
6135
- type: "warning"
6157
+ text: info.label,
6158
+ type: info.type
6136
6159
  };
6137
6160
  }
6138
6161
  //#endregion
@@ -6839,4 +6862,4 @@ var flow_list_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__
6839
6862
  }
6840
6863
  }), [["__scopeId", "data-v-56ed3cd3"]]);
6841
6864
  //#endregion
6842
- export { ApprovalModal_default as ApprovalModal, FLOW_UI_KEY, FlowActions_default as FlowActions, FlowAvatar_default as FlowAvatar, FlowConfig_default as FlowConfig, FlowConfigField_default as FlowConfigField, FlowConfigMore_default as FlowConfigMore, flow_list_default as FlowList, FlowNode_default as FlowNode, FlowNodesPanel_default as FlowNodesPanel, person_selector_default as PersonSelector, createFlowUI, fetchGetWflowConfigDetail, fetchGetWflowFlowNodes, fetchLaunchWflowFlow, fetchWflowUndoApprove, fetchWflowUndoReject, getRemoteOptions, isRemoteField, useFlowUI };
6865
+ export { ApprovalModal_default as ApprovalModal, FLOW_STATUS_MAP, FLOW_STATUS_OPTIONS, FLOW_UI_KEY, FlowActions_default as FlowActions, FlowAvatar_default as FlowAvatar, FlowConfig_default as FlowConfig, FlowConfigField_default as FlowConfigField, FlowConfigMore_default as FlowConfigMore, flow_list_default as FlowList, FlowNode_default as FlowNode, FlowNodesPanel_default as FlowNodesPanel, person_selector_default as PersonSelector, createFlowUI, fetchGetWflowConfigDetail, fetchGetWflowFlowNodes, fetchLaunchWflowFlow, fetchWflowUndoApprove, fetchWflowUndoReject, getFlowStatusInfo, getRemoteOptions, isRemoteField, useFlowUI };
@@ -4,11 +4,35 @@ import { WflowTodoDetail, WflowTodoRecord } from '../adapter/wflow';
4
4
  export type FlowTimelineData = Pick<WflowTodoDetail, 'nodes' | 'finished' | 'status'>;
5
5
  /** FlowActions 审批操作数据:FlowTimelineData 基础上补充 undo_id(同意/驳回接口入参)与 undo_finished(操作按钮显隐)——待办详情接口整份数据可直接传入 */
6
6
  export type FlowApprovalData = FlowTimelineData & Pick<WflowTodoDetail, 'undo_id' | 'undo_finished'>;
7
+ /** 流程状态标签颜色(对齐 NTag type) */
8
+ export type FlowStatusType = 'success' | 'error' | 'warning' | 'default';
9
+ /** 流程状态展示信息:文案 + 标签颜色 */
10
+ export interface FlowStatusInfo {
11
+ label: string;
12
+ type: FlowStatusType;
13
+ }
7
14
  /** 流程状态标签(getFlowStatusTag 返回):颜色映射 已通过=success / 已驳回=error / 已撤销=default / 审批中=warning */
8
15
  export interface FlowStatusTag {
9
16
  text: string;
10
- type: 'success' | 'error' | 'warning' | 'default';
17
+ type: FlowStatusType;
11
18
  }
19
+ /** 流程状态字典(单一来源,key=接口 status:-1 已驳回 / 0 已撤销 / 1 审批中 / 2 已通过) */
20
+ export declare const FLOW_STATUS_MAP: Record<number, FlowStatusInfo>;
21
+ /** 流程状态下拉选项(筛选表单直接用,value 对齐接口 status) */
22
+ export declare const FLOW_STATUS_OPTIONS: {
23
+ label: string;
24
+ value: number;
25
+ }[];
26
+ /**
27
+ * 解析流程状态展示信息:
28
+ * - status 明确为 -1/0/2 时直接取字典(已驳回/已撤销/已通过);
29
+ * - status=1 或缺失时结合 finished 判断——已结束按已通过兜底,未结束=审批中;
30
+ * - 无数据时默认审批中。
31
+ */
32
+ export declare function getFlowStatusInfo(data?: {
33
+ status?: number;
34
+ finished?: number;
35
+ }): FlowStatusInfo;
12
36
  /** 固定尾节点:节点有数据时渲染追加(display 下状态按流程是否走完覆盖),接口返回与提交数据均不包含 */
13
37
  export declare const END_NODE: FlowNodeItem;
14
38
  /** 人员处理记录映射:一行 records 对应一条展示记录(finished=0 未完成行过滤)——result 优先:result=2 同意;result=3 或 is_reject=1 驳回行按记录操作人判定方向(record.user_id=挂载人员 id 主动驳回「驳回到 rejecters.name」、否则被驳回「被 user_name 驳回」、名字均缺且 flowRejected=true 展示「驳回到 发起人」、否则「驳回」);result=0 不展示 */
@@ -22,5 +46,5 @@ export declare function isLatestRowsReject(rows: WflowTodoRecord[]): boolean;
22
46
  export declare function mapTimelineNodes(data?: FlowTimelineData): FlowNodeItem[];
23
47
  /** 组装完整节点链:有数据统一追加 END 结束节点,无数据为空数组走空态;display(非 form)流程全部完成时 END 状态同步 done;末节点已是 end(后端快照自带 end、或调用方传入已组装过 END 的节点链,如 FlowLayout → FlowNodesPanel)时幂等跳过,防止结束节点重复渲染 */
24
48
  export declare function withEndNode(baseNodes: FlowNodeItem[], mode?: 'display' | 'form'): FlowNodeItem[];
25
- /** 折叠面板标题流程状态标签:仅 display 模式且有详情数据时推导——finished=1 且 status=-1 已驳回(驳回到发起人终止)、finished=1 且 status=0 已撤销、finished=1 已通过、未结束审批中;form 发起模式无实例状态不展示,数据未返回前隐藏避免先展示「审批中」再跳变 */
49
+ /** 折叠面板标题流程状态标签:仅 display 模式且有详情数据时推导(判断口径见 getFlowStatusInfo);form 发起模式无实例状态不展示,数据未返回前隐藏避免先展示「审批中」再跳变 */
26
50
  export declare function getFlowStatusTag(mode: 'display' | 'form' | undefined, data?: FlowTimelineData): FlowStatusTag | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yugu-ui/flow-ui",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "堉古商城流程组件库:流程设计器(config)/ 审批时间线(timeline)/ 流程列表(FlowList)",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",