sy-form-components 0.2.13 → 0.2.15

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
@@ -107,6 +107,7 @@ __export(index_exports, {
107
107
  getProcessBasic: () => getProcessBasic,
108
108
  getProcessDefinition: () => getProcessDefinition,
109
109
  getProcessProgress: () => getProcessProgress,
110
+ getReturnableNodeResult: () => getReturnableNodeResult,
110
111
  getReturnableNodes: () => getReturnableNodes,
111
112
  getSystemFieldsForFormType: () => getSystemFieldsForFormType,
112
113
  getViewPermission: () => getViewPermission,
@@ -148,7 +149,7 @@ __export(index_exports, {
148
149
  module.exports = __toCommonJS(index_exports);
149
150
 
150
151
  // src/core/FormProvider.tsx
151
- var import_react38 = __toESM(require("react"));
152
+ var import_react40 = __toESM(require("react"));
152
153
 
153
154
  // src/core/FormContext.ts
154
155
  var import_react = require("react");
@@ -1502,9 +1503,10 @@ function CascadeDateField(props) {
1502
1503
  }
1503
1504
 
1504
1505
  // src/fields/AttachmentField/index.tsx
1505
- var import_react16 = require("react");
1506
+ var import_react17 = require("react");
1506
1507
 
1507
1508
  // src/fields/AttachmentField/AttachmentFieldPC.tsx
1509
+ var import_react16 = __toESM(require("react"));
1508
1510
  var import_antd10 = require("antd");
1509
1511
 
1510
1512
  // src/fields/shared/fieldFormat.ts
@@ -1611,6 +1613,31 @@ function normalizeAttachmentItem(item, fallback) {
1611
1613
  extension: item?.extension || fallback?.extension || getFileExtension(name)
1612
1614
  };
1613
1615
  }
1616
+ function getAttachmentItemIdentity(item) {
1617
+ return String(item?.uid || item?.id || item?.objectName || item?.url || item?.name || "");
1618
+ }
1619
+ function dedupeAttachmentItems(items) {
1620
+ const result = [];
1621
+ const indexes = /* @__PURE__ */ new Map();
1622
+ for (const item of items) {
1623
+ const key = getAttachmentItemIdentity(item);
1624
+ if (!key) {
1625
+ result.push(item);
1626
+ continue;
1627
+ }
1628
+ const existingIndex = indexes.get(key);
1629
+ if (existingIndex === void 0) {
1630
+ indexes.set(key, result.length);
1631
+ result.push(item);
1632
+ continue;
1633
+ }
1634
+ result[existingIndex] = {
1635
+ ...result[existingIndex],
1636
+ ...item
1637
+ };
1638
+ }
1639
+ return result;
1640
+ }
1614
1641
 
1615
1642
  // src/fields/AttachmentField/AttachmentFieldPC.tsx
1616
1643
  var import_jsx_runtime38 = require("react/jsx-runtime");
@@ -1665,38 +1692,47 @@ function AttachmentFieldPC({
1665
1692
  onChange
1666
1693
  }) {
1667
1694
  const { formData, setFieldValue, api } = useFormContext();
1668
- const value = formData[fieldId] ?? [];
1695
+ const value = import_react16.default.useMemo(
1696
+ () => dedupeAttachmentItems(
1697
+ Array.isArray(formData[fieldId]) ? formData[fieldId] : []
1698
+ ),
1699
+ [fieldId, formData]
1700
+ );
1701
+ const valueRef = import_react16.default.useRef(value);
1669
1702
  const disabled = behavior === "DISABLED";
1703
+ import_react16.default.useEffect(() => {
1704
+ valueRef.current = value;
1705
+ }, [value]);
1670
1706
  const setValue = (items) => {
1671
- setFieldValue(fieldId, items);
1672
- onChange?.(items);
1673
- };
1674
- const handleChange = (info) => {
1675
- const fileList2 = info.fileList ?? [];
1676
- const items = fileList2.map((f) => {
1677
- if (f.uid === void 0 && f.name === void 0 && f.url === void 0 && !f.response) {
1678
- return { url: "", name: "", id: "" };
1679
- }
1680
- return normalizeAttachmentItem({
1681
- url: f.url ?? f.response?.url ?? "",
1682
- name: f.name,
1683
- id: f.uid ?? f.response?.id,
1684
- uid: f.uid ?? f.response?.uid,
1685
- status: f.status,
1686
- percent: f.percent,
1687
- objectName: f.objectName ?? f.response?.objectName,
1688
- bucketName: f.bucketName ?? f.response?.bucketName,
1689
- size: f.size ?? f.response?.size,
1690
- contentType: f.type ?? f.response?.contentType,
1691
- downloadUrl: f.downloadUrl ?? f.response?.downloadUrl,
1692
- previewUrl: f.previewUrl ?? f.response?.previewUrl
1693
- });
1707
+ const nextItems = dedupeAttachmentItems(items).slice(0, maxCount ?? Infinity);
1708
+ valueRef.current = nextItems;
1709
+ setFieldValue(fieldId, nextItems);
1710
+ onChange?.(nextItems);
1711
+ };
1712
+ const replaceItem = (target, nextItem) => {
1713
+ const targetKeys = new Set(
1714
+ [target.id, target.uid, target.objectName, getAttachmentItemIdentity(target)].filter(Boolean)
1715
+ );
1716
+ let replaced = false;
1717
+ const nextItems = valueRef.current.map((item) => {
1718
+ const currentKeys = [item.id, item.uid, item.objectName, getAttachmentItemIdentity(item)];
1719
+ if (currentKeys.some((key) => key && targetKeys.has(key))) {
1720
+ replaced = true;
1721
+ return nextItem;
1722
+ }
1723
+ return item;
1694
1724
  });
1695
- setValue(items);
1725
+ if (!replaced) nextItems.push(nextItem);
1726
+ setValue(nextItems);
1696
1727
  };
1697
1728
  const handleRemove = (file) => {
1698
- const removed = value.find((item) => item.id === file.uid || item.uid === file.uid);
1699
- const newValue = value.filter((item) => item.id !== file.uid && item.uid !== file.uid);
1729
+ const fileKey = String(file.uid || file.id || file.objectName || "");
1730
+ const removed = valueRef.current.find(
1731
+ (item) => item.id === fileKey || item.uid === fileKey || item.objectName === fileKey
1732
+ );
1733
+ const newValue = valueRef.current.filter(
1734
+ (item) => item.id !== fileKey && item.uid !== fileKey && item.objectName !== fileKey
1735
+ );
1700
1736
  setValue(newValue);
1701
1737
  if (removed?.objectName) {
1702
1738
  api.deleteFile(removed.objectName, removed.bucketName || bucketName).catch(() => void 0);
@@ -1737,7 +1773,9 @@ function AttachmentFieldPC({
1737
1773
  return url;
1738
1774
  };
1739
1775
  const handlePreview = async (file) => {
1740
- const item = value.find((current) => current.id === file.uid || current.uid === file.uid);
1776
+ const item = valueRef.current.find(
1777
+ (current) => current.id === file.uid || current.uid === file.uid || current.objectName === file.uid
1778
+ );
1741
1779
  const url = item ? await resolvePreviewUrl(item) : file.url;
1742
1780
  if (url) window.open(url, "_blank", "noopener,noreferrer");
1743
1781
  };
@@ -1745,14 +1783,10 @@ function AttachmentFieldPC({
1745
1783
  const url = await resolveDownloadUrl(item);
1746
1784
  if (url) window.open(url, "_blank", "noopener,noreferrer");
1747
1785
  };
1748
- const fileList = value.map((item) => ({
1749
- uid: item.id,
1750
- name: item.name,
1751
- url: item.url,
1752
- status: item.status ?? "done",
1753
- percent: item.percent
1754
- }));
1755
1786
  const beforeUpload = (file) => {
1787
+ if (maxCount && valueRef.current.length >= maxCount) {
1788
+ return false;
1789
+ }
1756
1790
  if (maxSize && file.size / 1024 / 1024 > maxSize) {
1757
1791
  return false;
1758
1792
  }
@@ -1765,27 +1799,26 @@ function AttachmentFieldPC({
1765
1799
  const customRequest = async ({ file, onProgress, onSuccess, onError }) => {
1766
1800
  const currentFile = file;
1767
1801
  const localItem = createLocalItem(currentFile);
1768
- const nextValue = multiple ? [...value, localItem].slice(0, maxCount ?? Infinity) : [localItem];
1802
+ const currentValue = valueRef.current.filter(
1803
+ (item) => item.id !== localItem.id && item.uid !== localItem.uid
1804
+ );
1805
+ const nextValue = multiple ? [...currentValue, localItem] : [localItem];
1769
1806
  setValue(nextValue);
1770
1807
  try {
1771
1808
  const uploaded = await api.uploadFile(currentFile, bucketName, (percent) => {
1772
1809
  onProgress?.({ percent });
1773
- setValue(
1774
- nextValue.map(
1775
- (item) => item.id === localItem.id ? { ...item, percent, status: "uploading" } : item
1776
- )
1777
- );
1778
- });
1779
- const completed = normalizeAttachmentItem({
1780
- ...uploaded,
1781
- id: uploaded.id || localItem.id,
1782
- uid: uploaded.uid || localItem.uid,
1783
- url: uploaded.url || localItem.url,
1784
- status: "done",
1785
- percent: 100,
1786
- extension: uploaded.extension || getFileExtension(uploaded.name || localItem.name)
1810
+ replaceItem(localItem, { ...localItem, percent, status: "uploading" });
1787
1811
  });
1788
- setValue(nextValue.map((item) => item.id === localItem.id ? completed : item));
1812
+ const completed = normalizeAttachmentItem(
1813
+ {
1814
+ ...uploaded,
1815
+ status: "done",
1816
+ percent: 100,
1817
+ extension: uploaded.extension || getFileExtension(uploaded.name || localItem.name)
1818
+ },
1819
+ localItem
1820
+ );
1821
+ replaceItem(localItem, completed);
1789
1822
  onSuccess?.(completed);
1790
1823
  } catch (error) {
1791
1824
  const failed = {
@@ -1793,7 +1826,7 @@ function AttachmentFieldPC({
1793
1826
  status: "error",
1794
1827
  error: error?.message || "\u4E0A\u4F20\u5931\u8D25"
1795
1828
  };
1796
- setValue(nextValue.map((item) => item.id === localItem.id ? failed : item));
1829
+ replaceItem(localItem, failed);
1797
1830
  onError?.(error);
1798
1831
  }
1799
1832
  };
@@ -1802,61 +1835,71 @@ function AttachmentFieldPC({
1802
1835
  import_antd10.Upload,
1803
1836
  {
1804
1837
  "data-testid": `attachmentfield-input-${fieldId}`,
1805
- fileList,
1838
+ fileList: [],
1806
1839
  customRequest,
1807
1840
  accept,
1808
1841
  maxCount,
1809
1842
  multiple,
1810
1843
  disabled,
1811
- onChange: handleChange,
1844
+ showUploadList: false,
1812
1845
  onRemove: handleRemove,
1813
1846
  onPreview: handlePreview,
1814
1847
  beforeUpload,
1815
1848
  children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_antd10.Button, { disabled, "data-testid": `attachmentfield-upload-btn-${fieldId}`, children: "\u4E0A\u4F20\u6587\u4EF6" })
1816
1849
  }
1817
1850
  ),
1818
- value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "sy-file-list", "data-testid": `attachmentfield-rich-list-${fieldId}`, children: value.map((item) => {
1851
+ value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "sy-file-list", "data-testid": `attachmentfield-rich-list-${fieldId}`, children: value.map((item, index) => {
1819
1852
  const category = getFileCategory(item.name, item.contentType);
1820
1853
  const extension = getFileExtension(item.name);
1821
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "sy-file-item", children: [
1822
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: `sy-file-icon sy-file-icon-${category}`, "aria-hidden": "true", children: category === "image" ? "IMG" : extension || "FILE" }),
1823
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "sy-file-meta", children: [
1824
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "sy-file-name", title: item.name, children: item.name }),
1825
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "sy-file-sub", children: item.status === "uploading" ? `\u4E0A\u4F20\u4E2D ${Math.round(item.percent ?? 0)}%` : item.status === "error" ? item.error || "\u4E0A\u4F20\u5931\u8D25" : [
1826
- showFileTypeBadge && extension ? extension.toUpperCase() : "",
1827
- showFileSize ? formatFileSize(item.size) : ""
1828
- ].filter(Boolean).join(" \xB7 ") || "\u5DF2\u4E0A\u4F20" })
1829
- ] }),
1830
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "sy-file-actions", children: [
1831
- showPreview && canPreview(item) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1832
- "button",
1833
- {
1834
- type: "button",
1835
- disabled: item.status !== "done",
1836
- onClick: () => handlePreview({ uid: item.uid || item.id, url: item.url }),
1837
- children: "\u9884\u89C8"
1838
- }
1839
- ),
1840
- showDownload && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1841
- "button",
1842
- {
1843
- type: "button",
1844
- disabled: item.status !== "done",
1845
- onClick: () => handleDownload(item),
1846
- children: "\u4E0B\u8F7D"
1847
- }
1848
- ),
1849
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1850
- "button",
1851
- {
1852
- type: "button",
1853
- disabled,
1854
- onClick: () => handleRemove({ uid: item.uid || item.id }),
1855
- children: "\u5220\u9664"
1856
- }
1857
- )
1858
- ] })
1859
- ] }, item.id || item.uid || item.name);
1854
+ const itemKey = getAttachmentItemIdentity(item) || `${fieldId}-attachment-${String(index)}`;
1855
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
1856
+ "div",
1857
+ {
1858
+ className: "sy-file-item",
1859
+ "data-testid": `attachmentfield-item-${itemKey}`,
1860
+ children: [
1861
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: `sy-file-icon sy-file-icon-${category}`, "aria-hidden": "true", children: category === "image" ? "IMG" : extension || "FILE" }),
1862
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "sy-file-meta", children: [
1863
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "sy-file-name", title: item.name, children: item.name }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "sy-file-sub", children: item.status === "uploading" ? `\u4E0A\u4F20\u4E2D ${Math.round(item.percent ?? 0)}%` : item.status === "error" ? item.error || "\u4E0A\u4F20\u5931\u8D25" : [
1865
+ showFileTypeBadge && extension ? extension.toUpperCase() : "",
1866
+ showFileSize ? formatFileSize(item.size) : ""
1867
+ ].filter(Boolean).join(" \xB7 ") || "\u5DF2\u4E0A\u4F20" })
1868
+ ] }),
1869
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "sy-file-actions", children: [
1870
+ showPreview && canPreview(item) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1871
+ "button",
1872
+ {
1873
+ type: "button",
1874
+ disabled: item.status !== "done",
1875
+ onClick: () => handlePreview({ uid: item.uid || item.id, url: item.url }),
1876
+ children: "\u9884\u89C8"
1877
+ }
1878
+ ),
1879
+ showDownload && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1880
+ "button",
1881
+ {
1882
+ type: "button",
1883
+ disabled: item.status !== "done",
1884
+ onClick: () => handleDownload(item),
1885
+ children: "\u4E0B\u8F7D"
1886
+ }
1887
+ ),
1888
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
1889
+ "button",
1890
+ {
1891
+ type: "button",
1892
+ disabled,
1893
+ onClick: () => handleRemove({ uid: item.uid || item.id }),
1894
+ "data-testid": `attachmentfield-remove-${itemKey}`,
1895
+ children: "\u5220\u9664"
1896
+ }
1897
+ )
1898
+ ] })
1899
+ ]
1900
+ },
1901
+ `${itemKey}-${index}`
1902
+ );
1860
1903
  }) })
1861
1904
  ] });
1862
1905
  }
@@ -2009,7 +2052,7 @@ function AttachmentField(props) {
2009
2052
  const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
2010
2053
  const { isMobile } = useDeviceDetect();
2011
2054
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
2012
- (0, import_react16.useEffect)(() => {
2055
+ (0, import_react17.useEffect)(() => {
2013
2056
  registerField(fieldId);
2014
2057
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
2015
2058
  setFieldValue(fieldId, defaultValue);
@@ -2034,9 +2077,10 @@ function AttachmentField(props) {
2034
2077
  }
2035
2078
 
2036
2079
  // src/fields/ImageField/index.tsx
2037
- var import_react17 = require("react");
2080
+ var import_react19 = require("react");
2038
2081
 
2039
2082
  // src/fields/ImageField/ImageFieldPC.tsx
2083
+ var import_react18 = __toESM(require("react"));
2040
2084
  var import_antd11 = require("antd");
2041
2085
  var import_jsx_runtime42 = require("react/jsx-runtime");
2042
2086
  var createLocalItem2 = (file) => {
@@ -2054,6 +2098,23 @@ var createLocalItem2 = (file) => {
2054
2098
  extension: getFileExtension(file.name)
2055
2099
  };
2056
2100
  };
2101
+ function ImageThumbContent({ item }) {
2102
+ const [imageFailed, setImageFailed] = import_react18.default.useState(false);
2103
+ const src = item.previewUrl || item.url;
2104
+ import_react18.default.useEffect(() => {
2105
+ setImageFailed(false);
2106
+ }, [src]);
2107
+ if (src && !imageFailed) {
2108
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
2109
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("img", { src, alt: item.name, onError: () => setImageFailed(true) }),
2110
+ item.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { className: "sy-image-state", children: [
2111
+ Math.round(item.percent ?? 0),
2112
+ "%"
2113
+ ] })
2114
+ ] });
2115
+ }
2116
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "sy-image-state", children: item.status === "uploading" ? `${Math.round(item.percent ?? 0)}%` : item.status === "error" ? item.error || "\u4E0A\u4F20\u5931\u8D25" : item.name || "\u56FE\u7247" });
2117
+ }
2057
2118
  function ImageFieldPC({
2058
2119
  fieldId,
2059
2120
  behavior,
@@ -2069,44 +2130,56 @@ function ImageFieldPC({
2069
2130
  onChange
2070
2131
  }) {
2071
2132
  const { formData, setFieldValue, api } = useFormContext();
2072
- const value = formData[fieldId] ?? [];
2133
+ const value = import_react18.default.useMemo(
2134
+ () => dedupeAttachmentItems(
2135
+ Array.isArray(formData[fieldId]) ? formData[fieldId] : []
2136
+ ),
2137
+ [fieldId, formData]
2138
+ );
2139
+ const valueRef = import_react18.default.useRef(value);
2073
2140
  const disabled = behavior === "DISABLED";
2141
+ import_react18.default.useEffect(() => {
2142
+ valueRef.current = value;
2143
+ }, [value]);
2074
2144
  const setValue = (items) => {
2075
- setFieldValue(fieldId, items);
2076
- onChange?.(items);
2077
- };
2078
- const handleChange = (info) => {
2079
- const fileList2 = info.fileList ?? [];
2080
- const items = fileList2.map((f) => {
2081
- if (f.uid === void 0 && f.name === void 0 && f.url === void 0 && f.thumbUrl === void 0 && !f.response) {
2082
- return { url: "", name: "", id: "" };
2083
- }
2084
- return normalizeAttachmentItem({
2085
- url: f.url ?? f.thumbUrl ?? f.response?.url ?? "",
2086
- previewUrl: f.previewUrl ?? f.thumbUrl ?? f.response?.previewUrl,
2087
- name: f.name,
2088
- id: f.uid ?? f.response?.id,
2089
- uid: f.uid ?? f.response?.uid,
2090
- status: f.status,
2091
- percent: f.percent,
2092
- objectName: f.objectName ?? f.response?.objectName,
2093
- bucketName: f.bucketName ?? f.response?.bucketName,
2094
- size: f.size ?? f.response?.size,
2095
- contentType: f.type ?? f.response?.contentType
2096
- });
2145
+ const nextItems = dedupeAttachmentItems(items).slice(0, maxCount ?? Infinity);
2146
+ valueRef.current = nextItems;
2147
+ setFieldValue(fieldId, nextItems);
2148
+ onChange?.(nextItems);
2149
+ };
2150
+ const replaceItem = (target, nextItem) => {
2151
+ const targetKeys = new Set(
2152
+ [target.id, target.uid, target.objectName, getAttachmentItemIdentity(target)].filter(Boolean)
2153
+ );
2154
+ let replaced = false;
2155
+ const nextItems = valueRef.current.map((item) => {
2156
+ const currentKeys = [item.id, item.uid, item.objectName, getAttachmentItemIdentity(item)];
2157
+ if (currentKeys.some((key) => key && targetKeys.has(key))) {
2158
+ replaced = true;
2159
+ return nextItem;
2160
+ }
2161
+ return item;
2097
2162
  });
2098
- setValue(items);
2163
+ if (!replaced) nextItems.push(nextItem);
2164
+ setValue(nextItems);
2099
2165
  };
2100
2166
  const handleRemove = (file) => {
2101
- const removed = value.find((item) => item.id === file.uid || item.uid === file.uid);
2102
- const newValue = value.filter((item) => item.id !== file.uid && item.uid !== file.uid);
2167
+ const fileKey = String(file.uid || file.id || file.objectName || "");
2168
+ const removed = valueRef.current.find(
2169
+ (item) => item.id === fileKey || item.uid === fileKey || item.objectName === fileKey
2170
+ );
2171
+ const newValue = valueRef.current.filter(
2172
+ (item) => item.id !== fileKey && item.uid !== fileKey && item.objectName !== fileKey
2173
+ );
2103
2174
  setValue(newValue);
2104
2175
  if (removed?.objectName) {
2105
2176
  api.deleteFile(removed.objectName, removed.bucketName || bucketName).catch(() => void 0);
2106
2177
  }
2107
2178
  };
2108
2179
  const handlePreview = async (file) => {
2109
- const item = value.find((current) => current.id === file.uid || current.uid === file.uid);
2180
+ const item = valueRef.current.find(
2181
+ (current) => current.id === file.uid || current.uid === file.uid || current.objectName === file.uid
2182
+ );
2110
2183
  let url = item?.previewUrl || item?.url || file.url || file.thumbUrl;
2111
2184
  if (item?.objectName) {
2112
2185
  const ticket = await api.createFileAccessTicket(
@@ -2119,15 +2192,22 @@ function ImageFieldPC({
2119
2192
  }
2120
2193
  if (url) window.open(url, "_blank", "noopener,noreferrer");
2121
2194
  };
2122
- const fileList = value.map((item) => ({
2123
- uid: item.id,
2124
- name: item.name,
2125
- url: item.url,
2126
- thumbUrl: item.url,
2127
- status: item.status ?? "done",
2128
- percent: item.percent
2129
- }));
2195
+ const handleDownload = async (item) => {
2196
+ let url = item.downloadUrl || item.url;
2197
+ if (item.objectName) {
2198
+ const ticket = await api.createDownloadTicket(
2199
+ item.bucketName || bucketName,
2200
+ item.objectName,
2201
+ item.name
2202
+ );
2203
+ url = typeof ticket === "string" ? ticket : ticket?.downloadUrl || ticket?.relayUrl || ticket?.url || url;
2204
+ }
2205
+ if (url) window.open(url, "_blank", "noopener,noreferrer");
2206
+ };
2130
2207
  const beforeUpload = (file) => {
2208
+ if (maxCount && valueRef.current.length >= maxCount) {
2209
+ return false;
2210
+ }
2131
2211
  if (!String(file.type || "").startsWith("image/") && !/\.(png|jpe?g|gif|bmp|svg|webp)$/i.test(file.name)) {
2132
2212
  return false;
2133
2213
  }
@@ -2139,26 +2219,27 @@ function ImageFieldPC({
2139
2219
  const customRequest = async ({ file, onProgress, onSuccess, onError }) => {
2140
2220
  const currentFile = file;
2141
2221
  const localItem = createLocalItem2(currentFile);
2142
- const nextValue = multiple ? [...value, localItem].slice(0, maxCount ?? Infinity) : [localItem];
2222
+ const currentValue = valueRef.current.filter(
2223
+ (item) => item.id !== localItem.id && item.uid !== localItem.uid
2224
+ );
2225
+ const nextValue = multiple ? [...currentValue, localItem] : [localItem];
2143
2226
  setValue(nextValue);
2144
2227
  try {
2145
2228
  const uploaded = await api.uploadFile(currentFile, bucketName, (percent) => {
2146
2229
  onProgress?.({ percent });
2147
- setValue(
2148
- nextValue.map(
2149
- (item) => item.id === localItem.id ? { ...item, percent, status: "uploading" } : item
2150
- )
2151
- );
2230
+ replaceItem(localItem, { ...localItem, percent, status: "uploading" });
2152
2231
  });
2153
- const completed = normalizeAttachmentItem({
2154
- ...uploaded,
2155
- id: uploaded.id || localItem.id,
2156
- uid: uploaded.uid || localItem.uid,
2157
- url: uploaded.previewUrl || uploaded.url || localItem.url,
2158
- status: "done",
2159
- percent: 100
2160
- });
2161
- setValue(nextValue.map((item) => item.id === localItem.id ? completed : item));
2232
+ const completed = normalizeAttachmentItem(
2233
+ {
2234
+ ...uploaded,
2235
+ url: uploaded.previewUrl || uploaded.url || localItem.url,
2236
+ previewUrl: uploaded.previewUrl || uploaded.url || localItem.url,
2237
+ status: "done",
2238
+ percent: 100
2239
+ },
2240
+ localItem
2241
+ );
2242
+ replaceItem(localItem, completed);
2162
2243
  onSuccess?.(completed);
2163
2244
  } catch (error) {
2164
2245
  const failed = {
@@ -2166,7 +2247,7 @@ function ImageFieldPC({
2166
2247
  status: "error",
2167
2248
  error: error?.message || "\u4E0A\u4F20\u5931\u8D25"
2168
2249
  };
2169
- setValue(nextValue.map((item) => item.id === localItem.id ? failed : item));
2250
+ replaceItem(localItem, failed);
2170
2251
  onError?.(error);
2171
2252
  }
2172
2253
  };
@@ -2176,42 +2257,74 @@ function ImageFieldPC({
2176
2257
  {
2177
2258
  "data-testid": `imagefield-input-${fieldId}`,
2178
2259
  listType,
2179
- fileList,
2260
+ fileList: [],
2180
2261
  customRequest,
2181
2262
  accept: accept ?? "image/*",
2182
2263
  maxCount,
2183
2264
  multiple,
2184
2265
  disabled,
2185
- showUploadList: {
2186
- showPreviewIcon,
2187
- showRemoveIcon,
2188
- showDownloadIcon
2189
- },
2190
- onChange: handleChange,
2266
+ showUploadList: false,
2191
2267
  onRemove: handleRemove,
2192
2268
  onPreview: handlePreview,
2193
2269
  beforeUpload,
2194
2270
  children: (!maxCount || value.length < maxCount) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { "data-testid": `imagefield-upload-btn-${fieldId}`, children: "+ \u4E0A\u4F20\u56FE\u7247" })
2195
2271
  }
2196
2272
  ),
2197
- value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sy-image-grid", "data-testid": `imagefield-rich-grid-${fieldId}`, children: value.map((item) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2198
- "button",
2199
- {
2200
- type: "button",
2201
- className: "sy-image-thumb",
2202
- disabled: item.status !== "done",
2203
- onClick: () => handlePreview({
2204
- uid: item.uid || item.id,
2205
- url: item.url,
2206
- thumbUrl: item.previewUrl
2207
- }),
2208
- children: item.url || item.previewUrl ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("img", { src: item.previewUrl || item.url, alt: item.name }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
2209
- Math.round(item.percent ?? 0),
2210
- "%"
2211
- ] })
2212
- },
2213
- item.id || item.uid || item.name
2214
- )) })
2273
+ value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sy-image-grid", "data-testid": `imagefield-rich-grid-${fieldId}`, children: value.map((item, index) => {
2274
+ const itemKey = getAttachmentItemIdentity(item) || `${fieldId}-image-${String(index)}`;
2275
+ const canAct = item.status === "done";
2276
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
2277
+ "div",
2278
+ {
2279
+ className: "sy-image-thumb",
2280
+ "data-testid": `imagefield-thumb-${itemKey}`,
2281
+ children: [
2282
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2283
+ "button",
2284
+ {
2285
+ type: "button",
2286
+ className: "sy-image-preview",
2287
+ disabled: !canAct && !(item.previewUrl || item.url),
2288
+ onClick: () => handlePreview({
2289
+ uid: item.uid || item.id,
2290
+ url: item.url,
2291
+ thumbUrl: item.previewUrl
2292
+ }),
2293
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ImageThumbContent, { item })
2294
+ }
2295
+ ),
2296
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "sy-image-actions", children: [
2297
+ showPreviewIcon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2298
+ "button",
2299
+ {
2300
+ type: "button",
2301
+ disabled: !canAct,
2302
+ onClick: () => handlePreview({
2303
+ uid: item.uid || item.id,
2304
+ url: item.url,
2305
+ thumbUrl: item.previewUrl
2306
+ }),
2307
+ children: "\u9884\u89C8"
2308
+ }
2309
+ ),
2310
+ showDownloadIcon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", disabled: !canAct, onClick: () => handleDownload(item), children: "\u4E0B\u8F7D" }),
2311
+ showRemoveIcon && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2312
+ "button",
2313
+ {
2314
+ type: "button",
2315
+ disabled,
2316
+ onClick: () => handleRemove({ uid: item.uid || item.id }),
2317
+ "data-testid": `remove-btn-${itemKey}`,
2318
+ children: "\u5220\u9664"
2319
+ }
2320
+ )
2321
+ ] }),
2322
+ canAct && item.size ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "sy-image-meta", children: formatFileSize(item.size) }) : null
2323
+ ]
2324
+ },
2325
+ `${itemKey}-${index}`
2326
+ );
2327
+ }) })
2215
2328
  ] });
