@yugu-ui/flow-ui 0.1.15 → 0.1.17

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NAvatar, NButton, NCard, NCheckbox, NCheckboxGroup, NCollapse, NCollapseItem, NDrawer, NDrawerContent, NEl, NEllipsis, NEmpty, NForm, NFormItem, NImage, NInput, NInputGroup, NInputGroupLabel, NInputNumber, NModal, NPopover, NRadio, NRadioButton, NRadioGroup, NSelect, NSpace, NSpin, NSwitch, NTab, NTabs, NTag, NTooltip, useThemeVars } from "naive-ui";
2
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, unref, useModel, useSlots, vModelText, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, h, inject, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, unref, useModel, useSlots, vModelText, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
3
3
  import { Graph } from "@antv/x6";
4
4
  import { VueShapeView, getTeleport, register } from "@antv/x6-vue-shape";
5
5
  import dayjs from "dayjs";
@@ -65,6 +65,46 @@ function createDefaultPersonSelectorApi(request) {
65
65
  method: "get"
66
66
  });
67
67
  }
68
+ /** 已告警的注入组件集合:同一组件实例只警告一次(WeakSet,不阻止组件被回收) */
69
+ var warnedCustomSelectors = /* @__PURE__ */ new WeakSet();
70
+ /** props/emits 声明形态判定:数组含 key / 对象含 key / 完全未声明(null) */
71
+ var declaresKey = (decl, key) => {
72
+ if (Array.isArray(decl)) return decl.includes(key);
73
+ if (decl && typeof decl === "object") return key in decl;
74
+ return null;
75
+ };
76
+ /** DEV 契约警告(按组件实例去重;非对象组件无法入 WeakSet,直接警告) */
77
+ var warnPersonSelectorOnce = (comp, msg) => {
78
+ if (comp && (typeof comp === "object" || typeof comp === "function")) {
79
+ const key = comp;
80
+ if (warnedCustomSelectors.has(key)) return;
81
+ warnedCustomSelectors.add(key);
82
+ }
83
+ console.warn(`[flow-ui] ${msg}`);
84
+ };
85
+ /**
86
+ * 自定义选人组件契约校验(createFlowUI 注入时与 PersonSelectorSlot 渲染时各调用,按组件实例去重警告):
87
+ * 硬性不合格(非组件本体 / props 未声明 modelValue / emits 未声明 update:modelValue)返回 false,槽位据此回落内置实现。
88
+ * 不做 DEV 环境门控:包 dist 为预构建产物(import.meta.env.DEV 已固化为 false),宿主本地 dev 消费同一份产物,
89
+ * 门控会导致警告永不触发;不合格对任何环境都值得一报,WeakSet 去重保证不刷屏。
90
+ */
91
+ function validatePersonSelectorComponent(comp) {
92
+ if (!(!!comp && (typeof comp === "object" || typeof comp === "function"))) {
93
+ warnPersonSelectorOnce(comp, "components.PersonSelector 注入不合法:须为 Vue 组件对象或函数式组件,已回落内置选人组件");
94
+ return false;
95
+ }
96
+ const c = comp;
97
+ const problems = [];
98
+ const propState = declaresKey(c.props, "modelValue");
99
+ if (propState === null) problems.push("props 未声明(契约要求声明 modelValue/placeholder/display-mode/selectable-types)");
100
+ else if (propState === false) problems.push("props 未声明 modelValue(v-model 双向绑定将失效)");
101
+ if (declaresKey(c.emits, "update:modelValue") === false) problems.push("emits 未声明 update:modelValue(选择结果无法回传流程配置)");
102
+ if (problems.length) {
103
+ warnPersonSelectorOnce(comp, `components.PersonSelector 契约不合格:${problems.join(";")}——请按 provider/types.ts FlowUIComponents.PersonSelector 契约补齐,当前注入已回落内置选人组件`);
104
+ return false;
105
+ }
106
+ return true;
107
+ }
68
108
  /**
69
109
  * 流程组件库注入入口:`app.use(createFlowUI({ request, getToken?, baseURL?, personSelectorApi? }))`
70
110
  * - `request`:宿主请求实例(平面函数式,返回 `{ data, error }`),包内全部接口改走它;
@@ -75,6 +115,7 @@ function createDefaultPersonSelectorApi(request) {
75
115
  * Developed collaboratively with vscode - 改动代码行数: 1行(2.12 宿主全局组件解耦:注入入口文档补能力组件说明)
76
116
  */
