sy-form-components 0.2.12 → 0.2.14

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.mjs CHANGED
@@ -6563,12 +6563,13 @@ var normalizeProcessBasic = (value) => {
6563
6563
  processStatus: raw.processStatus ?? raw.status ?? instance.processStatus ?? instance.status,
6564
6564
  formUuid: raw.formUuid ?? instance.formUuid ?? instance.definition?.formUuid,
6565
6565
  appType: raw.appType ?? instance.appType ?? instance.definition?.appType,
6566
- title: raw.title ?? instance.title,
6566
+ title: raw.title ?? instance.title ?? instance.instanceTitle,
6567
6567
  originatorId: raw.originatorId ?? instance.originatorId ?? instance.startedBy,
6568
6568
  originatorName: raw.originatorName ?? instance.originatorName ?? instance.startedByName,
6569
6569
  originatorDepartment: raw.originatorDepartment ?? instance.originatorDepartment ?? instance.startedDepartmentName,
6570
6570
  createdAt: raw.createdAt ?? instance.createdAt ?? instance.startedAt,
6571
- currentTask
6571
+ currentTask,
6572
+ isExecuting: raw.isExecuting ?? instance.isExecuting
6572
6573
  };
6573
6574
  };
6574
6575
  var normalizeApprovalPermission = (value) => {
@@ -6592,6 +6593,13 @@ var normalizeReturnableNodes = (value) => {
6592
6593
  nodeName: node?.nodeName || node?.name || node?.title || node?.id || ""
6593
6594
  }));
6594
6595
  };