2216
2329
  }
2217
2330
 
@@ -2424,7 +2537,7 @@ function ImageField(props) {
2424
2537
  const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
2425
2538
  const { isMobile } = useDeviceDetect();
2426
2539
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
2427
- (0, import_react17.useEffect)(() => {
2540
+ (0, import_react19.useEffect)(() => {
2428
2541
  registerField(fieldId);
2429
2542
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
2430
2543
  setFieldValue(fieldId, defaultValue);
@@ -2449,10 +2562,10 @@ function ImageField(props) {
2449
2562
  }
2450
2563
 
2451
2564
  // src/fields/SubFormField/index.tsx
2452
- var import_react19 = require("react");
2565
+ var import_react21 = require("react");
2453
2566
 
2454
2567
  // src/fields/SubFormField/SubFormCell.tsx
2455
- var import_react18 = require("react");
2568
+ var import_react20 = require("react");
2456
2569
  var import_jsx_runtime46 = require("react/jsx-runtime");
2457
2570
  var stringifyFallbackValue = (value) => {
2458
2571
  if (value === void 0 || value === null) return "";
@@ -2473,7 +2586,7 @@ function SubFormCell({
2473
2586
  const scopedFieldId = `${parentFieldId}.${rowIndex}.${column.fieldId}`;
2474
2587
  const cellValue = row[column.fieldId];
2475
2588
  const resolvedBehavior = behavior ?? "NORMAL";
2476
- const childContext = (0, import_react18.useMemo)(
2589
+ const childContext = (0, import_react20.useMemo)(
2477
2590
  () => ({
2478
2591
  ...parentContext,
2479
2592
  formData: {
@@ -2765,7 +2878,7 @@ function SubFormField(props) {
2765
2878
  const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
2766
2879
  const { isMobile } = useDeviceDetect();
2767
2880
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
2768
- (0, import_react19.useEffect)(() => {
2881
+ (0, import_react21.useEffect)(() => {
2769
2882
  registerField(fieldId);
2770
2883
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
2771
2884
  setFieldValue(fieldId, defaultValue);
@@ -2790,20 +2903,20 @@ function SubFormField(props) {
2790
2903
  }
2791
2904
 
2792
2905
  // src/fields/UserSelectField/index.tsx
2793
- var import_react24 = require("react");
2906
+ var import_react26 = require("react");
2794
2907
 
2795
2908
  // src/fields/UserSelectField/UserSelectFieldPC.tsx
2796
- var import_react22 = require("react");
2909
+ var import_react24 = require("react");
2797
2910
  var import_antd13 = require("antd");
2798
2911
 
2799
2912
  // src/fields/shared/UserPicker.tsx
2800
- var import_react21 = require("react");
2913
+ var import_react23 = require("react");
2801
2914
  var import_antd12 = require("antd");
2802
2915
  var import_icons = require("@ant-design/icons");
2803
2916
  var MobileAntd2 = __toESM(require("antd-mobile"));
2804
2917
 
2805
2918
  // src/fields/shared/useLazyDepartmentTree.ts
2806
- var import_react20 = require("react");
2919
+ var import_react22 = require("react");
2807
2920
  var toLazyNode = (node) => {
2808
2921
  const normalized = normalizeDepartmentNode(node);
2809
2922
  const id = getDepartmentId(normalized);
@@ -2853,15 +2966,15 @@ function buildIndexes(nodes) {
2853
2966
  return { nodeMap, parentMap, flatNodes };
2854
2967
  }
2855
2968
  function useLazyDepartmentTree(api, configuredTreeData) {
2856
- const [treeData, setTreeDataState] = (0, import_react20.useState)(
2969
+ const [treeData, setTreeDataState] = (0, import_react22.useState)(
2857
2970
  () => (configuredTreeData || []).map(toLazyNode)
2858
2971
  );
2859
- const [treeLoading, setTreeLoading] = (0, import_react20.useState)(false);
2860
- const treeDataRef = (0, import_react20.useRef)(treeData);
2861
- const rootsLoadedRef = (0, import_react20.useRef)(Boolean(configuredTreeData?.length));
2862
- const rootPromiseRef = (0, import_react20.useRef)(null);
2863
- const childPromiseRef = (0, import_react20.useRef)({});
2864
- const setTreeData = (0, import_react20.useCallback)(
2972
+ const [treeLoading, setTreeLoading] = (0, import_react22.useState)(false);
2973
+ const treeDataRef = (0, import_react22.useRef)(treeData);
2974
+ const rootsLoadedRef = (0, import_react22.useRef)(Boolean(configuredTreeData?.length));
2975
+ const rootPromiseRef = (0, import_react22.useRef)(null);
2976
+ const childPromiseRef = (0, import_react22.useRef)({});
2977
+ const setTreeData = (0, import_react22.useCallback)(
2865
2978
  (next) => {
2866
2979
  const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
2867
2980
  treeDataRef.current = resolved;
@@ -2870,13 +2983,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
2870
2983
  },
2871
2984
  []
2872
2985
  );
2873
- (0, import_react20.useEffect)(() => {
2986
+ (0, import_react22.useEffect)(() => {
2874
2987
  if (!configuredTreeData) return;
2875
2988
  const next = configuredTreeData.map(toLazyNode);
2876
2989
  rootsLoadedRef.current = next.length > 0;
2877
2990
  setTreeData(next);
2878
2991
  }, [configuredTreeData, setTreeData]);
2879
- const loadRootDepartments = (0, import_react20.useCallback)(async () => {
2992
+ const loadRootDepartments = (0, import_react22.useCallback)(async () => {
2880
2993
  if (rootsLoadedRef.current) return treeDataRef.current;
2881
2994
  if (rootPromiseRef.current) return rootPromiseRef.current;
2882
2995
  setTreeLoading(true);
@@ -2892,7 +3005,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
2892
3005
  rootPromiseRef.current = promise;
2893
3006
  return promise;
2894
3007
  }, [api, setTreeData]);
2895
- const loadChildren = (0, import_react20.useCallback)(
3008
+ const loadChildren = (0, import_react22.useCallback)(
2896
3009
  async (parentId) => {
2897
3010
  const id = String(parentId || "");
2898
3011
  if (!id) return [];
@@ -2913,8 +3026,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
2913
3026
  },
2914
3027
  [api, setTreeData]
2915
3028
  );
2916
- const indexes = (0, import_react20.useMemo)(() => buildIndexes(treeData), [treeData]);
2917
- (0, import_react20.useEffect)(() => {
3029
+ const indexes = (0, import_react22.useMemo)(() => buildIndexes(treeData), [treeData]);
3030
+ (0, import_react22.useEffect)(() => {
2918
3031
  void loadRootDepartments();
2919
3032
  }, [loadRootDepartments]);
2920
3033
  return {
@@ -2957,25 +3070,25 @@ function UserPickerPanel({
2957
3070
  flatNodes,
2958
3071
  loadChildren
2959
3072
  } = useLazyDepartmentTree(api, treeData);
2960
- const [departmentKeyword, setDepartmentKeyword] = (0, import_react21.useState)("");
2961
- const [memberKeyword, setMemberKeyword] = (0, import_react21.useState)("");
2962
- const [mobileKeyword, setMobileKeyword] = (0, import_react21.useState)("");
2963
- const [currentDeptId, setCurrentDeptId] = (0, import_react21.useState)("");
2964
- const [expandedKeys, setExpandedKeys] = (0, import_react21.useState)([]);
2965
- const [members, setMembers] = (0, import_react21.useState)(() => normalizeUsers(dataSource));
2966
- const [loading, setLoading] = (0, import_react21.useState)(false);
2967
- const [selected, setSelected] = (0, import_react21.useState)(() => normalizeUsers(value));
3073
+ const [departmentKeyword, setDepartmentKeyword] = (0, import_react23.useState)("");
3074
+ const [memberKeyword, setMemberKeyword] = (0, import_react23.useState)("");
3075
+ const [mobileKeyword, setMobileKeyword] = (0, import_react23.useState)("");
3076
+ const [currentDeptId, setCurrentDeptId] = (0, import_react23.useState)("");
3077
+ const [expandedKeys, setExpandedKeys] = (0, import_react23.useState)([]);
3078
+ const [members, setMembers] = (0, import_react23.useState)(() => normalizeUsers(dataSource));
3079
+ const [loading, setLoading] = (0, import_react23.useState)(false);
3080
+ const [selected, setSelected] = (0, import_react23.useState)(() => normalizeUsers(value));
2968
3081
  const selectedIds = selected.map(getUserId);
2969
3082
  const MobileSearchBar = getMobileComponent("SearchBar");
2970
- (0, import_react21.useEffect)(() => {
3083
+ (0, import_react23.useEffect)(() => {
2971
3084
  if (dataSource?.length) setMembers(normalizeUsers(dataSource));
2972
3085
  }, [dataSource]);
2973
- (0, import_react21.useEffect)(() => {
3086
+ (0, import_react23.useEffect)(() => {
2974
3087
  if (currentDeptId || deptTreeData.length === 0) return;
2975
3088
  setCurrentDeptId(getDepartmentId(deptTreeData[0]));
2976
3089
  setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
2977
3090
  }, [currentDeptId, deptTreeData]);
2978
- (0, import_react21.useEffect)(() => {
3091
+ (0, import_react23.useEffect)(() => {
2979
3092
  let active = true;
2980
3093
  const keyword = (mobile ? mobileKeyword : memberKeyword).trim();
2981
3094
  if (dataSource?.length) {
@@ -3006,7 +3119,7 @@ function UserPickerPanel({
3006
3119
  clearTimeout(timer);
3007
3120
  };
3008
3121
  }, [api, currentDeptId, dataSource, memberKeyword, mobile, mobileKeyword]);
3009
- const currentPath = (0, import_react21.useMemo)(() => {
3122
+ const currentPath = (0, import_react23.useMemo)(() => {
3010
3123
  if (!currentDeptId) return [];
3011
3124
  const path = [];
3012
3125
  let cursor = currentDeptId;
@@ -3018,7 +3131,7 @@ function UserPickerPanel({
3018
3131
  }
3019
3132
  return path;
3020
3133
  }, [currentDeptId, nodeMap, parentMap]);
3021
- const mobileDepartments = (0, import_react21.useMemo)(() => {
3134
+ const mobileDepartments = (0, import_react23.useMemo)(() => {
3022
3135
  const keyword = mobileKeyword.trim().toLowerCase();
3023
3136
  if (keyword) {
3024
3137
  return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
@@ -3242,12 +3355,12 @@ function UserSelectFieldPC({
3242
3355
  const { formData, setFieldValue, api } = useFormContext();
3243
3356
  const value = formData[fieldId] ?? [];
3244
3357
  const disabled = behavior === "DISABLED";
3245
- const [optionsSource, setOptionsSource] = (0, import_react22.useState)(
3358
+ const [optionsSource, setOptionsSource] = (0, import_react24.useState)(
3246
3359
  () => dataSource.map(normalizeUser)
3247
3360
  );
3248
- const [loading, setLoading] = (0, import_react22.useState)(false);
3249
- const [pickerOpen, setPickerOpen] = (0, import_react22.useState)(false);
3250
- (0, import_react22.useEffect)(() => {
3361
+ const [loading, setLoading] = (0, import_react24.useState)(false);
3362
+ const [pickerOpen, setPickerOpen] = (0, import_react24.useState)(false);
3363
+ (0, import_react24.useEffect)(() => {
3251
3364
  if (dataSource.length) {
3252
3365
  setOptionsSource(dataSource.map(normalizeUser));
3253
3366
  }
@@ -3264,7 +3377,7 @@ function UserSelectFieldPC({
3264
3377
  setLoading(false);
3265
3378
  }
3266
3379
  };
3267
- (0, import_react22.useEffect)(() => {
3380
+ (0, import_react24.useEffect)(() => {
3268
3381
  fetchUsers();
3269
3382
  }, []);
3270
3383
  const handleChange = (selectedIds) => {
@@ -3289,7 +3402,7 @@ function UserSelectFieldPC({
3289
3402
  setFieldValue(fieldId, normalized);
3290
3403
  onChange?.(normalized);
3291
3404
  };
3292
- const options = (0, import_react22.useMemo)(
3405
+ const options = (0, import_react24.useMemo)(
3293
3406
  () => optionsSource.map((u) => ({
3294
3407
  value: getUserId(u),
3295
3408
  label: getUserName(u)
@@ -3349,7 +3462,7 @@ function UserSelectFieldPC({
3349
3462
  }
3350
3463
 
3351
3464
  // src/fields/UserSelectField/UserSelectFieldMobile.tsx
3352
- var import_react23 = require("react");
3465
+ var import_react25 = require("react");
3353
3466
  var MobileAntd3 = __toESM(require("antd-mobile"));
3354
3467
  var import_jsx_runtime53 = require("react/jsx-runtime");
3355
3468
  var getMobilePopup = () => {
@@ -3372,11 +3485,11 @@ function UserSelectFieldMobile({
3372
3485
  const { formData, setFieldValue, api } = useFormContext();
3373
3486
  const value = formData[fieldId] ?? [];
3374
3487
  const disabled = behavior === "DISABLED";
3375
- const [showPicker, setShowPicker] = (0, import_react23.useState)(false);
3376
- const [optionsSource, setOptionsSource] = (0, import_react23.useState)(
3488
+ const [showPicker, setShowPicker] = (0, import_react25.useState)(false);
3489
+ const [optionsSource, setOptionsSource] = (0, import_react25.useState)(
3377
3490
  () => dataSource.map(normalizeUser)
3378
3491
  );
3379
- (0, import_react23.useEffect)(() => {
3492
+ (0, import_react25.useEffect)(() => {
3380
3493
  if (dataSource.length) {
3381
3494
  setOptionsSource(dataSource.map(normalizeUser));
3382
3495
  }
@@ -3486,7 +3599,7 @@ function UserSelectField(props) {
3486
3599
  const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
3487
3600
  const { isMobile } = useDeviceDetect();
3488
3601
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
3489
- (0, import_react24.useEffect)(() => {
3602
+ (0, import_react26.useEffect)(() => {
3490
3603
  registerField(fieldId);
3491
3604
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
3492
3605
  setFieldValue(fieldId, defaultValue);
@@ -3511,14 +3624,14 @@ function UserSelectField(props) {
3511
3624
  }
3512
3625
 
3513
3626
  // src/fields/DepartmentSelectField/index.tsx
3514
- var import_react28 = require("react");
3627
+ var import_react30 = require("react");
3515
3628
 
3516
3629
  // src/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
3517
- var import_react26 = require("react");
3630
+ var import_react28 = require("react");
3518
3631
  var import_antd15 = require("antd");
3519
3632
 
3520
3633
  // src/fields/shared/DepartmentPicker.tsx
3521
- var import_react25 = require("react");
3634
+ var import_react27 = require("react");
3522
3635
  var import_antd14 = require("antd");
3523
3636
  var import_icons2 = require("@ant-design/icons");
3524
3637
  var MobileAntd4 = __toESM(require("antd-mobile"));
@@ -3562,17 +3675,17 @@ function DepartmentPickerPanel({
3562
3675
  flatNodes,
3563
3676
  loadChildren
3564
3677
  } = useLazyDepartmentTree(api, treeData);
3565
- const [keyword, setKeyword] = (0, import_react25.useState)("");
3566
- const [selected, setSelected] = (0, import_react25.useState)(() => normalizeSelection(value));
3567
- const [expandedKeys, setExpandedKeys] = (0, import_react25.useState)([]);
3568
- const [currentDeptId, setCurrentDeptId] = (0, import_react25.useState)(null);
3678
+ const [keyword, setKeyword] = (0, import_react27.useState)("");
3679
+ const [selected, setSelected] = (0, import_react27.useState)(() => normalizeSelection(value));
3680
+ const [expandedKeys, setExpandedKeys] = (0, import_react27.useState)([]);
3681
+ const [currentDeptId, setCurrentDeptId] = (0, import_react27.useState)(null);
3569
3682
  const selectedIds = selected.map((item) => item.id);
3570
3683
  const MobileSearchBar = getMobileComponent2("SearchBar");
3571
- const filteredTreeData = (0, import_react25.useMemo)(
3684
+ const filteredTreeData = (0, import_react27.useMemo)(
3572
3685
  () => matchSearch(loadedTreeData, keyword.trim()),
3573
3686
  [keyword, loadedTreeData]
3574
3687
  );
3575
- const currentPath = (0, import_react25.useMemo)(() => {
3688
+ const currentPath = (0, import_react27.useMemo)(() => {
3576
3689
  if (!currentDeptId) return [];
3577
3690
  const path = [];
3578
3691
  let cursor = currentDeptId;
@@ -3584,7 +3697,7 @@ function DepartmentPickerPanel({
3584
3697
  }
3585
3698
  return path;
3586
3699
  }, [currentDeptId, nodeMap, parentMap]);
3587
- const mobileList = (0, import_react25.useMemo)(() => {
3700
+ const mobileList = (0, import_react27.useMemo)(() => {
3588
3701
  if (keyword.trim()) {
3589
3702
  const lower = keyword.trim().toLowerCase();
3590
3703
  return flatNodes.filter((item) => item.name.toLowerCase().includes(lower)).map((item) => item.node);
@@ -3802,10 +3915,10 @@ function DepartmentSelectFieldPC({
3802
3915
  const value = formData[fieldId] ?? [];
3803
3916
  const disabled = behavior === "DISABLED";
3804
3917
  const configuredTreeData = treeData ?? EMPTY_TREE_DATA;
3805
- const remoteLoadedRef = (0, import_react26.useRef)(false);
3806
- const [loadedTreeData, setLoadedTreeData] = (0, import_react26.useState)(configuredTreeData);
3807
- const [pickerOpen, setPickerOpen] = (0, import_react26.useState)(false);
3808
- (0, import_react26.useEffect)(() => {
3918
+ const remoteLoadedRef = (0, import_react28.useRef)(false);
3919
+ const [loadedTreeData, setLoadedTreeData] = (0, import_react28.useState)(configuredTreeData);
3920
+ const [pickerOpen, setPickerOpen] = (0, import_react28.useState)(false);
3921
+ (0, import_react28.useEffect)(() => {
3809
3922
  if (configuredTreeData.length) {
3810
3923
  setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
3811
3924
  return;
@@ -3894,7 +4007,7 @@ function DepartmentSelectFieldPC({
3894
4007
  }
3895
4008
 
3896
4009
  // src/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
3897
- var import_react27 = require("react");
4010
+ var import_react29 = require("react");
3898
4011
  var MobileAntd5 = __toESM(require("antd-mobile"));
3899
4012
  var import_jsx_runtime58 = require("react/jsx-runtime");
3900
4013
  var EMPTY_TREE_DATA2 = [];
@@ -3917,11 +4030,11 @@ function DepartmentSelectFieldMobile({
3917
4030
  const { formData, setFieldValue, api } = useFormContext();
3918
4031
  const value = formData[fieldId] ?? [];
3919
4032
  const disabled = behavior === "DISABLED";
3920
- const [showPicker, setShowPicker] = (0, import_react27.useState)(false);
4033
+ const [showPicker, setShowPicker] = (0, import_react29.useState)(false);
3921
4034
  const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
3922
- const remoteLoadedRef = (0, import_react27.useRef)(false);
3923
- const [loadedTreeData, setLoadedTreeData] = (0, import_react27.useState)(configuredTreeData);
3924
- (0, import_react27.useEffect)(() => {
4035
+ const remoteLoadedRef = (0, import_react29.useRef)(false);
4036
+ const [loadedTreeData, setLoadedTreeData] = (0, import_react29.useState)(configuredTreeData);
4037
+ (0, import_react29.useEffect)(() => {
3925
4038
  if (configuredTreeData.length) {
3926
4039
  setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
3927
4040
  }
@@ -4036,7 +4149,7 @@ function DepartmentSelectField(props) {
4036
4149
  const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
4037
4150
  const { isMobile } = useDeviceDetect();
4038
4151
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
4039
- (0, import_react28.useEffect)(() => {
4152
+ (0, import_react30.useEffect)(() => {
4040
4153
  registerField(fieldId);
4041
4154
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
4042
4155
  setFieldValue(fieldId, defaultValue);
@@ -4061,7 +4174,7 @@ function DepartmentSelectField(props) {
4061
4174
  }
4062
4175
 
4063
4176
  // src/fields/CascadeSelectField/index.tsx
4064
- var import_react29 = require("react");
4177
+ var import_react31 = require("react");
4065
4178
  var import_antd16 = require("antd");
4066
4179
  var import_jsx_runtime61 = require("react/jsx-runtime");
4067
4180
  var toValuePath = (value, multiple) => {
@@ -4100,7 +4213,7 @@ function CascadeSelectField(props) {
4100
4213
  const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
4101
4214
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
4102
4215
  const value = formData[fieldId] ?? (multiple ? [] : []);
4103
- (0, import_react29.useEffect)(() => {
4216
+ (0, import_react31.useEffect)(() => {
4104
4217
  registerField(fieldId);
4105
4218
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
4106
4219
  setFieldValue(fieldId, defaultValue);
@@ -4153,7 +4266,7 @@ function CascadeSelectField(props) {
4153
4266
  }
4154
4267
 
4155
4268
  // src/fields/AddressField/index.tsx
4156
- var import_react30 = require("react");
4269
+ var import_react32 = require("react");
4157
4270
  var import_antd17 = require("antd");
4158
4271
  var MobileAntd6 = __toESM(require("antd-mobile"));
4159
4272
  var import_jsx_runtime62 = require("react/jsx-runtime");
@@ -4205,19 +4318,19 @@ function AddressField(props) {
4205
4318
  const { isMobile } = useDeviceDetect();
4206
4319
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
4207
4320
  const value = formData[fieldId];
4208
- const [options, setOptions] = (0, import_react30.useState)([]);
4209
- const [loadingRoots, setLoadingRoots] = (0, import_react30.useState)(false);
4210
- const [mobileOpen, setMobileOpen] = (0, import_react30.useState)(false);
4211
- const [mobileLevelIndex, setMobileLevelIndex] = (0, import_react30.useState)(0);
4212
- const [mobileOptions, setMobileOptions] = (0, import_react30.useState)([]);
4213
- const [mobileLoading, setMobileLoading] = (0, import_react30.useState)(false);
4214
- const [tempValue, setTempValue] = (0, import_react30.useState)();
4321
+ const [options, setOptions] = (0, import_react32.useState)([]);
4322
+ const [loadingRoots, setLoadingRoots] = (0, import_react32.useState)(false);
4323
+ const [mobileOpen, setMobileOpen] = (0, import_react32.useState)(false);
4324
+ const [mobileLevelIndex, setMobileLevelIndex] = (0, import_react32.useState)(0);
4325
+ const [mobileOptions, setMobileOptions] = (0, import_react32.useState)([]);
4326
+ const [mobileLoading, setMobileLoading] = (0, import_react32.useState)(false);
4327
+ const [tempValue, setTempValue] = (0, import_react32.useState)();
4215
4328
  const depth = modeDepth(mode);
4216
- const levels = (0, import_react30.useMemo)(() => activeLevels(mode), [mode]);
4329
+ const levels = (0, import_react32.useMemo)(() => activeLevels(mode), [mode]);
4217
4330
  const detailEnabled = mode === "province-city-district-street-detail";
4218
4331
  const disabled = behavior === "DISABLED";
4219
4332
  const MobilePopup = getMobileComponent3("Popup");
4220
- (0, import_react30.useEffect)(() => {
4333
+ (0, import_react32.useEffect)(() => {
4221
4334
  registerField(fieldId);
4222
4335
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
4223
4336
  setFieldValue(fieldId, defaultValue);
@@ -4228,11 +4341,11 @@ function AddressField(props) {
4228
4341
  const list = await api.getChinaDivisions(parentAdcode);
4229
4342
  return list.map((item) => normalizeDivision(item, level, depth, index));
4230
4343
  };
4231
- (0, import_react30.useEffect)(() => {
4344
+ (0, import_react32.useEffect)(() => {
4232
4345
  setLoadingRoots(true);
4233
4346
  loadDivisions(void 0, "province", 0).then(setOptions).finally(() => setLoadingRoots(false));
4234
4347
  }, [api, depth]);
4235
- (0, import_react30.useEffect)(() => {
4348
+ (0, import_react32.useEffect)(() => {
4236
4349
  if (!mobileOpen) return;
4237
4350
  const level = levels[mobileLevelIndex] || "province";
4238
4351
  const parentLevel = levels[mobileLevelIndex - 1];
@@ -4401,7 +4514,7 @@ function AddressField(props) {
4401
4514
  }
4402
4515
 
4403
4516
  // src/fields/AssociationFormField/index.tsx
4404
- var import_react31 = require("react");
4517
+ var import_react33 = require("react");
4405
4518
  var import_antd18 = require("antd");
4406
4519
  var import_jsx_runtime63 = require("react/jsx-runtime");
4407
4520
  var DEFAULT_PAGE_SIZE = 10;
@@ -4451,22 +4564,22 @@ function AssociationFormField(props) {
4451
4564
  const { isMobile } = useDeviceDetect();
4452
4565
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
4453
4566
  const rawValue = formData[fieldId];
4454
- const value = (0, import_react31.useMemo)(() => normalizeValues(rawValue), [rawValue]);
4567
+ const value = (0, import_react33.useMemo)(() => normalizeValues(rawValue), [rawValue]);
4455
4568
  const disabled = behavior === "DISABLED";
4456
- const [options, setOptions] = (0, import_react31.useState)([]);
4457
- const [selectLoading, setSelectLoading] = (0, import_react31.useState)(false);
4458
- const [selectorOpen, setSelectorOpen] = (0, import_react31.useState)(false);
4459
- const [tableLoading, setTableLoading] = (0, import_react31.useState)(false);
4460
- const [tableData, setTableData] = (0, import_react31.useState)([]);
4461
- const [keyword, setKeyword] = (0, import_react31.useState)("");
4462
- const [pagination, setPagination] = (0, import_react31.useState)({
4569
+ const [options, setOptions] = (0, import_react33.useState)([]);
4570
+ const [selectLoading, setSelectLoading] = (0, import_react33.useState)(false);
4571
+ const [selectorOpen, setSelectorOpen] = (0, import_react33.useState)(false);
4572
+ const [tableLoading, setTableLoading] = (0, import_react33.useState)(false);
4573
+ const [tableData, setTableData] = (0, import_react33.useState)([]);
4574
+ const [keyword, setKeyword] = (0, import_react33.useState)("");
4575
+ const [pagination, setPagination] = (0, import_react33.useState)({
4463
4576
  current: 1,
4464
4577
  pageSize: DEFAULT_PAGE_SIZE,
4465
4578
  total: 0
4466
4579
  });
4467
- const [selectedRowKeys, setSelectedRowKeys] = (0, import_react31.useState)([]);
4468
- const [selectedRecords, setSelectedRecords] = (0, import_react31.useState)([]);
4469
- (0, import_react31.useEffect)(() => {
4580
+ const [selectedRowKeys, setSelectedRowKeys] = (0, import_react33.useState)([]);
4581
+ const [selectedRecords, setSelectedRecords] = (0, import_react33.useState)([]);
4582
+ (0, import_react33.useEffect)(() => {
4470
4583
  registerField(fieldId);
4471
4584
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
4472
4585
  setFieldValue(fieldId, normalizeValues(defaultValue));
@@ -4474,7 +4587,7 @@ function AssociationFormField(props) {
4474
4587
  return () => unregisterField(fieldId);
4475
4588
  }, [fieldId]);
4476
4589
  const canQuery = Boolean(associationForm?.appType && associationForm?.formUuid);
4477
- const normalizeRecord = (0, import_react31.useCallback)(
4590
+ const normalizeRecord = (0, import_react33.useCallback)(
4478
4591
  (record) => {
4479
4592
  const mainFieldValue = associationForm?.mainFieldId ? record?.[associationForm.mainFieldId] : void 0;
4480
4593
  const labelText = normalizeCellValue(mainFieldValue);
@@ -4487,7 +4600,7 @@ function AssociationFormField(props) {
4487
4600
  },
4488
4601
  [associationForm?.mainFieldId]
4489
4602
  );
4490
- const toValue = (0, import_react31.useCallback)(
4603
+ const toValue = (0, import_react33.useCallback)(
4491
4604
  (record) => ({
4492
4605
  label: record.__associationLabel,
4493
4606
  value: record.__associationValue,
@@ -4495,7 +4608,7 @@ function AssociationFormField(props) {
4495
4608
  }),
4496
4609
  []
4497
4610
  );
4498
- const buildFilters = (0, import_react31.useCallback)(() => {
4611
+ const buildFilters = (0, import_react33.useCallback)(() => {
4499
4612
  const rules = associationForm?.dataFilterRules || [];
4500
4613
  return rules.map((rule) => {
4501
4614
  if (!rule?.key) return null;
@@ -4509,7 +4622,7 @@ function AssociationFormField(props) {
4509
4622
  };
4510
4623
  }).filter(Boolean);
4511
4624
  }, [associationForm?.dataFilterRules, formData]);
4512
- const fetchRecords = (0, import_react31.useCallback)(
4625
+ const fetchRecords = (0, import_react33.useCallback)(
4513
4626
  async (params) => {
4514
4627
  if (!canQuery) return { list: [], total: 0 };
4515
4628
  const filters = buildFilters();
@@ -4532,7 +4645,7 @@ function AssociationFormField(props) {
4532
4645
  },
4533
4646
  [api, associationForm, buildFilters, canQuery, normalizeRecord]
4534
4647
  );
4535
- const loadOptions = (0, import_react31.useCallback)(
4648
+ const loadOptions = (0, import_react33.useCallback)(
4536
4649
  async (searchKeyWord) => {
4537
4650
  setSelectLoading(true);
4538
4651
  try {
@@ -4544,7 +4657,7 @@ function AssociationFormField(props) {
4544
4657
  },
4545
4658
  [fetchRecords, toValue]
4546
4659
  );
4547
- const loadTable = (0, import_react31.useCallback)(
4660
+ const loadTable = (0, import_react33.useCallback)(
4548
4661
  async (next) => {
4549
4662
  setTableLoading(true);
4550
4663
  const current = next?.current || 1;
@@ -4563,10 +4676,10 @@ function AssociationFormField(props) {
4563
4676
  },
4564
4677
  [fetchRecords, keyword, pagination.pageSize]
4565
4678
  );
4566
- (0, import_react31.useEffect)(() => {
4679
+ (0, import_react33.useEffect)(() => {
4567
4680
  void loadOptions();
4568
4681
  }, [loadOptions]);
4569
- (0, import_react31.useEffect)(() => {
4682
+ (0, import_react33.useEffect)(() => {
4570
4683
  setSelectedRowKeys(value.map((item) => item.value));
4571
4684
  setSelectedRecords(
4572
4685
  value.map(
@@ -4574,7 +4687,7 @@ function AssociationFormField(props) {
4574
4687
  ).filter(Boolean)
4575
4688
  );
4576
4689
  }, [normalizeRecord, value]);
4577
- const applyDataFilling = (0, import_react31.useCallback)(
4690
+ const applyDataFilling = (0, import_react33.useCallback)(
4578
4691
  (next) => {
4579
4692
  if (!associationForm?.dataFillingEnabled && !associationForm?.dataFillingRules?.mainRules) {
4580
4693
  return;
@@ -4588,7 +4701,7 @@ function AssociationFormField(props) {
4588
4701
  },
4589
4702
  [associationForm?.dataFillingEnabled, associationForm?.dataFillingRules, setFieldValue]
4590
4703
  );
4591
- const commitSelection = (0, import_react31.useCallback)(
4704
+ const commitSelection = (0, import_react33.useCallback)(
4592
4705
  (next) => {
4593
4706
  const normalized = multiple ? next : next.slice(0, 1);
4594
4707
  setFieldValue(fieldId, normalized);
@@ -4597,7 +4710,7 @@ function AssociationFormField(props) {
4597
4710
  },
4598
4711
  [applyDataFilling, fieldId, multiple, onChange, setFieldValue]
4599
4712
  );
4600
- const selectorColumns = (0, import_react31.useMemo)(() => {
4713
+ const selectorColumns = (0, import_react33.useMemo)(() => {
4601
4714
  const configured = associationForm?.selectorColumns || [];
4602
4715
  if (configured.length) {
4603
4716
  return configured.map((column) => {
@@ -4632,7 +4745,7 @@ function AssociationFormField(props) {
4632
4745
  }
4633
4746
  ];
4634
4747
  }, [associationForm?.mainFieldId, associationForm?.selectorColumns]);
4635
- const selectOptions = (0, import_react31.useMemo)(
4748
+ const selectOptions = (0, import_react33.useMemo)(
4636
4749
  () => [...options, ...value].filter(
4637
4750
  (item, index, list) => list.findIndex((candidate) => candidate.value === item.value) === index
4638
4751
  ).map((item) => ({ label: item.label, value: item.value })),
@@ -4840,8 +4953,8 @@ function AssociationFormField(props) {
4840
4953
  }
4841
4954
 
4842
4955
  // src/fields/EditorField/index.tsx
4843
- var import_react32 = require("react");
4844
- var import_react33 = require("@tiptap/react");
4956
+ var import_react34 = require("react");
4957
+ var import_react35 = require("@tiptap/react");
4845
4958
  var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
4846
4959
  var import_extension_image = __toESM(require("@tiptap/extension-image"));
4847
4960
  var import_extension_link = __toESM(require("@tiptap/extension-link"));
@@ -5162,19 +5275,19 @@ function EditorField(props) {
5162
5275
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
5163
5276
  const value = formData[fieldId] ?? "";
5164
5277
  const disabled = behavior === "DISABLED";
5165
- const inputRef = (0, import_react32.useRef)(null);
5166
- const [uploading, setUploading] = (0, import_react32.useState)(false);
5167
- const [uploadError, setUploadError] = (0, import_react32.useState)("");
5168
- const [charCount, setCharCount] = (0, import_react32.useState)(0);
5169
- (0, import_react32.useEffect)(() => {
5278
+ const inputRef = (0, import_react34.useRef)(null);
5279
+ const [uploading, setUploading] = (0, import_react34.useState)(false);
5280
+ const [uploadError, setUploadError] = (0, import_react34.useState)("");
5281
+ const [charCount, setCharCount] = (0, import_react34.useState)(0);
5282
+ (0, import_react34.useEffect)(() => {
5170
5283
  registerField(fieldId);
5171
5284
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
5172
5285
  setFieldValue(fieldId, defaultValue);
5173
5286
  }
5174
5287
  return () => unregisterField(fieldId);
5175
5288
  }, [fieldId]);
5176
- const actions = (0, import_react32.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
5177
- const extensions = (0, import_react32.useMemo)(
5289
+ const actions = (0, import_react34.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
5290
+ const extensions = (0, import_react34.useMemo)(
5178
5291
  () => [
5179
5292
  import_starter_kit.default.configure({
5180
5293
  heading: { levels: [1, 2, 3] }
@@ -5197,14 +5310,14 @@ function EditorField(props) {
5197
5310
  ],
5198
5311
  [placeholder]
5199
5312
  );
5200
- const updateHtml = (0, import_react32.useCallback)(
5313
+ const updateHtml = (0, import_react34.useCallback)(
5201
5314
  (next) => {
5202
5315
  setFieldValue(fieldId, next);
5203
5316
  onChange?.(next);
5204
5317
  },
5205
5318
  [fieldId, onChange, setFieldValue]
5206
5319
  );
5207
- const editor = (0, import_react33.useEditor)(
5320
+ const editor = (0, import_react35.useEditor)(
5208
5321
  {
5209
5322
  extensions,
5210
5323
  content: value || "",
@@ -5227,11 +5340,11 @@ function EditorField(props) {
5227
5340
  },
5228
5341
  [fieldId, extensions, disabled, maxLength, updateHtml]
5229
5342
  );
5230
- (0, import_react32.useEffect)(() => {
5343
+ (0, import_react34.useEffect)(() => {
5231
5344
  if (!editor) return;
5232
5345
  editor.setEditable(!disabled);
5233
5346
  }, [disabled, editor]);
5234
- (0, import_react32.useEffect)(() => {
5347
+ (0, import_react34.useEffect)(() => {
5235
5348
  if (!editor) return;
5236
5349
  const currentHtml = editor.isEmpty ? "" : editor.getHTML();
5237
5350
  if ((value || "") !== currentHtml) {
@@ -5239,7 +5352,7 @@ function EditorField(props) {
5239
5352
  setCharCount(editor.getText().length);
5240
5353
  }
5241
5354
  }, [editor, value]);
5242
- const insertImageFiles = (0, import_react32.useCallback)(
5355
+ const insertImageFiles = (0, import_react34.useCallback)(
5243
5356
  async (files) => {
5244
5357
  if (!editor || disabled || files.length === 0) return;
5245
5358
  const validFiles = files.filter((file) => {
@@ -5322,7 +5435,7 @@ function EditorField(props) {
5322
5435
  void insertImageFiles(files);
5323
5436
  }
5324
5437
  },
5325
- children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react33.EditorContent, { editor })
5438
+ children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react35.EditorContent, { editor })
5326
5439
  }
5327
5440
  ),
5328
5441
  /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
@@ -5355,7 +5468,7 @@ function EditorField(props) {
5355
5468
  }
5356
5469
 
5357
5470
  // src/fields/SerialNumberField/index.tsx
5358
- var import_react34 = require("react");
5471
+ var import_react36 = require("react");
5359
5472
  var import_antd19 = require("antd");
5360
5473
  var import_jsx_runtime65 = require("react/jsx-runtime");
5361
5474
  function SerialNumberField(props) {
@@ -5375,7 +5488,7 @@ function SerialNumberField(props) {
5375
5488
  const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
5376
5489
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
5377
5490
  const value = formData[fieldId] ?? "";
5378
- (0, import_react34.useEffect)(() => {
5491
+ (0, import_react36.useEffect)(() => {
5379
5492
  registerField(fieldId);
5380
5493
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
5381
5494
  setFieldValue(fieldId, defaultValue);
@@ -5417,7 +5530,7 @@ function SerialNumberField(props) {
5417
5530
  }
5418
5531
 
5419
5532
  // src/fields/LocationField/index.tsx
5420
- var import_react35 = require("react");
5533
+ var import_react37 = require("react");
5421
5534
  var import_antd20 = require("antd");
5422
5535
  var import_jsx_runtime66 = require("react/jsx-runtime");
5423
5536
  var getDingTalkApi = () => {
@@ -5459,9 +5572,9 @@ function LocationField(props) {
5459
5572
  const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
5460
5573
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
5461
5574
  const value = formData[fieldId];
5462
- const [locating, setLocating] = (0, import_react35.useState)(false);
5463
- const [error, setError] = (0, import_react35.useState)("");
5464
- (0, import_react35.useEffect)(() => {
5575
+ const [locating, setLocating] = (0, import_react37.useState)(false);
5576
+ const [error, setError] = (0, import_react37.useState)("");
5577
+ (0, import_react37.useEffect)(() => {
5465
5578
  registerField(fieldId);
5466
5579
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
5467
5580
  setFieldValue(fieldId, defaultValue);
@@ -5602,7 +5715,7 @@ function LocationField(props) {
5602
5715
  }
5603
5716
 
5604
5717
  // src/fields/DigitalSignatureField/index.tsx
5605
- var import_react36 = require("react");
5718
+ var import_react38 = require("react");
5606
5719
  var import_antd21 = require("antd");
5607
5720
  var import_jsx_runtime67 = require("react/jsx-runtime");
5608
5721
  var CANVAS_HEIGHT = 260;
@@ -5636,21 +5749,21 @@ function DigitalSignatureField(props) {
5636
5749
  const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
5637
5750
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
5638
5751
  const value = formData[fieldId];
5639
- const [open, setOpen] = (0, import_react36.useState)(false);
5640
- const [saving, setSaving] = (0, import_react36.useState)(false);
5641
- const [drawn, setDrawn] = (0, import_react36.useState)(false);
5642
- const [error, setError] = (0, import_react36.useState)("");
5643
- const canvasRef = (0, import_react36.useRef)(null);
5644
- const drawingRef = (0, import_react36.useRef)(false);
5645
- const pointsRef = (0, import_react36.useRef)([]);
5646
- (0, import_react36.useEffect)(() => {
5752
+ const [open, setOpen] = (0, import_react38.useState)(false);
5753
+ const [saving, setSaving] = (0, import_react38.useState)(false);
5754
+ const [drawn, setDrawn] = (0, import_react38.useState)(false);
5755
+ const [error, setError] = (0, import_react38.useState)("");
5756
+ const canvasRef = (0, import_react38.useRef)(null);
5757
+ const drawingRef = (0, import_react38.useRef)(false);
5758
+ const pointsRef = (0, import_react38.useRef)([]);
5759
+ (0, import_react38.useEffect)(() => {
5647
5760
  registerField(fieldId);
5648
5761
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
5649
5762
  setFieldValue(fieldId, defaultValue);
5650
5763
  }
5651
5764
  return () => unregisterField(fieldId);
5652
5765
  }, [fieldId]);
5653
- const prepareCanvas = (0, import_react36.useCallback)(() => {
5766
+ const prepareCanvas = (0, import_react38.useCallback)(() => {
5654
5767
  const canvas = canvasRef.current;
5655
5768
  if (!canvas) return;
5656
5769
  const rect = canvas.getBoundingClientRect();
@@ -5670,7 +5783,7 @@ function DigitalSignatureField(props) {
5670
5783
  ctx.lineJoin = "round";
5671
5784
  ctx.strokeStyle = "#111827";
5672
5785
  }, []);
5673
- (0, import_react36.useEffect)(() => {
5786
+ (0, import_react38.useEffect)(() => {
5674
5787
  if (!open) return;
5675
5788
  pointsRef.current = [];
5676
5789
  setDrawn(false);
@@ -5813,7 +5926,7 @@ function DigitalSignatureField(props) {
5813
5926
  }
5814
5927
 
5815
5928
  // src/fields/JSONField/index.tsx
5816
- var import_react37 = require("react");
5929
+ var import_react39 = require("react");
5817
5930
  var import_jsx_runtime68 = require("react/jsx-runtime");
5818
5931
  var formatJson = (value) => {
5819
5932
  if (value === void 0 || value === null || value === "") return "--";
@@ -5840,7 +5953,7 @@ function JSONField(props) {
5840
5953
  const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
5841
5954
  const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
5842
5955
  const value = formData[fieldId];
5843
- (0, import_react37.useEffect)(() => {
5956
+ (0, import_react39.useEffect)(() => {
5844
5957
  registerField(fieldId);
5845
5958
  if (defaultValue !== void 0 && formData[fieldId] === void 0) {
5846
5959
  setFieldValue(fieldId, defaultValue);
@@ -6340,7 +6453,7 @@ function FormProvider({
6340
6453
  components,
6341
6454
  children
6342
6455
  }) {
6343
- const computedInitialValues = (0, import_react38.useMemo)(() => {
6456
+ const computedInitialValues = (0, import_react40.useMemo)(() => {
6344
6457
  const values = {};
6345
6458
  for (const field of schema.fields) {
6346
6459
  if (field.defaultValue !== void 0) {
@@ -6349,12 +6462,12 @@ function FormProvider({
6349
6462
  }
6350
6463
  return { ...values, ...initialValues };
6351
6464
  }, [schema, initialValues]);
6352
- const initialValuesRef = (0, import_react38.useRef)(computedInitialValues);
6353
- const [formData, setFormData] = (0, import_react38.useState)({ ...computedInitialValues });
6354
- const [fieldErrors, setFieldErrors] = (0, import_react38.useState)({});
6355
- const [registeredFields] = (0, import_react38.useState)(/* @__PURE__ */ new Set());
6356
- const api = (0, import_react38.useMemo)(() => createFormRuntimeApi(config.api), [config.api]);
6357
- const fieldBehaviors = (0, import_react38.useMemo)(() => {
6465
+ const initialValuesRef = (0, import_react40.useRef)(computedInitialValues);
6466
+ const [formData, setFormData] = (0, import_react40.useState)({ ...computedInitialValues });
6467
+ const [fieldErrors, setFieldErrors] = (0, import_react40.useState)({});
6468
+ const [registeredFields] = (0, import_react40.useState)(/* @__PURE__ */ new Set());
6469
+ const api = (0, import_react40.useMemo)(() => createFormRuntimeApi(config.api), [config.api]);
6470
+ const fieldBehaviors = (0, import_react40.useMemo)(() => {
6358
6471
  const baseBehaviors = {};
6359
6472
  for (const field of schema.fields) {
6360
6473
  baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
@@ -6377,7 +6490,7 @@ function FormProvider({
6377
6490
  }
6378
6491
  return computed;
6379
6492
  }, [schema, config.effects, config.permissions, config.mode, formData]);
6380
- const setFieldValue = (0, import_react38.useCallback)((fieldId, value) => {
6493
+ const setFieldValue = (0, import_react40.useCallback)((fieldId, value) => {
6381
6494
  setFormData((prev) => ({ ...prev, [fieldId]: value }));
6382
6495
  setFieldErrors((prev) => {
6383
6496
  if (prev[fieldId]) {
@@ -6388,9 +6501,9 @@ function FormProvider({
6388
6501
  return prev;
6389
6502
  });
6390
6503
  }, []);
6391
- const getFieldValue = (0, import_react38.useCallback)((fieldId) => formData[fieldId], [formData]);
6392
- const getFormData2 = (0, import_react38.useCallback)(() => ({ ...formData }), [formData]);
6393
- const validateFieldById = (0, import_react38.useCallback)(
6504
+ const getFieldValue = (0, import_react40.useCallback)((fieldId) => formData[fieldId], [formData]);
6505
+ const getFormData2 = (0, import_react40.useCallback)(() => ({ ...formData }), [formData]);
6506
+ const validateFieldById = (0, import_react40.useCallback)(
6394
6507
  async (fieldId) => {
6395
6508
  const field = schema.fields.find((f) => f.fieldId === fieldId);
6396
6509
  if (!field) return true;
@@ -6415,7 +6528,7 @@ function FormProvider({
6415
6528
  },
6416
6529
  [schema, formData]
6417
6530
  );
6418
- const validateAll = (0, import_react38.useCallback)(async () => {
6531
+ const validateAll = (0, import_react40.useCallback)(async () => {
6419
6532
  const fieldRules = {};
6420
6533
  for (const field of schema.fields) {
6421
6534
  const rules = [];
@@ -6433,23 +6546,23 @@ function FormProvider({
6433
6546
  setFieldErrors(errors);
6434
6547
  return Object.keys(errors).length === 0;
6435
6548
  }, [schema, formData]);
6436
- const resetForm = (0, import_react38.useCallback)(() => {
6549
+ const resetForm = (0, import_react40.useCallback)(() => {
6437
6550
  setFormData({ ...initialValuesRef.current });
6438
6551
  setFieldErrors({});
6439
6552
  }, []);
6440
- const registerField = (0, import_react38.useCallback)(
6553
+ const registerField = (0, import_react40.useCallback)(
6441
6554
  (fieldId) => {
6442
6555
  registeredFields.add(fieldId);
6443
6556
  },
6444
6557
  [registeredFields]
6445
6558
  );
6446
- const unregisterField = (0, import_react38.useCallback)(
6559
+ const unregisterField = (0, import_react40.useCallback)(
6447
6560
  (fieldId) => {
6448
6561
  registeredFields.delete(fieldId);
6449
6562
  },
6450
6563
  [registeredFields]
6451
6564
  );
6452
- const contextValue = (0, import_react38.useMemo)(
6565
+ const contextValue = (0, import_react40.useMemo)(
6453
6566
  () => ({
6454
6567
  mode: config.mode,
6455
6568
  schema,
@@ -6495,15 +6608,15 @@ function FormProvider({
6495
6608
  ]
6496
6609
  );
6497
6610
  const registryComponents = components ?? defaultComponentRegistry;
6498
- return import_react38.default.createElement(
6611
+ return import_react40.default.createElement(
6499
6612
  FormContext.Provider,
6500
6613
  { value: contextValue },
6501
- import_react38.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
6614
+ import_react40.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
6502
6615
  );
6503
6616
  }
6504
6617
 
6505
6618
  // src/core/FormRenderer.tsx
6506
- var import_react39 = __toESM(require("react"));
6619
+ var import_react41 = __toESM(require("react"));
6507
6620
  var import_jsx_runtime69 = require("react/jsx-runtime");
6508
6621
  var columnsClassMap = {
6509
6622
  1: "sy-grid-cols-1",
@@ -6527,7 +6640,7 @@ function FieldRenderer({ field, fieldClassName }) {
6527
6640
  return null;
6528
6641
  }
6529
6642
  const { fieldId, componentName: _, ...fieldProps } = field;
6530
- return import_react39.default.createElement(Component, {
6643
+ return import_react41.default.createElement(Component, {
6531
6644
  ...fieldProps,
6532
6645
  fieldId,
6533
6646
  className: fieldClassName ?? fieldProps.className
@@ -6547,7 +6660,7 @@ function FormRenderer({
6547
6660
  }
6548
6661
 
6549
6662
  // src/core/FormActions.tsx
6550
- var import_react40 = require("react");
6663
+ var import_react42 = require("react");
6551
6664
  var import_antd22 = require("antd");
6552
6665
  var import_jsx_runtime70 = require("react/jsx-runtime");
6553
6666
  function FormActions({
@@ -6558,9 +6671,9 @@ function FormActions({
6558
6671
  onSubmit
6559
6672
  }) {
6560
6673
  const { mode, validateAll, getFormData: getFormData2, resetForm, api, config } = useFormContext();
6561
- const [isSubmitting, setIsSubmitting] = (0, import_react40.useState)(false);
6562
- const [submitError, setSubmitError] = (0, import_react40.useState)(null);
6563
- const handleSubmit = (0, import_react40.useCallback)(async () => {
6674
+ const [isSubmitting, setIsSubmitting] = (0, import_react42.useState)(false);
6675
+ const [submitError, setSubmitError] = (0, import_react42.useState)(null);
6676
+ const handleSubmit = (0, import_react42.useCallback)(async () => {
6564
6677
  setSubmitError(null);
6565
6678
  const valid = await validateAll();
6566
6679
  if (!valid) return;
@@ -6596,7 +6709,7 @@ function FormActions({
6596
6709
  setIsSubmitting(false);
6597
6710
  }
6598
6711
  }, [api, config, getFormData2, mode, onSubmit, validateAll]);
6599
- const handleReset = (0, import_react40.useCallback)(() => {
6712
+ const handleReset = (0, import_react42.useCallback)(() => {
6600
6713
  resetForm();
6601
6714
  }, [resetForm]);
6602
6715
  if (mode === "readonly") return null;
@@ -6712,12 +6825,13 @@ var normalizeProcessBasic = (value) => {
6712
6825
  processStatus: raw.processStatus ?? raw.status ?? instance.processStatus ?? instance.status,
6713
6826
  formUuid: raw.formUuid ?? instance.formUuid ?? instance.definition?.formUuid,
6714
6827
  appType: raw.appType ?? instance.appType ?? instance.definition?.appType,
6715
- title: raw.title ?? instance.title,
6828
+ title: raw.title ?? instance.title ?? instance.instanceTitle,
6716
6829
  originatorId: raw.originatorId ?? instance.originatorId ?? instance.startedBy,
6717
6830
  originatorName: raw.originatorName ?? instance.originatorName ?? instance.startedByName,
6718
6831
  originatorDepartment: raw.originatorDepartment ?? instance.originatorDepartment ?? instance.startedDepartmentName,
6719
6832
  createdAt: raw.createdAt ?? instance.createdAt ?? instance.startedAt,
6720
- currentTask
6833
+ currentTask,
6834
+ isExecuting: raw.isExecuting ?? instance.isExecuting
6721
6835
  };
6722
6836
  };
6723
6837
  var normalizeApprovalPermission = (value) => {
@@ -6741,6 +6855,13 @@ var normalizeReturnableNodes = (value) => {
6741
6855
  nodeName: node?.nodeName || node?.name || node?.title || node?.id || ""
6742
6856
  }));
6743
6857
  };
6858
+ var normalizeReturnableNodeResult = (value) => {
6859
+ const raw = value?.data || value || {};
6860
+ return {
6861
+ nodes: normalizeReturnableNodes(raw),
6862
+ policy: raw?.policy || null
6863
+ };
6864
+ };
6744
6865
  var normalizeProcessDefinition = (value) => {
6745
6866
  const raw = value?.definitionJson || value?.viewJson || value || {};
6746
6867
  const nodes = Array.isArray(raw.nodes) ? raw.nodes : [];
@@ -6827,11 +6948,15 @@ async function saveTask(request, params) {
6827
6948
  return response.data || response.result;
6828
6949
  }
6829
6950
  async function getReturnableNodes(request, taskId) {
6951
+ const result = await getReturnableNodeResult(request, taskId);
6952
+ return result.nodes;
6953
+ }
6954
+ async function getReturnableNodeResult(request, taskId) {
6830
6955
  const response = await request({
6831
6956
  url: `/workflow/task/${taskId}/returnable-nodes`,
6832
6957
  method: "get"
6833
6958
  });
6834
- return normalizeReturnableNodes(response.data || response.result);
6959
+ return normalizeReturnableNodeResult(response.data || response.result);
6835
6960
  }
6836
6961
  async function previewProcess(request, params) {
6837
6962
  const response = await request({
@@ -7203,7 +7328,7 @@ async function getDataManagementTransferRecords(request, params) {
7203
7328
  }
7204
7329
 
7205
7330
  // src/layout/FormSection/index.tsx
7206
- var import_react41 = require("react");
7331
+ var import_react43 = require("react");
7207
7332
  var import_jsx_runtime72 = require("react/jsx-runtime");
7208
7333
  function FormSection({
7209
7334
  title,
@@ -7215,7 +7340,7 @@ function FormSection({
7215
7340
  contentClassName,
7216
7341
  children
7217
7342
  }) {
7218
- const [collapsed, setCollapsed] = (0, import_react41.useState)(defaultCollapsed);
7343
+ const [collapsed, setCollapsed] = (0, import_react43.useState)(defaultCollapsed);
7219
7344
  const handleToggle = () => {
7220
7345
  if (collapsible) {
7221
7346
  setCollapsed((prev) => !prev);
@@ -7283,10 +7408,10 @@ function FormGrid({ columns = 2, gap = 4, className, children }) {
7283
7408
  }
7284
7409
 
7285
7410
  // src/layout/FormTabs/index.tsx
7286
- var import_react42 = require("react");
7411
+ var import_react44 = require("react");
7287
7412
  var import_jsx_runtime74 = require("react/jsx-runtime");
7288
7413
  function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
7289
- const [activeKey, setActiveKey] = (0, import_react42.useState)(defaultActiveKey || items[0]?.key || "");
7414
+ const [activeKey, setActiveKey] = (0, import_react44.useState)(defaultActiveKey || items[0]?.key || "");
7290
7415
  const activeItem = items.find((item) => item.key === activeKey);
7291
7416
  return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-tabs", children: [
7292
7417
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
@@ -7315,10 +7440,10 @@ function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
7315
7440
  }
7316
7441
 
7317
7442
  // src/layout/FormSteps/index.tsx
7318
- var import_react43 = __toESM(require("react"));
7443
+ var import_react45 = __toESM(require("react"));
7319
7444
  var import_jsx_runtime75 = require("react/jsx-runtime");
7320
7445
  function FormSteps({ items, className, onStepChange }) {
7321
- const [currentStep, setCurrentStep] = (0, import_react43.useState)(0);
7446
+ const [currentStep, setCurrentStep] = (0, import_react45.useState)(0);
7322
7447
  const goTo = (step) => {
7323
7448
  setCurrentStep(step);
7324
7449
  onStepChange?.(step);
@@ -7334,7 +7459,7 @@ function FormSteps({ items, className, onStepChange }) {
7334
7459
  }
7335
7460
  };
7336
7461
  return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-steps", children: [
7337
- /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_react43.default.Fragment, { children: [
7462
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "flex items-center mb-6", "data-testid": "form-steps-indicator", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_react45.default.Fragment, { children: [
7338
7463
  /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center", children: [
7339
7464
  /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
7340
7465
  "div",
@@ -7426,9 +7551,9 @@ function FormSummary({
7426
7551
  }
7427
7552
 
7428
7553
  // src/hooks/useFormEngine.ts
7429
- var import_react44 = require("react");
7554
+ var import_react46 = require("react");
7430
7555
  function useFormEngine(schema, config) {
7431
- const initialValues = (0, import_react44.useMemo)(() => {
7556
+ const initialValues = (0, import_react46.useMemo)(() => {
7432
7557
  const values = {};
7433
7558
  for (const field of schema.fields) {
7434
7559
  if (field.defaultValue !== void 0) {
@@ -7437,10 +7562,10 @@ function useFormEngine(schema, config) {
7437
7562
  }
7438
7563
  return values;
7439
7564
  }, [schema]);
7440
- const initialValuesRef = (0, import_react44.useRef)(initialValues);
7441
- const [formData, setFormData] = (0, import_react44.useState)({ ...initialValues });
7442
- const [fieldErrors, setFieldErrors] = (0, import_react44.useState)({});
7443
- const fieldBehaviors = (0, import_react44.useMemo)(() => {
7565
+ const initialValuesRef = (0, import_react46.useRef)(initialValues);
7566
+ const [formData, setFormData] = (0, import_react46.useState)({ ...initialValues });
7567
+ const [fieldErrors, setFieldErrors] = (0, import_react46.useState)({});
7568
+ const fieldBehaviors = (0, import_react46.useMemo)(() => {
7444
7569
  const baseBehaviors = {};
7445
7570
  for (const field of schema.fields) {
7446
7571
  baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
@@ -7463,7 +7588,7 @@ function useFormEngine(schema, config) {
7463
7588
  }
7464
7589
  return computed;
7465
7590
  }, [schema, config.effects, config.permissions, config.mode, formData]);
7466
- const setFieldValue = (0, import_react44.useCallback)((fieldId, value) => {
7591
+ const setFieldValue = (0, import_react46.useCallback)((fieldId, value) => {
7467
7592
  setFormData((prev) => ({ ...prev, [fieldId]: value }));
7468
7593
  setFieldErrors((prev) => {
7469
7594
  if (prev[fieldId]) {
@@ -7474,9 +7599,9 @@ function useFormEngine(schema, config) {
7474
7599
  return prev;
7475
7600
  });
7476
7601
  }, []);
7477
- const getFieldValue = (0, import_react44.useCallback)((fieldId) => formData[fieldId], [formData]);
7478
- const getFormData2 = (0, import_react44.useCallback)(() => ({ ...formData }), [formData]);
7479
- const validateAll = (0, import_react44.useCallback)(async () => {
7602
+ const getFieldValue = (0, import_react46.useCallback)((fieldId) => formData[fieldId], [formData]);
7603
+ const getFormData2 = (0, import_react46.useCallback)(() => ({ ...formData }), [formData]);
7604
+ const validateAll = (0, import_react46.useCallback)(async () => {
7480
7605
  const fieldRules = {};
7481
7606
  for (const field of schema.fields) {
7482
7607
  const rules = [];
@@ -7494,7 +7619,7 @@ function useFormEngine(schema, config) {
7494
7619
  setFieldErrors(errors);
7495
7620
  return Object.keys(errors).length === 0;
7496
7621
  }, [schema, formData]);
7497
- const resetForm = (0, import_react44.useCallback)(() => {
7622
+ const resetForm = (0, import_react46.useCallback)(() => {
7498
7623
  setFormData({ ...initialValuesRef.current });
7499
7624
  setFieldErrors({});
7500
7625
  }, []);
@@ -7512,12 +7637,12 @@ function useFormEngine(schema, config) {
7512
7637
  }
7513
7638
 
7514
7639
  // src/hooks/useFormData.ts
7515
- var import_react45 = require("react");
7640
+ var import_react47 = require("react");
7516
7641
  function useFormData(initialValues = {}) {
7517
- const [formData, setFormData] = (0, import_react45.useState)({ ...initialValues });
7518
- const [dirtyFields, setDirtyFields] = (0, import_react45.useState)(/* @__PURE__ */ new Set());
7519
- const initialValuesRef = (0, import_react45.useRef)(initialValues);
7520
- const setFieldValue = (0, import_react45.useCallback)((fieldId, value) => {
7642
+ const [formData, setFormData] = (0, import_react47.useState)({ ...initialValues });
7643
+ const [dirtyFields, setDirtyFields] = (0, import_react47.useState)(/* @__PURE__ */ new Set());
7644
+ const initialValuesRef = (0, import_react47.useRef)(initialValues);
7645
+ const setFieldValue = (0, import_react47.useCallback)((fieldId, value) => {
7521
7646
  setFormData((prev) => ({ ...prev, [fieldId]: value }));
7522
7647
  setDirtyFields((prev) => {
7523
7648
  const next = new Set(prev);
@@ -7525,16 +7650,16 @@ function useFormData(initialValues = {}) {
7525
7650
  return next;
7526
7651
  });
7527
7652
  }, []);
7528
- const getFieldValue = (0, import_react45.useCallback)(
7653
+ const getFieldValue = (0, import_react47.useCallback)(
7529
7654
  (fieldId) => {
7530
7655
  return formData[fieldId];
7531
7656
  },
7532
7657
  [formData]
7533
7658
  );
7534
- const getFormData2 = (0, import_react45.useCallback)(() => {
7659
+ const getFormData2 = (0, import_react47.useCallback)(() => {
7535
7660
  return { ...formData };
7536
7661
  }, [formData]);
7537
- const resetForm = (0, import_react45.useCallback)(() => {
7662
+ const resetForm = (0, import_react47.useCallback)(() => {
7538
7663
  setFormData({ ...initialValuesRef.current });
7539
7664
  setDirtyFields(/* @__PURE__ */ new Set());
7540
7665
  }, []);
@@ -7549,7 +7674,7 @@ function useFormData(initialValues = {}) {
7549
7674
  }
7550
7675
 
7551
7676
  // src/hooks/useFieldBehavior.ts
7552
- var import_react46 = require("react");
7677
+ var import_react48 = require("react");
7553
7678
  function useFieldBehavior({
7554
7679
  fieldId,
7555
7680
  permissions,
@@ -7557,7 +7682,7 @@ function useFieldBehavior({
7557
7682
  formData,
7558
7683
  defaultBehavior = "NORMAL"
7559
7684
  }) {
7560
- return (0, import_react46.useMemo)(() => {
7685
+ return (0, import_react48.useMemo)(() => {
7561
7686
  if (permissions && permissions[fieldId]) {
7562
7687
  return permissions[fieldId];
7563
7688
  }
@@ -7571,11 +7696,11 @@ function useFieldBehavior({
7571
7696
  }
7572
7697
 
7573
7698
  // src/hooks/useFormSubmit.ts
7574
- var import_react47 = require("react");
7699
+ var import_react49 = require("react");
7575
7700
  function useFormSubmit(config) {
7576
- const [isSubmitting, setIsSubmitting] = (0, import_react47.useState)(false);
7577
- const [submitError, setSubmitError] = (0, import_react47.useState)(null);
7578
- const submit = (0, import_react47.useCallback)(
7701
+ const [isSubmitting, setIsSubmitting] = (0, import_react49.useState)(false);
7702
+ const [submitError, setSubmitError] = (0, import_react49.useState)(null);
7703
+ const submit = (0, import_react49.useCallback)(
7579
7704
  async (formData, validateFn) => {
7580
7705
  setSubmitError(null);
7581
7706
  const isValid = await validateFn();
@@ -7607,7 +7732,7 @@ function useFormSubmit(config) {
7607
7732
  }
7608
7733
 
7609
7734
  // src/hooks/useFieldPermission.ts
7610
- var import_react48 = require("react");
7735
+ var import_react50 = require("react");
7611
7736
 
7612
7737
  // src/utils/permissions.ts
7613
7738
  var OPERATION_ALIASES = {
@@ -7680,7 +7805,7 @@ var normalizeFlowConfig = (config) => {
7680
7805
  };
7681
7806
  function useFieldPermission(options) {
7682
7807
  const { viewPermissions, processDefinition, currentTask, isApprover, mode } = options;
7683
- const computeBehaviors = (0, import_react48.useCallback)(() => {
7808
+ const computeBehaviors = (0, import_react50.useCallback)(() => {
7684
7809
  const behaviors = {};
7685
7810
  if (!currentTask && viewPermissions) {
7686
7811
  return normalizeFieldBehaviors(viewPermissions, mode);
@@ -7725,12 +7850,12 @@ function useFieldPermission(options) {
7725
7850
  }
7726
7851
  return behaviors;
7727
7852
  }, [viewPermissions, processDefinition, currentTask, isApprover, mode]);
7728
- const fieldBehaviors = (0, import_react48.useMemo)(() => computeBehaviors(), [computeBehaviors]);
7853
+ const fieldBehaviors = (0, import_react50.useMemo)(() => computeBehaviors(), [computeBehaviors]);
7729
7854
  return { fieldBehaviors, computeBehaviors };
7730
7855
  }
7731
7856
 
7732
7857
  // src/hooks/useFormDetail.ts
7733
- var import_react49 = require("react");
7858
+ var import_react51 = require("react");
7734
7859
 
7735
7860
  // src/utils/formInstanceData.ts
7736
7861
  var FORM_INSTANCE_METADATA_KEYS = /* @__PURE__ */ new Set([
@@ -7889,24 +8014,24 @@ function useFormDetail(options) {
7889
8014
  const { formUuid, appType, formInstanceId, fieldIds, onPermissionDenied } = options;
7890
8015
  const { api } = useFormContext();
7891
8016
  const request = api.request;
7892
- const [loading, setLoading] = (0, import_react49.useState)(true);
7893
- const [mode, setMode] = (0, import_react49.useState)("readonly");
7894
- const [formData, setFormData] = (0, import_react49.useState)(null);
7895
- const [instanceInfo, setInstanceInfo] = (0, import_react49.useState)(null);
7896
- const [permissions, setPermissions] = (0, import_react49.useState)(null);
7897
- const mountedRef = (0, import_react49.useRef)(true);
7898
- const onPermissionDeniedRef = (0, import_react49.useRef)(onPermissionDenied);
8017
+ const [loading, setLoading] = (0, import_react51.useState)(true);
8018
+ const [mode, setMode] = (0, import_react51.useState)("readonly");
8019
+ const [formData, setFormData] = (0, import_react51.useState)(null);
8020
+ const [instanceInfo, setInstanceInfo] = (0, import_react51.useState)(null);
8021
+ const [permissions, setPermissions] = (0, import_react51.useState)(null);
8022
+ const mountedRef = (0, import_react51.useRef)(true);
8023
+ const onPermissionDeniedRef = (0, import_react51.useRef)(onPermissionDenied);
7899
8024
  const fieldIdsKey = fieldIds?.join("") ?? "";
7900
- (0, import_react49.useEffect)(() => {
8025
+ (0, import_react51.useEffect)(() => {
7901
8026
  mountedRef.current = true;
7902
8027
  return () => {
7903
8028
  mountedRef.current = false;
7904
8029
  };
7905
8030
  }, []);
7906
- (0, import_react49.useEffect)(() => {
8031
+ (0, import_react51.useEffect)(() => {
7907
8032
  onPermissionDeniedRef.current = onPermissionDenied;
7908
8033
  }, [onPermissionDenied]);
7909
- const loadData = (0, import_react49.useCallback)(async () => {
8034
+ const loadData = (0, import_react51.useCallback)(async () => {
7910
8035
  if (!mountedRef.current) return;
7911
8036
  setLoading(true);
7912
8037
  try {
@@ -7941,21 +8066,21 @@ function useFormDetail(options) {
7941
8066
  }
7942
8067
  }
7943
8068
  }, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
7944
- (0, import_react49.useEffect)(() => {
8069
+ (0, import_react51.useEffect)(() => {
7945
8070
  loadData();
7946
8071
  }, [loadData]);
7947
8072
  const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
7948
8073
  const canEdit = hasViewOperation(permissions?.operations, "edit");
7949
8074
  const canDelete = hasViewOperation(permissions?.operations, "delete");
7950
8075
  const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
7951
- const switchToEdit = (0, import_react49.useCallback)(() => {
8076
+ const switchToEdit = (0, import_react51.useCallback)(() => {
7952
8077
  setMode("edit");
7953
8078
  loadData();
7954
8079
  }, [loadData]);
7955
- const switchToReadonly = (0, import_react49.useCallback)(() => {
8080
+ const switchToReadonly = (0, import_react51.useCallback)(() => {
7956
8081
  setMode("readonly");
7957
8082
  }, []);
7958
- const saveChanges = (0, import_react49.useCallback)(
8083
+ const saveChanges = (0, import_react51.useCallback)(
7959
8084
  async (values) => {
7960
8085
  try {
7961
8086
  await api.updateFormData({
@@ -7976,7 +8101,7 @@ function useFormDetail(options) {
7976
8101
  },
7977
8102
  [api, formInstanceId, formUuid, appType]
7978
8103
  );
7979
- const deleteInstance = (0, import_react49.useCallback)(async () => {
8104
+ const deleteInstance = (0, import_react51.useCallback)(async () => {
7980
8105
  try {
7981
8106
  await deleteFormData(request, { formInstanceId, appType, formUuid });
7982
8107
  return true;
@@ -8003,12 +8128,19 @@ function useFormDetail(options) {
8003
8128
  }
8004
8129
 
8005
8130
  // src/hooks/useProcessDetail.ts
8006
- var import_react50 = require("react");
8131
+ var import_react52 = require("react");
8007
8132
  var DEFAULT_APPROVAL_ACTIONS = [
8008
8133
  { action: "agree", name: { zh_CN: "\u540C\u610F" } },
8009
8134
  { action: "rejected", name: { zh_CN: "\u62D2\u7EDD" } }
8010
8135
  ];
8011
8136
  var WITHDRAW_ACTION = { action: "withdraw", name: { zh_CN: "\u64A4\u9500" } };
8137
+ var FINAL_PROCESS_STATUSES = /* @__PURE__ */ new Set([
8138
+ "completed",
8139
+ "terminated",
8140
+ "withdrawn",
8141
+ "cancelled"
8142
+ ]);
8143
+ var EDITABLE_COMPLETED_STATUSES = /* @__PURE__ */ new Set(["completed", "terminated"]);
8012
8144
  function mergeCurrentTask(processTask, approvalTask) {
8013
8145
  if (!approvalTask) return processTask ?? null;
8014
8146
  if (!processTask) return approvalTask;
@@ -8024,50 +8156,61 @@ function useProcessDetail(options) {
8024
8156
  const { formUuid, appType, formInstanceId, fieldIds } = options;
8025
8157
  const { api } = useFormContext();
8026
8158
  const request = api.request;
8027
- const [loading, setLoading] = (0, import_react50.useState)(true);
8028
- const [mode, setMode] = (0, import_react50.useState)("readonly");
8029
- const [processInfo, setProcessInfo] = (0, import_react50.useState)(null);
8030
- const [progressList, setProgressList] = (0, import_react50.useState)([]);
8031
- const [formData, setFormData] = (0, import_react50.useState)(null);
8032
- const [instanceInfo, setInstanceInfo] = (0, import_react50.useState)(null);
8033
- const [isApprover, setIsApprover] = (0, import_react50.useState)(false);
8034
- const [canWithdraw, setCanWithdraw] = (0, import_react50.useState)(false);
8035
- const [approvalTasks, setApprovalTasks] = (0, import_react50.useState)([]);
8036
- const [permissions, setPermissions] = (0, import_react50.useState)(null);
8037
- const [processDefinition, setProcessDefinition] = (0, import_react50.useState)(null);
8038
- const mountedRef = (0, import_react50.useRef)(true);
8159
+ const [loading, setLoading] = (0, import_react52.useState)(true);
8160
+ const [mode, setMode] = (0, import_react52.useState)("readonly");
8161
+ const [processInfo, setProcessInfo] = (0, import_react52.useState)(null);
8162
+ const [progressList, setProgressList] = (0, import_react52.useState)([]);
8163
+ const [formData, setFormData] = (0, import_react52.useState)(null);
8164
+ const [instanceInfo, setInstanceInfo] = (0, import_react52.useState)(null);
8165
+ const [accessDenied, setAccessDenied] = (0, import_react52.useState)(false);
8166
+ const [loadError, setLoadError] = (0, import_react52.useState)(null);
8167
+ const [isApprover, setIsApprover] = (0, import_react52.useState)(false);
8168
+ const [canWithdraw, setCanWithdraw] = (0, import_react52.useState)(false);
8169
+ const [approvalTasks, setApprovalTasks] = (0, import_react52.useState)([]);
8170
+ const [permissions, setPermissions] = (0, import_react52.useState)(null);
8171
+ const [processDefinition, setProcessDefinition] = (0, import_react52.useState)(null);
8172
+ const [dataVersion, setDataVersion] = (0, import_react52.useState)(0);
8173
+ const mountedRef = (0, import_react52.useRef)(true);
8039
8174
  const fieldIdsKey = fieldIds?.join("") ?? "";
8040
- (0, import_react50.useEffect)(() => {
8175
+ (0, import_react52.useEffect)(() => {
8041
8176
  mountedRef.current = true;
8042
8177
  return () => {
8043
8178
  mountedRef.current = false;
8044
8179
  };
8045
8180
  }, []);
8046
- const currentTask = (0, import_react50.useMemo)(
8181
+ const currentTask = (0, import_react52.useMemo)(
8047
8182
  () => mergeCurrentTask(processInfo?.currentTask, approvalTasks[0]),
8048
8183
  [processInfo?.currentTask, approvalTasks]
8049
8184
  );
8050
8185
  const processStatus = processInfo?.processStatus ?? null;
8051
- const isOriginatorReturn = currentTask?.nodeType === "originator_return";
8052
- const isProcessCompleted = processStatus === "completed" || processStatus === "terminated";
8186
+ const isProcessFinal = processStatus ? FINAL_PROCESS_STATUSES.has(processStatus) : false;
8187
+ const isOriginatorReturn = !isProcessFinal && currentTask?.nodeType === "originator_return";
8188
+ const isProcessCompleted = processStatus ? EDITABLE_COMPLETED_STATUSES.has(processStatus) : false;
8189
+ const canEdit = hasViewOperation(permissions?.operations, "edit");
8190
+ const canDelete = hasViewOperation(permissions?.operations, "delete");
8191
+ const canViewWorkflow = hasViewOperation(permissions?.operations, "workflow");
8192
+ const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
8193
+ const fieldPermissionTask = isProcessFinal ? void 0 : currentTask ?? void 0;
8053
8194
  const { fieldBehaviors } = useFieldPermission({
8054
8195
  viewPermissions: permissions ?? void 0,
8055
8196
  processDefinition: processDefinition ?? void 0,
8056
- currentTask: currentTask ?? void 0,
8057
- isApprover,
8197
+ currentTask: fieldPermissionTask,
8198
+ isApprover: isProcessFinal ? false : isApprover,
8058
8199
  mode
8059
8200
  });
8060
- const activeActions = (0, import_react50.useMemo)(() => {
8061
- if (!isApprover) return [];
8201
+ const activeActions = (0, import_react52.useMemo)(() => {
8202
+ if (!isApprover || isProcessFinal) return [];
8062
8203
  const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
8063
8204
  if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
8064
8205
  actions.push(WITHDRAW_ACTION);
8065
8206
  }
8066
8207
  return actions;
8067
- }, [isApprover, currentTask?.actions, canWithdraw]);
8068
- const loadData = (0, import_react50.useCallback)(async () => {
8208
+ }, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
8209
+ const loadData = (0, import_react52.useCallback)(async () => {
8069
8210
  if (!mountedRef.current) return;
8070
8211
  setLoading(true);
8212
+ setAccessDenied(false);
8213
+ setLoadError(null);
8071
8214
  try {
8072
8215
  const [basicResult, approvalResult, permResult, formResult] = await Promise.all([
8073
8216
  getProcessBasic(request, formInstanceId),
@@ -8076,16 +8219,35 @@ function useProcessDetail(options) {
8076
8219
  getFormData(request, { formInstanceId, appType, formUuid })
8077
8220
  ]);
8078
8221
  if (!mountedRef.current) return;
8222
+ if (!hasViewPermission(permResult)) {
8223
+ setAccessDenied(true);
8224
+ setProcessInfo(null);
8225
+ setIsApprover(false);
8226
+ setCanWithdraw(false);
8227
+ setApprovalTasks([]);
8228
+ setPermissions(permResult);
8229
+ setInstanceInfo(null);
8230
+ setFormData(null);
8231
+ setProgressList([]);
8232
+ setProcessDefinition(null);
8233
+ return;
8234
+ }
8079
8235
  setProcessInfo(basicResult);
8080
- setIsApprover(approvalResult?.isApprover ?? false);
8081
- setCanWithdraw(approvalResult?.canUndo ?? false);
8082
- setApprovalTasks(approvalResult?.currentTasks ?? []);
8236
+ const nextProcessStatus = basicResult?.processStatus ?? null;
8237
+ const nextIsProcessFinal = nextProcessStatus ? FINAL_PROCESS_STATUSES.has(nextProcessStatus) : false;
8238
+ const nextCanWithdraw = Boolean(
8239
+ approvalResult?.canUndo && nextProcessStatus === "running" && basicResult?.isExecuting !== true
8240
+ );
8241
+ setIsApprover(nextIsProcessFinal ? false : approvalResult?.isApprover ?? false);
8242
+ setCanWithdraw(nextCanWithdraw);
8243
+ setApprovalTasks(nextIsProcessFinal ? [] : approvalResult?.currentTasks ?? []);
8083
8244
  setPermissions(permResult);
8084
8245
  setInstanceInfo(formResult);
8085
8246
  setFormData(
8086
8247
  extractFormValues(formResult, fieldIdsKey ? fieldIdsKey.split("") : void 0)
8087
8248
  );
8088
- if (permResult?.operations?.includes("VIEW_PROCESS") || permResult?.operations?.length > 0) {
8249
+ setDataVersion((version) => version + 1);
8250
+ if (hasViewOperation(permResult?.operations, "workflow")) {
8089
8251
  try {
8090
8252
  const progress = await getProcessProgress(request, formInstanceId);
8091
8253
  if (mountedRef.current) {
@@ -8095,8 +8257,8 @@ function useProcessDetail(options) {
8095
8257
  console.error("[useProcessDetail] Failed to load progress:", error);
8096
8258
  }
8097
8259
  }
8098
- const task = basicResult?.currentTask;
8099
- if (approvalResult?.isApprover && task && (task.nodeType === "originator_return" || task.nodeType === "approval")) {
8260
+ const task = mergeCurrentTask(basicResult?.currentTask, approvalResult?.currentTasks?.[0]);
8261
+ if (!nextIsProcessFinal && approvalResult?.isApprover && task && (task.nodeType === "originator_return" || task.nodeType === "approval")) {
8100
8262
  try {
8101
8263
  const definition = await getProcessDefinition(request, formUuid);
8102
8264
  if (mountedRef.current) {
@@ -8105,14 +8267,20 @@ function useProcessDetail(options) {
8105
8267
  } catch (error) {
8106
8268
  console.error("[useProcessDetail] Failed to load process definition:", error);
8107
8269
  }
8270
+ } else if (mountedRef.current) {
8271
+ setProcessDefinition(null);
8108
8272
  }
8109
8273
  } catch (error) {
8110
8274
  console.error("[useProcessDetail] Failed to load data:", error);
8111
8275
  if (mountedRef.current) {
8276
+ setLoadError(error instanceof Error ? error.message : "\u9875\u9762\u52A0\u8F7D\u5931\u8D25");
8277
+ setAccessDenied(false);
8112
8278
  setProcessInfo(null);
8113
8279
  setFormData(null);
8114
8280
  setInstanceInfo(null);
8115
8281
  setApprovalTasks([]);
8282
+ setProgressList([]);
8283
+ setProcessDefinition(null);
8116
8284
  }
8117
8285
  } finally {
8118
8286
  if (mountedRef.current) {
@@ -8120,29 +8288,51 @@ function useProcessDetail(options) {
8120
8288
  }
8121
8289
  }
8122
8290
  }, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
8123
- (0, import_react50.useEffect)(() => {
8291
+ (0, import_react52.useEffect)(() => {
8124
8292
  loadData();
8125
8293
  }, [loadData]);
8126
- const switchToEdit = (0, import_react50.useCallback)(() => {
8294
+ const switchToEdit = (0, import_react52.useCallback)(() => {
8127
8295
  setMode("edit");
8128
- }, []);
8129
- const switchToReadonly = (0, import_react50.useCallback)(() => {
8296
+ void loadData();
8297
+ }, [loadData]);
8298
+ const switchToReadonly = (0, import_react52.useCallback)(() => {
8130
8299
  setMode("readonly");
8131
8300
  }, []);
8132
- const refreshProgress = (0, import_react50.useCallback)(async () => {
8133
- try {
8134
- const [progress, basicResult] = await Promise.all([
8135
- getProcessProgress(request, formInstanceId),
8136
- getProcessBasic(request, formInstanceId)
8137
- ]);
8138
- if (mountedRef.current) {
8139
- setProgressList(progress);
8140
- setProcessInfo(basicResult);
8301
+ const refreshDetail = (0, import_react52.useCallback)(async () => {
8302
+ setMode("readonly");
8303
+ await loadData();
8304
+ }, [loadData]);
8305
+ const refreshProgress = (0, import_react52.useCallback)(async () => {
8306
+ await refreshDetail();
8307
+ }, [refreshDetail]);
8308
+ const saveChanges = (0, import_react52.useCallback)(
8309
+ async (values) => {
8310
+ try {
8311
+ await api.updateFormData({
8312
+ formInstanceId,
8313
+ formUuid,
8314
+ appType,
8315
+ updateFormDataJson: JSON.stringify(values)
8316
+ });
8317
+ setMode("readonly");
8318
+ await loadData();
8319
+ return true;
8320
+ } catch (error) {
8321
+ console.error("[useProcessDetail] Failed to save changes:", error);
8322
+ return false;
8141
8323
  }
8324
+ },
8325
+ [api, formInstanceId, formUuid, appType, loadData]
8326
+ );
8327
+ const deleteInstance = (0, import_react52.useCallback)(async () => {
8328
+ try {
8329
+ await deleteFormData(request, { formInstanceId, appType, formUuid });
8330
+ return true;
8142
8331
  } catch (error) {
8143
- console.error("[useProcessDetail] Failed to refresh progress:", error);
8332
+ console.error("[useProcessDetail] Failed to delete instance:", error);
8333
+ return false;
8144
8334
  }
8145
- }, [request, formInstanceId]);
8335
+ }, [request, formInstanceId, appType, formUuid]);
8146
8336
  return {
8147
8337
  loading,
8148
8338
  processInfo,
@@ -8151,6 +8341,8 @@ function useProcessDetail(options) {
8151
8341
  progressList,
8152
8342
  formData,
8153
8343
  instanceInfo,
8344
+ accessDenied,
8345
+ loadError,
8154
8346
  isApprover,
8155
8347
  activeActions,
8156
8348
  fieldBehaviors,
@@ -8158,35 +8350,44 @@ function useProcessDetail(options) {
8158
8350
  isOriginatorReturn,
8159
8351
  isProcessCompleted,
8160
8352
  canWithdraw,
8353
+ canEdit,
8354
+ canDelete,
8355
+ canViewWorkflow,
8356
+ canViewChangeRecords,
8357
+ dataVersion,
8161
8358
  switchToEdit,
8162
8359
  switchToReadonly,
8360
+ saveChanges,
8361
+ deleteInstance,
8362
+ refreshDetail,
8163
8363
  refreshProgress
8164
8364
  };
8165
8365
  }
8166
8366
 
8167
8367
  // src/hooks/useApprovalActions.ts
8168
- var import_react51 = require("react");
8368
+ var import_react53 = require("react");
8169
8369
  function useApprovalActions(options) {
8170
8370
  const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
8171
8371
  const { api } = useFormContext();
8172
8372
  const request = api.request;
8173
- const [isLoading, setIsLoading] = (0, import_react51.useState)(false);
8174
- const [currentAction, setCurrentAction] = (0, import_react51.useState)(null);
8175
- const [returnableNodes, setReturnableNodes] = (0, import_react51.useState)([]);
8176
- const mountedRef = (0, import_react51.useRef)(true);
8177
- (0, import_react51.useEffect)(() => {
8373
+ const [isLoading, setIsLoading] = (0, import_react53.useState)(false);
8374
+ const [currentAction, setCurrentAction] = (0, import_react53.useState)(null);
8375
+ const [returnableNodes, setReturnableNodes] = (0, import_react53.useState)([]);
8376
+ const [returnPolicy, setReturnPolicy] = (0, import_react53.useState)(null);
8377
+ const mountedRef = (0, import_react53.useRef)(true);
8378
+ (0, import_react53.useEffect)(() => {
8178
8379
  mountedRef.current = true;
8179
8380
  return () => {
8180
8381
  mountedRef.current = false;
8181
8382
  };
8182
8383
  }, []);
8183
- const resetLoading = (0, import_react51.useCallback)(() => {
8384
+ const resetLoading = (0, import_react53.useCallback)(() => {
8184
8385
  if (mountedRef.current) {
8185
8386
  setIsLoading(false);
8186
8387
  setCurrentAction(null);
8187
8388
  }
8188
8389
  }, []);
8189
- const approve = (0, import_react51.useCallback)(
8390
+ const approve = (0, import_react53.useCallback)(
8190
8391
  async (comments) => {
8191
8392
  setIsLoading(true);
8192
8393
  setCurrentAction("approve");
@@ -8200,8 +8401,8 @@ function useApprovalActions(options) {
8200
8401
  formUuid,
8201
8402
  updateFormDataJson: formValues ? JSON.stringify(formValues) : void 0
8202
8403
  });
8404
+ await onActionComplete?.("approve");
8203
8405
  resetLoading();
8204
- onActionComplete?.("approve");
8205
8406
  return true;
8206
8407
  } catch (error) {
8207
8408
  console.error("[useApprovalActions] approve failed:", error);
@@ -8211,22 +8412,18 @@ function useApprovalActions(options) {
8211
8412
  },
8212
8413
  [request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
8213
8414
  );
8214
- const reject = (0, import_react51.useCallback)(
8415
+ const reject = (0, import_react53.useCallback)(
8215
8416
  async (comments) => {
8216
8417
  setIsLoading(true);
8217
8418
  setCurrentAction("reject");
8218
8419
  try {
8219
- const formValues = getFormValues?.();
8220
8420
  await handleApproval(request, {
8221
8421
  instanceId: formInstanceId,
8222
8422
  action: "rejected",
8223
- comments,
8224
- appType,
8225
- formUuid,
8226
- updateFormDataJson: formValues ? JSON.stringify(formValues) : void 0
8423
+ comments
8227
8424
  });
8425
+ await onActionComplete?.("reject");
8228
8426
  resetLoading();
8229
- onActionComplete?.("reject");
8230
8427
  return true;
8231
8428
  } catch (error) {
8232
8429
  console.error("[useApprovalActions] reject failed:", error);
@@ -8234,9 +8431,9 @@ function useApprovalActions(options) {
8234
8431
  return false;
8235
8432
  }
8236
8433
  },
8237
- [request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
8434
+ [request, formInstanceId, onActionComplete, resetLoading]
8238
8435
  );
8239
- const transfer = (0, import_react51.useCallback)(
8436
+ const transfer = (0, import_react53.useCallback)(
8240
8437
  async (userId, reason) => {
8241
8438
  if (!currentTaskId) {
8242
8439
  console.error("[useApprovalActions] transfer failed: no currentTaskId");
@@ -8250,8 +8447,8 @@ function useApprovalActions(options) {
8250
8447
  newAssignee: userId,
8251
8448
  reason
8252
8449
  });
8450
+ await onActionComplete?.("transfer");
8253
8451
  resetLoading();
8254
- onActionComplete?.("transfer");
8255
8452
  return true;
8256
8453
  } catch (error) {
8257
8454
  console.error("[useApprovalActions] transfer failed:", error);
@@ -8261,7 +8458,7 @@ function useApprovalActions(options) {
8261
8458
  },
8262
8459
  [request, currentTaskId, onActionComplete, resetLoading]
8263
8460
  );
8264
- const returnTo = (0, import_react51.useCallback)(
8461
+ const returnTo = (0, import_react53.useCallback)(
8265
8462
  async (nodeId, reason) => {
8266
8463
  if (!currentTaskId) {
8267
8464
  console.error("[useApprovalActions] returnTo failed: no currentTaskId");
@@ -8275,8 +8472,8 @@ function useApprovalActions(options) {
8275
8472
  targetNodeId: nodeId,
8276
8473
  reason
8277
8474
  });
8475
+ await onActionComplete?.("return");
8278
8476
  resetLoading();
8279
- onActionComplete?.("return");
8280
8477
  return true;
8281
8478
  } catch (error) {
8282
8479
  console.error("[useApprovalActions] returnTo failed:", error);
@@ -8286,7 +8483,7 @@ function useApprovalActions(options) {
8286
8483
  },
8287
8484
  [request, currentTaskId, onActionComplete, resetLoading]
8288
8485
  );
8289
- const withdraw = (0, import_react51.useCallback)(
8486
+ const withdraw = (0, import_react53.useCallback)(
8290
8487
  async (reason) => {
8291
8488
  setIsLoading(true);
8292
8489
  setCurrentAction("withdraw");
@@ -8295,8 +8492,8 @@ function useApprovalActions(options) {
8295
8492
  instanceId: formInstanceId,
8296
8493
  reason
8297
8494
  });
8495
+ await onActionComplete?.("withdraw");
8298
8496
  resetLoading();
8299
- onActionComplete?.("withdraw");
8300
8497
  return true;
8301
8498
  } catch (error) {
8302
8499
  console.error("[useApprovalActions] withdraw failed:", error);
@@ -8306,7 +8503,7 @@ function useApprovalActions(options) {
8306
8503
  },
8307
8504
  [request, formInstanceId, onActionComplete, resetLoading]
8308
8505
  );
8309
- const save = (0, import_react51.useCallback)(async () => {
8506
+ const save = (0, import_react53.useCallback)(async () => {
8310
8507
  setIsLoading(true);
8311
8508
  setCurrentAction("save");
8312
8509
  try {
@@ -8317,8 +8514,8 @@ function useApprovalActions(options) {
8317
8514
  appType,
8318
8515
  updateFormDataJson: JSON.stringify(formValues)
8319
8516
  });
8517
+ await onActionComplete?.("save");
8320
8518
  resetLoading();
8321
- onActionComplete?.("save");
8322
8519
  return true;
8323
8520
  } catch (error) {
8324
8521
  console.error("[useApprovalActions] save failed:", error);
@@ -8326,7 +8523,7 @@ function useApprovalActions(options) {
8326
8523
  return false;
8327
8524
  }
8328
8525
  }, [request, formInstanceId, formUuid, appType, getFormValues, onActionComplete, resetLoading]);
8329
- const resubmit = (0, import_react51.useCallback)(
8526
+ const resubmit = (0, import_react53.useCallback)(
8330
8527
  async (comments) => {
8331
8528
  if (!currentTaskId) {
8332
8529
  console.error("[useApprovalActions] resubmit failed: no currentTaskId");
@@ -8343,8 +8540,8 @@ function useApprovalActions(options) {
8343
8540
  updateFormDataJson: JSON.stringify(formValues),
8344
8541
  comments
8345
8542
  });
8543
+ await onActionComplete?.("resubmit");
8346
8544
  resetLoading();
8347
- onActionComplete?.("resubmit");
8348
8545
  return true;
8349
8546
  } catch (error) {
8350
8547
  console.error("[useApprovalActions] resubmit failed:", error);
@@ -8354,7 +8551,7 @@ function useApprovalActions(options) {
8354
8551
  },
8355
8552
  [request, currentTaskId, formUuid, appType, getFormValues, onActionComplete, resetLoading]
8356
8553
  );
8357
- const callbackTask = (0, import_react51.useCallback)(
8554
+ const callbackTask = (0, import_react53.useCallback)(
8358
8555
  async (payload) => {
8359
8556
  if (!currentTaskId) {
8360
8557
  console.error("[useApprovalActions] callbackTask failed: no currentTaskId");
@@ -8367,8 +8564,8 @@ function useApprovalActions(options) {
8367
8564
  taskId: currentTaskId,
8368
8565
  payload
8369
8566
  });
8567
+ await onActionComplete?.("callback");
8370
8568
  resetLoading();
8371
- onActionComplete?.("callback");
8372
8569
  return true;
8373
8570
  } catch (error) {
8374
8571
  console.error("[useApprovalActions] callbackTask failed:", error);
@@ -8378,15 +8575,22 @@ function useApprovalActions(options) {
8378
8575
  },
8379
8576
  [request, currentTaskId, onActionComplete, resetLoading]
8380
8577
  );
8381
- const loadReturnableNodes = (0, import_react51.useCallback)(async () => {
8382
- if (!currentTaskId) return;
8578
+ const loadReturnableNodes = (0, import_react53.useCallback)(async () => {
8579
+ if (!currentTaskId) return [];
8383
8580
  try {
8384
- const nodes = await getReturnableNodes(request, currentTaskId);
8581
+ const result = await getReturnableNodeResult(request, currentTaskId);
8385
8582
  if (mountedRef.current) {
8386
- setReturnableNodes(nodes);
8583
+ setReturnableNodes(result.nodes);
8584
+ setReturnPolicy(result.policy || null);
8387
8585
  }
8586
+ return result.nodes;
8388
8587
  } catch (error) {
8389
8588
  console.error("[useApprovalActions] loadReturnableNodes failed:", error);
8589
+ if (mountedRef.current) {
8590
+ setReturnableNodes([]);
8591
+ setReturnPolicy(null);
8592
+ }
8593
+ return [];
8390
8594
  }
8391
8595
  }, [request, currentTaskId]);
8392
8596
  return {
@@ -8401,12 +8605,13 @@ function useApprovalActions(options) {
8401
8605
  isLoading,
8402
8606
  currentAction,
8403
8607
  returnableNodes,
8608
+ returnPolicy,
8404
8609
  loadReturnableNodes
8405
8610
  };
8406
8611
  }
8407
8612
 
8408
8613
  // src/hooks/useChangeRecords.ts
8409
- var import_react52 = require("react");
8614
+ var import_react54 = require("react");
8410
8615
  var normalizeChangeRecordList = (value) => {
8411
8616
  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;
8412
8617
  const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
@@ -8421,18 +8626,18 @@ function useChangeRecords(options) {
8421
8626
  const { formUuid, appType, formInstanceId, pageSize = 20, autoLoad = true } = options;
8422
8627
  const { api } = useFormContext();
8423
8628
  const request = api.request;
8424
- const [records, setRecords] = (0, import_react52.useState)([]);
8425
- const [loading, setLoading] = (0, import_react52.useState)(false);
8426
- const [total, setTotal] = (0, import_react52.useState)(0);
8427
- const [page, setPage] = (0, import_react52.useState)(1);
8428
- const mountedRef = (0, import_react52.useRef)(true);
8429
- (0, import_react52.useEffect)(() => {
8629
+ const [records, setRecords] = (0, import_react54.useState)([]);
8630
+ const [loading, setLoading] = (0, import_react54.useState)(false);
8631
+ const [total, setTotal] = (0, import_react54.useState)(0);
8632
+ const [page, setPage] = (0, import_react54.useState)(1);
8633
+ const mountedRef = (0, import_react54.useRef)(true);
8634
+ (0, import_react54.useEffect)(() => {
8430
8635
  mountedRef.current = true;
8431
8636
  return () => {
8432
8637
  mountedRef.current = false;
8433
8638
  };
8434
8639
  }, []);
8435
- const fetchRecords = (0, import_react52.useCallback)(
8640
+ const fetchRecords = (0, import_react54.useCallback)(
8436
8641
  async (pageNum, append) => {
8437
8642
  if (!mountedRef.current) return;
8438
8643
  setLoading(true);
@@ -8463,18 +8668,18 @@ function useChangeRecords(options) {
8463
8668
  },
8464
8669
  [request, formUuid, appType, formInstanceId, pageSize]
8465
8670
  );
8466
- (0, import_react52.useEffect)(() => {
8671
+ (0, import_react54.useEffect)(() => {
8467
8672
  if (autoLoad) {
8468
8673
  fetchRecords(1, false);
8469
8674
  }
8470
8675
  }, [autoLoad, fetchRecords]);
8471
8676
  const safeRecords = Array.isArray(records) ? records : [];
8472
8677
  const hasMore = safeRecords.length < total;
8473
- const loadMore = (0, import_react52.useCallback)(async () => {
8678
+ const loadMore = (0, import_react54.useCallback)(async () => {
8474
8679
  if (!hasMore || loading) return;
8475
8680
  await fetchRecords(page + 1, true);
8476
8681
  }, [hasMore, loading, page, fetchRecords]);
8477
- const refresh = (0, import_react52.useCallback)(async () => {
8682
+ const refresh = (0, import_react54.useCallback)(async () => {
8478
8683
  setRecords([]);
8479
8684
  setPage(1);
8480
8685
  setTotal(0);
@@ -8492,7 +8697,7 @@ function useChangeRecords(options) {
8492
8697
  }
8493
8698
 
8494
8699
  // src/hooks/useFormNavigation.ts
8495
- var import_react53 = require("react");
8700
+ var import_react55 = require("react");
8496
8701
  var normalizeBasePath = (basePath) => {
8497
8702
  const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
8498
8703
  return normalized ? `/${normalized}` : "";
@@ -8519,12 +8724,12 @@ function useFormNavigation(options) {
8519
8724
  basePath,
8520
8725
  onStay
8521
8726
  } = options;
8522
- const [isRedirecting, setIsRedirecting] = (0, import_react53.useState)(false);
8523
- const [countdown, setCountdown] = (0, import_react53.useState)(0);
8524
- const timerRef = (0, import_react53.useRef)(null);
8525
- const redirectTargetRef = (0, import_react53.useRef)(null);
8526
- const mountedRef = (0, import_react53.useRef)(true);
8527
- (0, import_react53.useEffect)(() => {
8727
+ const [isRedirecting, setIsRedirecting] = (0, import_react55.useState)(false);
8728
+ const [countdown, setCountdown] = (0, import_react55.useState)(0);
8729
+ const timerRef = (0, import_react55.useRef)(null);
8730
+ const redirectTargetRef = (0, import_react55.useRef)(null);
8731
+ const mountedRef = (0, import_react55.useRef)(true);
8732
+ (0, import_react55.useEffect)(() => {
8528
8733
  mountedRef.current = true;
8529
8734
  return () => {
8530
8735
  mountedRef.current = false;
@@ -8534,13 +8739,13 @@ function useFormNavigation(options) {
8534
8739
  }
8535
8740
  };
8536
8741
  }, []);
8537
- const navigateToDetail = (0, import_react53.useCallback)(
8742
+ const navigateToDetail = (0, import_react55.useCallback)(
8538
8743
  (formInstId) => {
8539
8744
  window.location.href = buildDetailUrl(appType, formUuid, formInstId, "formDetail", basePath);
8540
8745
  },
8541
8746
  [appType, basePath, formUuid]
8542
8747
  );
8543
- const navigateToProcessDetail = (0, import_react53.useCallback)(
8748
+ const navigateToProcessDetail = (0, import_react55.useCallback)(
8544
8749
  (formInstId) => {
8545
8750
  window.location.href = buildDetailUrl(
8546
8751
  appType,
@@ -8552,7 +8757,7 @@ function useFormNavigation(options) {
8552
8757
  },
8553
8758
  [appType, basePath, formUuid]
8554
8759
  );
8555
- const startRedirectCountdown = (0, import_react53.useCallback)(
8760
+ const startRedirectCountdown = (0, import_react55.useCallback)(
8556
8761
  (targetUrl) => {
8557
8762
  const totalSeconds = Math.ceil(redirectDelay / 1e3);
8558
8763
  setIsRedirecting(true);
@@ -8585,7 +8790,7 @@ function useFormNavigation(options) {
8585
8790
  },
8586
8791
  [redirectDelay]
8587
8792
  );
8588
- const cancelRedirect = (0, import_react53.useCallback)(() => {
8793
+ const cancelRedirect = (0, import_react55.useCallback)(() => {
8589
8794
  if (timerRef.current) {
8590
8795
  clearInterval(timerRef.current);
8591
8796
  timerRef.current = null;
@@ -8594,7 +8799,7 @@ function useFormNavigation(options) {
8594
8799
  setCountdown(0);
8595
8800
  redirectTargetRef.current = null;
8596
8801
  }, []);
8597
- const handlePostSubmit = (0, import_react53.useCallback)(
8802
+ const handlePostSubmit = (0, import_react55.useCallback)(
8598
8803
  (formInstId) => {
8599
8804
  if (mode === "stay") {
8600
8805
  onStay?.(formInstId);
@@ -8626,7 +8831,7 @@ function useFormNavigation(options) {
8626
8831
  }
8627
8832
 
8628
8833
  // src/hooks/useDraftStorage.ts
8629
- var import_react54 = require("react");
8834
+ var import_react56 = require("react");
8630
8835
  function getDraftKey(appType, formUuid) {
8631
8836
  return `${appType}__${formUuid}__draft`;
8632
8837
  }
@@ -8646,10 +8851,10 @@ function readDraft(key) {
8646
8851
  function useDraftStorage(options) {
8647
8852
  const { appType, formUuid, autoRestore = false } = options;
8648
8853
  const key = getDraftKey(appType, formUuid);
8649
- const [hasDraft, setHasDraft] = (0, import_react54.useState)(false);
8650
- const [draftData, setDraftData] = (0, import_react54.useState)(null);
8651
- const [draftTimestamp, setDraftTimestamp] = (0, import_react54.useState)(null);
8652
- (0, import_react54.useEffect)(() => {
8854
+ const [hasDraft, setHasDraft] = (0, import_react56.useState)(false);
8855
+ const [draftData, setDraftData] = (0, import_react56.useState)(null);
8856
+ const [draftTimestamp, setDraftTimestamp] = (0, import_react56.useState)(null);
8857
+ (0, import_react56.useEffect)(() => {
8653
8858
  const stored = readDraft(key);
8654
8859
  if (stored) {
8655
8860
  setHasDraft(true);
@@ -8663,7 +8868,7 @@ function useDraftStorage(options) {
8663
8868
  setDraftTimestamp(null);
8664
8869
  }
8665
8870
  }, [key, autoRestore]);
8666
- const saveDraft = (0, import_react54.useCallback)(
8871
+ const saveDraft = (0, import_react56.useCallback)(
8667
8872
  (data) => {
8668
8873
  const payload = { data, ts: Date.now() };
8669
8874
  try {
@@ -8677,7 +8882,7 @@ function useDraftStorage(options) {
8677
8882
  },
8678
8883
  [key]
8679
8884
  );
8680
- const restoreDraft = (0, import_react54.useCallback)(() => {
8885
+ const restoreDraft = (0, import_react56.useCallback)(() => {
8681
8886
  const stored = readDraft(key);
8682
8887
  if (stored) {
8683
8888
  setDraftData(stored.data);
@@ -8685,7 +8890,7 @@ function useDraftStorage(options) {
8685
8890
  }
8686
8891
  return null;
8687
8892
  }, [key]);
8688
- const clearDraft = (0, import_react54.useCallback)(() => {
8893
+ const clearDraft = (0, import_react56.useCallback)(() => {
8689
8894
  try {
8690
8895
  localStorage.removeItem(key);
8691
8896
  } catch (error) {
@@ -8778,7 +8983,7 @@ var FormSummaryCard = ({
8778
8983
  };
8779
8984
 
8780
8985
  // src/modules/RecordChangePanel.tsx
8781
- var import_react55 = require("react");
8986
+ var import_react57 = require("react");
8782
8987
  var import_antd23 = require("antd");
8783
8988
  var import_icons3 = require("@ant-design/icons");
8784
8989
  var import_jsx_runtime78 = require("react/jsx-runtime");
@@ -8824,7 +9029,7 @@ var RecordChangePanel = ({
8824
9029
  onPageChange,
8825
9030
  className = ""
8826
9031
  }) => {
8827
- const [expanded, setExpanded] = (0, import_react55.useState)(defaultExpanded);
9032
+ const [expanded, setExpanded] = (0, import_react57.useState)(defaultExpanded);
8828
9033
  const count = total ?? records.length;
8829
9034
  const handleToggle = () => {
8830
9035
  const next = !expanded;
@@ -8994,7 +9199,7 @@ var ChangeRecords = ({
8994
9199
  };
8995
9200
 
8996
9201
  // src/modules/ApprovalTimeline.tsx
8997
- var import_react56 = require("react");
9202
+ var import_react58 = require("react");
8998
9203
  var import_icons4 = require("@ant-design/icons");
8999
9204
  var import_jsx_runtime80 = require("react/jsx-runtime");
9000
9205
  var systemNodeTypes = /* @__PURE__ */ new Set([
@@ -9143,8 +9348,8 @@ var ApprovalTimeline = ({
9143
9348
  compactMode = false,
9144
9349
  showApproverInfo = true
9145
9350
  }) => {
9146
- const taskList = (0, import_react56.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
9147
- const groups = (0, import_react56.useMemo)(() => groupTasks(taskList), [taskList]);
9351
+ const taskList = (0, import_react58.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
9352
+ const groups = (0, import_react58.useMemo)(() => groupTasks(taskList), [taskList]);
9148
9353
  if (taskList.length === 0) {
9149
9354
  return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
9150
9355
  "div",
@@ -9239,12 +9444,12 @@ var ApprovalTimeline = ({
9239
9444
  };
9240
9445
 
9241
9446
  // src/modules/ApprovalActionBar.tsx
9242
- var import_react58 = require("react");
9447
+ var import_react60 = __toESM(require("react"));
9243
9448
  var import_antd25 = require("antd");
9244
9449
  var import_icons6 = require("@ant-design/icons");
9245
9450
 
9246
9451
  // src/modules/StickyActionBar.tsx
9247
- var import_react57 = require("react");
9452
+ var import_react59 = require("react");
9248
9453
  var import_antd24 = require("antd");
9249
9454
  var import_icons5 = require("@ant-design/icons");
9250
9455
 
@@ -9270,7 +9475,6 @@ var getActionPriority = (action) => {
9270
9475
  if (action.type === "danger") return 90;
9271
9476
  return 50;
9272
9477
  };
9273
- var getPlacement = (action) => action.placement;
9274
9478
  var StickyActionBar = ({
9275
9479
  actions,
9276
9480
  className = "",
@@ -9279,14 +9483,14 @@ var StickyActionBar = ({
9279
9483
  maxWidth = 1120,
9280
9484
  position = "sticky"
9281
9485
  }) => {
9282
- const [isMobile, setIsMobile] = (0, import_react57.useState)(false);
9283
- (0, import_react57.useEffect)(() => {
9486
+ const [isMobile, setIsMobile] = (0, import_react59.useState)(false);
9487
+ (0, import_react59.useEffect)(() => {
9284
9488
  const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
9285
9489
  update();
9286
9490
  window.addEventListener("resize", update);
9287
9491
  return () => window.removeEventListener("resize", update);
9288
9492
  }, []);
9289
- const visibleActions = (0, import_react57.useMemo)(
9493
+ const visibleActions = (0, import_react59.useMemo)(
9290
9494
  () => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
9291
9495
  [actions]
9292
9496
  );
@@ -9294,8 +9498,6 @@ var StickyActionBar = ({
9294
9498
  const maxWidthStyle = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
9295
9499
  const primaryMobile = visibleActions.slice(0, maxMobileButtons);
9296
9500
  const moreMobile = visibleActions.slice(maxMobileButtons);
9297
- const leftActions = visibleActions.filter((action) => getPlacement(action) === "left");
9298
- const rightActions = visibleActions.filter((action) => getPlacement(action) !== "left");
9299
9501
  const positionClass = position === "fixed" ? "fixed bottom-0 left-0 right-0" : position === "inline" ? "relative" : "sticky bottom-0";
9300
9502
  const runAction = (action) => {
9301
9503
  if (action.confirm) {
@@ -9325,7 +9527,7 @@ var StickyActionBar = ({
9325
9527
  children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
9326
9528
  "div",
9327
9529
  {
9328
- className: `mx-auto flex w-full items-center gap-3 ${layoutMode === "approval" && !isMobile ? "justify-between" : "justify-end"}`,
9530
+ className: `mx-auto flex w-full items-center gap-3 ${layoutMode === "approval" && !isMobile ? "justify-center" : "justify-end"}`,
9329
9531
  style: { maxWidth: maxWidthStyle },
9330
9532
  children: isMobile ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
9331
9533
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex flex-1 gap-2", children: primaryMobile.map((action) => renderButton(action, true)) }),
@@ -9347,10 +9549,7 @@ var StickyActionBar = ({
9347
9549
  children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_antd24.Button, { icon: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_icons5.MoreOutlined, {}), className: "rounded-md", children: "\u66F4\u591A" })
9348
9550
  }
9349
9551
  )
9350
- ] }) : layoutMode === "approval" && leftActions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
9351
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex flex-wrap items-center gap-3", children: leftActions.map((action) => renderButton(action)) }),
9352
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: rightActions.map((action) => renderButton(action)) })
9353
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: visibleActions.map((action) => renderButton(action)) })
9552
+ ] }) : layoutMode === "approval" ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex flex-wrap items-center justify-center gap-3", children: visibleActions.map((action) => renderButton(action)) }) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: visibleActions.map((action) => renderButton(action)) })
9354
9553
  }
9355
9554
  )
9356
9555
  }
@@ -9400,6 +9599,50 @@ function getModalTitle(action) {
9400
9599
  return "\u786E\u8BA4\u64CD\u4F5C";
9401
9600
  }
9402
9601
  }
9602
+ function formatReturnPolicy(policy) {
9603
+ if (!policy?.resubmitMode) return null;
9604
+ return policy.resubmitMode === "resume_current" ? "\u4ECE\u5F53\u524D\u8282\u70B9\u5BA1\u6279" : "\u91CD\u65B0\u4F9D\u6B21\u5BA1\u6279";
9605
+ }
9606
+ function DefaultTransferSelector({
9607
+ value,
9608
+ onChange
9609
+ }) {
9610
+ const formContext = import_react60.default.useContext(FormContext);
9611
+ const [open, setOpen] = (0, import_react60.useState)(false);
9612
+ const [selectedUsers, setSelectedUsers] = (0, import_react60.useState)([]);
9613
+ if (!formContext) {
9614
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_antd25.Input, { value, onChange: (event) => onChange(event.target.value) });
9615
+ }
9616
+ const selectedLabel = selectedUsers[0] ? getUserName(selectedUsers[0]) : value;
9617
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [
9618
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9619
+ import_antd25.Input,
9620
+ {
9621
+ readOnly: true,
9622
+ value: selectedLabel,
9623
+ placeholder: "\u8BF7\u9009\u62E9\u8F6C\u4EA4\u7528\u6237",
9624
+ addonAfter: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "cursor-pointer text-blue-600", onClick: () => setOpen(true), children: "\u9009\u62E9" })
9625
+ }
9626
+ ),
9627
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9628
+ UserPicker,
9629
+ {
9630
+ api: formContext.api,
9631
+ open,
9632
+ onOpenChange: setOpen,
9633
+ multiple: false,
9634
+ value: selectedUsers,
9635
+ onCancel: () => setOpen(false),
9636
+ onConfirm: (items) => {
9637
+ const next = items.slice(0, 1);
9638
+ setSelectedUsers(next);
9639
+ const userId = next[0] ? getUserId(next[0]) : "";
9640
+ onChange(userId);
9641
+ }
9642
+ }
9643
+ )
9644
+ ] });
9645
+ }
9403
9646
  var ApprovalActionBar = ({
9404
9647
  actions,
9405
9648
  onApprove,
@@ -9411,6 +9654,7 @@ var ApprovalActionBar = ({
9411
9654
  onResubmit,
9412
9655
  onCallback,
9413
9656
  returnableNodes = [],
9657
+ returnPolicy,
9414
9658
  onLoadReturnableNodes,
9415
9659
  renderTransferSelector,
9416
9660
  renderReturnNodeLabel,
@@ -9420,10 +9664,10 @@ var ApprovalActionBar = ({
9420
9664
  inDrawer = false
9421
9665
  }) => {
9422
9666
  const [form] = import_antd25.Form.useForm();
9423
- const [modalAction, setModalAction] = (0, import_react58.useState)(null);
9424
- const [activeAction, setActiveAction] = (0, import_react58.useState)(null);
9425
- const [loading, setLoading] = (0, import_react58.useState)(false);
9426
- const visibleActions = (0, import_react58.useMemo)(
9667
+ const [modalAction, setModalAction] = (0, import_react60.useState)(null);
9668
+ const [activeAction, setActiveAction] = (0, import_react60.useState)(null);
9669
+ const [loading, setLoading] = (0, import_react60.useState)(false);
9670
+ const visibleActions = (0, import_react60.useMemo)(
9427
9671
  () => actions.filter((action) => !action.hidden).sort((a, b) => (actionPriority[a.action] ?? 50) - (actionPriority[b.action] ?? 50)),
9428
9672
  [actions]
9429
9673
  );
@@ -9436,7 +9680,12 @@ var ApprovalActionBar = ({
9436
9680
  userId: void 0,
9437
9681
  nodeId: void 0
9438
9682
  });
9439
- if (target === "return") await onLoadReturnableNodes?.();
9683
+ if (target === "return") {
9684
+ const loadedNodes = await onLoadReturnableNodes?.() || returnableNodes;
9685
+ if (loadedNodes.length === 1) {
9686
+ form.setFieldsValue({ nodeId: loadedNodes[0].nodeId || loadedNodes[0].id || "" });
9687
+ }
9688
+ }
9440
9689
  setModalAction(target);
9441
9690
  };
9442
9691
  const executeDirect = async (action) => {
@@ -9451,6 +9700,14 @@ var ApprovalActionBar = ({
9451
9700
  }
9452
9701
  if (normalized === "agree") {
9453
9702
  await onApprove?.();
9703
+ return;
9704
+ }
9705
+ if (normalized === "rejected") {
9706
+ await onReject?.();
9707
+ return;
9708
+ }
9709
+ if (normalized === "resubmit") {
9710
+ await onResubmit?.();
9454
9711
  }
9455
9712
  };
9456
9713
  const handleActionClick = async (action) => {
@@ -9459,6 +9716,10 @@ var ApprovalActionBar = ({
9459
9716
  await executeDirect(action);
9460
9717
  return;
9461
9718
  }
9719
+ if ((normalized === "agree" || normalized === "rejected" || normalized === "resubmit") && !action.remark?.popUp) {
9720
+ await executeDirect(action);
9721
+ return;
9722
+ }
9462
9723
  await openModal(action, normalized);
9463
9724
  };
9464
9725
  const handleOk = async () => {
@@ -9520,7 +9781,7 @@ var ApprovalActionBar = ({
9520
9781
  setActiveAction(null);
9521
9782
  form.resetFields();
9522
9783
  },
9523
- destroyOnClose: true,
9784
+ destroyOnHidden: true,
9524
9785
  children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_antd25.Form, { form, layout: "vertical", children: [
9525
9786
  modalAction === "transfer" && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9526
9787
  import_antd25.Form.Item,
@@ -9531,28 +9792,40 @@ var ApprovalActionBar = ({
9531
9792
  children: renderTransferSelector ? renderTransferSelector({
9532
9793
  value: form.getFieldValue("userId"),
9533
9794
  onChange: (userId) => form.setFieldsValue({ userId })
9534
- }) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_antd25.Input, { placeholder: "\u8BF7\u8F93\u5165\u7528\u6237 ID" })
9535
- }
9536
- ),
9537
- modalAction === "return" && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9538
- import_antd25.Form.Item,
9539
- {
9540
- name: "nodeId",
9541
- label: "\u9000\u56DE\u5230\u8282\u70B9",
9542
- rules: [{ required: true, message: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9" }],
9543
- children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9544
- import_antd25.Select,
9795
+ }) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9796
+ DefaultTransferSelector,
9545
9797
  {
9546
- placeholder: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9",
9547
- getPopupContainer: (triggerNode) => triggerNode.parentElement || document.body,
9548
- options: returnableNodes.map((node) => ({
9549
- value: node.nodeId || node.id || "",
9550
- label: renderReturnNodeLabel ? renderReturnNodeLabel(node) : node.nodeName || node.name || node.nodeId || node.id
9551
- }))
9798
+ value: form.getFieldValue("userId"),
9799
+ onChange: (userId) => form.setFieldsValue({ userId })
9552
9800
  }
9553
9801
  )
9554
9802
  }
9555
9803
  ),
9804
+ modalAction === "return" && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [
9805
+ formatReturnPolicy(returnPolicy) && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "mb-3 text-sm text-gray-500", children: [
9806
+ "\u9000\u56DE\u540E\u5BA1\u6279\u903B\u8F91\uFF1A",
9807
+ formatReturnPolicy(returnPolicy)
9808
+ ] }),
9809
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9810
+ import_antd25.Form.Item,
9811
+ {
9812
+ name: "nodeId",
9813
+ label: "\u9000\u56DE\u5230\u8282\u70B9",
9814
+ rules: [{ required: true, message: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9" }],
9815
+ children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9816
+ import_antd25.Select,
9817
+ {
9818
+ placeholder: "\u8BF7\u9009\u62E9\u9000\u56DE\u8282\u70B9",
9819
+ getPopupContainer: (triggerNode) => triggerNode.parentElement || document.body,
9820
+ options: returnableNodes.map((node) => ({
9821
+ value: node.nodeId || node.id || "",
9822
+ label: renderReturnNodeLabel ? renderReturnNodeLabel(node) : node.nodeName || node.name || node.nodeId || node.id
9823
+ }))
9824
+ }
9825
+ )
9826
+ }
9827
+ )
9828
+ ] }),
9556
9829
  /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
9557
9830
  import_antd25.Form.Item,
9558
9831
  {
@@ -9570,7 +9843,7 @@ var ApprovalActionBar = ({
9570
9843
  };
9571
9844
 
9572
9845
  // src/modules/ApprovalActions.tsx
9573
- var import_react59 = require("react");
9846
+ var import_react61 = require("react");
9574
9847
  var import_antd26 = require("antd");
9575
9848
  var import_icons7 = require("@ant-design/icons");
9576
9849
  var import_jsx_runtime83 = require("react/jsx-runtime");
@@ -9598,11 +9871,12 @@ var ApprovalActions = ({
9598
9871
  className = ""
9599
9872
  }) => {
9600
9873
  const [form] = import_antd26.Form.useForm();
9601
- const [modalAction, setModalAction] = (0, import_react59.useState)(null);
9602
- const [activeAction, setActiveAction] = (0, import_react59.useState)(null);
9603
- const [loading, setLoading] = (0, import_react59.useState)(false);
9604
- const [saveLoading, setSaveLoading] = (0, import_react59.useState)(false);
9605
- const renderableActions = (0, import_react59.useMemo)(
9874
+ const [modalAction, setModalAction] = (0, import_react61.useState)(null);
9875
+ const [activeAction, setActiveAction] = (0, import_react61.useState)(null);
9876
+ const [loading, setLoading] = (0, import_react61.useState)(false);
9877
+ const [saveLoading, setSaveLoading] = (0, import_react61.useState)(false);
9878
+ const [directLoading, setDirectLoading] = (0, import_react61.useState)(null);
9879
+ const renderableActions = (0, import_react61.useMemo)(
9606
9880
  () => actions.filter((action) => !action.hidden).sort((a, b) => (priority[a.action] ?? 50) - (priority[b.action] ?? 50)),
9607
9881
  [actions]
9608
9882
  );
@@ -9619,6 +9893,14 @@ var ApprovalActions = ({
9619
9893
  setSaveLoading(false);
9620
9894
  }
9621
9895
  };
9896
+ const executeDirect = async (action, fn) => {
9897
+ setDirectLoading(action.action);
9898
+ try {
9899
+ await fn?.();
9900
+ } finally {
9901
+ setDirectLoading(null);
9902
+ }
9903
+ };
9622
9904
  const handleAction = (action) => {
9623
9905
  if (action.action === "transfer") {
9624
9906
  onTransfer?.();
@@ -9637,9 +9919,17 @@ var ApprovalActions = ({
9637
9919
  return;
9638
9920
  }
9639
9921
  if (action.action === "rejected" || action.action === "reject") {
9922
+ if (!action.remark?.popUp) {
9923
+ void executeDirect(action, onReject);
9924
+ return;
9925
+ }
9640
9926
  openModal("reject", action);
9641
9927
  return;
9642
9928
  }
9929
+ if (!action.remark?.popUp) {
9930
+ void executeDirect(action, onApprove);
9931
+ return;
9932
+ }
9643
9933
  openModal("approve", action);
9644
9934
  };
9645
9935
  const handleConfirm = async () => {
@@ -9665,7 +9955,7 @@ var ApprovalActions = ({
9665
9955
  type: action.action === "agree" || action.action === "approved" ? "primary" : "default",
9666
9956
  danger: action.action === "rejected" || action.action === "reject" || action.action === "withdraw",
9667
9957
  onClick: () => handleAction(action),
9668
- loading: action.action === "save" && saveLoading,
9958
+ loading: action.action === "save" && saveLoading || directLoading === action.action,
9669
9959
  children: getLabel(action)
9670
9960
  },
9671
9961
  action.action
@@ -9674,7 +9964,7 @@ var ApprovalActions = ({
9674
9964
  /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
9675
9965
  "div",
9676
9966
  {
9677
- className: `${layout === "horizontal" ? "flex items-center gap-3" : "flex flex-col gap-2"} ${className}`,
9967
+ className: `${layout === "horizontal" ? "flex items-center justify-center gap-3" : "flex flex-col items-center gap-2"} ${className}`,
9678
9968
  children: [
9679
9969
  visibleButtons.map(button),
9680
9970
  moreButtons.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
@@ -9711,7 +10001,7 @@ var ApprovalActions = ({
9711
10001
  setActiveAction(null);
9712
10002
  form.resetFields();
9713
10003
  },
9714
- destroyOnClose: true,
10004
+ destroyOnHidden: true,
9715
10005
  children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_antd26.Form, { form, layout: "vertical", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
9716
10006
  import_antd26.Form.Item,
9717
10007
  {
@@ -9732,7 +10022,7 @@ var ApprovalActions = ({
9732
10022
  };
9733
10023
 
9734
10024
  // src/modules/FormActionBar.tsx
9735
- var import_react60 = require("react");
10025
+ var import_react62 = require("react");
9736
10026
  var import_antd27 = require("antd");
9737
10027
  var import_jsx_runtime84 = require("react/jsx-runtime");
9738
10028
  var FormActionBar = ({
@@ -9740,7 +10030,7 @@ var FormActionBar = ({
9740
10030
  position = "bottom-fixed",
9741
10031
  className = ""
9742
10032
  }) => {
9743
- const [loadingKeys, setLoadingKeys] = (0, import_react60.useState)(/* @__PURE__ */ new Set());
10033
+ const [loadingKeys, setLoadingKeys] = (0, import_react62.useState)(/* @__PURE__ */ new Set());
9744
10034
  const visibleActions = actions.filter((a) => a.visible !== false);
9745
10035
  const sortedActions = [...visibleActions].sort((a, b) => {
9746
10036
  if (a.type === "danger" && b.type !== "danger") return -1;
@@ -10023,7 +10313,7 @@ var ProcessPreview = ({
10023
10313
  };
10024
10314
 
10025
10315
  // src/modules/DataManagementList.tsx
10026
- var import_react61 = require("react");
10316
+ var import_react63 = require("react");
10027
10317
  var import_antd32 = require("antd");
10028
10318
  var import_dayjs5 = __toESM(require("dayjs"));
10029
10319
  var import_icons11 = require("@ant-design/icons");
@@ -10347,7 +10637,7 @@ function ResizableColumnTitle({
10347
10637
  onResize,
10348
10638
  onResizeEnd
10349
10639
  }) {
10350
- const dragRef = (0, import_react61.useRef)({ startX: 0, startWidth: width, latestWidth: width });
10640
+ const dragRef = (0, import_react63.useRef)({ startX: 0, startWidth: width, latestWidth: width });
10351
10641
  const handleMouseDown = (event) => {
10352
10642
  event.preventDefault();
10353
10643
  event.stopPropagation();
@@ -10408,71 +10698,71 @@ var DataManagementList = ({
10408
10698
  requestOverride,
10409
10699
  rowActions = []
10410
10700
  }) => {
10411
- const rootRef = (0, import_react61.useRef)(null);
10412
- const api = (0, import_react61.useMemo)(() => {
10701
+ const rootRef = (0, import_react63.useRef)(null);
10702
+ const api = (0, import_react63.useMemo)(() => {
10413
10703
  if (typeof requestOverride === "function") {
10414
10704
  return createFormRuntimeApi({ request: requestOverride });
10415
10705
  }
10416
10706
  return createFormRuntimeApi(requestOverride);
10417
10707
  }, [requestOverride]);
10418
- const [fields, setFields] = (0, import_react61.useState)([]);
10419
- const [config, setConfig] = (0, import_react61.useState)({});
10420
- const [formType, setFormType] = (0, import_react61.useState)("form");
10421
- const [showFields, setShowFields] = (0, import_react61.useState)([]);
10422
- const [lockFieldIds, setLockFieldIds] = (0, import_react61.useState)([]);
10423
- const [widths, setWidths] = (0, import_react61.useState)({});
10424
- const widthsRef = (0, import_react61.useRef)({});
10425
- const [sort, setSort] = (0, import_react61.useState)([]);
10426
- const [density, setDensity] = (0, import_react61.useState)("middle");
10427
- const [detailOpenMode, setDetailOpenMode] = (0, import_react61.useState)("drawer");
10428
- const [searchKeyWord, setSearchKeyWord] = (0, import_react61.useState)("");
10429
- const [filterGroup, setFilterGroup] = (0, import_react61.useState)(createGroup);
10430
- const [dataSource, setDataSource] = (0, import_react61.useState)([]);
10431
- const [total, setTotal] = (0, import_react61.useState)(0);
10432
- const [current, setCurrent] = (0, import_react61.useState)(1);
10433
- const [pageSize, setPageSize] = (0, import_react61.useState)(10);
10434
- const [loading, setLoading] = (0, import_react61.useState)(false);
10435
- const [schemaLoading, setSchemaLoading] = (0, import_react61.useState)(true);
10436
- const [selectedRowKeys, setSelectedRowKeys] = (0, import_react61.useState)([]);
10437
- const [filterOpen, setFilterOpen] = (0, import_react61.useState)(false);
10438
- const [columnOpen, setColumnOpen] = (0, import_react61.useState)(false);
10439
- const [exportOpen, setExportOpen] = (0, import_react61.useState)(false);
10440
- const [exportScope, setExportScope] = (0, import_react61.useState)("all");
10441
- const [exportFields, setExportFields] = (0, import_react61.useState)([]);
10442
- const [exporting, setExporting] = (0, import_react61.useState)(false);
10443
- const [importOpen, setImportOpen] = (0, import_react61.useState)(false);
10444
- const [importPreview, setImportPreview] = (0, import_react61.useState)([]);
10445
- const [importBase64, setImportBase64] = (0, import_react61.useState)("");
10446
- const [templateDownloading, setTemplateDownloading] = (0, import_react61.useState)(false);
10447
- const [recordsOpen, setRecordsOpen] = (0, import_react61.useState)(false);
10448
- const [recordTab, setRecordTab] = (0, import_react61.useState)("export");
10449
- const [transferRecords, setTransferRecords] = (0, import_react61.useState)([]);
10450
- const [batchApprovalOpen, setBatchApprovalOpen] = (0, import_react61.useState)(false);
10451
- const [batchApprovalAction, setBatchApprovalAction] = (0, import_react61.useState)(
10708
+ const [fields, setFields] = (0, import_react63.useState)([]);
10709
+ const [config, setConfig] = (0, import_react63.useState)({});
10710
+ const [formType, setFormType] = (0, import_react63.useState)("form");
10711
+ const [showFields, setShowFields] = (0, import_react63.useState)([]);
10712
+ const [lockFieldIds, setLockFieldIds] = (0, import_react63.useState)([]);
10713
+ const [widths, setWidths] = (0, import_react63.useState)({});
10714
+ const widthsRef = (0, import_react63.useRef)({});
10715
+ const [sort, setSort] = (0, import_react63.useState)([]);
10716
+ const [density, setDensity] = (0, import_react63.useState)("middle");
10717
+ const [detailOpenMode, setDetailOpenMode] = (0, import_react63.useState)("drawer");
10718
+ const [searchKeyWord, setSearchKeyWord] = (0, import_react63.useState)("");
10719
+ const [filterGroup, setFilterGroup] = (0, import_react63.useState)(createGroup);
10720
+ const [dataSource, setDataSource] = (0, import_react63.useState)([]);
10721
+ const [total, setTotal] = (0, import_react63.useState)(0);
10722
+ const [current, setCurrent] = (0, import_react63.useState)(1);
10723
+ const [pageSize, setPageSize] = (0, import_react63.useState)(10);
10724
+ const [loading, setLoading] = (0, import_react63.useState)(false);
10725
+ const [schemaLoading, setSchemaLoading] = (0, import_react63.useState)(true);
10726
+ const [selectedRowKeys, setSelectedRowKeys] = (0, import_react63.useState)([]);
10727
+ const [filterOpen, setFilterOpen] = (0, import_react63.useState)(false);
10728
+ const [columnOpen, setColumnOpen] = (0, import_react63.useState)(false);
10729
+ const [exportOpen, setExportOpen] = (0, import_react63.useState)(false);
10730
+ const [exportScope, setExportScope] = (0, import_react63.useState)("all");
10731
+ const [exportFields, setExportFields] = (0, import_react63.useState)([]);
10732
+ const [exporting, setExporting] = (0, import_react63.useState)(false);
10733
+ const [importOpen, setImportOpen] = (0, import_react63.useState)(false);
10734
+ const [importPreview, setImportPreview] = (0, import_react63.useState)([]);
10735
+ const [importBase64, setImportBase64] = (0, import_react63.useState)("");
10736
+ const [templateDownloading, setTemplateDownloading] = (0, import_react63.useState)(false);
10737
+ const [recordsOpen, setRecordsOpen] = (0, import_react63.useState)(false);
10738
+ const [recordTab, setRecordTab] = (0, import_react63.useState)("export");
10739
+ const [transferRecords, setTransferRecords] = (0, import_react63.useState)([]);
10740
+ const [batchApprovalOpen, setBatchApprovalOpen] = (0, import_react63.useState)(false);
10741
+ const [batchApprovalAction, setBatchApprovalAction] = (0, import_react63.useState)(
10452
10742
  "approved"
10453
10743
  );
10454
- const [batchApprovalComments, setBatchApprovalComments] = (0, import_react61.useState)("");
10455
- const [batchApproving, setBatchApproving] = (0, import_react61.useState)(false);
10456
- const [activeRecord, setActiveRecord] = (0, import_react61.useState)(null);
10457
- const [detailOpen, setDetailOpen] = (0, import_react61.useState)(false);
10458
- const [submitOpen, setSubmitOpen] = (0, import_react61.useState)(false);
10459
- const fetchStateRef = (0, import_react61.useRef)({});
10744
+ const [batchApprovalComments, setBatchApprovalComments] = (0, import_react63.useState)("");
10745
+ const [batchApproving, setBatchApproving] = (0, import_react63.useState)(false);
10746
+ const [activeRecord, setActiveRecord] = (0, import_react63.useState)(null);
10747
+ const [detailOpen, setDetailOpen] = (0, import_react63.useState)(false);
10748
+ const [submitOpen, setSubmitOpen] = (0, import_react63.useState)(false);
10749
+ const fetchStateRef = (0, import_react63.useRef)({});
10460
10750
  const request = api.request;
10461
- const getPopupContainer = (0, import_react61.useCallback)(
10751
+ const getPopupContainer = (0, import_react63.useCallback)(
10462
10752
  (triggerNode) => rootRef.current || triggerNode?.ownerDocument?.body || (typeof document !== "undefined" ? document.body : triggerNode?.parentElement),
10463
10753
  []
10464
10754
  );
10465
- const confirmDanger = (0, import_react61.useCallback)((title2, content, onOk) => {
10755
+ const confirmDanger = (0, import_react63.useCallback)((title2, content, onOk) => {
10466
10756
  if (confirmAction(title2, content)) onOk();
10467
10757
  }, []);
10468
- const visibleFields = (0, import_react61.useMemo)(
10758
+ const visibleFields = (0, import_react63.useMemo)(
10469
10759
  () => showFields.map((fieldId) => fields.find((field) => field.fieldId === fieldId)).filter(Boolean),
10470
10760
  [fields, showFields]
10471
10761
  );
10472
- (0, import_react61.useEffect)(() => {
10762
+ (0, import_react63.useEffect)(() => {
10473
10763
  widthsRef.current = widths;
10474
10764
  }, [widths]);
10475
- (0, import_react61.useEffect)(() => {
10765
+ (0, import_react63.useEffect)(() => {
10476
10766
  fetchStateRef.current = {
10477
10767
  current,
10478
10768
  pageSize,
@@ -10481,7 +10771,7 @@ var DataManagementList = ({
10481
10771
  sort
10482
10772
  };
10483
10773
  }, [current, filterGroup, pageSize, searchKeyWord, sort]);
10484
- const loadData = (0, import_react61.useCallback)(
10774
+ const loadData = (0, import_react63.useCallback)(
10485
10775
  async (overrides = {}) => {
10486
10776
  if (!appType || !formUuid) return;
10487
10777
  const fetchState = { ...fetchStateRef.current, ...overrides };
@@ -10516,7 +10806,7 @@ var DataManagementList = ({
10516
10806
  },
10517
10807
  [appType, formUuid, request]
10518
10808
  );
10519
- (0, import_react61.useEffect)(() => {
10809
+ (0, import_react63.useEffect)(() => {
10520
10810
  let mounted = true;
10521
10811
  const loadSchemaAndConfig = async () => {
10522
10812
  if (!appType || !formUuid) return;
@@ -10572,7 +10862,7 @@ var DataManagementList = ({
10572
10862
  mounted = false;
10573
10863
  };
10574
10864
  }, [appType, configScope, formUuid, loadData, menuFormUuid, request]);
10575
- const persistConfig = (0, import_react61.useCallback)(
10865
+ const persistConfig = (0, import_react63.useCallback)(
10576
10866
  async (patch) => {
10577
10867
  const nextConfig = { ...config, ...patch };
10578
10868
  setConfig(nextConfig);
@@ -10615,12 +10905,12 @@ var DataManagementList = ({
10615
10905
  const handleRemoveSort = (index) => {
10616
10906
  setSort((prev) => prev.filter((_, itemIndex) => itemIndex !== index));
10617
10907
  };
10618
- const updateColumnWidth = (0, import_react61.useCallback)((fieldId, width) => {
10908
+ const updateColumnWidth = (0, import_react63.useCallback)((fieldId, width) => {
10619
10909
  const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
10620
10910
  widthsRef.current = { ...widthsRef.current, [fieldId]: nextWidth };
10621
10911
  setWidths(widthsRef.current);
10622
10912
  }, []);
10623
- const commitColumnWidth = (0, import_react61.useCallback)(
10913
+ const commitColumnWidth = (0, import_react63.useCallback)(
10624
10914
  (fieldId, width) => {
10625
10915
  const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
10626
10916
  const nextWidths = { ...widthsRef.current, [fieldId]: nextWidth };
@@ -10630,7 +10920,7 @@ var DataManagementList = ({
10630
10920
  },
10631
10921
  [persistConfig]
10632
10922
  );
10633
- const handleDetail = (0, import_react61.useCallback)(
10923
+ const handleDetail = (0, import_react63.useCallback)(
10634
10924
  (record) => {
10635
10925
  const formInstanceId = getRecordId(record);
10636
10926
  if (!formInstanceId) {
@@ -10655,7 +10945,7 @@ var DataManagementList = ({
10655
10945
  },
10656
10946
  [appType, detailBasePath, detailOpenMode, detailPageUrlBuilder, formType, formUuid]
10657
10947
  );
10658
- const handleDelete = (0, import_react61.useCallback)(
10948
+ const handleDelete = (0, import_react63.useCallback)(
10659
10949
  async (ids) => {
10660
10950
  if (ids.length === 0) return;
10661
10951
  await deleteDataManagementRows(request, { appType, formUuid, formInstanceIds: ids });
@@ -10664,7 +10954,7 @@ var DataManagementList = ({
10664
10954
  },
10665
10955
  [appType, current, formUuid, loadData, pageSize, request]
10666
10956
  );
10667
- const getSelectedRecordIds = (0, import_react61.useCallback)(
10957
+ const getSelectedRecordIds = (0, import_react63.useCallback)(
10668
10958
  () => selectedRowKeys.map((key) => {
10669
10959
  const record = dataSource.find((item) => String(getRecordId(item)) === String(key));
10670
10960
  return String(getSelectedRecordId(record, key));
@@ -10781,7 +11071,7 @@ var DataManagementList = ({
10781
11071
  setImportBase64("");
10782
11072
  await loadData({ current: 1, pageSize });
10783
11073
  };
10784
- const columns = (0, import_react61.useMemo)(() => {
11074
+ const columns = (0, import_react63.useMemo)(() => {
10785
11075
  const baseColumns = visibleFields.map((field) => {
10786
11076
  const columnWidth = widths[field.fieldId] || field.width || 160;
10787
11077
  return {
@@ -10872,7 +11162,7 @@ var DataManagementList = ({
10872
11162
  900,
10873
11163
  visibleFields.reduce((sum, field) => sum + (widths[field.fieldId] || field.width || 160), 136)
10874
11164
  );
10875
- const importPreviewColumns = (0, import_react61.useMemo)(() => {
11165
+ const importPreviewColumns = (0, import_react63.useMemo)(() => {
10876
11166
  const keys = Array.from(
10877
11167
  new Set(importPreview.flatMap((record) => Object.keys(record || {})))
10878
11168
  ).slice(0, 16);
@@ -11397,7 +11687,7 @@ var DataManagementList = ({
11397
11687
  };
11398
11688
 
11399
11689
  // src/templates/FormSubmitTemplate.tsx
11400
- var import_react62 = require("react");
11690
+ var import_react64 = require("react");
11401
11691
  var import_antd33 = require("antd");
11402
11692
  var import_icons12 = require("@ant-design/icons");
11403
11693
  var import_jsx_runtime90 = require("react/jsx-runtime");
@@ -11462,14 +11752,14 @@ var InnerFormContent = ({
11462
11752
  inDrawer = false
11463
11753
  }) => {
11464
11754
  const { validateAll, getFormData: getFormData2, setFieldValue, resetForm, api } = useFormContext();
11465
- const [submitted, setSubmitted] = (0, import_react62.useState)(false);
11466
- const [successInfo, setSuccessInfo] = (0, import_react62.useState)(null);
11467
- const [submitting, setSubmitting] = (0, import_react62.useState)(false);
11468
- const [departmentId, setDepartmentId] = (0, import_react62.useState)();
11469
- const [previewOpen, setPreviewOpen] = (0, import_react62.useState)(false);
11470
- const [previewLoading, setPreviewLoading] = (0, import_react62.useState)(false);
11471
- const [previewRoutes, setPreviewRoutes] = (0, import_react62.useState)([]);
11472
- const [pendingFormData, setPendingFormData] = (0, import_react62.useState)(null);
11755
+ const [submitted, setSubmitted] = (0, import_react64.useState)(false);
11756
+ const [successInfo, setSuccessInfo] = (0, import_react64.useState)(null);
11757
+ const [submitting, setSubmitting] = (0, import_react64.useState)(false);
11758
+ const [departmentId, setDepartmentId] = (0, import_react64.useState)();
11759
+ const [previewOpen, setPreviewOpen] = (0, import_react64.useState)(false);
11760
+ const [previewLoading, setPreviewLoading] = (0, import_react64.useState)(false);
11761
+ const [previewRoutes, setPreviewRoutes] = (0, import_react64.useState)([]);
11762
+ const [pendingFormData, setPendingFormData] = (0, import_react64.useState)(null);
11473
11763
  const { hasDraft, draftTimestamp, saveDraft, restoreDraft, clearDraft } = useDraftStorage({
11474
11764
  appType: config.appType,
11475
11765
  formUuid: config.formUuid
@@ -11481,7 +11771,7 @@ var InnerFormContent = ({
11481
11771
  mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
11482
11772
  basePath: config.navigation?.basePath
11483
11773
  });
11484
- const performSubmit = (0, import_react62.useCallback)(
11774
+ const performSubmit = (0, import_react64.useCallback)(
11485
11775
  async (formData) => {
11486
11776
  setSubmitting(true);
11487
11777
  try {
@@ -11534,7 +11824,7 @@ var InnerFormContent = ({
11534
11824
  submitSuccessMode
11535
11825
  ]
11536
11826
  );
11537
- const prepareSubmit = (0, import_react62.useCallback)(async () => {
11827
+ const prepareSubmit = (0, import_react64.useCallback)(async () => {
11538
11828
  const valid = await validateAll();
11539
11829
  if (!valid) return;
11540
11830
  const formData = getFormData2();
@@ -11575,29 +11865,29 @@ var InnerFormContent = ({
11575
11865
  departmentId,
11576
11866
  performSubmit
11577
11867
  ]);
11578
- const handlePreviewConfirm = (0, import_react62.useCallback)(async () => {
11868
+ const handlePreviewConfirm = (0, import_react64.useCallback)(async () => {
11579
11869
  const data = pendingFormData ?? getFormData2();
11580
11870
  setPreviewOpen(false);
11581
11871
  setPendingFormData(null);
11582
11872
  await performSubmit(data);
11583
11873
  }, [getFormData2, pendingFormData, performSubmit]);
11584
- const handleSaveDraft = (0, import_react62.useCallback)(() => {
11874
+ const handleSaveDraft = (0, import_react64.useCallback)(() => {
11585
11875
  const data = getFormData2();
11586
11876
  saveDraft(data);
11587
11877
  }, [getFormData2, saveDraft]);
11588
- const handleRestoreDraft = (0, import_react62.useCallback)(() => {
11878
+ const handleRestoreDraft = (0, import_react64.useCallback)(() => {
11589
11879
  const data = restoreDraft();
11590
11880
  if (!data) return;
11591
11881
  Object.entries(data).forEach(([fieldId, value]) => {
11592
11882
  setFieldValue(fieldId, value);
11593
11883
  });
11594
11884
  }, [restoreDraft, setFieldValue]);
11595
- const handleContinue = (0, import_react62.useCallback)(() => {
11885
+ const handleContinue = (0, import_react64.useCallback)(() => {
11596
11886
  setSubmitted(false);
11597
11887
  setSuccessInfo(null);
11598
11888
  resetForm();
11599
11889
  }, [resetForm]);
11600
- const handleViewDetail = (0, import_react62.useCallback)(() => {
11890
+ const handleViewDetail = (0, import_react64.useCallback)(() => {
11601
11891
  if (!successInfo) return;
11602
11892
  if (formType === "process") {
11603
11893
  navigateToProcessDetail(successInfo.formInstanceId);
@@ -11756,7 +12046,7 @@ var FormSubmitTemplate = ({
11756
12046
  };
11757
12047
 
11758
12048
  // src/templates/FormDetailTemplate.tsx
11759
- var import_react63 = require("react");
12049
+ var import_react65 = require("react");
11760
12050
  var import_dayjs6 = __toESM(require("dayjs"));
11761
12051
 
11762
12052
  // src/templates/PageSkeleton.tsx
@@ -11850,9 +12140,9 @@ var InnerDetailContent = ({
11850
12140
  onSave,
11851
12141
  inDrawer = false
11852
12142
  }) => {
11853
- const formDataRef = (0, import_react63.useRef)(void 0);
11854
- const [accessDenied, setAccessDenied] = (0, import_react63.useState)(false);
11855
- const fieldIds = (0, import_react63.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
12143
+ const formDataRef = (0, import_react65.useRef)(void 0);
12144
+ const [accessDenied, setAccessDenied] = (0, import_react65.useState)(false);
12145
+ const fieldIds = (0, import_react65.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
11856
12146
  const {
11857
12147
  loading,
11858
12148
  mode,
@@ -11887,7 +12177,7 @@ var InnerDetailContent = ({
11887
12177
  formInstanceId,
11888
12178
  autoLoad: enableChangeRecords && canViewChangeRecords
11889
12179
  });
11890
- const handleSave = (0, import_react63.useCallback)(async () => {
12180
+ const handleSave = (0, import_react65.useCallback)(async () => {
11891
12181
  const values = formDataRef.current?.() ?? formData;
11892
12182
  if (!values) return;
11893
12183
  const success = await saveChanges(values);
@@ -11895,13 +12185,13 @@ var InnerDetailContent = ({
11895
12185
  onSave?.(values);
11896
12186
  }
11897
12187
  }, [formData, saveChanges, onSave]);
11898
- const handleDelete = (0, import_react63.useCallback)(async () => {
12188
+ const handleDelete = (0, import_react65.useCallback)(async () => {
11899
12189
  const success = await deleteInstance();
11900
12190
  if (success) {
11901
12191
  onDelete?.();
11902
12192
  }
11903
12193
  }, [deleteInstance, onDelete]);
11904
- const handleCancel = (0, import_react63.useCallback)(() => {
12194
+ const handleCancel = (0, import_react65.useCallback)(() => {
11905
12195
  switchToReadonly();
11906
12196
  }, [switchToReadonly]);
11907
12197
  const readonlyActions = [];
@@ -12012,13 +12302,16 @@ var FormDetailTemplate = (props) => {
12012
12302
  };
12013
12303
 
12014
12304
  // src/templates/ProcessDetailTemplate.tsx
12015
- var import_react64 = require("react");
12305
+ var import_react66 = require("react");
12306
+ var import_antd35 = require("antd");
12016
12307
  var import_jsx_runtime93 = require("react/jsx-runtime");
12017
12308
  function FormDataBridge2({
12018
- formDataRef
12309
+ formDataRef,
12310
+ validateRef
12019
12311
  }) {
12020
- const { getFormData: getFormData2 } = useFormContext();
12312
+ const { getFormData: getFormData2, validateAll } = useFormContext();
12021
12313
  formDataRef.current = getFormData2;
12314
+ validateRef.current = validateAll;
12022
12315
  return null;
12023
12316
  }
12024
12317
  var InnerProcessContent = ({
@@ -12026,19 +12319,32 @@ var InnerProcessContent = ({
12026
12319
  formUuid,
12027
12320
  appType,
12028
12321
  formInstanceId,
12322
+ enableEdit = true,
12323
+ enableDelete = true,
12324
+ enableChangeRecords = true,
12325
+ showApproverInfo = true,
12029
12326
  header,
12030
12327
  renderTimeline,
12031
12328
  renderActions,
12329
+ renderFooterActions,
12032
12330
  renderTransferSelector,
12033
12331
  renderReturnNodeLabel,
12034
12332
  renderActionModalExtra,
12035
12333
  beforeForm,
12036
12334
  afterForm,
12037
12335
  onActionComplete,
12336
+ onSave,
12337
+ onDelete,
12038
12338
  inDrawer = false
12039
12339
  }) => {
12040
- const formDataRef = (0, import_react64.useRef)(void 0);
12041
- const fieldIds = (0, import_react64.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
12340
+ const formDataRef = (0, import_react66.useRef)(void 0);
12341
+ const validateRef = (0, import_react66.useRef)(void 0);
12342
+ const [withdrawForm] = import_antd35.Form.useForm();
12343
+ const [withdrawOpen, setWithdrawOpen] = (0, import_react66.useState)(false);
12344
+ const [withdrawLoading, setWithdrawLoading] = (0, import_react66.useState)(false);
12345
+ const [saveLoading, setSaveLoading] = (0, import_react66.useState)(false);
12346
+ const [deleteLoading, setDeleteLoading] = (0, import_react66.useState)(false);
12347
+ const fieldIds = (0, import_react66.useMemo)(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
12042
12348
  const {
12043
12349
  loading,
12044
12350
  processInfo,
@@ -12047,15 +12353,25 @@ var InnerProcessContent = ({
12047
12353
  progressList,
12048
12354
  formData,
12049
12355
  instanceInfo,
12356
+ accessDenied,
12357
+ loadError,
12050
12358
  isApprover,
12051
12359
  activeActions,
12052
12360
  fieldBehaviors,
12053
12361
  mode,
12054
12362
  isOriginatorReturn,
12363
+ isProcessCompleted,
12055
12364
  canWithdraw,
12365
+ canEdit,
12366
+ canDelete,
12367
+ canViewWorkflow,
12368
+ canViewChangeRecords,
12369
+ dataVersion,
12056
12370
  switchToEdit,
12057
12371
  switchToReadonly,
12058
- refreshProgress
12372
+ saveChanges,
12373
+ deleteInstance,
12374
+ refreshDetail
12059
12375
  } = useProcessDetail({ formUuid, appType, formInstanceId, fieldIds });
12060
12376
  const {
12061
12377
  approve,
@@ -12067,6 +12383,7 @@ var InnerProcessContent = ({
12067
12383
  resubmit,
12068
12384
  callbackTask,
12069
12385
  returnableNodes,
12386
+ returnPolicy,
12070
12387
  loadReturnableNodes
12071
12388
  } = useApprovalActions({
12072
12389
  formInstanceId,
@@ -12074,58 +12391,158 @@ var InnerProcessContent = ({
12074
12391
  appType,
12075
12392
  currentTaskId: currentTask?.taskId ?? currentTask?.id,
12076
12393
  onActionComplete: async (action) => {
12077
- onActionComplete?.(action);
12078
- await refreshProgress();
12394
+ await onActionComplete?.(action);
12395
+ await refreshDetail();
12079
12396
  },
12080
12397
  getFormValues: () => formDataRef.current?.() ?? formData ?? {}
12081
12398
  });
12082
- const handleApprove = (0, import_react64.useCallback)(
12399
+ const {
12400
+ records,
12401
+ loading: recordsLoading,
12402
+ total: recordsTotal,
12403
+ page: recordsPage,
12404
+ hasMore,
12405
+ loadMore,
12406
+ refresh: refreshRecords
12407
+ } = useChangeRecords({
12408
+ formUuid,
12409
+ appType,
12410
+ formInstanceId,
12411
+ autoLoad: enableChangeRecords && canViewChangeRecords
12412
+ });
12413
+ const validateForm = (0, import_react66.useCallback)(async () => {
12414
+ return validateRef.current ? validateRef.current() : true;
12415
+ }, []);
12416
+ const handleApprove = (0, import_react66.useCallback)(
12083
12417
  async (comments) => {
12418
+ if (!await validateForm()) return;
12084
12419
  await approve(comments);
12085
12420
  },
12086
- [approve]
12421
+ [approve, validateForm]
12087
12422
  );
12088
- const handleReject = (0, import_react64.useCallback)(
12423
+ const handleReject = (0, import_react66.useCallback)(
12089
12424
  async (comments) => {
12090
12425
  await reject(comments);
12091
12426
  },
12092
12427
  [reject]
12093
12428
  );
12094
- const handleTransfer = (0, import_react64.useCallback)(
12429
+ const handleTransfer = (0, import_react66.useCallback)(
12095
12430
  async (userId, reason) => {
12096
12431
  await transfer(userId, reason);
12097
12432
  },
12098
12433
  [transfer]
12099
12434
  );
12100
- const handleReturn = (0, import_react64.useCallback)(
12435
+ const handleReturn = (0, import_react66.useCallback)(
12101
12436
  async (nodeId, reason) => {
12102
12437
  await returnTo(nodeId, reason);
12103
12438
  },
12104
12439
  [returnTo]
12105
12440
  );
12106
- const handleWithdraw = (0, import_react64.useCallback)(
12441
+ const handleWithdraw = (0, import_react66.useCallback)(
12107
12442
  async (reason) => {
12108
12443
  await withdraw(reason);
12109
12444
  },
12110
12445
  [withdraw]
12111
12446
  );
12112
- const handleSave = (0, import_react64.useCallback)(async () => {
12447
+ const handleSave = (0, import_react66.useCallback)(async () => {
12448
+ if (!await validateForm()) return;
12113
12449
  await save();
12114
- }, [save]);
12115
- const handleResubmit = (0, import_react64.useCallback)(
12450
+ }, [save, validateForm]);
12451
+ const handleResubmit = (0, import_react66.useCallback)(
12116
12452
  async (comments) => {
12453
+ if (!await validateForm()) return;
12117
12454
  await resubmit(comments);
12118
12455
  },
12119
- [resubmit]
12456
+ [resubmit, validateForm]
12120
12457
  );
12121
- const handleCallback = (0, import_react64.useCallback)(async () => {
12458
+ const handleCallback = (0, import_react66.useCallback)(async () => {
12122
12459
  await callbackTask();
12123
12460
  }, [callbackTask]);
12124
- const bottomActions = (0, import_react64.useMemo)(() => {
12125
- if (isApprover && activeActions.length > 0) return [];
12461
+ const handleCompletedSave = (0, import_react66.useCallback)(async () => {
12462
+ if (!await validateForm()) return;
12463
+ const values = formDataRef.current?.() ?? formData;
12464
+ if (!values) return;
12465
+ setSaveLoading(true);
12466
+ try {
12467
+ const success = await saveChanges(values);
12468
+ if (success) {
12469
+ await onSave?.(values);
12470
+ }
12471
+ } finally {
12472
+ setSaveLoading(false);
12473
+ }
12474
+ }, [formData, onSave, saveChanges, validateForm]);
12475
+ const handleCompletedDelete = (0, import_react66.useCallback)(async () => {
12476
+ setDeleteLoading(true);
12477
+ try {
12478
+ const success = await deleteInstance();
12479
+ if (success) {
12480
+ await onDelete?.();
12481
+ }
12482
+ } finally {
12483
+ setDeleteLoading(false);
12484
+ }
12485
+ }, [deleteInstance, onDelete]);
12486
+ const handleFooterWithdraw = (0, import_react66.useCallback)(async () => {
12487
+ const values = await withdrawForm.validateFields();
12488
+ setWithdrawLoading(true);
12489
+ try {
12490
+ await handleWithdraw(values.reason || void 0);
12491
+ setWithdrawOpen(false);
12492
+ withdrawForm.resetFields();
12493
+ } finally {
12494
+ setWithdrawLoading(false);
12495
+ }
12496
+ }, [handleWithdraw, withdrawForm]);
12497
+ const handleFooterWithdrawCancel = (0, import_react66.useCallback)(() => {
12498
+ setWithdrawOpen(false);
12499
+ withdrawForm.resetFields();
12500
+ }, [withdrawForm]);
12501
+ const bottomActions = (0, import_react66.useMemo)(() => {
12502
+ if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
12503
+ if (isProcessCompleted) {
12504
+ if (mode === "readonly") {
12505
+ const actions = [];
12506
+ if (enableEdit && canEdit) {
12507
+ actions.push({
12508
+ key: "edit",
12509
+ label: "\u7F16\u8F91",
12510
+ type: "primary",
12511
+ onClick: switchToEdit
12512
+ });
12513
+ }
12514
+ if (enableDelete && canDelete) {
12515
+ actions.push({
12516
+ key: "delete",
12517
+ label: "\u5220\u9664",
12518
+ type: "danger",
12519
+ loading: deleteLoading,
12520
+ onClick: handleCompletedDelete,
12521
+ confirm: { title: "\u786E\u8BA4\u5220\u9664", content: "\u5220\u9664\u540E\u5C06\u65E0\u6CD5\u6062\u590D\uFF0C\u786E\u8BA4\u8981\u5220\u9664\u5417\uFF1F" }
12522
+ });
12523
+ }
12524
+ return actions;
12525
+ }
12526
+ return [
12527
+ {
12528
+ key: "cancel",
12529
+ label: "\u53D6\u6D88",
12530
+ type: "default",
12531
+ onClick: switchToReadonly,
12532
+ placement: "left"
12533
+ },
12534
+ {
12535
+ key: "save",
12536
+ label: "\u4FDD\u5B58",
12537
+ type: "primary",
12538
+ loading: saveLoading,
12539
+ onClick: handleCompletedSave
12540
+ }
12541
+ ];
12542
+ }
12126
12543
  if (isOriginatorReturn) {
12127
12544
  if (mode === "readonly") {
12128
- return [
12545
+ const actions2 = [
12129
12546
  {
12130
12547
  key: "edit",
12131
12548
  label: "\u7F16\u8F91",
@@ -12133,8 +12550,23 @@ var InnerProcessContent = ({
12133
12550
  onClick: switchToEdit
12134
12551
  }
12135
12552
  ];
12553
+ actions2.push({
12554
+ key: "resubmit",
12555
+ label: "\u91CD\u65B0\u63D0\u4EA4",
12556
+ type: "default",
12557
+ onClick: () => handleResubmit()
12558
+ });
12559
+ if (canWithdraw) {
12560
+ actions2.push({
12561
+ key: "withdraw",
12562
+ label: "\u64A4\u9500",
12563
+ type: "danger",
12564
+ onClick: () => setWithdrawOpen(true)
12565
+ });
12566
+ }
12567
+ return actions2;
12136
12568
  }
12137
- return [
12569
+ const actions = [
12138
12570
  {
12139
12571
  key: "cancel",
12140
12572
  label: "\u53D6\u6D88",
@@ -12149,6 +12581,15 @@ var InnerProcessContent = ({
12149
12581
  onClick: () => handleResubmit()
12150
12582
  }
12151
12583
  ];
12584
+ if (canWithdraw) {
12585
+ actions.push({
12586
+ key: "withdraw",
12587
+ label: "\u64A4\u9500",
12588
+ type: "danger",
12589
+ onClick: () => setWithdrawOpen(true)
12590
+ });
12591
+ }
12592
+ return actions;
12152
12593
  }
12153
12594
  if (canWithdraw) {
12154
12595
  return [
@@ -12156,22 +12597,31 @@ var InnerProcessContent = ({
12156
12597
  key: "withdraw",
12157
12598
  label: "\u64A4\u9500",
12158
12599
  type: "danger",
12159
- onClick: () => handleWithdraw(),
12160
- confirm: { title: "\u786E\u8BA4\u64A4\u9500", content: "\u64A4\u9500\u540E\u6D41\u7A0B\u5C06\u7EC8\u6B62\uFF0C\u786E\u8BA4\u7EE7\u7EED\u5417\uFF1F" }
12600
+ loading: withdrawLoading,
12601
+ onClick: () => setWithdrawOpen(true)
12161
12602
  }
12162
12603
  ];
12163
12604
  }
12164
12605
  return [];
12165
12606
  }, [
12166
12607
  activeActions.length,
12608
+ canDelete,
12609
+ canEdit,
12167
12610
  canWithdraw,
12611
+ deleteLoading,
12612
+ enableDelete,
12613
+ enableEdit,
12614
+ handleCompletedDelete,
12615
+ handleCompletedSave,
12168
12616
  handleResubmit,
12169
- handleWithdraw,
12170
12617
  isApprover,
12171
12618
  isOriginatorReturn,
12619
+ isProcessCompleted,
12172
12620
  mode,
12621
+ saveLoading,
12173
12622
  switchToEdit,
12174
- switchToReadonly
12623
+ switchToReadonly,
12624
+ withdrawLoading
12175
12625
  ]);
12176
12626
  const formConfig = {
12177
12627
  mode: mode === "edit" ? "edit" : "readonly",
@@ -12186,7 +12636,10 @@ var InnerProcessContent = ({
12186
12636
  if (loading) {
12187
12637
  return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "min-h-screen bg-ant-bg-layout", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "mx-auto max-w-4xl px-6 py-8 pb-24", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(PageSkeleton, { type: "process" }) }) });
12188
12638
  }
12189
- const showApprovalActions = isApprover && activeActions.length > 0;
12639
+ if (accessDenied || loadError) {
12640
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(RuntimePageShell, { accessDenied, error: loadError, inDrawer, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", {}) });
12641
+ }
12642
+ const showApprovalActions = isApprover && !isOriginatorReturn && activeActions.length > 0;
12190
12643
  const actionsNode = showApprovalActions ? renderActions ? renderActions(activeActions) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
12191
12644
  ApprovalActionBar,
12192
12645
  {
@@ -12200,52 +12653,108 @@ var InnerProcessContent = ({
12200
12653
  onResubmit: handleResubmit,
12201
12654
  onCallback: handleCallback,
12202
12655
  returnableNodes,
12656
+ returnPolicy,
12203
12657
  onLoadReturnableNodes: loadReturnableNodes,
12204
12658
  renderTransferSelector,
12205
12659
  renderReturnNodeLabel,
12206
12660
  renderActionModalExtra,
12207
12661
  inDrawer
12208
12662
  }
12209
- ) : bottomActions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(StickyActionBar, { actions: bottomActions, inDrawer }) : null;
12663
+ ) : bottomActions.length > 0 ? renderFooterActions ? renderFooterActions(bottomActions) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(StickyActionBar, { actions: bottomActions, inDrawer }) : null;
12210
12664
  const statusMeta = processStatus ? PROCESS_STATUS_META[processStatus] : void 0;
12211
- return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(RuntimePageShell, { actions: actionsNode, inDrawer, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "space-y-6", children: [
12212
- header,
12665
+ return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(RuntimePageShell, { actions: actionsNode, inDrawer, children: [
12666
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "space-y-6", children: [
12667
+ header,
12668
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
12669
+ SummaryPanel,
12670
+ {
12671
+ title: processInfo?.title || instanceInfo?.title || schema.formMeta.title,
12672
+ eyebrow: `\u6D41\u7A0B\u5B9E\u4F8B ${formInstanceId?.slice(0, 8) || "-"}`,
12673
+ creator: processInfo?.originatorName ? {
12674
+ name: processInfo.originatorName,
12675
+ department: processInfo.originatorDepartment
12676
+ } : void 0,
12677
+ createdAt: processInfo?.createdAt,
12678
+ status: statusMeta,
12679
+ metaItems: [
12680
+ { key: "currentTask", label: "\u5F53\u524D\u8282\u70B9", value: currentTask?.nodeName || "\u65E0" },
12681
+ {
12682
+ key: "processStatus",
12683
+ label: "\u5B9E\u4F8B\u72B6\u6001",
12684
+ value: statusMeta?.label || processStatus || "-"
12685
+ }
12686
+ ]
12687
+ }
12688
+ ),
12689
+ beforeForm,
12690
+ mode === "edit" && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("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" }),
12691
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
12692
+ FormProvider,
12693
+ {
12694
+ schema,
12695
+ config: formConfig,
12696
+ initialValues: formData ?? void 0,
12697
+ children: [
12698
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FormDataBridge2, { formDataRef, validateRef }),
12699
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FormRenderer, { columns: 2 })
12700
+ ]
12701
+ },
12702
+ `${mode}-${dataVersion}`
12703
+ ) }),
12704
+ afterForm,
12705
+ canViewWorkflow && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: [
12706
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "mb-4 flex items-center justify-between gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { children: [
12707
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("h3", { className: "text-base font-semibold text-ant-color-text", children: "\u5BA1\u6279\u8FDB\u5EA6" }),
12708
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("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" })
12709
+ ] }) }),
12710
+ renderTimeline ? renderTimeline(progressList) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
12711
+ ApprovalTimeline,
12712
+ {
12713
+ tasks: progressList,
12714
+ showRemarks: true,
12715
+ showApproverInfo
12716
+ }
12717
+ )
12718
+ ] }),
12719
+ enableChangeRecords && canViewChangeRecords && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
12720
+ RecordChangePanel,
12721
+ {
12722
+ records,
12723
+ loading: recordsLoading,
12724
+ total: recordsTotal,
12725
+ page: recordsPage,
12726
+ hasMore,
12727
+ onLoadMore: loadMore,
12728
+ onRefresh: refreshRecords,
12729
+ onExpand: refreshRecords
12730
+ }
12731
+ )
12732
+ ] }),
12213
12733
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
12214
- SummaryPanel,
12734
+ import_antd35.Modal,
12215
12735
  {
12216
- title: processInfo?.title || instanceInfo?.title || schema.formMeta.title,
12217
- eyebrow: `\u6D41\u7A0B\u5B9E\u4F8B ${formInstanceId?.slice(0, 8) || "-"}`,
12218
- creator: processInfo?.originatorName ? {
12219
- name: processInfo.originatorName,
12220
- department: processInfo.originatorDepartment
12221
- } : void 0,
12222
- createdAt: processInfo?.createdAt,
12223
- status: statusMeta,
12224
- metaItems: [
12225
- { key: "currentTask", label: "\u5F53\u524D\u8282\u70B9", value: currentTask?.nodeName || "\u65E0" },
12736
+ getContainer: false,
12737
+ title: "\u64A4\u9500\u6D41\u7A0B",
12738
+ open: withdrawOpen,
12739
+ okText: "\u786E\u8BA4\u64A4\u9500",
12740
+ cancelText: "\u53D6\u6D88",
12741
+ confirmLoading: withdrawLoading,
12742
+ okButtonProps: { danger: true },
12743
+ onOk: handleFooterWithdraw,
12744
+ onCancel: handleFooterWithdrawCancel,
12745
+ destroyOnHidden: true,
12746
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_antd35.Form, { form: withdrawForm, layout: "vertical", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
12747
+ import_antd35.Form.Item,
12226
12748
  {
12227
- key: "processStatus",
12228
- label: "\u5B9E\u4F8B\u72B6\u6001",
12229
- value: statusMeta?.label || processStatus || "-"
12749
+ name: "reason",
12750
+ label: "\u64A4\u9500\u539F\u56E0",
12751
+ rules: [{ required: true, message: "\u8BF7\u586B\u5199\u64A4\u9500\u539F\u56E0" }],
12752
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_antd35.Input.TextArea, { rows: 4, maxLength: 500, showCount: true, placeholder: "\u8BF7\u8F93\u5165\u64A4\u9500\u539F\u56E0" })
12230
12753
  }
12231
- ]
12754
+ ) })
12232
12755
  }
12233
- ),
12234
- beforeForm,
12235
- mode === "edit" && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("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" }),
12236
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(FormProvider, { schema, config: formConfig, initialValues: formData ?? void 0, children: [
12237
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FormDataBridge2, { formDataRef }),
12238
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FormRenderer, { columns: 2 })
12239
- ] }) }),
12240
- afterForm,
12241
- /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "rounded-lg border border-ant-border-secondary bg-ant-bg-container p-5 md:p-6", children: [
12242
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "mb-4 flex items-center justify-between gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { children: [
12243
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("h3", { className: "text-base font-semibold text-ant-color-text", children: "\u5BA1\u6279\u8FDB\u5EA6" }),
12244
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("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" })
12245
- ] }) }),
12246
- renderTimeline ? renderTimeline(progressList) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ApprovalTimeline, { tasks: progressList, showRemarks: true, showApproverInfo: true })
12247
- ] })
12248
- ] }) });
12756
+ )
12757
+ ] });
12249
12758
  };
12250
12759
  var ProcessDetailTemplate = (props) => {
12251
12760
  const { schema, formUuid, appType, formInstanceId } = props;
@@ -12336,6 +12845,7 @@ var ProcessDetailTemplate = (props) => {
12336
12845
  getProcessBasic,
12337
12846
  getProcessDefinition,
12338
12847
  getProcessProgress,
12848
+ getReturnableNodeResult,
12339
12849
  getReturnableNodes,
12340
12850
  getSystemFieldsForFormType,
12341
12851
  getViewPermission,