77
117
  function createFlowUI(options) {
118
+ if (options.components?.PersonSelector !== void 0) validatePersonSelectorComponent(options.components.PersonSelector);
78
119
  const config = {
79
120
  request: options.request,
80
121
  getToken: options.getToken ?? (() => ""),
@@ -1033,14 +1074,14 @@ var centerXOf = (node) => {
1033
1074
  return node.getPosition().x + node.getSize().width / 2;
1034
1075
  };
1035
1076
  var getTypeLabel = (type) => NODE_TYPES.find((t) => t.value === type)?.label || "节点";
1036
- var getDefaultConfig = (type) => {
1077
+ var getDefaultConfig = (type, isExternal) => {
1037
1078
  switch (type) {
1038
1079
  case NODE_TYPE.START: return {
1039
1080
  range: "all",
1040
1081
  members: []
1041
1082
  };
1042
1083
  case NODE_TYPE.APPROVER: return {
1043
- assigneeType: "selfSelect",
1084
+ assigneeType: isExternal === 0 ? "selfSelect" : "specified",
1044
1085
  approvers: [],
1045
1086
  mode: "and",
1046
1087
  empty: "pass"
@@ -1159,30 +1200,66 @@ var getConditionBranchSubtree = (graph, condId, convergeId) => {
1159
1200
  return ids;
1160
1201
  };
1161
1202
  /**
1162
- * 发布校验:仅校验条件分支完整性(审批 / 抄送 / 开始节点均有默认值,无需校验),返回具体错误明细
1203
+ * 发布校验:校验审批人(指定审批人但人员为空)与条件分支完整性,返回错误明细与失败节点 id
1163
1204
  * @param {Graph} graph 图实例
1164
- * @returns {string[]} 错误明细列表
1205
+ * @returns {{ errors: string[], errorNodeIds: string[] }} 错误明细列表与失败节点 id 列表
1165
1206
  */
1166
- var validateFlow = (graph) => {
1207
+ var validateFlowDetails = (graph) => {
1167
1208
  const errors = [];
1168
- if (!graph) return errors;
1209
+ const errorNodeIds = [];
1210
+ if (!graph) return {
1211
+ errors,
1212
+ errorNodeIds
1213
+ };
1169
1214
  graph.getNodes().forEach((n) => {
1170
1215
  const d = n.getData() || {};
1216
+ if (d.type === NODE_TYPE.APPROVER) {
1217
+ const cfg = d.config || {};
1218
+ const approvers = Array.isArray(cfg.approvers) ? cfg.approvers : [];
1219
+ if (cfg.assigneeType === "specified" && !approvers.length) {
1220
+ errors.push(`审批节点「${d.name || "审批人"}」尚未选择审批人`);
1221
+ if (!errorNodeIds.includes(n.id)) errorNodeIds.push(n.id);
1222
+ }
1223
+ return;
1224
+ }
1171
1225
  if (d.type !== NODE_TYPE.CONDITION || d.isDefault) return;
1172
1226
  const name = d.name || "条件分支";
1173
1227
  const groups = d.config?.conditionGroups;
1228
+ const markNode = () => {
1229
+ if (!errorNodeIds.includes(n.id)) errorNodeIds.push(n.id);
1230
+ };
1174
1231
  if (!Array.isArray(groups) || groups.length === 0) {
1175
1232
  errors.push(`条件分支「${name}」尚未配置条件`);
1233
+ markNode();
1176
1234
  return;
1177
1235
  }
1178
1236
  groups.forEach((g, gi) => {
1179
1237
  (Array.isArray(g?.rules) ? g.rules : []).forEach((r, ri) => {
1180
- if (!r.field) errors.push(`条件分支「${name}」第 ${gi + 1} 组第 ${ri + 1} 条规则未选择字段`);
1181
- if (Array.isArray(r.value) ? r.value.length === 0 : r.value === void 0 || r.value === null || String(r.value).trim() === "") errors.push(`条件分支「${name}」第 ${gi + 1} 组第 ${ri + 1} 条规则未填写条件值`);
1238
+ if (!r.field) {
1239
+ errors.push(`条件分支「${name}」第 ${gi + 1} 组第 ${ri + 1} 条规则未选择字段`);
1240
+ markNode();
1241
+ }
1242
+ if (Array.isArray(r.value) ? r.value.length === 0 : r.value === void 0 || r.value === null || String(r.value).trim() === "") {
1243
+ errors.push(`条件分支「${name}」第 ${gi + 1} 组第 ${ri + 1} 条规则未填写条件值`);
1244
+ markNode();
1245
+ }
1182
1246
  });
1183
1247
  });
1184
1248
  });
1185
- return errors;
1249
+ return {
1250
+ errors,
1251
+ errorNodeIds
1252
+ };
1253
+ };
1254
+ /**
1255
+ * 校验结果标红:失败节点 data.invalid = true 驱动卡片红边框,其余节点清除标记;
1256
+ * 仅在标记变化时 setData,避免无谓触发 change:data 重渲染
1257
+ */
1258
+ var markInvalidNodes = (graph, errorNodeIds = []) => {
1259
+ graph?.getNodes().forEach((n) => {
1260
+ const shouldMark = errorNodeIds.includes(n.id);
1261
+ if (!!n.getData()?.invalid !== shouldMark) n.setData({ invalid: shouldMark });
1262
+ });
1186
1263
  };
1187
1264
  //#endregion
1188
1265
  //#region src/config/FlowConfigFlow/graph/layout.js
@@ -1631,7 +1708,7 @@ var insertConditionGroup = (graph, upstreamIds, downstreamIds) => {
1631
1708
  });
1632
1709
  };
1633
1710
  /** 插入普通节点(附带默认 config):上游 ids → 新节点 → 下游 ids */
1634
- var insertPlainNode = (graph, type, upstreamIds, downstreamIds) => {
1711
+ var insertPlainNode = (graph, type, upstreamIds, downstreamIds, isExternal) => {
1635
1712
  const nodeId = genId();
1636
1713
  graph.addNode(nodeOptions({
1637
1714
  id: nodeId,
@@ -1639,7 +1716,7 @@ var insertPlainNode = (graph, type, upstreamIds, downstreamIds) => {
1639
1716
  type,
1640
1717
  x: 0,
1641
1718
  y: 0,
1642
- config: getDefaultConfig(type)
1719
+ config: getDefaultConfig(type, isExternal)
1643
1720
  }));
1644
1721
  upstreamIds.forEach((uid) => graph.addEdge(edgeOptions(uid, nodeId)));
1645
1722
  downstreamIds.forEach((did) => graph.addEdge(edgeOptions(nodeId, did)));
@@ -1660,7 +1737,7 @@ var insertPlainNode = (graph, type, upstreamIds, downstreamIds) => {
1660
1737
  * @param {string} sourceId 源节点 id
1661
1738
  * @param {string} targetId 目标节点 id
1662
1739
  * @param {string} type 要插入的节点类型(NODE_TYPE 中的值)
1663
- * @param {{afterGroup?: boolean}} [options] afterGroup:是否在整组之后插入(组出口按钮专用)
1740
+ * @param {{afterGroup?: boolean, isExternal?: number}} [options] afterGroup:是否在整组之后插入(组出口按钮专用);isExternal:外部流程标识(透传 getDefaultConfig,外部流程下审批人节点默认指定审批人)
1664
1741
  */
1665
1742
  var insertNodeBetween = (graph, sourceId, targetId, type, options = {}) => {
1666
1743
  if (!graph) return;
@@ -1674,7 +1751,7 @@ var insertNodeBetween = (graph, sourceId, targetId, type, options = {}) => {
1674
1751
  graph.getEdges().filter((e) => e.getSourceCellId() === sourceId && e.getTargetCellId() === cid).forEach((e) => graph.removeEdge(e));
1675
1752
  });
1676
1753
  if (type === NODE_TYPE.CONDITION) insertConditionGroup(graph, [sourceId], siblingConds);
1677
- else insertPlainNode(graph, type, [sourceId], siblingConds);
1754
+ else insertPlainNode(graph, type, [sourceId], siblingConds, options.isExternal);
1678
1755
  autoLayout(graph);
1679
1756
  return;
1680
1757
  }
@@ -1684,14 +1761,14 @@ var insertNodeBetween = (graph, sourceId, targetId, type, options = {}) => {
1684
1761
  const tailIds = [...new Set(oldExitEdges.map((e) => e.getSourceCellId()))];
1685
1762
  oldExitEdges.forEach((e) => graph.removeEdge(e));
1686
1763
  if (type === NODE_TYPE.CONDITION) insertConditionGroup(graph, tailIds, [convergeId]);
1687
- else insertPlainNode(graph, type, tailIds, [convergeId]);
1764
+ else insertPlainNode(graph, type, tailIds, [convergeId], options.isExternal);
1688
1765
  autoLayout(graph);
1689
1766
  return;
1690
1767
  }
1691
1768
  const oldEdge = graph.getEdges().find((e) => e.getSourceCellId() === sourceId && e.getTargetCellId() === targetId);
1692
1769
  if (oldEdge) graph.removeEdge(oldEdge);
1693
1770
  if (type === NODE_TYPE.CONDITION) insertConditionGroup(graph, [sourceId], [targetId]);
1694
- else insertPlainNode(graph, type, [sourceId], [targetId]);
1771
+ else insertPlainNode(graph, type, [sourceId], [targetId], options.isExternal);
1695
1772
  autoLayout(graph);
1696
1773
  };
1697
1774
  //#endregion
@@ -2634,7 +2711,7 @@ function usePersonData() {
2634
2711
  //#endregion
2635
2712
  //#region src/person-selector/composables/useSelection.ts
2636
2713
  function useSelection(options) {
2637
- const { modelValue, depts, roles, people, paused, onChange } = options;
2714
+ const { modelValue, depts, roles, people, paused, multiple = true, onChange } = options;
2638
2715
  const modelValueArray = computed(() => Array.isArray(modelValue()) ? modelValue() : []);
2639
2716
  const localSelected = ref([...modelValueArray.value]);
2640
2717
  watch(modelValueArray, (v) => {
@@ -2726,7 +2803,7 @@ function useSelection(options) {
2726
2803
  if (it.type === "person" && covered.has(key)) return false;
2727
2804
  return !isItemStopDisabled(it);
2728
2805
  });
2729
- localSelected.value = [...kept, ...fresh];
2806
+ localSelected.value = multiple === false ? fresh.slice(-1) : [...kept, ...fresh];
2730
2807
  };
2731
2808
  const removeMany = (items) => {
2732
2809
  if (!items.length) return;
@@ -2929,7 +3006,11 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
2929
3006
  modelValue: { default: () => [] },
2930
3007
  selectableTypes: { default: () => ["person"] },
2931
3008
  placeholder: { default: "请选择" },
2932
- displayMode: { default: "overflow" }
3009
+ displayMode: { default: "overflow" },
3010
+ multiple: {
3011
+ type: Boolean,
3012
+ default: true
3013
+ }
2933
3014
  },
2934
3015
  emits: ["update:modelValue", "change"],
2935
3016
  setup(__props, { emit: __emit }) {
@@ -2968,6 +3049,7 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
2968
3049
  depts,
2969
3050
  roles,
2970
3051
  people,
3052
+ multiple: props.multiple,
2971
3053
  paused: () => dialogVisible.value,
2972
3054
  onChange: (value) => {
2973
3055
  emit("update:modelValue", value);
@@ -3274,7 +3356,7 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3274
3356
  _: 1
3275
3357
  }, 8, ["value"])) : createCommentVNode("", true),
3276
3358
  showDeptNav.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_12$3, [
3277
- canSelectDept.value ? (openBlock(), createBlock(unref(NCheckbox), {
3359
+ canSelectDept.value && __props.multiple ? (openBlock(), createBlock(unref(NCheckbox), {
3278
3360
  key: 0,
3279
3361
  checked: allDeptsChecked.value,
3280
3362
  indeterminate: allDeptsIndeterminate.value,
@@ -3292,7 +3374,7 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3292
3374
  }]),
3293
3375
  onClick: ($event) => activeDept.value = dept.id
3294
3376
  }, [
3295
- canSelectDept.value ? (openBlock(), createBlock(unref(NCheckbox), {
3377
+ canSelectDept.value && __props.multiple ? (openBlock(), createBlock(unref(NCheckbox), {
3296
3378
  key: 0,
3297
3379
  checked: unref(isSelected)("dept", dept.id),
3298
3380
  disabled: unref(isDeptDisabled)(dept.id) && !unref(isSelected)("dept", dept.id),
@@ -3322,11 +3404,12 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3322
3404
  ], 10, _hoisted_16$1);
3323
3405
  }), 128))])], 512)), [[vShow, !showNavTabs.value || navTab.value === "dept"]]) : createCommentVNode("", true),
3324
3406
  canSelectRole.value ? withDirectives((openBlock(), createElementBlock("div", _hoisted_18$1, [
3325
- createVNode(unref(NCheckbox), {
3407
+ __props.multiple ? (openBlock(), createBlock(unref(NCheckbox), {
3408
+ key: 0,
3326
3409
  checked: allRolesChecked.value,
3327
3410
  indeterminate: allRolesIndeterminate.value,
3328
3411
  "onUpdate:checked": toggleAllRoles
3329
- }, null, 8, ["checked", "indeterminate"]),
3412
+ }, null, 8, ["checked", "indeterminate"])) : createCommentVNode("", true),
3330
3413
  _cache[12] || (_cache[12] = createTextVNode(" 角色 ", -1)),
3331
3414
  _cache[13] || (_cache[13] = createElementVNode("span", { class: "person-selector__panel-hint" }, "(点击选择)", -1))
3332
3415
  ], 512)), [[vShow, !showNavTabs.value || navTab.value === "role"]]) : createCommentVNode("", true),
@@ -3339,7 +3422,7 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3339
3422
  }]),
3340
3423
  onClick: ($event) => activeRole.value = role.id
3341
3424
  }, [
3342
- canSelectRole.value ? (openBlock(), createBlock(unref(NCheckbox), {
3425
+ canSelectRole.value && __props.multiple ? (openBlock(), createBlock(unref(NCheckbox), {
3343
3426
  key: 0,
3344
3427
  checked: unref(isSelected)("role", role.id),
3345
3428
  disabled: unref(isRoleDisabled)(role.id) && !unref(isSelected)("role", role.id),
@@ -3369,7 +3452,8 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3369
3452
  ], 10, _hoisted_21$1);
3370
3453
  }), 128))])], 512)), [[vShow, !showNavTabs.value || navTab.value === "role"]]) : createCommentVNode("", true)