6596
+ var normalizeReturnableNodeResult = (value) => {
6597
+ const raw = value?.data || value || {};
6598
+ return {
6599
+ nodes: normalizeReturnableNodes(raw),
6600
+ policy: raw?.policy || null
6601
+ };
6602
+ };
6595
6603
  var normalizeProcessDefinition = (value) => {
6596
6604
  const raw = value?.definitionJson || value?.viewJson || value || {};
6597
6605
  const nodes = Array.isArray(raw.nodes) ? raw.nodes : [];
@@ -6678,11 +6686,15 @@ async function saveTask(request, params) {
6678
6686
  return response.data || response.result;
6679
6687
  }
6680
6688
  async function getReturnableNodes(request, taskId) {
6689
+ const result = await getReturnableNodeResult(request, taskId);
6690
+ return result.nodes;
6691
+ }
6692
+ async function getReturnableNodeResult(request, taskId) {
6681
6693
  const response = await request({
6682
6694
  url: `/workflow/task/${taskId}/returnable-nodes`,
6683
6695
  method: "get"
6684
6696
  });
6685
- return normalizeReturnableNodes(response.data || response.result);
6697
+ return normalizeReturnableNodeResult(response.data || response.result);
6686
6698
  }
6687
6699
  async function previewProcess(request, params) {
6688
6700
  const response = await request({
@@ -7860,6 +7872,13 @@ var DEFAULT_APPROVAL_ACTIONS = [
7860
7872
  { action: "rejected", name: { zh_CN: "\u62D2\u7EDD" } }
7861
7873
  ];
7862
7874
  var WITHDRAW_ACTION = { action: "withdraw", name: { zh_CN: "\u64A4\u9500" } };
7875
+ var FINAL_PROCESS_STATUSES = /* @__PURE__ */ new Set([
7876
+ "completed",
7877
+ "terminated",
7878
+ "withdrawn",
7879
+ "cancelled"
7880
+ ]);
7881
+ var EDITABLE_COMPLETED_STATUSES = /* @__PURE__ */ new Set(["completed", "terminated"]);
7863
7882
  function mergeCurrentTask(processTask, approvalTask) {
7864
7883
  if (!approvalTask) return processTask ?? null;
7865
7884
  if (!processTask) return approvalTask;
@@ -7881,11 +7900,14 @@ function useProcessDetail(options) {
7881
7900
  const [progressList, setProgressList] = useState25([]);
7882
7901
  const [formData, setFormData] = useState25(null);
7883
7902
  const [instanceInfo, setInstanceInfo] = useState25(null);
7903
+ const [accessDenied, setAccessDenied] = useState25(false);
7904
+ const [loadError, setLoadError] = useState25(null);
7884
7905
  const [isApprover, setIsApprover] = useState25(false);
7885
7906
  const [canWithdraw, setCanWithdraw] = useState25(false);
7886
7907
  const [approvalTasks, setApprovalTasks] = useState25([]);
7887
7908
  const [permissions, setPermissions] = useState25(null);
7888
7909
  const [processDefinition, setProcessDefinition] = useState25(null);
7910
+ const [dataVersion, setDataVersion] = useState25(0);
7889
7911
  const mountedRef = useRef10(true);
7890
7912
  const fieldIdsKey = fieldIds?.join("") ?? "";
7891
7913
  useEffect30(() => {
@@ -7899,26 +7921,34 @@ function useProcessDetail(options) {
7899
7921
  [processInfo?.currentTask, approvalTasks]
7900
7922
  );
7901
7923
  const processStatus = processInfo?.processStatus ?? null;
7902
- const isOriginatorReturn = currentTask?.nodeType === "originator_return";
7903
- const isProcessCompleted = processStatus === "completed" || processStatus === "terminated";
7924
+ const isProcessFinal = processStatus ? FINAL_PROCESS_STATUSES.has(processStatus) : false;
7925
+ const isOriginatorReturn = !isProcessFinal && currentTask?.nodeType === "originator_return";
7926
+ const isProcessCompleted = processStatus ? EDITABLE_COMPLETED_STATUSES.has(processStatus) : false;
7927
+ const canEdit = hasViewOperation(permissions?.operations, "edit");
7928
+ const canDelete = hasViewOperation(permissions?.operations, "delete");
7929
+ const canViewWorkflow = hasViewOperation(permissions?.operations, "workflow");
7930
+ const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
7931
+ const fieldPermissionTask = isProcessFinal ? void 0 : currentTask ?? void 0;
7904
7932
  const { fieldBehaviors } = useFieldPermission({
7905
7933
  viewPermissions: permissions ?? void 0,
7906
7934
  processDefinition: processDefinition ?? void 0,
7907
- currentTask: currentTask ?? void 0,
7908
- isApprover,
7935
+ currentTask: fieldPermissionTask,
7936
+ isApprover: isProcessFinal ? false : isApprover,
7909
7937
  mode
7910
7938
  });
7911
7939
  const activeActions = useMemo13(() => {
7912
- if (!isApprover) return [];
7940
+ if (!isApprover || isProcessFinal) return [];
7913
7941
  const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
7914
7942
  if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
7915
7943
  actions.push(WITHDRAW_ACTION);
7916
7944
  }
7917
7945
  return actions;
7918
- }, [isApprover, currentTask?.actions, canWithdraw]);
7946
+ }, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
7919
7947
  const loadData = useCallback12(async () => {
7920
7948
  if (!mountedRef.current) return;
7921
7949
  setLoading(true);
7950
+ setAccessDenied(false);
7951
+ setLoadError(null);
7922
7952
  try {
7923
7953
  const [basicResult, approvalResult, permResult, formResult] = await Promise.all([
7924
7954
  getProcessBasic(request, formInstanceId),
@@ -7927,16 +7957,35 @@ function useProcessDetail(options) {
7927
7957
  getFormData(request, { formInstanceId, appType, formUuid })
7928
7958
  ]);
7929
7959
  if (!mountedRef.current) return;
7960
+ if (!hasViewPermission(permResult)) {
7961
+ setAccessDenied(true);
7962
+ setProcessInfo(null);
7963
+ setIsApprover(false);
7964
+ setCanWithdraw(false);
7965
+ setApprovalTasks([]);
7966
+ setPermissions(permResult);
7967
+ setInstanceInfo(null);
7968
+ setFormData(null);
7969
+ setProgressList([]);
7970
+ setProcessDefinition(null);
7971
+ return;
7972
+ }
7930
7973
  setProcessInfo(basicResult);
7931
- setIsApprover(approvalResult?.isApprover ?? false);
7932
- setCanWithdraw(approvalResult?.canUndo ?? false);
7933
- setApprovalTasks(approvalResult?.currentTasks ?? []);
7974
+ const nextProcessStatus = basicResult?.processStatus ?? null;
7975
+ const nextIsProcessFinal = nextProcessStatus ? FINAL_PROCESS_STATUSES.has(nextProcessStatus) : false;
7976
+ const nextCanWithdraw = Boolean(
7977
+ approvalResult?.canUndo && nextProcessStatus === "running" && basicResult?.isExecuting !== true
7978
+ );
7979
+ setIsApprover(nextIsProcessFinal ? false : approvalResult?.isApprover ?? false);
7980
+ setCanWithdraw(nextCanWithdraw);
7981
+ setApprovalTasks(nextIsProcessFinal ? [] : approvalResult?.currentTasks ?? []);
7934
7982
  setPermissions(permResult);
7935
7983
  setInstanceInfo(formResult);
7936
7984
  setFormData(
7937
7985
  extractFormValues(formResult, fieldIdsKey ? fieldIdsKey.split("") : void 0)
7938
7986
  );
7939
- if (permResult?.operations?.includes("VIEW_PROCESS") || permResult?.operations?.length > 0) {
7987
+ setDataVersion((version) => version + 1);
7988
+ if (hasViewOperation(permResult?.operations, "workflow")) {
7940
7989
  try {
7941
7990
  const progress = await getProcessProgress(request, formInstanceId);
7942
7991
  if (mountedRef.current) {
@@ -7946,8 +7995,8 @@ function useProcessDetail(options) {
7946
7995
  console.error("[useProcessDetail] Failed to load progress:", error);
7947
7996
  }
7948
7997
  }
7949
- const task = basicResult?.currentTask;
7950
- if (approvalResult?.isApprover && task && (task.nodeType === "originator_return" || task.nodeType === "approval")) {
7998
+ const task = mergeCurrentTask(basicResult?.currentTask, approvalResult?.currentTasks?.[0]);
7999
+ if (!nextIsProcessFinal && approvalResult?.isApprover && task && (task.nodeType === "originator_return" || task.nodeType === "approval")) {
7951
8000
  try {
7952
8001
  const definition = await getProcessDefinition(request, formUuid);
7953
8002
  if (mountedRef.current) {
@@ -7956,14 +8005,20 @@ function useProcessDetail(options) {
7956
8005
  } catch (error) {
7957
8006
  console.error("[useProcessDetail] Failed to load process definition:", error);
7958
8007
  }
8008
+ } else if (mountedRef.current) {
8009
+ setProcessDefinition(null);
7959
8010
  }
7960
8011
  } catch (error) {
7961
8012
  console.error("[useProcessDetail] Failed to load data:", error);
7962
8013
  if (mountedRef.current) {
8014
+ setLoadError(error instanceof Error ? error.message : "\u9875\u9762\u52A0\u8F7D\u5931\u8D25");
8015
+ setAccessDenied(false);
7963
8016
  setProcessInfo(null);
7964
8017
  setFormData(null);
7965
8018
  setInstanceInfo(null);
7966
8019
  setApprovalTasks([]);
8020
+ setProgressList([]);
8021
+ setProcessDefinition(null);
7967
8022
  }
7968
8023
  } finally {
7969
8024
  if (mountedRef.current) {
@@ -7976,24 +8031,46 @@ function useProcessDetail(options) {
7976
8031
  }, [loadData]);
7977
8032
  const switchToEdit = useCallback12(() => {
7978
8033
  setMode("edit");
7979
- }, []);
8034
+ void loadData();
8035
+ }, [loadData]);
7980
8036
  const switchToReadonly = useCallback12(() => {
7981
8037
  setMode("readonly");
7982
8038
  }, []);
8039
+ const refreshDetail = useCallback12(async () => {
8040
+ setMode("readonly");
8041
+ await loadData();
8042
+ }, [loadData]);
7983
8043
  const refreshProgress = useCallback12(async () => {
7984
- try {
7985
- const [progress, basicResult] = await Promise.all([
7986
- getProcessProgress(request, formInstanceId),
7987
- getProcessBasic(request, formInstanceId)
7988
- ]);
7989
- if (mountedRef.current) {
7990
- setProgressList(progress);
7991
- setProcessInfo(basicResult);
8044
+ await refreshDetail();
8045
+ }, [refreshDetail]);
8046
+ const saveChanges = useCallback12(
8047
+ async (values) => {
8048
+ try {
8049
+ await api.updateFormData({
8050
+ formInstanceId,
8051
+ formUuid,
8052
+ appType,
8053
+ updateFormDataJson: JSON.stringify(values)
8054
+ });
8055
+ setMode("readonly");
8056
+ await loadData();
8057
+ return true;
8058
+ } catch (error) {
8059
+ console.error("[useProcessDetail] Failed to save changes:", error);
8060
+ return false;
7992
8061
  }
8062
+ },
8063
+ [api, formInstanceId, formUuid, appType, loadData]
8064
+ );
8065
+ const deleteInstance = useCallback12(async () => {
8066
+ try {
8067
+ await deleteFormData(request, { formInstanceId, appType, formUuid });
8068
+ return true;
7993
8069
  } catch (error) {
7994
- console.error("[useProcessDetail] Failed to refresh progress:", error);
8070
+ console.error("[useProcessDetail] Failed to delete instance:", error);
8071
+ return false;
7995
8072
  }
7996
- }, [request, formInstanceId]);
8073
+ }, [request, formInstanceId, appType, formUuid]);
7997
8074
  return {
7998
8075
  loading,
7999
8076
  processInfo,
@@ -8002,6 +8079,8 @@ function useProcessDetail(options) {
8002
8079
  progressList,
8003
8080
  formData,
8004
8081
  instanceInfo,
8082
+ accessDenied,
8083
+ loadError,
8005
8084
  isApprover,
8006
8085
  activeActions,
8007
8086
  fieldBehaviors,
@@ -8009,8 +8088,16 @@ function useProcessDetail(options) {
8009
8088
  isOriginatorReturn,
8010
8089
  isProcessCompleted,
8011
8090
  canWithdraw,
8091
+ canEdit,
8092
+ canDelete,
8093
+ canViewWorkflow,
8094
+ canViewChangeRecords,
8095
+ dataVersion,
8012
8096
  switchToEdit,
8013
8097
  switchToReadonly,
8098
+ saveChanges,
8099
+ deleteInstance,
8100
+ refreshDetail,
8014
8101
  refreshProgress
8015
8102
  };
8016
8103
  }
@@ -8024,6 +8111,7 @@ function useApprovalActions(options) {
8024
8111
  const [isLoading, setIsLoading] = useState26(false);
8025
8112
  const [currentAction, setCurrentAction] = useState26(null);
8026
8113
  const [returnableNodes, setReturnableNodes] = useState26([]);
8114
+ const [returnPolicy, setReturnPolicy] = useState26(null);
8027
8115
  const mountedRef = useRef11(true);
8028
8116
  useEffect31(() => {
8029
8117
  mountedRef.current = true;
@@ -8051,8 +8139,8 @@ function useApprovalActions(options) {
8051
8139
  formUuid,
8052
8140
  updateFormDataJson: formValues ? JSON.stringify(formValues) : void 0
8053
8141
  });
8142
+ await onActionComplete?.("approve");
8054
8143
  resetLoading();
8055
- onActionComplete?.("approve");
8056
8144
  return true;
8057
8145
  } catch (error) {
8058
8146
  console.error("[useApprovalActions] approve failed:", error);
@@ -8067,17 +8155,13 @@ function useApprovalActions(options) {
8067
8155
  setIsLoading(true);
8068
8156
  setCurrentAction("reject");
8069
8157
  try {
8070
- const formValues = getFormValues?.();
8071
8158
  await handleApproval(request, {
8072
8159
  instanceId: formInstanceId,
8073
8160
  action: "rejected",
8074
- comments,
8075
- appType,
8076
- formUuid,
8077
- updateFormDataJson: formValues ? JSON.stringify(formValues) : void 0
8161
+ comments
8078
8162
  });
8163
+ await onActionComplete?.("reject");
8079
8164
  resetLoading();
8080
- onActionComplete?.("reject");
8081
8165
  return true;
8082
8166
  } catch (error) {
8083
8167
  console.error("[useApprovalActions] reject failed:", error);
@@ -8085,7 +8169,7 @@ function useApprovalActions(options) {
8085
8169
  return false;
8086
8170
  }
8087
8171
  },
8088
- [request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
8172
+ [request, formInstanceId, onActionComplete, resetLoading]
8089
8173
  );
8090
8174
  const transfer = useCallback13(
8091
8175
  async (userId, reason) => {
@@ -8101,8 +8185,8 @@ function useApprovalActions(options) {
8101
8185
  newAssignee: userId,
8102
8186
  reason
8103
8187
  });
8188
+ await onActionComplete?.("transfer");
8104
8189
  resetLoading();
8105
- onActionComplete?.("transfer");
8106
8190
  return true;
8107
8191
  } catch (error) {
8108
8192
  console.error("[useApprovalActions] transfer failed:", error);
@@ -8126,8 +8210,8 @@ function useApprovalActions(options) {
8126
8210
  targetNodeId: nodeId,
8127
8211
  reason
8128
8212
  });
8213
+ await onActionComplete?.("return");
8129
8214
  resetLoading();
8130
- onActionComplete?.("return");
8131
8215
  return true;
8132
8216
  } catch (error) {
8133
8217
  console.error("[useApprovalActions] returnTo failed:", error);
@@ -8146,8 +8230,8 @@ function useApprovalActions(options) {
8146
8230
  instanceId: formInstanceId,
8147
8231
  reason
8148
8232
  });
8233
+ await onActionComplete?.("withdraw");
8149
8234
  resetLoading();
8150
- onActionComplete?.("withdraw");
8151
8235
  return true;
8152
8236
  } catch (error) {
8153
8237
  console.error("[useApprovalActions] withdraw failed:", error);
@@ -8168,8 +8252,8 @@ function useApprovalActions(options) {
8168
8252
  appType,
8169
8253
  updateFormDataJson: JSON.stringify(formValues)
8170
8254
  });
8255
+ await onActionComplete?.("save");
8171
8256
  resetLoading();
8172
- onActionComplete?.("save");
8173
8257
  return true;
8174
8258
  } catch (error) {
8175
8259
  console.error("[useApprovalActions] save failed:", error);
@@ -8194,8 +8278,8 @@ function useApprovalActions(options) {
8194
8278
  updateFormDataJson: JSON.stringify(formValues),
8195
8279
  comments
8196
8280
  });
8281
+ await onActionComplete?.("resubmit");
8197
8282
  resetLoading();
8198
- onActionComplete?.("resubmit");
8199
8283
  return true;
8200
8284
  } catch (error) {
8201
8285
  console.error("[useApprovalActions] resubmit failed:", error);
@@ -8218,8 +8302,8 @@ function useApprovalActions(options) {
8218
8302
  taskId: currentTaskId,
8219
8303
  payload
8220
8304
  });
8305
+ await onActionComplete?.("callback");
8221
8306
  resetLoading();
8222
- onActionComplete?.("callback");
8223
8307
  return true;
8224
8308
  } catch (error) {
8225
8309
  console.error("[useApprovalActions] callbackTask failed:", error);
@@ -8230,14 +8314,21 @@ function useApprovalActions(options) {
8230
8314
  [request, currentTaskId, onActionComplete, resetLoading]
8231
8315
  );
8232
8316
  const loadReturnableNodes = useCallback13(async () => {
8233
- if (!currentTaskId) return;
8317
+ if (!currentTaskId) return [];
8234
8318
  try {
8235
- const nodes = await getReturnableNodes(request, currentTaskId);
8319
+ const result = await getReturnableNodeResult(request, currentTaskId);
8236
8320
  if (mountedRef.current) {
8237
- setReturnableNodes(nodes);
8321
+ setReturnableNodes(result.nodes);
8322
+ setReturnPolicy(result.policy || null);
8238
8323
  }
8324
+ return result.nodes;
8239
8325
  } catch (error) {
8240
8326
  console.error("[useApprovalActions] loadReturnableNodes failed:", error);
8327
+ if (mountedRef.current) {
8328
+ setReturnableNodes([]);
8329
+ setReturnPolicy(null);
8330
+ }
8331
+ return [];
8241
8332
  }
8242
8333
  }, [request, currentTaskId]);
8243
8334
  return {
@@ -8252,6 +8343,7 @@ function useApprovalActions(options) {
8252
8343
  isLoading,
8253
8344
  currentAction,
8254
8345
  returnableNodes,
8346
+ returnPolicy,
8255
8347
  loadReturnableNodes
8256
8348
  };
8257
8349
  }
@@ -8259,13 +8351,13 @@ function useApprovalActions(options) {
8259
8351
  // src/hooks/useChangeRecords.ts
8260
8352
  import { useState as useState27, useEffect as useEffect32, useCallback as useCallback14, useRef as useRef12 } from "react";
8261
8353
  var normalizeChangeRecordList = (value) => {
8262
- const body = value?.data ?? value?.result ?? value ?? {};
8263
- const records = body.records ?? body.data ?? body.list ?? body.items ?? [];
8354
+ const body = value && typeof value === "object" && !Array.isArray(value) ? Array.isArray(value.data) || Array.isArray(value.records) || Array.isArray(value.list) || Array.isArray(value.items) ? value : value.data ?? value.result ?? value : value;
8355
+ const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
8264
8356
  return {
8265
8357
  records: Array.isArray(records) ? records : [],
8266
- total: Number(body.total ?? body.totalCount ?? body.count ?? records.length) || 0,
8267
- page: Number(body.page ?? body.currentPage ?? 1) || 1,
8268
- pageSize: Number(body.pageSize ?? body.limit ?? 20) || 20
8358
+ total: Number(body?.total ?? body?.totalCount ?? body?.count ?? records.length) || 0,
8359
+ page: Number(body?.page ?? body?.currentPage ?? 1) || 1,
8360
+ pageSize: Number(body?.pageSize ?? body?.limit ?? 20) || 20
8269
8361
  };
8270
8362
  };
8271
8363
  function useChangeRecords(options) {
@@ -9110,7 +9202,7 @@ var ApprovalTimeline = ({
9110
9202
  };
9111
9203
 
9112
9204
  // src/modules/ApprovalActionBar.tsx
9113
- import { useMemo as useMemo16, useState as useState32 } from "react";
9205
+ import React43, { useMemo as useMemo16, useState as useState32 } from "react";
9114
9206
  import { Form, Input as Input10, Modal as Modal5, Select as Select5 } from "antd";
9115
9207
  import {
9116
9208
  CheckOutlined,
@@ -9147,7 +9239,6 @@ var getActionPriority = (action) => {
9147
9239
  if (action.type === "danger") return 90;
9148
9240
  return 50;
9149
9241
  };
9150
- var getPlacement = (action) => action.placement;
9151
9242
  var StickyActionBar = ({
9152
9243
  actions,
9153
9244
  className = "",
@@ -9171,8 +9262,6 @@ var StickyActionBar = ({
9171
9262
  const maxWidthStyle = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
9172
9263
  const primaryMobile = visibleActions.slice(0, maxMobileButtons);
9173
9264
  const moreMobile = visibleActions.slice(maxMobileButtons);
9174
- const leftActions = visibleActions.filter((action) => getPlacement(action) === "left");
9175
- const rightActions = visibleActions.filter((action) => getPlacement(action) !== "left");
9176
9265
  const positionClass = position === "fixed" ? "fixed bottom-0 left-0 right-0" : position === "inline" ? "relative" : "sticky bottom-0";
9177
9266
  const runAction = (action) => {
9178
9267
  if (action.confirm) {
@@ -9202,7 +9291,7 @@ var StickyActionBar = ({
9202
9291
  children: /* @__PURE__ */ jsx81(
9203
9292
  "div",
9204
9293
  {
9205
- className: `mx-auto flex w-full items-center gap-3 ${layoutMode === "approval" && !isMobile ? "justify-between" : "justify-end"}`,
9294
+ className: `mx-auto flex w-full items-center gap-3 ${layoutMode === "approval" && !isMobile ? "justify-center" : "justify-end"}`,
9206
9295
  style: { maxWidth: maxWidthStyle },
9207
9296
  children: isMobile ? /* @__PURE__ */ jsxs33(Fragment2, { children: [
9208
9297
  /* @__PURE__ */ jsx81("div", { className: "flex flex-1 gap-2", children: primaryMobile.map((action) => renderButton(action, true)) }),
@@ -9224,10 +9313,7 @@ var StickyActionBar = ({
9224
9313
  children: /* @__PURE__ */ jsx81(Button10, { icon: /* @__PURE__ */ jsx81(MoreOutlined, {}), className: "rounded-md", children: "\u66F4\u591A" })
9225
9314
  }
9226
9315
  )
9227
- ] }) : layoutMode === "approval" && leftActions.length > 0 ? /* @__PURE__ */ jsxs33(Fragment2, { children: [
9228
- /* @__PURE__ */ jsx81("div", { className: "flex flex-wrap items-center gap-3", children: leftActions.map((action) => renderButton(action)) }),
9229
- /* @__PURE__ */ jsx81("div", { className: "flex flex-wrap items-center justify-end gap-3", children: rightActions.map((action) => renderButton(action)) })
9230
- ] }) : /* @__PURE__ */ jsx81("div", { className: "flex flex-wrap items-center justify-end gap-3", children: visibleActions.map((action) => renderButton(action)) })
9316
+ ] }) : layoutMode === "approval" ? /* @__PURE__ */ jsx81("div", { className: "flex flex-wrap items-center justify-center gap-3", children: visibleActions.map((action) => renderButton(action)) }) : /* @__PURE__ */ jsx81("div", { className: "flex flex-wrap items-center justify-end gap-3", children: visibleActions.map((action) => renderButton(action)) })
9231
9317
  }
9232
9318
  )
9233
9319
  }
@@ -9277,6 +9363,50 @@ function getModalTitle(action) {
9277
9363
  return "\u786E\u8BA4\u64CD\u4F5C";
9278
9364
  }
9279
9365
  }
9366
+ function formatReturnPolicy(policy) {
9367
+ if (!policy?.resubmitMode) return null;
9368
+ return policy.resubmitMode === "resume_current" ? "\u4ECE\u5F53\u524D\u8282\u70B9\u5BA1\u6279" : "\u91CD\u65B0\u4F9D\u6B21\u5BA1\u6279";
9369
+ }
9370
+ function DefaultTransferSelector({
9371
+ value,
9372
+ onChange
9373
+ }) {
9374
+ const formContext = React43.useContext(FormContext);
9375
+ const [open, setOpen] = useState32(false);
9376
+ const [selectedUsers, setSelectedUsers] = useState32([]);
9377
+ if (!formContext) {
9378
+ return /* @__PURE__ */ jsx82(Input10, { value, onChange: (event) => onChange(event.target.value) });
9379
+ }
9380
+ const selectedLabel = selectedUsers[0] ? getUserName(selectedUsers[0]) : value;
9381
+ return /* @__PURE__ */ jsxs34(Fragment3, { children: [
9382
+ /* @__PURE__ */ jsx82(
9383
+ Input10,
9384
+ {
9385
+ readOnly: true,
9386
+ value: selectedLabel,
9387
+ placeholder: "\u8BF7\u9009\u62E9\u8F6C\u4EA4\u7528\u6237",
9388
+ addonAfter: /* @__PURE__ */ jsx82("span", { className: "cursor-pointer text-blue-600", onClick: () => setOpen(true), children: "\u9009\u62E9" })
9389
+ }
9390
+ ),
9391
+ /* @__PURE__ */ jsx82(
9392
+ UserPicker,
9393
+ {
9394
+ api: formContext.api,
9395
+ open,
9396
+ onOpenChange: setOpen,
9397
+ multiple: false,
9398
+ value: selectedUsers,
9399
+ onCancel: () => setOpen(false),
9400
+ onConfirm: (items) => {
9401
+ const next = items.slice(0, 1);
9402
+ setSelectedUsers(next);
9403
+ const userId = next[0] ? getUserId(next[0]) : "";
9404
+ onChange(userId);
9405
+ }
9406
+ }
9407
+ )
9408
+ ] });
9409
+ }
9280
9410
  var ApprovalActionBar = ({
9281
9411
  actions,
9282
9412
  onApprove,
@@ -9288,6 +9418,7 @@ var ApprovalActionBar = ({
9288
9418
  onResubmit,
9289
9419
  onCallback,
9290
9420
  returnableNodes = [],
9421
+ returnPolicy,
9291
9422
  onLoadReturnableNodes,
9292
9423
  renderTransferSelector,
9293
9424
  renderReturnNodeLabel,
@@ -9313,7 +9444,12 @@ var ApprovalActionBar = ({
9313
9444
  userId: void 0,
9314
9445
  nodeId: void 0
9315
9446
  });
9316
- if (target === "return") await onLoadReturnableNodes?.();
9447
+ if (target === "return") {
9448
+ const loadedNodes = await onLoadReturnableNodes?.() || returnableNodes;
9449
+ if (loadedNodes.length === 1) {
9450
+ form.setFieldsValue({ nodeId: loadedNodes[0].nodeId || loadedNodes[0].id || "" });
9451
+ }
9452
+ }
9317
9453
  setModalAction(target);
9318
9454
  };
9319
9455
  const executeDirect = async (action) => {
@@ -9328,6 +9464,14 @@ var ApprovalActionBar = ({
9328
9464
  }
9329
9465
  if (normalized === "agree") {
9330
9466
  await onApprove?.();
9467
+ return;
9468
+ }
9469
+ if (normalized === "rejected") {
9470
+ await onReject?.();
9471
+ return;
9472
+ }
9473
+ if (normalized === "resubmit") {
9474
+ await onResubmit?.();
9331
9475
  }
9332
9476
  };
9333
9477
  const handleActionClick = async (action) => {
@@ -9336,6 +9480,10 @@ var ApprovalActionBar = ({
9336
9480
  await executeDirect(action);
9337
9481
  return;
9338
9482
  }
9483
+ if ((normalized === "agree" || normalized === "rejected" || normalized === "resubmit") && !action.remark?.popUp) {
9484
+ await executeDirect(action);
9485
+ return;
9486
+ }
9339
9487
  await openModal(action, normalized);
9340
9488
  };
9341
9489
  const handleOk = async () => {
@@ -9397,7 +9545,7 @@ var ApprovalActionBar = ({
9397
9545
  setActiveAction(null);
9398
9546
  form.resetFields();
9399
9547
  },
9400
- destroyOnClose: true,
9548
+ destroyOnHidden: true,
9401
9549
  children: /* @__PURE__ */ jsxs34(Form, { form, layout: "vertical", children: [
9402
9550
  modalAction === "transfer" && /* @__PURE__ */ jsx82(
9403
9551
  Form.Item,
@@ -9408,28 +9556,40 @@ var ApprovalActionBar = ({
9408
9556
  children: renderTransferSelector ? renderTransferSelector({
9409
9557
  value: form.getFieldValue("userId"),
9410
9558
  onChange: (userId) => form.setFieldsValue({ userId })
9411
- }) : /* @__PURE__ */ jsx82(Input10, { placeholder: "\u8BF7\u8F93\u5165\u7528\u6237 ID" })
9412
- }
9413
- ),
9414
- modalAction === "return" && /* @__PURE__ */ jsx82(
9415
- Form.Item,
9416
- {
9417
- name: "nodeId",
9418
- label: "\u9000\u56DE\u5230\u8282\u70B9",
9419
- rules: [{ required: true, message: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9" }],
9420
- children: /* @__PURE__ */ jsx82(
9421
- Select5,
9559
+ }) : /* @__PURE__ */ jsx82(
9560
+ DefaultTransferSelector,
9422
9561
  {
9423
- placeholder: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9",
9424
- getPopupContainer: (triggerNode) => triggerNode.parentElement || document.body,
9425
- options: returnableNodes.map((node) => ({
9426
- value: node.nodeId || node.id || "",
9427
- label: renderReturnNodeLabel ? renderReturnNodeLabel(node) : node.nodeName || node.name || node.nodeId || node.id
9428
- }))
9562
+ value: form.getFieldValue("userId"),
9563
+ onChange: (userId) => form.setFieldsValue({ userId })
9429
9564
  }
9430
9565
  )
9431
9566
  }
9432
9567
  ),
9568
+ modalAction === "return" && /* @__PURE__ */ jsxs34(Fragment3, { children: [
9569
+ formatReturnPolicy(returnPolicy) && /* @__PURE__ */ jsxs34("div", { className: "mb-3 text-sm text-gray-500", children: [
9570
+ "\u9000\u56DE\u540E\u5BA1\u6279\u903B\u8F91\uFF1A",
9571
+ formatReturnPolicy(returnPolicy)
9572
+ ] }),
9573
+ /* @__PURE__ */ jsx82(
9574
+ Form.Item,
9575
+ {
9576
+ name: "nodeId",
9577
+ label: "\u9000\u56DE\u5230\u8282\u70B9",
9578
+ rules: [{ required: true, message: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9" }],
9579
+ children: /* @__PURE__ */ jsx82(
9580
+ Select5,
9581
+ {
9582
+ placeholder: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9",
9583
+ getPopupContainer: (triggerNode) => triggerNode.parentElement || document.body,
9584
+ options: returnableNodes.map((node) => ({
9585
+ value: node.nodeId || node.id || "",
9586
+ label: renderReturnNodeLabel ? renderReturnNodeLabel(node) : node.nodeName || node.name || node.nodeId || node.id
9587
+ }))
9588
+ }
9589
+ )
9590
+ }
9591
+ )
9592
+ ] }),
9433
9593
  /* @__PURE__ */ jsx82(
9434
9594
  Form.Item,
9435
9595
  {
@@ -9479,6 +9639,7 @@ var ApprovalActions = ({
9479
9639
  const [activeAction, setActiveAction] = useState33(null);
9480
9640
  const [loading, setLoading] = useState33(false);
9481
9641
  const [saveLoading, setSaveLoading] = useState33(false);
9642
+ const [directLoading, setDirectLoading] = useState33(null);
9482
9643
  const renderableActions = useMemo17(
9483
9644
  () => actions.filter((action) => !action.hidden).sort((a, b) => (priority[a.action] ?? 50) - (priority[b.action] ?? 50)),
9484
9645
  [actions]
@@ -9496,6 +9657,14 @@ var ApprovalActions = ({
9496
9657
  setSaveLoading(false);
9497
9658
  }
9498
9659
  };
9660
+ const executeDirect = async (action, fn) => {
9661
+ setDirectLoading(action.action);
9662
+ try {
9663
+ await fn?.();
9664
+ } finally {
9665
+ setDirectLoading(null);
9666
+ }
9667
+ };
9499
9668
  const handleAction = (action) => {
9500
9669
  if (action.action === "transfer") {
9501
9670
  onTransfer?.();
@@ -9514,9 +9683,17 @@ var ApprovalActions = ({
9514
9683
  return;
9515
9684
  }
9516
9685
  if (action.action === "rejected" || action.action === "reject") {
9686
+ if (!action.remark?.popUp) {
9687
+ void executeDirect(action, onReject);
9688
+ return;
9689
+ }
9517
9690
  openModal("reject", action);
9518
9691
  return;
9519
9692
  }
9693
+ if (!action.remark?.popUp) {
9694
+ void executeDirect(action, onApprove);
9695
+ return;
9696
+ }
9520
9697
  openModal("approve", action);
9521
9698
  };
9522
9699
  const handleConfirm = async () => {
@@ -9542,7 +9719,7 @@ var ApprovalActions = ({
9542
9719
  type: action.action === "agree" || action.action === "approved" ? "primary" : "default",
9543
9720
  danger: action.action === "rejected" || action.action === "reject" || action.action === "withdraw",
9544
9721
  onClick: () => handleAction(action),
9545
- loading: action.action === "save" && saveLoading,
9722
+ loading: action.action === "save" && saveLoading || directLoading === action.action,
9546
9723
  children: getLabel(action)
9547
9724
  },
9548
9725
  action.action
@@ -9551,7 +9728,7 @@ var ApprovalActions = ({
9551
9728
  /* @__PURE__ */ jsxs35(
9552
9729
  "div",
9553
9730
  {
9554
- className: `${layout === "horizontal" ? "flex items-center gap-3" : "flex flex-col gap-2"} ${className}`,
9731
+ className: `${layout === "horizontal" ? "flex items-center justify-center gap-3" : "flex flex-col items-center gap-2"} ${className}`,
9555
9732
  children: [
9556
9733
  visibleButtons.map(button),
9557
9734
  moreButtons.length > 0 && /* @__PURE__ */ jsx83(
@@ -9588,7 +9765,7 @@ var ApprovalActions = ({
9588
9765
  setActiveAction(null);
9589
9766
  form.resetFields();
9590
9767
  },
9591
- destroyOnClose: true,
9768
+ destroyOnHidden: true,
9592
9769
  children: /* @__PURE__ */ jsx83(Form2, { form, layout: "vertical", children: /* @__PURE__ */ jsx83(
9593
9770
  Form2.Item,
9594
9771
  {
@@ -11782,6 +11959,8 @@ var InnerDetailContent = ({
11782
11959
  const {
11783
11960
  records,
11784
11961
  loading: recordsLoading,
11962
+ total: recordsTotal,
11963
+ page: recordsPage,
11785
11964
  hasMore,
11786
11965
  loadMore,
11787
11966
  refresh: refreshRecords
@@ -11893,7 +12072,8 @@ var InnerDetailContent = ({
11893
12072
  {
11894
12073
  records,
11895
12074
  loading: recordsLoading,
11896
- total: records.length,
12075
+ total: recordsTotal,
12076
+ page: recordsPage,
11897
12077
  hasMore,
11898
12078
  onLoadMore: loadMore,
11899
12079
  onRefresh: refreshRecords,
@@ -11915,13 +12095,16 @@ var FormDetailTemplate = (props) => {
11915
12095
  };
11916
12096
 
11917
12097
  // src/templates/ProcessDetailTemplate.tsx
11918
- import { useCallback as useCallback20, useMemo as useMemo20, useRef as useRef16 } from "react";
12098
+ import { useCallback as useCallback20, useMemo as useMemo20, useRef as useRef16, useState as useState38 } from "react";
12099
+ import { Form as AntForm, Input as Input13, Modal as Modal9 } from "antd";
11919
12100
  import { jsx as jsx93, jsxs as jsxs45 } from "react/jsx-runtime";
11920
12101
  function FormDataBridge2({
11921
- formDataRef
12102
+ formDataRef,
12103
+ validateRef
11922
12104
  }) {
11923
- const { getFormData: getFormData2 } = useFormContext();
12105
+ const { getFormData: getFormData2, validateAll } = useFormContext();
11924
12106
  formDataRef.current = getFormData2;
12107
+ validateRef.current = validateAll;
11925
12108
  return null;
11926
12109
  }
11927
12110
  var InnerProcessContent = ({
@@ -11929,18 +12112,31 @@ var InnerProcessContent = ({
11929
12112
  formUuid,
11930
12113
  appType,
11931
12114
  formInstanceId,
12115
+ enableEdit = true,
12116
+ enableDelete = true,
12117
+ enableChangeRecords = true,
12118
+ showApproverInfo = true,
11932
12119
  header,
11933
12120
  renderTimeline,
11934
12121
  renderActions,
12122
+ renderFooterActions,
11935
12123
  renderTransferSelector,
11936
12124
  renderReturnNodeLabel,
11937
12125
  renderActionModalExtra,
11938
12126
  beforeForm,
11939
12127
  afterForm,
11940
12128
  onActionComplete,
12129
+ onSave,
12130
+ onDelete,
11941
12131
  inDrawer = false
11942
12132
  }) => {
11943
12133
  const formDataRef = useRef16(void 0);
12134
+ const validateRef = useRef16(void 0);
12135
+ const [withdrawForm] = AntForm.useForm();
12136
+ const [withdrawOpen, setWithdrawOpen] = useState38(false);
12137
+ const [withdrawLoading, setWithdrawLoading] = useState38(false);
12138
+ const [saveLoading, setSaveLoading] = useState38(false);
12139
+ const [deleteLoading, setDeleteLoading] = useState38(false);
11944
12140
  const fieldIds = useMemo20(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
11945
12141
  const {
11946
12142
  loading,
@@ -11950,15 +12146,25 @@ var InnerProcessContent = ({
11950
12146
  progressList,
11951
12147
  formData,
11952
12148
  instanceInfo,
12149
+ accessDenied,
12150
+ loadError,
11953
12151
  isApprover,
11954
12152
  activeActions,
11955
12153
  fieldBehaviors,
11956
12154
  mode,
11957
12155
  isOriginatorReturn,
12156
+ isProcessCompleted,
11958
12157
  canWithdraw,
12158
+ canEdit,
12159
+ canDelete,
12160
+ canViewWorkflow,
12161
+ canViewChangeRecords,
12162
+ dataVersion,
11959
12163
  switchToEdit,
11960
12164
  switchToReadonly,
11961
- refreshProgress
12165
+ saveChanges,
12166
+ deleteInstance,
12167
+ refreshDetail
11962
12168
  } = useProcessDetail({ formUuid, appType, formInstanceId, fieldIds });
11963
12169
  const {
11964
12170
  approve,
@@ -11970,6 +12176,7 @@ var InnerProcessContent = ({
11970
12176
  resubmit,
11971
12177
  callbackTask,
11972
12178
  returnableNodes,
12179
+ returnPolicy,
11973
12180
  loadReturnableNodes
11974
12181
  } = useApprovalActions({
11975
12182
  formInstanceId,
@@ -11977,16 +12184,34 @@ var InnerProcessContent = ({
11977
12184
  appType,
11978
12185
  currentTaskId: currentTask?.taskId ?? currentTask?.id,
11979
12186
  onActionComplete: async (action) => {
11980
- onActionComplete?.(action);
11981
- await refreshProgress();
12187
+ await onActionComplete?.(action);
12188
+ await refreshDetail();
11982
12189
  },
11983
12190
  getFormValues: () => formDataRef.current?.() ?? formData ?? {}
11984
12191
  });
12192
+ const {
12193
+ records,
12194
+ loading: recordsLoading,
12195
+ total: recordsTotal,
12196
+ page: recordsPage,
12197
+ hasMore,
12198
+ loadMore,
12199
+ refresh: refreshRecords
12200
+ } = useChangeRecords({
12201
+ formUuid,
12202
+ appType,
12203
+ formInstanceId,
12204
+ autoLoad: enableChangeRecords && canViewChangeRecords
12205
+ });
12206
+ const validateForm = useCallback20(async () => {
12207
+ return validateRef.current ? validateRef.current() : true;
12208
+ }, []);
11985
12209
  const handleApprove = useCallback20(
11986
12210
  async (comments) => {
12211
+ if (!await validateForm()) return;
11987
12212
  await approve(comments);
11988
12213
  },
11989
- [approve]
12214
+ [approve, validateForm]
11990
12215
  );
11991
12216
  const handleReject = useCallback20(
11992
12217
  async (comments) => {
@@ -12013,22 +12238,104 @@ var InnerProcessContent = ({
12013
12238
  [withdraw]
12014
12239
  );
12015
12240
  const handleSave = useCallback20(async () => {
12241
+ if (!await validateForm()) return;
12016
12242
  await save();
12017
- }, [save]);
12243
+ }, [save, validateForm]);
12018
12244
  const handleResubmit = useCallback20(
12019
12245
  async (comments) => {
12246
+ if (!await validateForm()) return;
12020
12247
  await resubmit(comments);
12021
12248
  },
12022
- [resubmit]
12249
+ [resubmit, validateForm]
12023
12250
  );
12024
12251
  const handleCallback = useCallback20(async () => {
12025
12252
  await callbackTask();
12026
12253
  }, [callbackTask]);
12254
+ const handleCompletedSave = useCallback20(async () => {
12255
+ if (!await validateForm()) return;
12256
+ const values = formDataRef.current?.() ?? formData;
12257
+ if (!values) return;
12258
+ setSaveLoading(true);
12259
+ try {
12260
+ const success = await saveChanges(values);
12261
+ if (success) {
12262
+ await onSave?.(values);
12263
+ }
12264
+ } finally {
12265
+ setSaveLoading(false);
12266
+ }
12267
+ }, [formData, onSave, saveChanges, validateForm]);
12268
+ const handleCompletedDelete = useCallback20(async () => {
12269
+ setDeleteLoading(true);
12270
+ try {
12271
+ const success = await deleteInstance();
12272
+ if (success) {
12273
+ await onDelete?.();
12274
+ }
12275
+ } finally {
12276
+ setDeleteLoading(false);
12277
+ }
12278
+ }, [deleteInstance, onDelete]);
12279
+ const handleFooterWithdraw = useCallback20(async () => {
12280
+ const values = await withdrawForm.validateFields();
12281
+ setWithdrawLoading(true);
12282
+ try {
12283
+ await handleWithdraw(values.reason || void 0);
12284
+ setWithdrawOpen(false);
12285
+ withdrawForm.resetFields();
12286
+ } finally {
12287
+ setWithdrawLoading(false);
12288
+ }
12289
+ }, [handleWithdraw, withdrawForm]);
12290
+ const handleFooterWithdrawCancel = useCallback20(() => {
12291
+ setWithdrawOpen(false);
12292
+ withdrawForm.resetFields();
12293
+ }, [withdrawForm]);
12027
12294
  const bottomActions = useMemo20(() => {
12028
- if (isApprover && activeActions.length > 0) return [];
12295
+ if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
12296
+ if (isProcessCompleted) {
12297
+ if (mode === "readonly") {
12298
+ const actions = [];
12299
+ if (enableEdit && canEdit) {
12300
+ actions.push({
12301
+ key: "edit",
12302
+ label: "\u7F16\u8F91",
12303
+ type: "primary",
12304
+ onClick: switchToEdit
12305
+ });
12306
+ }
12307
+ if (enableDelete && canDelete) {
12308
+ actions.push({
12309
+ key: "delete",
12310
+ label: "\u5220\u9664",
12311
+ type: "danger",
12312
+ loading: deleteLoading,
12313
+ onClick: handleCompletedDelete,
12314
+ confirm: { title: "\u786E\u8BA4\u5220\u9664", content: "\u5220\u9664\u540E\u5C06\u65E0\u6CD5\u6062\u590D\uFF0C\u786E\u8BA4\u8981\u5220\u9664\u5417\uFF1F" }
12315
+ });
12316
+ }
12317
+ return actions;
12318
+ }
12319
+ return [
12320
+ {
12321
+ key: "cancel",
12322
+ label: "\u53D6\u6D88",
12323
+ type: "default",
12324
+ onClick: switchToReadonly,
12325
+ placement: "left"
12326
+ },
12327
+ {
12328
+ key: "save",
12329
+ label: "\u4FDD\u5B58",
12330
+ type: "primary",
12331
+ loading: saveLoading,
12332
+ onClick: handleCompletedSave
12333
+ }
12334
+ ];
12335
+ }
12029
12336
  if (isOriginatorReturn) {
12030
12337
  if (mode === "readonly") {
12031
- return [
12338
+ const actions2 = [
12032
12339
  {
12033
12340
  key: "edit",
12034
12341
  label: "\u7F16\u8F91",
@@ -12036,8 +12343,23 @@ var InnerProcessContent = ({
12036
12343
  onClick: switchToEdit
12037
12344
  }
12038
12345
  ];
12346
+ actions2.push({
12347
+ key: "resubmit",
12348
+ label: "\u91CD\u65B0\u63D0\u4EA4",
12349
+ type: "default",
12350
+ onClick: () => handleResubmit()
12351
+ });
12352
+ if (canWithdraw) {
12353
+ actions2.push({
12354
+ key: "withdraw",
12355
+ label: "\u64A4\u9500",
12356
+ type: "danger",
12357
+ onClick: () => setWithdrawOpen(true)
12358
+ });
12359
+ }
12360
+ return actions2;
12039
12361
  }
12040
- return [
12362
+ const actions = [
12041
12363
  {
12042
12364
  key: "cancel",
12043
12365
  label: "\u53D6\u6D88",
@@ -12052,6 +12374,15 @@ var InnerProcessContent = ({
12052
12374
  onClick: () => handleResubmit()
12053
12375
  }
12054
12376
  ];
12377
+ if (canWithdraw) {
12378
+ actions.push({
12379
+ key: "withdraw",
12380
+ label: "\u64A4\u9500",
12381
+ type: "danger",
12382
+ onClick: () => setWithdrawOpen(true)
12383
+ });
12384
+ }
12385
+ return actions;
12055
12386
  }
12056
12387
  if (canWithdraw) {
12057
12388
  return [
@@ -12059,22 +12390,31 @@ var InnerProcessContent = ({
12059
12390
  key: "withdraw",
12060
12391
  label: "\u64A4\u9500",
12061
12392
  type: "danger",
12062
- onClick: () => handleWithdraw(),
12063
- confirm: { title: "\u786E\u8BA4\u64A4\u9500", content: "\u64A4\u9500\u540E\u6D41\u7A0B\u5C06\u7EC8\u6B62\uFF0C\u786E\u8BA4\u7EE7\u7EED\u5417\uFF1F" }
12393
+ loading: withdrawLoading,
12394
+ onClick: () => setWithdrawOpen(true)
12064
12395
  }
12065
12396
  ];
12066
12397
  }
12067
12398
  return [];
12068
12399
  }, [
12069
12400
  activeActions.length,
12401
+ canDelete,
12402
+ canEdit,
12070
12403
  canWithdraw,
12404
+ deleteLoading,
12405
+ enableDelete,
12406
+ enableEdit,
12407
+ handleCompletedDelete,
12408
+ handleCompletedSave,
12071
12409
  handleResubmit,
12072
- handleWithdraw,
12073
12410
  isApprover,
12074
12411
  isOriginatorReturn,
12412
+ isProcessCompleted,
12075
12413
  mode,
12414
+ saveLoading,
12076
12415
  switchToEdit,
12077
- switchToReadonly
12416
+ switchToReadonly,
12417
+ withdrawLoading
12078
12418
  ]);
12079
12419
  const formConfig = {
12080
12420
  mode: mode === "edit" ? "edit" : "readonly",
@@ -12089,7 +12429,10 @@ var InnerProcessContent = ({
12089
12429
  if (loading) {
12090
12430
  return /* @__PURE__ */ jsx93("div", { className: "min-h-screen bg-ant-bg-layout", children: /* @__PURE__ */ jsx93("div", { className: "mx-auto max-w-4xl px-6 py-8 pb-24", children: /* @__PURE__ */ jsx93(PageSkeleton, { type: "process" }) }) });
12091
12431
  }
12092
- const showApprovalActions = isApprover && activeActions.length > 0;
12432
+ if (accessDenied || loadError) {
12433
+ return /* @__PURE__ */ jsx93(RuntimePageShell, { accessDenied, error: loadError, inDrawer, children: /* @__PURE__ */ jsx93("div", {}) });
12434
+ }
12435
+ const showApprovalActions = isApprover && !isOriginatorReturn && activeActions.length > 0;
12093
12436
  const actionsNode = showApprovalActions ? renderActions ? renderActions(activeActions) : /* @__PURE__ */ jsx93(
12094
12437
  ApprovalActionBar,
12095
12438
  {
@@ -12103,52 +12446,108 @@ var InnerProcessContent = ({
12103
12446
  onResubmit: handleResubmit,
12104
12447
  onCallback: handleCallback,
12105
12448
  returnableNodes,
12449
+ returnPolicy,
12106
12450
  onLoadReturnableNodes: loadReturnableNodes,
12107
12451
  renderTransferSelector,
12108
12452
  renderReturnNodeLabel,
12109
12453
  renderActionModalExtra,
12110
12454
  inDrawer
12111
12455
  }
12112
- ) : bottomActions.length > 0 ? /* @__PURE__ */ jsx93(StickyActionBar, { actions: bottomActions, inDrawer }) : null;
12456
+ ) : bottomActions.length > 0 ? renderFooterActions ? renderFooterActions(bottomActions) : /* @__PURE__ */ jsx93(StickyActionBar, { actions: bottomActions, inDrawer }) : null;
12113
12457
  const statusMeta = processStatus ? PROCESS_STATUS_META[processStatus] : void 0;
12114
- return /* @__PURE__ */ jsx93(RuntimePageShell, { actions: actionsNode, inDrawer, children: /* @__PURE__ */ jsxs45("div", { className: "space-y-6", children: [
12115
- header,
12458
+ return /* @__PURE__ */ jsxs45(RuntimePageShell, { actions: actionsNode, inDrawer, children: [
12459
+ /* @__PURE__ */ jsxs45("div", { className: "space-y-6", children: [
12460
+ header,
12461
+ /* @__PURE__ */ jsx93(
12462
+ SummaryPanel,
12463
+ {
12464
+ title: processInfo?.title || instanceInfo?.title || schema.formMeta.title,
12465
+ eyebrow: `\u6D41\u7A0B\u5B9E\u4F8B ${formInstanceId?.slice(0, 8) || "-"}`,
12466
+ creator: processInfo?.originatorName ? {
12467
+ name: processInfo.originatorName,
12468
+ department: processInfo.originatorDepartment
12469
+ } : void 0,
12470
+ createdAt: processInfo?.createdAt,
12471
+ status: statusMeta,
12472
+ metaItems: [
12473
+ { key: "currentTask", label: "\u5F53\u524D\u8282\u70B9", value: currentTask?.nodeName || "\u65E0" },
12474
+ {
12475
+ key: "processStatus",
12476
+ label: "\u5B9E\u4F8B\u72B6\u6001",
12477
+ value: statusMeta?.label || processStatus || "-"
12478
+ }
12479
+ ]
12480
+ }
12481
+ ),
12482
+ beforeForm,
12483
+ mode === "edit" && /* @__PURE__ */ jsx93("div", { className: "rounded-lg border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700 transition-all duration-150", children: isProcessCompleted ? "\u6B63\u5728\u7F16\u8F91\uFF0C\u4FEE\u6539\u540E\u8BF7\u4FDD\u5B58" : "\u6B63\u5728\u7F16\u8F91\u8868\u5355\uFF0C\u4FEE\u6539\u540E\u8BF7\u91CD\u65B0\u63D0\u4EA4" }),
12484
+ /* @__PURE__ */ jsx93("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: /* @__PURE__ */ jsxs45(
12485
+ FormProvider,
12486
+ {
12487
+ schema,
12488
+ config: formConfig,
12489
+ initialValues: formData ?? void 0,
12490
+ children: [
12491
+ /* @__PURE__ */ jsx93(FormDataBridge2, { formDataRef, validateRef }),
12492
+ /* @__PURE__ */ jsx93(FormRenderer, { columns: 2 })
12493
+ ]
12494
+ },
12495
+ `${mode}-${dataVersion}`
12496
+ ) }),
12497
+ afterForm,
12498
+ canViewWorkflow && /* @__PURE__ */ jsxs45("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: [
12499
+ /* @__PURE__ */ jsx93("div", { className: "mb-4 flex items-center justify-between gap-3", children: /* @__PURE__ */ jsxs45("div", { children: [
12500
+ /* @__PURE__ */ jsx93("h3", { className: "text-base font-semibold text-ant-color-text", children: "\u5BA1\u6279\u8FDB\u5EA6" }),
12501
+ /* @__PURE__ */ jsx93("p", { className: "mt-1 text-xs text-ant-color-text-tertiary", children: "\u8282\u70B9\u3001\u5BA1\u6279\u4EBA\u3001\u5904\u7406\u610F\u89C1\u548C\u7B49\u5F85\u72B6\u6001" })
12502
+ ] }) }),
12503
+ renderTimeline ? renderTimeline(progressList) : /* @__PURE__ */ jsx93(
12504
+ ApprovalTimeline,
12505
+ {
12506
+ tasks: progressList,
12507
+ showRemarks: true,
12508
+ showApproverInfo
12509
+ }
12510
+ )
12511
+ ] }),
12512
+ enableChangeRecords && canViewChangeRecords && /* @__PURE__ */ jsx93(
12513
+ RecordChangePanel,
12514
+ {
12515
+ records,
12516
+ loading: recordsLoading,
12517
+ total: recordsTotal,
12518
+ page: recordsPage,
12519
+ hasMore,
12520
+ onLoadMore: loadMore,
12521
+ onRefresh: refreshRecords,
12522
+ onExpand: refreshRecords
12523
+ }
12524
+ )
12525
+ ] }),
12116
12526
  /* @__PURE__ */ jsx93(
12117
- SummaryPanel,
12527
+ Modal9,
12118
12528
  {
12119
- title: processInfo?.title || instanceInfo?.title || schema.formMeta.title,
12120
- eyebrow: `\u6D41\u7A0B\u5B9E\u4F8B ${formInstanceId?.slice(0, 8) || "-"}`,
12121
- creator: processInfo?.originatorName ? {
12122
- name: processInfo.originatorName,
12123
- department: processInfo.originatorDepartment
12124
- } : void 0,
12125
- createdAt: processInfo?.createdAt,
12126
- status: statusMeta,
12127
- metaItems: [
12128
- { key: "currentTask", label: "\u5F53\u524D\u8282\u70B9", value: currentTask?.nodeName || "\u65E0" },
12529
+ getContainer: false,
12530
+ title: "\u64A4\u9500\u6D41\u7A0B",
12531
+ open: withdrawOpen,
12532
+ okText: "\u786E\u8BA4\u64A4\u9500",
12533
+ cancelText: "\u53D6\u6D88",
12534
+ confirmLoading: withdrawLoading,
12535
+ okButtonProps: { danger: true },
12536
+ onOk: handleFooterWithdraw,
12537
+ onCancel: handleFooterWithdrawCancel,
12538
+ destroyOnHidden: true,
12539
+ children: /* @__PURE__ */ jsx93(AntForm, { form: withdrawForm, layout: "vertical", children: /* @__PURE__ */ jsx93(
12540
+ AntForm.Item,
12129
12541
  {
12130
- key: "processStatus",
12131
- label: "\u5B9E\u4F8B\u72B6\u6001",
12132
- value: statusMeta?.label || processStatus || "-"
12542
+ name: "reason",
12543
+ label: "\u64A4\u9500\u539F\u56E0",
12544
+ rules: [{ required: true, message: "\u8BF7\u586B\u5199\u64A4\u9500\u539F\u56E0" }],
12545
+ children: /* @__PURE__ */ jsx93(Input13.TextArea, { rows: 4, maxLength: 500, showCount: true, placeholder: "\u8BF7\u8F93\u5165\u64A4\u9500\u539F\u56E0" })
12133
12546
  }
12134
- ]
12547
+ ) })
12135
12548
  }
12136
- ),
12137
- beforeForm,
12138
- mode === "edit" && /* @__PURE__ */ jsx93("div", { className: "rounded-lg border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700 transition-all duration-150", children: "\u6B63\u5728\u7F16\u8F91\u8868\u5355\uFF0C\u4FEE\u6539\u540E\u8BF7\u91CD\u65B0\u63D0\u4EA4" }),
12139
- /* @__PURE__ */ jsx93("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: /* @__PURE__ */ jsxs45(FormProvider, { schema, config: formConfig, initialValues: formData ?? void 0, children: [
12140
- /* @__PURE__ */ jsx93(FormDataBridge2, { formDataRef }),
12141
- /* @__PURE__ */ jsx93(FormRenderer, { columns: 2 })
12142
- ] }) }),
12143
- afterForm,
12144
- /* @__PURE__ */ jsxs45("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: [
12145
- /* @__PURE__ */ jsx93("div", { className: "mb-4 flex items-center justify-between gap-3", children: /* @__PURE__ */ jsxs45("div", { children: [
12146
- /* @__PURE__ */ jsx93("h3", { className: "text-base font-semibold text-ant-color-text", children: "\u5BA1\u6279\u8FDB\u5EA6" }),
12147
- /* @__PURE__ */ jsx93("p", { className: "mt-1 text-xs text-ant-color-text-tertiary", children: "\u8282\u70B9\u3001\u5BA1\u6279\u4EBA\u3001\u5904\u7406\u610F\u89C1\u548C\u7B49\u5F85\u72B6\u6001" })
12148
- ] }) }),
12149
- renderTimeline ? renderTimeline(progressList) : /* @__PURE__ */ jsx93(ApprovalTimeline, { tasks: progressList, showRemarks: true, showApproverInfo: true })
12150
- ] })
12151
- ] }) });
12549
+ )
12550
+ ] });
12152
12551
  };
12153
12552
  var ProcessDetailTemplate = (props) => {
12154
12553
  const { schema, formUuid, appType, formInstanceId } = props;
@@ -12238,6 +12637,7 @@ export {
12238
12637
  getProcessBasic,
12239
12638
  getProcessDefinition,
12240
12639
  getProcessProgress,
12640
+ getReturnableNodeResult,
12241
12641
  getReturnableNodes,
12242
12642
  getSystemFieldsForFormType,
12243
12643
  getViewPermission,