3371
3454
  ]), canSelectPerson.value ? (openBlock(), createElementBlock("div", _hoisted_23$1, [createElementVNode("div", _hoisted_24$1, [
3372
- createVNode(unref(NCheckbox), {
3455
+ __props.multiple ? (openBlock(), createBlock(unref(NCheckbox), {
3456
+ key: 0,
3373
3457
  checked: allPeopleChecked.value,
3374
3458
  indeterminate: allPeopleIndeterminate.value,
3375
3459
  disabled: allPeopleDisabled.value,
@@ -3378,7 +3462,7 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3378
3462
  "checked",
3379
3463
  "indeterminate",
3380
3464
  "disabled"
3381
- ]),
3465
+ ])) : createCommentVNode("", true),
3382
3466
  _cache[15] || (_cache[15] = createTextVNode(" 人员 ", -1)),
3383
3467
  createElementVNode("span", _hoisted_25$1, toDisplayString(allPeopleDisabled.value ? `(${peopleDisabledReason.value})` : "(点击选择)"), 1)
3384
3468
  ]), createElementVNode("div", _hoisted_26$1, [createElementVNode("div", _hoisted_27, [(openBlock(true), createElementBlock(Fragment, null, renderList(displayPeople.value, (p) => {
@@ -3430,11 +3514,12 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3430
3514
  createElementVNode("path", { d: "M21 21l-4.35-4.35" }),
3431
3515
  createElementVNode("path", { d: "M8 11h6" })
3432
3516
  ], -1), createElementVNode("span", null, "暂无人员", -1)])])) : createCommentVNode("", true)])])])) : createCommentVNode("", true)], 2),
3433
- unref(localSelected).length ? (openBlock(), createElementBlock("div", _hoisted_31, [createElementVNode("div", _hoisted_32, [createElementVNode("span", _hoisted_33, [createVNode(unref(NCheckbox), {
3517
+ unref(localSelected).length ? (openBlock(), createElementBlock("div", _hoisted_31, [createElementVNode("div", _hoisted_32, [createElementVNode("span", _hoisted_33, [__props.multiple ? (openBlock(), createBlock(unref(NCheckbox), {
3518
+ key: 0,
3434
3519
  checked: allGlobalChecked.value,
3435
3520
  indeterminate: allGlobalIndeterminate.value,
3436
3521
  "onUpdate:checked": toggleAllGlobal
3437
- }, null, 8, ["checked", "indeterminate"]), createElementVNode("span", null, [
3522
+ }, null, 8, ["checked", "indeterminate"])) : createCommentVNode("", true), createElementVNode("span", null, [
3438
3523
  _cache[18] || (_cache[18] = createTextVNode(" 已选 ", -1)),
3439
3524
  createElementVNode("strong", null, toDisplayString(unref(localSelected).length), 1),
3440
3525
  _cache[19] || (_cache[19] = createTextVNode(" 项 ", -1))
@@ -3472,7 +3557,7 @@ var person_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(
3472
3557
  ])]);
3473
3558
  };
3474
3559
  }
3475
- }), [["__scopeId", "data-v-fe31f4e2"]]);
3560
+ }), [["__scopeId", "data-v-94c096c2"]]);
3476
3561
  //#endregion
3477
3562
  //#region src/person-selector/PersonSelectorSlot.vue
3478
3563
  var PersonSelectorSlot_default = /* @__PURE__ */ defineComponent({
@@ -3480,7 +3565,10 @@ var PersonSelectorSlot_default = /* @__PURE__ */ defineComponent({
3480
3565
  inheritAttrs: false,
3481
3566
  __name: "PersonSelectorSlot",
3482
3567
  setup(__props) {
3483
- const resolved = computed(() => getFlowUIConfig().components.PersonSelector || person_selector_default);
3568
+ const resolved = computed(() => {
3569
+ const custom = getFlowUIConfig().components.PersonSelector;
3570
+ return custom && validatePersonSelectorComponent(custom) ? custom : person_selector_default;
3571
+ });
3484
3572
  return (_ctx, _cache) => {
3485
3573
  return openBlock(), createBlock(resolveDynamicComponent(resolved.value), normalizeProps(guardReactiveProps(_ctx.$attrs)), null, 16);
3486
3574
  };
@@ -3981,8 +4069,15 @@ var NodeConfigDrawer_default = /* @__PURE__ */ _plugin_vue_export_helper_default
3981
4069
  watch(() => props.visible, (v) => {
3982
4070
  if (v) initForm();
3983
4071
  });
3984
- /** 确认:条件类型先校验完整性(未配置 / 条件值未填写),不通过则提示且不关闭抽屉 */
4072
+ /** 确认:审批人类型(指定审批人但人员为空)/ 条件类型(未配置 / 条件值未填写)先校验完整性,不通过则提示且不关闭抽屉 */
3985
4073
  const handleConfirm = (close) => {
4074
+ if (nodeType.value === NODE_TYPE.APPROVER && form.config.assigneeType === "specified") {
4075
+ if (!(Array.isArray(form.config.approvers) ? form.config.approvers : []).length) {
4076
+ window.$message?.warning("请选择审批人");
4077
+ close(false);
4078
+ return;
4079
+ }
4080
+ }
3986
4081
  if (nodeType.value === NODE_TYPE.CONDITION) {
3987
4082
  const groups = form.config.conditionGroups || [];
3988
4083
  if (!groups.some((g) => g.rules?.some((r) => r.field))) {
@@ -4049,7 +4144,7 @@ var NodeConfigDrawer_default = /* @__PURE__ */ _plugin_vue_export_helper_default
4049
4144
  }, 8, ["show", "title"]);
4050
4145
  };
4051
4146
  }
4052
- }), [["__scopeId", "data-v-3485c546"]]);
4147
+ }), [["__scopeId", "data-v-1d8631e0"]]);
4053
4148
  //#endregion
4054
4149
  //#region src/config/FlowConfigFlow/composables/useNodeDrawer.ts
4055
4150
  /**
@@ -4102,7 +4197,8 @@ function useNodeDrawer(getGraph, onConfirm) {
4102
4197
  const d = cell.getData() || {};
4103
4198
  cell.setData({
4104
4199
  ...d,
4105
- config
4200
+ config,
4201
+ invalid: false
4106
4202
  }, { overwrite: true });
4107
4203
  }
4108
4204
  onConfirm?.();
@@ -4350,7 +4446,8 @@ var FlowNodeCard_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/*
4350
4446
  key: 1,
4351
4447
  class: normalizeClass(["fnode", [`fnode--${data.type}`, {
4352
4448
  "fnode--active": data.active,
4353
- "fnode--default-condition": isDefaultCondition.value
4449
+ "fnode--default-condition": isDefaultCondition.value,
4450
+ "fnode--invalid": data.invalid
4354
4451
  }]])
4355
4452
  }, [
4356
4453
  createElementVNode("div", _hoisted_2$9, [createVNode(FlowIcon_default, {
@@ -4423,7 +4520,7 @@ var FlowNodeCard_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/*
4423
4520
  ], 2));
4424
4521
  };
4425
4522
  }
4426
- }), [["__scopeId", "data-v-626844a8"]]);
4523
+ }), [["__scopeId", "data-v-eda68330"]]);
4427
4524
  //#endregion
4428
4525
  //#region src/config/FlowConfigFlow/index.vue?vue&type=script&setup=true&lang.ts
4429
4526
  var _hoisted_1$12 = { class: "flow-config-flow" };
@@ -4577,16 +4674,23 @@ var FlowConfigFlow_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/
4577
4674
  closeMenu();
4578
4675
  return;
4579
4676
  }
4580
- insertNodeBetween(graph, pendingInsert.sourceId, pendingInsert.targetId, type, { afterGroup: pendingInsert.afterGroup });
4677
+ insertNodeBetween(graph, pendingInsert.sourceId, pendingInsert.targetId, type, {
4678
+ afterGroup: pendingInsert.afterGroup,
4679
+ isExternal: props.isExternal
4680
+ });
4581
4681
  closeMenu();
4582
4682
  refreshAllButtons();
4583
4683
  emitGraphChange();
4584
4684
  };
4585
- const validateFlow$1 = () => validateFlow(graph);
4685
+ const validateFlow = () => {
4686
+ const { errors, errorNodeIds } = validateFlowDetails(graph);
4687
+ markInvalidNodes(graph, errorNodeIds);
4688
+ return errors;
4689
+ };
4586
4690
  /** 导出嵌套子节点链(链首 start 节点本体,不含画布元素):供父组件保存时打印 / 提交 */
4587
4691
  const getProcessData = () => graphToProcessData(graph);
4588
4692
  __expose({
4589
- validateFlow: validateFlow$1,
4693
+ validateFlow,
4590
4694
  getProcessData
4591
4695
  });
4592
4696
  onMounted(() => {
@@ -4612,7 +4716,10 @@ var FlowConfigFlow_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/
4612
4716
  return;
4613
4717
  }
4614
4718
  if (data?.type === NODE_TYPE.END) return;
4615
- if (data?.type === NODE_TYPE.START && props.isExternal !== 0) return;
4719
+ if (data?.type === NODE_TYPE.START && props.isExternal !== 0) {
4720
+ window.$message?.warning("外部流程由外部系统发起,发起人无需配置");
4721
+ return;
4722
+ }
4616
4723
  if (data?.isDefault) return;
4617
4724
  openNodeDrawer(node);
4618
4725
  });
@@ -4680,7 +4787,7 @@ var FlowConfigFlow_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/
4680
4787
  ]);
4681
4788
  };
4682
4789
  }
4683
- }), [["__scopeId", "data-v-c3fa1fc2"]]);
4790
+ }), [["__scopeId", "data-v-edefe008"]]);
4684
4791
  //#endregion
4685
4792
  //#region src/config/FlowConfigMore.vue?vue&type=script&setup=true&lang.ts
4686
4793
  var _hoisted_1$11 = { class: "flow-config-more" };
@@ -4763,7 +4870,8 @@ var FlowConfigMore_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/
4763
4870
  default: withCtx(() => [createVNode(PersonSelectorSlot_default, {
4764
4871
  modelValue: settings.value.manager,
4765
4872
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => settings.value.manager = $event),
4766
- placeholder: "请选择流程管理员"
4873
+ placeholder: "请选择流程管理员",
4874
+ multiple: false
4767
4875
  }, null, 8, ["modelValue"])]),
4768
4876
  _: 1
4769
4877
  }),
@@ -4872,7 +4980,7 @@ var FlowConfigMore_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/
4872
4980
  }, 8, ["model"])]);
4873
4981
  };
4874
4982
  }
4875
- }), [["__scopeId", "data-v-5850f6ef"]]);
4983
+ }), [["__scopeId", "data-v-fde6bc00"]]);
4876
4984
  //#endregion
4877
4985
  //#region src/config/FlowConfig.vue?vue&type=script&setup=true&lang.ts
4878
4986
  var _hoisted_1$10 = { class: "flow-config__header" };
@@ -4961,9 +5069,21 @@ var FlowConfig_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @_
4961
5069
  const fieldRef = ref();
4962
5070
  const flowRef = ref();
4963
5071
  const moreRef = ref();
4964
- /** 校验失败提示:每个模块仅弹一条 message,只展示精简标题文案 */
4965
- const notifyErrors = (tip) => {
4966
- window.$message?.error(tip);
5072
+ /** 校验失败提示:每个模块弹一条 message,标题下列具体错误明细(含节点名),便于直接定位无需逐个排查 */
5073
+ const notifyErrors = (tip, errors = []) => {
5074
+ if (!errors.length) {
5075
+ window.$message?.error(tip);
5076
+ return;
5077
+ }
5078
+ const shown = errors.slice(0, 5);
5079
+ window.$message?.error(() => h("div", { style: "max-width:420px" }, [
5080
+ h("div", { style: "font-weight:600" }, tip),
5081
+ ...shown.map((e) => h("div", { style: "font-size:12px;opacity:.85;margin-top:4px;line-height:1.5" }, `· ${e}`)),
5082
+ ...errors.length > shown.length ? [h("div", { style: "font-size:12px;opacity:.85;margin-top:4px" }, `…等共 ${errors.length} 项问题`)] : []
5083
+ ]), {
5084
+ duration: 5e3,
5085
+ closable: true
5086
+ });
4967
5087
  };
4968
5088
  /** 保存前校验:字段配置(添加了字段则各项配置必填)→ 流程设计(条件完整性)→ 更多设置(流程管理员必填)。
4969
5089
  * 校验失败时切换到首个出错页签;多个模块出错时逐条弹出对应提示;全部通过才向上抛出 publish。
@@ -4980,7 +5100,7 @@ var FlowConfig_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @_
4980
5100
  }],
4981
5101
  {
4982
5102
  step: 2,
4983
- tip: "【流程设计】条件未配置完整",
5103
+ tip: "【流程设计】流程配置不完整",
4984
5104
  errors: flowRef.value?.validateFlow?.() || []
4985
5105
  },
4986
5106
  {
@@ -5003,7 +5123,7 @@ var FlowConfig_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @_
5003
5123
  return;
5004
5124
  }
5005
5125
  currentStep.value = failed[0].step;
5006
- failed.forEach((c) => notifyErrors(c.tip));
5126
+ failed.forEach((c) => notifyErrors(c.tip, c.errors));
5007
5127
  } finally {
5008
5128
  validating.value = false;
5009
5129
  }
@@ -5085,7 +5205,7 @@ var FlowConfig_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @_
5085
5205
  }, 8, ["style"]);
5086
5206
  };
5087
5207
  }
5088
- }), [["__scopeId", "data-v-5e56d074"]]);
5208
+ }), [["__scopeId", "data-v-a1a3b101"]]);
5089
5209
  //#endregion
5090
5210
  //#region src/utils/common.ts
5091
5211
  /** 判断是否为空(undefined/null/空字符串) */
@@ -5162,7 +5282,7 @@ var _hoisted_3$4 = {
5162
5282
  };
5163
5283
  /** 扩展名 → 预览类型映射(代码/文本类不在表内,走下载兜底) */
5164
5284
  var FILE_ORIGIN = "https://download.yugu8.com";
5165
- /** 文件同域反代前缀 */
5285
+ /** 文件同域反代前缀(仅 localhost dev) */
5166
5286
  var FILE_PROXY_PREFIX = "/download-proxy";
5167
5287
  //#endregion
5168
5288
  //#region src/file-preview/index.vue
@@ -5224,10 +5344,13 @@ var file_preview_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/*
5224
5344
  "excel",
5225
5345
  "pptx"
5226
5346
  ].includes(kind.value));
5227
- /** 文件资源域名(与 vite.config.ts 的 /download-proxy 代理目标保持一致) */
5347
+ /** 文件资源域名(vite.config.ts 的 /download-proxy 代理目标;仅 localhost dev 走该改写,线上直连) */
5348
+ const isLocalhost = ["localhost", "127.0.0.1"].includes(window.location.hostname);
5349
+ /** 文档类预览 URL:线上直连完整文件域名(CORS 已放行);仅 localhost 开发环境改写为同域反代路径 */
5228
5350
  const previewUrl = computed(() => {
5229
5351
  if (!isDocKind.value) return props.url;
5230
- return props.url.startsWith(FILE_ORIGIN) ? FILE_PROXY_PREFIX + props.url.slice(26) : props.url;
5352
+ if (isLocalhost && props.url.startsWith(FILE_ORIGIN)) return FILE_PROXY_PREFIX + props.url.slice(26);
5353
+ return props.url;
5231
5354
  });
5232
5355
  /** @vue-office 可选组件懒加载器:kind → 动态 import(未安装/加载失败时 promise reject,由加载函数降级) */
5233
5356
  const OFFICE_LOADERS = {
@@ -5404,7 +5527,7 @@ var file_preview_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/*
5404
5527
  }, 8, ["description"])]))], 4);
5405
5528
  };
5406
5529
  }
5407
- }), [["__scopeId", "data-v-e50ab833"]]);
5530
+ }), [["__scopeId", "data-v-39ebb3af"]]);
5408
5531
  //#endregion
5409
5532
  //#region src/file-preview/file-preview-modal.vue
5410
5533
  var file_preview_modal_default = /* @__PURE__ */ defineComponent({
@@ -5855,7 +5978,7 @@ var FlowNode_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__P
5855
5978
  ], 6);
5856
5979
  };
5857
5980
  }
5858
- }), [["__scopeId", "data-v-c108c6cb"]]);
5981
+ }), [["__scopeId", "data-v-c730ebf8"]]);
5859
5982
  //#endregion
5860
5983
  //#region src/timeline/ApprovalModal.vue?vue&type=script&setup=true&lang.ts
5861
5984
  var _hoisted_1$6 = { class: "reject-node-list" };
@@ -6123,7 +6246,7 @@ function isLatestRowsReject(rows) {
6123
6246
  const latest = rows.reduce((acc, cur) => (cur.assertion_time ?? 0) >= (acc.assertion_time ?? 0) ? cur : acc, rows[0]);
6124
6247
  return latest.result === 3 || latest.is_reject === 1;
6125
6248
  }
6126
- /** 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 最新一条:驳回标红、同意标绿),无操作记录随节点状态(进行中节点淡黄、其余灰色未处理) */
6249
+ /** 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 最新一条:驳回标红、同意标绿;发起人节点人员固定成功绿色),无操作记录随节点状态(进行中节点淡黄、其余灰色未处理) */
6127
6250
  function mapTimelineNodes(data) {
6128
6251
  const d = data;
6129
6252
  if (!d?.nodes?.length) return [];
@@ -6134,13 +6257,13 @@ function mapTimelineNodes(data) {
6134
6257
  const currentIndex = activeIndex > -1 ? activeIndex : pendingIndex > -1 ? pendingIndex : instanceFinished ? -1 : d.nodes.findIndex((item) => item.finished !== 1);
6135
6258
  return d.nodes.map((node, index) => {
6136
6259
  const forcePending = !instanceFinished && (activeIndex > -1 || pendingIndex > -1) && index > currentIndex;
6137
- const nodeStatus = node.type === "start" ? instanceRejected ? "rejected" : "done" : instanceRejected ? "pending" : forcePending ? "pending" : !instanceFinished && index === currentIndex ? "doing" : instanceFinished || node.finished === 1 || currentIndex > -1 && index < currentIndex ? "done" : "pending";
6260
+ const nodeStatus = node.type === "start" ? "done" : instanceRejected ? "pending" : forcePending ? "pending" : !instanceFinished && index === currentIndex ? "doing" : instanceFinished || node.finished === 1 || currentIndex > -1 && index < currentIndex ? "done" : "pending";
6138
6261
  const users = node.users.map((user) => {
6139
6262
  const records = toUserRecords(user, instanceRejected);
6140
6263
  const rawRows = Array.isArray(user.records) ? user.records : [];
6141
6264
  const hasPendingRow = rawRows.some((record) => record.result === 0 && record.finished === 0);
6142
6265
  const processedRows = rawRows.filter((record) => record.result === 2 || record.result === 3 || record.is_reject === 1);
6143
- const status = hasPendingRow ? nodeStatus === "doing" ? "doing" : "pending" : processedRows.length ? isLatestRowsReject(processedRows) ? "rejected" : "done" : nodeStatus === "doing" ? "doing" : nodeStatus === "done" && node.mode === "orsign" ? "pending" : nodeStatus;
6266
+ const status = node.type === "start" ? "done" : hasPendingRow ? nodeStatus === "doing" ? "doing" : "pending" : processedRows.length ? isLatestRowsReject(processedRows) ? "rejected" : "done" : nodeStatus === "doing" ? "doing" : nodeStatus === "done" && node.mode === "orsign" ? "pending" : nodeStatus;
6144
6267
  return {
6145
6268
  id: user.id,
6146
6269
  name: user.name,
@@ -6155,7 +6278,7 @@ function mapTimelineNodes(data) {
6155
6278
  status: nodeStatus,
6156
6279
  name: node.name,
6157
6280
  desc: node.desc ?? void 0,
6158
- time: node.created_time && (node.finished === 1 || nodeStatus === "done" || nodeStatus === "rejected") ? formatTime(node.created_time, "YYYY-MM-DD HH:mm") : void 0,
6281
+ time: node.created_time && (node.finished === 1 || nodeStatus === "done") ? formatTime(node.created_time, "YYYY-MM-DD HH:mm") : void 0,
6159
6282
  mode: node.mode,
6160
6283
  selfSelect: node.selfSelect,
6161
6284
  users
@@ -6674,6 +6797,18 @@ var FlowLayout_default = /* @__PURE__ */ defineComponent({
6674
6797
  function handleReject() {
6675
6798
  openApproval("reject");
6676
6799
  }
6800
+ /** 撤回:二次确认(window.$dialog 由宿主 app-provider 注入);撤回接口待接入,确认后暂仅提示成功 */
6801
+ function handleWithdraw() {
6802
+ window.$dialog?.warning({
6803
+ title: "撤回确认",
6804
+ content: "确定撤回当前流程吗?",
6805
+ positiveText: "确定",
6806
+ negativeText: "取消",
6807
+ onPositiveClick: () => {
6808
+ window.$message?.success("流程已撤回");
6809
+ }
6810
+ });
6811
+ }
6677
6812
  /** 审批弹窗提交:approve 调 /wflow/undo/approve(意见附件可空)、reject 调 /wflow/undo/reject(意见与目标节点 ID 必传,整节点重置);成功 done() 关闭弹窗并 emit success 通知页面刷新详情,失败 done(false) 保持弹窗打开并结束确认按钮 loading */
6678
6813
  async function handleApprovalSubmit(value, done) {
6679
6814
  const undoId = props.timelineData?.undo_id;
@@ -6811,14 +6946,25 @@ var FlowLayout_default = /* @__PURE__ */ defineComponent({
6811
6946
  _: 2
6812
6947
  }, [canReject.value || _ctx.$slots["footer-center"] ? {
6813
6948
  name: "footer-center",
6814
- fn: withCtx(() => [canReject.value ? (openBlock(), createBlock(_component_NButton, {
6815
- key: 0,
6816
- type: "error",
6817
- onClick: handleReject
6818
- }, {
6819
- default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("驳回", -1)])]),
6820
- _: 1
6821
- })) : createCommentVNode("", true), renderSlot(_ctx.$slots, "footer-center")]),
6949
+ fn: withCtx(() => [
6950
+ canReject.value ? (openBlock(), createBlock(_component_NButton, {
6951
+ key: 0,
6952
+ type: "warning",
6953
+ onClick: handleWithdraw
6954
+ }, {
6955
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("撤回", -1)])]),
6956
+ _: 1
6957
+ })) : createCommentVNode("", true),
6958
+ canReject.value ? (openBlock(), createBlock(_component_NButton, {
6959
+ key: 1,
6960
+ type: "error",
6961
+ onClick: handleReject
6962
+ }, {
6963
+ default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode("驳回", -1)])]),
6964
+ _: 1
6965
+ })) : createCommentVNode("", true),
6966
+ renderSlot(_ctx.$slots, "footer-center")
6967
+ ]),
6822
6968
  key: "0"
6823
6969
  } : void 0]), 1032, ["loading", "confirm-config"]);
6824
6970
  };
@@ -7,6 +7,8 @@ interface UseSelectionOptions {
7
7
  people: Ref<PersonItem[]>;
8
8
  /** 弹窗打开期间暂停外部 modelValue 同步,避免用户编辑被外部变化覆盖 */
9
9
  paused?: () => boolean;
10
+ /** 单选模式:false 时新增项替换草稿(最多 1 项),默认多选保持既有行为 */
11
+ multiple?: boolean;
10
12
  /** 确认提交回调(组件内在此触发 update:modelValue / change) */
11
13
  onChange: (value: SelectedItem[]) => void;
12
14
  }