sy-form-components 0.2.14 → 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 +704 -592
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +309 -197
- package/dist/index.mjs.map +1 -1
- package/dist/tailwind.preset.js +59 -0
- package/dist/tailwind.preset.js.map +1 -1
- package/dist/tailwind.preset.mjs +59 -0
- package/dist/tailwind.preset.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -149,7 +149,7 @@ __export(index_exports, {
|
|
|
149
149
|
module.exports = __toCommonJS(index_exports);
|
|
150
150
|
|
|
151
151
|
// src/core/FormProvider.tsx
|
|
152
|
-
var
|
|
152
|
+
var import_react40 = __toESM(require("react"));
|
|
153
153
|
|
|
154
154
|
// src/core/FormContext.ts
|
|
155
155
|
var import_react = require("react");
|
|
@@ -1503,9 +1503,10 @@ function CascadeDateField(props) {
|
|
|
1503
1503
|
}
|
|
1504
1504
|
|
|
1505
1505
|
// src/fields/AttachmentField/index.tsx
|
|
1506
|
-
var
|
|
1506
|
+
var import_react17 = require("react");
|
|
1507
1507
|
|
|
1508
1508
|
// src/fields/AttachmentField/AttachmentFieldPC.tsx
|
|
1509
|
+
var import_react16 = __toESM(require("react"));
|
|
1509
1510
|
var import_antd10 = require("antd");
|
|
1510
1511
|
|
|
1511
1512
|
// src/fields/shared/fieldFormat.ts
|
|
@@ -1612,6 +1613,31 @@ function normalizeAttachmentItem(item, fallback) {
|
|
|
1612
1613
|
extension: item?.extension || fallback?.extension || getFileExtension(name)
|
|
1613
1614
|
};
|
|
1614
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
|
+
}
|
|
1615
1641
|
|
|
1616
1642
|
// src/fields/AttachmentField/AttachmentFieldPC.tsx
|
|
1617
1643
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
@@ -1666,38 +1692,47 @@ function AttachmentFieldPC({
|
|
|
1666
1692
|
onChange
|
|
1667
1693
|
}) {
|
|
1668
1694
|
const { formData, setFieldValue, api } = useFormContext();
|
|
1669
|
-
const value =
|
|
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);
|
|
1670
1702
|
const disabled = behavior === "DISABLED";
|
|
1703
|
+
import_react16.default.useEffect(() => {
|
|
1704
|
+
valueRef.current = value;
|
|
1705
|
+
}, [value]);
|
|
1671
1706
|
const setValue = (items) => {
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
bucketName: f.bucketName ?? f.response?.bucketName,
|
|
1690
|
-
size: f.size ?? f.response?.size,
|
|
1691
|
-
contentType: f.type ?? f.response?.contentType,
|
|
1692
|
-
downloadUrl: f.downloadUrl ?? f.response?.downloadUrl,
|
|
1693
|
-
previewUrl: f.previewUrl ?? f.response?.previewUrl
|
|
1694
|
-
});
|
|
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;
|
|
1695
1724
|
});
|
|
1696
|
-
|
|
1725
|
+
if (!replaced) nextItems.push(nextItem);
|
|
1726
|
+
setValue(nextItems);
|
|
1697
1727
|
};
|
|
1698
1728
|
const handleRemove = (file) => {
|
|
1699
|
-
const
|
|
1700
|
-
const
|
|
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
|
+
);
|
|
1701
1736
|
setValue(newValue);
|
|
1702
1737
|
if (removed?.objectName) {
|
|
1703
1738
|
api.deleteFile(removed.objectName, removed.bucketName || bucketName).catch(() => void 0);
|
|
@@ -1738,7 +1773,9 @@ function AttachmentFieldPC({
|
|
|
1738
1773
|
return url;
|
|
1739
1774
|
};
|
|
1740
1775
|
const handlePreview = async (file) => {
|
|
1741
|
-
const item =
|
|
1776
|
+
const item = valueRef.current.find(
|
|
1777
|
+
(current) => current.id === file.uid || current.uid === file.uid || current.objectName === file.uid
|
|
1778
|
+
);
|
|
1742
1779
|
const url = item ? await resolvePreviewUrl(item) : file.url;
|
|
1743
1780
|
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
|
1744
1781
|
};
|
|
@@ -1746,14 +1783,10 @@ function AttachmentFieldPC({
|
|
|
1746
1783
|
const url = await resolveDownloadUrl(item);
|
|
1747
1784
|
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
|
1748
1785
|
};
|
|
1749
|
-
const fileList = value.map((item) => ({
|
|
1750
|
-
uid: item.id,
|
|
1751
|
-
name: item.name,
|
|
1752
|
-
url: item.url,
|
|
1753
|
-
status: item.status ?? "done",
|
|
1754
|
-
percent: item.percent
|
|
1755
|
-
}));
|
|
1756
1786
|
const beforeUpload = (file) => {
|
|
1787
|
+
if (maxCount && valueRef.current.length >= maxCount) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1757
1790
|
if (maxSize && file.size / 1024 / 1024 > maxSize) {
|
|
1758
1791
|
return false;
|
|
1759
1792
|
}
|
|
@@ -1766,27 +1799,26 @@ function AttachmentFieldPC({
|
|
|
1766
1799
|
const customRequest = async ({ file, onProgress, onSuccess, onError }) => {
|
|
1767
1800
|
const currentFile = file;
|
|
1768
1801
|
const localItem = createLocalItem(currentFile);
|
|
1769
|
-
const
|
|
1802
|
+
const currentValue = valueRef.current.filter(
|
|
1803
|
+
(item) => item.id !== localItem.id && item.uid !== localItem.uid
|
|
1804
|
+
);
|
|
1805
|
+
const nextValue = multiple ? [...currentValue, localItem] : [localItem];
|
|
1770
1806
|
setValue(nextValue);
|
|
1771
1807
|
try {
|
|
1772
1808
|
const uploaded = await api.uploadFile(currentFile, bucketName, (percent) => {
|
|
1773
1809
|
onProgress?.({ percent });
|
|
1774
|
-
|
|
1775
|
-
nextValue.map(
|
|
1776
|
-
(item) => item.id === localItem.id ? { ...item, percent, status: "uploading" } : item
|
|
1777
|
-
)
|
|
1778
|
-
);
|
|
1779
|
-
});
|
|
1780
|
-
const completed = normalizeAttachmentItem({
|
|
1781
|
-
...uploaded,
|
|
1782
|
-
id: uploaded.id || localItem.id,
|
|
1783
|
-
uid: uploaded.uid || localItem.uid,
|
|
1784
|
-
url: uploaded.url || localItem.url,
|
|
1785
|
-
status: "done",
|
|
1786
|
-
percent: 100,
|
|
1787
|
-
extension: uploaded.extension || getFileExtension(uploaded.name || localItem.name)
|
|
1810
|
+
replaceItem(localItem, { ...localItem, percent, status: "uploading" });
|
|
1788
1811
|
});
|
|
1789
|
-
|
|
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);
|
|
1790
1822
|
onSuccess?.(completed);
|
|
1791
1823
|
} catch (error) {
|
|
1792
1824
|
const failed = {
|
|
@@ -1794,7 +1826,7 @@ function AttachmentFieldPC({
|
|
|
1794
1826
|
status: "error",
|
|
1795
1827
|
error: error?.message || "\u4E0A\u4F20\u5931\u8D25"
|
|
1796
1828
|
};
|
|
1797
|
-
|
|
1829
|
+
replaceItem(localItem, failed);
|
|
1798
1830
|
onError?.(error);
|
|
1799
1831
|
}
|
|
1800
1832
|
};
|
|
@@ -1803,61 +1835,71 @@ function AttachmentFieldPC({
|
|
|
1803
1835
|
import_antd10.Upload,
|
|
1804
1836
|
{
|
|
1805
1837
|
"data-testid": `attachmentfield-input-${fieldId}`,
|
|
1806
|
-
fileList,
|
|
1838
|
+
fileList: [],
|
|
1807
1839
|
customRequest,
|
|
1808
1840
|
accept,
|
|
1809
1841
|
maxCount,
|
|
1810
1842
|
multiple,
|
|
1811
1843
|
disabled,
|
|
1812
|
-
|
|
1844
|
+
showUploadList: false,
|
|
1813
1845
|
onRemove: handleRemove,
|
|
1814
1846
|
onPreview: handlePreview,
|
|
1815
1847
|
beforeUpload,
|
|
1816
1848
|
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_antd10.Button, { disabled, "data-testid": `attachmentfield-upload-btn-${fieldId}`, children: "\u4E0A\u4F20\u6587\u4EF6" })
|
|
1817
1849
|
}
|
|
1818
1850
|
),
|
|
1819
|
-
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) => {
|
|
1820
1852
|
const category = getFileCategory(item.name, item.contentType);
|
|
1821
1853
|
const extension = getFileExtension(item.name);
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
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
|
+
);
|
|
1861
1903
|
}) })
|
|
1862
1904
|
] });
|
|
1863
1905
|
}
|
|
@@ -2010,7 +2052,7 @@ function AttachmentField(props) {
|
|
|
2010
2052
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
2011
2053
|
const { isMobile } = useDeviceDetect();
|
|
2012
2054
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
2013
|
-
(0,
|
|
2055
|
+
(0, import_react17.useEffect)(() => {
|
|
2014
2056
|
registerField(fieldId);
|
|
2015
2057
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
2016
2058
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -2035,9 +2077,10 @@ function AttachmentField(props) {
|
|
|
2035
2077
|
}
|
|
2036
2078
|
|
|
2037
2079
|
// src/fields/ImageField/index.tsx
|
|
2038
|
-
var
|
|
2080
|
+
var import_react19 = require("react");
|
|
2039
2081
|
|
|
2040
2082
|
// src/fields/ImageField/ImageFieldPC.tsx
|
|
2083
|
+
var import_react18 = __toESM(require("react"));
|
|
2041
2084
|
var import_antd11 = require("antd");
|
|
2042
2085
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2043
2086
|
var createLocalItem2 = (file) => {
|
|
@@ -2055,6 +2098,23 @@ var createLocalItem2 = (file) => {
|
|
|
2055
2098
|
extension: getFileExtension(file.name)
|
|
2056
2099
|
};
|
|
2057
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
|
+
}
|
|
2058
2118
|
function ImageFieldPC({
|
|
2059
2119
|
fieldId,
|
|
2060
2120
|
behavior,
|
|
@@ -2070,44 +2130,56 @@ function ImageFieldPC({
|
|
|
2070
2130
|
onChange
|
|
2071
2131
|
}) {
|
|
2072
2132
|
const { formData, setFieldValue, api } = useFormContext();
|
|
2073
|
-
const value =
|
|
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);
|
|
2074
2140
|
const disabled = behavior === "DISABLED";
|
|
2141
|
+
import_react18.default.useEffect(() => {
|
|
2142
|
+
valueRef.current = value;
|
|
2143
|
+
}, [value]);
|
|
2075
2144
|
const setValue = (items) => {
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
objectName: f.objectName ?? f.response?.objectName,
|
|
2094
|
-
bucketName: f.bucketName ?? f.response?.bucketName,
|
|
2095
|
-
size: f.size ?? f.response?.size,
|
|
2096
|
-
contentType: f.type ?? f.response?.contentType
|
|
2097
|
-
});
|
|
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;
|
|
2098
2162
|
});
|
|
2099
|
-
|
|
2163
|
+
if (!replaced) nextItems.push(nextItem);
|
|
2164
|
+
setValue(nextItems);
|
|
2100
2165
|
};
|
|
2101
2166
|
const handleRemove = (file) => {
|
|
2102
|
-
const
|
|
2103
|
-
const
|
|
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
|
+
);
|
|
2104
2174
|
setValue(newValue);
|
|
2105
2175
|
if (removed?.objectName) {
|
|
2106
2176
|
api.deleteFile(removed.objectName, removed.bucketName || bucketName).catch(() => void 0);
|
|
2107
2177
|
}
|
|
2108
2178
|
};
|
|
2109
2179
|
const handlePreview = async (file) => {
|
|
2110
|
-
const item =
|
|
2180
|
+
const item = valueRef.current.find(
|
|
2181
|
+
(current) => current.id === file.uid || current.uid === file.uid || current.objectName === file.uid
|
|
2182
|
+
);
|
|
2111
2183
|
let url = item?.previewUrl || item?.url || file.url || file.thumbUrl;
|
|
2112
2184
|
if (item?.objectName) {
|
|
2113
2185
|
const ticket = await api.createFileAccessTicket(
|
|
@@ -2120,15 +2192,22 @@ function ImageFieldPC({
|
|
|
2120
2192
|
}
|
|
2121
2193
|
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
|
2122
2194
|
};
|
|
2123
|
-
const
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
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
|
+
};
|
|
2131
2207
|
const beforeUpload = (file) => {
|
|
2208
|
+
if (maxCount && valueRef.current.length >= maxCount) {
|
|
2209
|
+
return false;
|
|
2210
|
+
}
|
|
2132
2211
|
if (!String(file.type || "").startsWith("image/") && !/\.(png|jpe?g|gif|bmp|svg|webp)$/i.test(file.name)) {
|
|
2133
2212
|
return false;
|
|
2134
2213
|
}
|
|
@@ -2140,26 +2219,27 @@ function ImageFieldPC({
|
|
|
2140
2219
|
const customRequest = async ({ file, onProgress, onSuccess, onError }) => {
|
|
2141
2220
|
const currentFile = file;
|
|
2142
2221
|
const localItem = createLocalItem2(currentFile);
|
|
2143
|
-
const
|
|
2222
|
+
const currentValue = valueRef.current.filter(
|
|
2223
|
+
(item) => item.id !== localItem.id && item.uid !== localItem.uid
|
|
2224
|
+
);
|
|
2225
|
+
const nextValue = multiple ? [...currentValue, localItem] : [localItem];
|
|
2144
2226
|
setValue(nextValue);
|
|
2145
2227
|
try {
|
|
2146
2228
|
const uploaded = await api.uploadFile(currentFile, bucketName, (percent) => {
|
|
2147
2229
|
onProgress?.({ percent });
|
|
2148
|
-
|
|
2149
|
-
nextValue.map(
|
|
2150
|
-
(item) => item.id === localItem.id ? { ...item, percent, status: "uploading" } : item
|
|
2151
|
-
)
|
|
2152
|
-
);
|
|
2153
|
-
});
|
|
2154
|
-
const completed = normalizeAttachmentItem({
|
|
2155
|
-
...uploaded,
|
|
2156
|
-
id: uploaded.id || localItem.id,
|
|
2157
|
-
uid: uploaded.uid || localItem.uid,
|
|
2158
|
-
url: uploaded.previewUrl || uploaded.url || localItem.url,
|
|
2159
|
-
status: "done",
|
|
2160
|
-
percent: 100
|
|
2230
|
+
replaceItem(localItem, { ...localItem, percent, status: "uploading" });
|
|
2161
2231
|
});
|
|
2162
|
-
|
|
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);
|
|
2163
2243
|
onSuccess?.(completed);
|
|
2164
2244
|
} catch (error) {
|
|
2165
2245
|
const failed = {
|
|
@@ -2167,7 +2247,7 @@ function ImageFieldPC({
|
|
|
2167
2247
|
status: "error",
|
|
2168
2248
|
error: error?.message || "\u4E0A\u4F20\u5931\u8D25"
|
|
2169
2249
|
};
|
|
2170
|
-
|
|
2250
|
+
replaceItem(localItem, failed);
|
|
2171
2251
|
onError?.(error);
|
|
2172
2252
|
}
|
|
2173
2253
|
};
|
|
@@ -2177,42 +2257,74 @@ function ImageFieldPC({
|
|
|
2177
2257
|
{
|
|
2178
2258
|
"data-testid": `imagefield-input-${fieldId}`,
|
|
2179
2259
|
listType,
|
|
2180
|
-
fileList,
|
|
2260
|
+
fileList: [],
|
|
2181
2261
|
customRequest,
|
|
2182
2262
|
accept: accept ?? "image/*",
|
|
2183
2263
|
maxCount,
|
|
2184
2264
|
multiple,
|
|
2185
2265
|
disabled,
|
|
2186
|
-
showUploadList:
|
|
2187
|
-
showPreviewIcon,
|
|
2188
|
-
showRemoveIcon,
|
|
2189
|
-
showDownloadIcon
|
|
2190
|
-
},
|
|
2191
|
-
onChange: handleChange,
|
|
2266
|
+
showUploadList: false,
|
|
2192
2267
|
onRemove: handleRemove,
|
|
2193
2268
|
onPreview: handlePreview,
|
|
2194
2269
|
beforeUpload,
|
|
2195
2270
|
children: (!maxCount || value.length < maxCount) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { "data-testid": `imagefield-upload-btn-${fieldId}`, children: "+ \u4E0A\u4F20\u56FE\u7247" })
|
|
2196
2271
|
}
|
|
2197
2272
|
),
|
|
2198
|
-
value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sy-image-grid", "data-testid": `imagefield-rich-grid-${fieldId}`, children: value.map((item) =>
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
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
|
+
}) })
|
|
2216
2328
|
] });
|
|
2217
2329
|
}
|
|
2218
2330
|
|
|
@@ -2425,7 +2537,7 @@ function ImageField(props) {
|
|
|
2425
2537
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
2426
2538
|
const { isMobile } = useDeviceDetect();
|
|
2427
2539
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
2428
|
-
(0,
|
|
2540
|
+
(0, import_react19.useEffect)(() => {
|
|
2429
2541
|
registerField(fieldId);
|
|
2430
2542
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
2431
2543
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -2450,10 +2562,10 @@ function ImageField(props) {
|
|
|
2450
2562
|
}
|
|
2451
2563
|
|
|
2452
2564
|
// src/fields/SubFormField/index.tsx
|
|
2453
|
-
var
|
|
2565
|
+
var import_react21 = require("react");
|
|
2454
2566
|
|
|
2455
2567
|
// src/fields/SubFormField/SubFormCell.tsx
|
|
2456
|
-
var
|
|
2568
|
+
var import_react20 = require("react");
|
|
2457
2569
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
2458
2570
|
var stringifyFallbackValue = (value) => {
|
|
2459
2571
|
if (value === void 0 || value === null) return "";
|
|
@@ -2474,7 +2586,7 @@ function SubFormCell({
|
|
|
2474
2586
|
const scopedFieldId = `${parentFieldId}.${rowIndex}.${column.fieldId}`;
|
|
2475
2587
|
const cellValue = row[column.fieldId];
|
|
2476
2588
|
const resolvedBehavior = behavior ?? "NORMAL";
|
|
2477
|
-
const childContext = (0,
|
|
2589
|
+
const childContext = (0, import_react20.useMemo)(
|
|
2478
2590
|
() => ({
|
|
2479
2591
|
...parentContext,
|
|
2480
2592
|
formData: {
|
|
@@ -2766,7 +2878,7 @@ function SubFormField(props) {
|
|
|
2766
2878
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
2767
2879
|
const { isMobile } = useDeviceDetect();
|
|
2768
2880
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
2769
|
-
(0,
|
|
2881
|
+
(0, import_react21.useEffect)(() => {
|
|
2770
2882
|
registerField(fieldId);
|
|
2771
2883
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
2772
2884
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -2791,20 +2903,20 @@ function SubFormField(props) {
|
|
|
2791
2903
|
}
|
|
2792
2904
|
|
|
2793
2905
|
// src/fields/UserSelectField/index.tsx
|
|
2794
|
-
var
|
|
2906
|
+
var import_react26 = require("react");
|
|
2795
2907
|
|
|
2796
2908
|
// src/fields/UserSelectField/UserSelectFieldPC.tsx
|
|
2797
|
-
var
|
|
2909
|
+
var import_react24 = require("react");
|
|
2798
2910
|
var import_antd13 = require("antd");
|
|
2799
2911
|
|
|
2800
2912
|
// src/fields/shared/UserPicker.tsx
|
|
2801
|
-
var
|
|
2913
|
+
var import_react23 = require("react");
|
|
2802
2914
|
var import_antd12 = require("antd");
|
|
2803
2915
|
var import_icons = require("@ant-design/icons");
|
|
2804
2916
|
var MobileAntd2 = __toESM(require("antd-mobile"));
|
|
2805
2917
|
|
|
2806
2918
|
// src/fields/shared/useLazyDepartmentTree.ts
|
|
2807
|
-
var
|
|
2919
|
+
var import_react22 = require("react");
|
|
2808
2920
|
var toLazyNode = (node) => {
|
|
2809
2921
|
const normalized = normalizeDepartmentNode(node);
|
|
2810
2922
|
const id = getDepartmentId(normalized);
|
|
@@ -2854,15 +2966,15 @@ function buildIndexes(nodes) {
|
|
|
2854
2966
|
return { nodeMap, parentMap, flatNodes };
|
|
2855
2967
|
}
|
|
2856
2968
|
function useLazyDepartmentTree(api, configuredTreeData) {
|
|
2857
|
-
const [treeData, setTreeDataState] = (0,
|
|
2969
|
+
const [treeData, setTreeDataState] = (0, import_react22.useState)(
|
|
2858
2970
|
() => (configuredTreeData || []).map(toLazyNode)
|
|
2859
2971
|
);
|
|
2860
|
-
const [treeLoading, setTreeLoading] = (0,
|
|
2861
|
-
const treeDataRef = (0,
|
|
2862
|
-
const rootsLoadedRef = (0,
|
|
2863
|
-
const rootPromiseRef = (0,
|
|
2864
|
-
const childPromiseRef = (0,
|
|
2865
|
-
const setTreeData = (0,
|
|
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)(
|
|
2866
2978
|
(next) => {
|
|
2867
2979
|
const resolved = typeof next === "function" ? next(treeDataRef.current) : next;
|
|
2868
2980
|
treeDataRef.current = resolved;
|
|
@@ -2871,13 +2983,13 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
2871
2983
|
},
|
|
2872
2984
|
[]
|
|
2873
2985
|
);
|
|
2874
|
-
(0,
|
|
2986
|
+
(0, import_react22.useEffect)(() => {
|
|
2875
2987
|
if (!configuredTreeData) return;
|
|
2876
2988
|
const next = configuredTreeData.map(toLazyNode);
|
|
2877
2989
|
rootsLoadedRef.current = next.length > 0;
|
|
2878
2990
|
setTreeData(next);
|
|
2879
2991
|
}, [configuredTreeData, setTreeData]);
|
|
2880
|
-
const loadRootDepartments = (0,
|
|
2992
|
+
const loadRootDepartments = (0, import_react22.useCallback)(async () => {
|
|
2881
2993
|
if (rootsLoadedRef.current) return treeDataRef.current;
|
|
2882
2994
|
if (rootPromiseRef.current) return rootPromiseRef.current;
|
|
2883
2995
|
setTreeLoading(true);
|
|
@@ -2893,7 +3005,7 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
2893
3005
|
rootPromiseRef.current = promise;
|
|
2894
3006
|
return promise;
|
|
2895
3007
|
}, [api, setTreeData]);
|
|
2896
|
-
const loadChildren = (0,
|
|
3008
|
+
const loadChildren = (0, import_react22.useCallback)(
|
|
2897
3009
|
async (parentId) => {
|
|
2898
3010
|
const id = String(parentId || "");
|
|
2899
3011
|
if (!id) return [];
|
|
@@ -2914,8 +3026,8 @@ function useLazyDepartmentTree(api, configuredTreeData) {
|
|
|
2914
3026
|
},
|
|
2915
3027
|
[api, setTreeData]
|
|
2916
3028
|
);
|
|
2917
|
-
const indexes = (0,
|
|
2918
|
-
(0,
|
|
3029
|
+
const indexes = (0, import_react22.useMemo)(() => buildIndexes(treeData), [treeData]);
|
|
3030
|
+
(0, import_react22.useEffect)(() => {
|
|
2919
3031
|
void loadRootDepartments();
|
|
2920
3032
|
}, [loadRootDepartments]);
|
|
2921
3033
|
return {
|
|
@@ -2958,25 +3070,25 @@ function UserPickerPanel({
|
|
|
2958
3070
|
flatNodes,
|
|
2959
3071
|
loadChildren
|
|
2960
3072
|
} = useLazyDepartmentTree(api, treeData);
|
|
2961
|
-
const [departmentKeyword, setDepartmentKeyword] = (0,
|
|
2962
|
-
const [memberKeyword, setMemberKeyword] = (0,
|
|
2963
|
-
const [mobileKeyword, setMobileKeyword] = (0,
|
|
2964
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
2965
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
2966
|
-
const [members, setMembers] = (0,
|
|
2967
|
-
const [loading, setLoading] = (0,
|
|
2968
|
-
const [selected, setSelected] = (0,
|
|
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));
|
|
2969
3081
|
const selectedIds = selected.map(getUserId);
|
|
2970
3082
|
const MobileSearchBar = getMobileComponent("SearchBar");
|
|
2971
|
-
(0,
|
|
3083
|
+
(0, import_react23.useEffect)(() => {
|
|
2972
3084
|
if (dataSource?.length) setMembers(normalizeUsers(dataSource));
|
|
2973
3085
|
}, [dataSource]);
|
|
2974
|
-
(0,
|
|
3086
|
+
(0, import_react23.useEffect)(() => {
|
|
2975
3087
|
if (currentDeptId || deptTreeData.length === 0) return;
|
|
2976
3088
|
setCurrentDeptId(getDepartmentId(deptTreeData[0]));
|
|
2977
3089
|
setExpandedKeys(deptTreeData.map((node) => getDepartmentId(node)));
|
|
2978
3090
|
}, [currentDeptId, deptTreeData]);
|
|
2979
|
-
(0,
|
|
3091
|
+
(0, import_react23.useEffect)(() => {
|
|
2980
3092
|
let active = true;
|
|
2981
3093
|
const keyword = (mobile ? mobileKeyword : memberKeyword).trim();
|
|
2982
3094
|
if (dataSource?.length) {
|
|
@@ -3007,7 +3119,7 @@ function UserPickerPanel({
|
|
|
3007
3119
|
clearTimeout(timer);
|
|
3008
3120
|
};
|
|
3009
3121
|
}, [api, currentDeptId, dataSource, memberKeyword, mobile, mobileKeyword]);
|
|
3010
|
-
const currentPath = (0,
|
|
3122
|
+
const currentPath = (0, import_react23.useMemo)(() => {
|
|
3011
3123
|
if (!currentDeptId) return [];
|
|
3012
3124
|
const path = [];
|
|
3013
3125
|
let cursor = currentDeptId;
|
|
@@ -3019,7 +3131,7 @@ function UserPickerPanel({
|
|
|
3019
3131
|
}
|
|
3020
3132
|
return path;
|
|
3021
3133
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
3022
|
-
const mobileDepartments = (0,
|
|
3134
|
+
const mobileDepartments = (0, import_react23.useMemo)(() => {
|
|
3023
3135
|
const keyword = mobileKeyword.trim().toLowerCase();
|
|
3024
3136
|
if (keyword) {
|
|
3025
3137
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(keyword)).map((item) => item.node);
|
|
@@ -3243,12 +3355,12 @@ function UserSelectFieldPC({
|
|
|
3243
3355
|
const { formData, setFieldValue, api } = useFormContext();
|
|
3244
3356
|
const value = formData[fieldId] ?? [];
|
|
3245
3357
|
const disabled = behavior === "DISABLED";
|
|
3246
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
3358
|
+
const [optionsSource, setOptionsSource] = (0, import_react24.useState)(
|
|
3247
3359
|
() => dataSource.map(normalizeUser)
|
|
3248
3360
|
);
|
|
3249
|
-
const [loading, setLoading] = (0,
|
|
3250
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
3251
|
-
(0,
|
|
3361
|
+
const [loading, setLoading] = (0, import_react24.useState)(false);
|
|
3362
|
+
const [pickerOpen, setPickerOpen] = (0, import_react24.useState)(false);
|
|
3363
|
+
(0, import_react24.useEffect)(() => {
|
|
3252
3364
|
if (dataSource.length) {
|
|
3253
3365
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
3254
3366
|
}
|
|
@@ -3265,7 +3377,7 @@ function UserSelectFieldPC({
|
|
|
3265
3377
|
setLoading(false);
|
|
3266
3378
|
}
|
|
3267
3379
|
};
|
|
3268
|
-
(0,
|
|
3380
|
+
(0, import_react24.useEffect)(() => {
|
|
3269
3381
|
fetchUsers();
|
|
3270
3382
|
}, []);
|
|
3271
3383
|
const handleChange = (selectedIds) => {
|
|
@@ -3290,7 +3402,7 @@ function UserSelectFieldPC({
|
|
|
3290
3402
|
setFieldValue(fieldId, normalized);
|
|
3291
3403
|
onChange?.(normalized);
|
|
3292
3404
|
};
|
|
3293
|
-
const options = (0,
|
|
3405
|
+
const options = (0, import_react24.useMemo)(
|
|
3294
3406
|
() => optionsSource.map((u) => ({
|
|
3295
3407
|
value: getUserId(u),
|
|
3296
3408
|
label: getUserName(u)
|
|
@@ -3350,7 +3462,7 @@ function UserSelectFieldPC({
|
|
|
3350
3462
|
}
|
|
3351
3463
|
|
|
3352
3464
|
// src/fields/UserSelectField/UserSelectFieldMobile.tsx
|
|
3353
|
-
var
|
|
3465
|
+
var import_react25 = require("react");
|
|
3354
3466
|
var MobileAntd3 = __toESM(require("antd-mobile"));
|
|
3355
3467
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
3356
3468
|
var getMobilePopup = () => {
|
|
@@ -3373,11 +3485,11 @@ function UserSelectFieldMobile({
|
|
|
3373
3485
|
const { formData, setFieldValue, api } = useFormContext();
|
|
3374
3486
|
const value = formData[fieldId] ?? [];
|
|
3375
3487
|
const disabled = behavior === "DISABLED";
|
|
3376
|
-
const [showPicker, setShowPicker] = (0,
|
|
3377
|
-
const [optionsSource, setOptionsSource] = (0,
|
|
3488
|
+
const [showPicker, setShowPicker] = (0, import_react25.useState)(false);
|
|
3489
|
+
const [optionsSource, setOptionsSource] = (0, import_react25.useState)(
|
|
3378
3490
|
() => dataSource.map(normalizeUser)
|
|
3379
3491
|
);
|
|
3380
|
-
(0,
|
|
3492
|
+
(0, import_react25.useEffect)(() => {
|
|
3381
3493
|
if (dataSource.length) {
|
|
3382
3494
|
setOptionsSource(dataSource.map(normalizeUser));
|
|
3383
3495
|
}
|
|
@@ -3487,7 +3599,7 @@ function UserSelectField(props) {
|
|
|
3487
3599
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
3488
3600
|
const { isMobile } = useDeviceDetect();
|
|
3489
3601
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
3490
|
-
(0,
|
|
3602
|
+
(0, import_react26.useEffect)(() => {
|
|
3491
3603
|
registerField(fieldId);
|
|
3492
3604
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
3493
3605
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -3512,14 +3624,14 @@ function UserSelectField(props) {
|
|
|
3512
3624
|
}
|
|
3513
3625
|
|
|
3514
3626
|
// src/fields/DepartmentSelectField/index.tsx
|
|
3515
|
-
var
|
|
3627
|
+
var import_react30 = require("react");
|
|
3516
3628
|
|
|
3517
3629
|
// src/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
|
|
3518
|
-
var
|
|
3630
|
+
var import_react28 = require("react");
|
|
3519
3631
|
var import_antd15 = require("antd");
|
|
3520
3632
|
|
|
3521
3633
|
// src/fields/shared/DepartmentPicker.tsx
|
|
3522
|
-
var
|
|
3634
|
+
var import_react27 = require("react");
|
|
3523
3635
|
var import_antd14 = require("antd");
|
|
3524
3636
|
var import_icons2 = require("@ant-design/icons");
|
|
3525
3637
|
var MobileAntd4 = __toESM(require("antd-mobile"));
|
|
@@ -3563,17 +3675,17 @@ function DepartmentPickerPanel({
|
|
|
3563
3675
|
flatNodes,
|
|
3564
3676
|
loadChildren
|
|
3565
3677
|
} = useLazyDepartmentTree(api, treeData);
|
|
3566
|
-
const [keyword, setKeyword] = (0,
|
|
3567
|
-
const [selected, setSelected] = (0,
|
|
3568
|
-
const [expandedKeys, setExpandedKeys] = (0,
|
|
3569
|
-
const [currentDeptId, setCurrentDeptId] = (0,
|
|
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);
|
|
3570
3682
|
const selectedIds = selected.map((item) => item.id);
|
|
3571
3683
|
const MobileSearchBar = getMobileComponent2("SearchBar");
|
|
3572
|
-
const filteredTreeData = (0,
|
|
3684
|
+
const filteredTreeData = (0, import_react27.useMemo)(
|
|
3573
3685
|
() => matchSearch(loadedTreeData, keyword.trim()),
|
|
3574
3686
|
[keyword, loadedTreeData]
|
|
3575
3687
|
);
|
|
3576
|
-
const currentPath = (0,
|
|
3688
|
+
const currentPath = (0, import_react27.useMemo)(() => {
|
|
3577
3689
|
if (!currentDeptId) return [];
|
|
3578
3690
|
const path = [];
|
|
3579
3691
|
let cursor = currentDeptId;
|
|
@@ -3585,7 +3697,7 @@ function DepartmentPickerPanel({
|
|
|
3585
3697
|
}
|
|
3586
3698
|
return path;
|
|
3587
3699
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
3588
|
-
const mobileList = (0,
|
|
3700
|
+
const mobileList = (0, import_react27.useMemo)(() => {
|
|
3589
3701
|
if (keyword.trim()) {
|
|
3590
3702
|
const lower = keyword.trim().toLowerCase();
|
|
3591
3703
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(lower)).map((item) => item.node);
|
|
@@ -3803,10 +3915,10 @@ function DepartmentSelectFieldPC({
|
|
|
3803
3915
|
const value = formData[fieldId] ?? [];
|
|
3804
3916
|
const disabled = behavior === "DISABLED";
|
|
3805
3917
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA;
|
|
3806
|
-
const remoteLoadedRef = (0,
|
|
3807
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
3808
|
-
const [pickerOpen, setPickerOpen] = (0,
|
|
3809
|
-
(0,
|
|
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)(() => {
|
|
3810
3922
|
if (configuredTreeData.length) {
|
|
3811
3923
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
3812
3924
|
return;
|
|
@@ -3895,7 +4007,7 @@ function DepartmentSelectFieldPC({
|
|
|
3895
4007
|
}
|
|
3896
4008
|
|
|
3897
4009
|
// src/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
|
|
3898
|
-
var
|
|
4010
|
+
var import_react29 = require("react");
|
|
3899
4011
|
var MobileAntd5 = __toESM(require("antd-mobile"));
|
|
3900
4012
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
3901
4013
|
var EMPTY_TREE_DATA2 = [];
|
|
@@ -3918,11 +4030,11 @@ function DepartmentSelectFieldMobile({
|
|
|
3918
4030
|
const { formData, setFieldValue, api } = useFormContext();
|
|
3919
4031
|
const value = formData[fieldId] ?? [];
|
|
3920
4032
|
const disabled = behavior === "DISABLED";
|
|
3921
|
-
const [showPicker, setShowPicker] = (0,
|
|
4033
|
+
const [showPicker, setShowPicker] = (0, import_react29.useState)(false);
|
|
3922
4034
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
|
|
3923
|
-
const remoteLoadedRef = (0,
|
|
3924
|
-
const [loadedTreeData, setLoadedTreeData] = (0,
|
|
3925
|
-
(0,
|
|
4035
|
+
const remoteLoadedRef = (0, import_react29.useRef)(false);
|
|
4036
|
+
const [loadedTreeData, setLoadedTreeData] = (0, import_react29.useState)(configuredTreeData);
|
|
4037
|
+
(0, import_react29.useEffect)(() => {
|
|
3926
4038
|
if (configuredTreeData.length) {
|
|
3927
4039
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
3928
4040
|
}
|
|
@@ -4037,7 +4149,7 @@ function DepartmentSelectField(props) {
|
|
|
4037
4149
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
4038
4150
|
const { isMobile } = useDeviceDetect();
|
|
4039
4151
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
4040
|
-
(0,
|
|
4152
|
+
(0, import_react30.useEffect)(() => {
|
|
4041
4153
|
registerField(fieldId);
|
|
4042
4154
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
4043
4155
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -4062,7 +4174,7 @@ function DepartmentSelectField(props) {
|
|
|
4062
4174
|
}
|
|
4063
4175
|
|
|
4064
4176
|
// src/fields/CascadeSelectField/index.tsx
|
|
4065
|
-
var
|
|
4177
|
+
var import_react31 = require("react");
|
|
4066
4178
|
var import_antd16 = require("antd");
|
|
4067
4179
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
4068
4180
|
var toValuePath = (value, multiple) => {
|
|
@@ -4101,7 +4213,7 @@ function CascadeSelectField(props) {
|
|
|
4101
4213
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
4102
4214
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
4103
4215
|
const value = formData[fieldId] ?? (multiple ? [] : []);
|
|
4104
|
-
(0,
|
|
4216
|
+
(0, import_react31.useEffect)(() => {
|
|
4105
4217
|
registerField(fieldId);
|
|
4106
4218
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
4107
4219
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -4154,7 +4266,7 @@ function CascadeSelectField(props) {
|
|
|
4154
4266
|
}
|
|
4155
4267
|
|
|
4156
4268
|
// src/fields/AddressField/index.tsx
|
|
4157
|
-
var
|
|
4269
|
+
var import_react32 = require("react");
|
|
4158
4270
|
var import_antd17 = require("antd");
|
|
4159
4271
|
var MobileAntd6 = __toESM(require("antd-mobile"));
|
|
4160
4272
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
@@ -4206,19 +4318,19 @@ function AddressField(props) {
|
|
|
4206
4318
|
const { isMobile } = useDeviceDetect();
|
|
4207
4319
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
4208
4320
|
const value = formData[fieldId];
|
|
4209
|
-
const [options, setOptions] = (0,
|
|
4210
|
-
const [loadingRoots, setLoadingRoots] = (0,
|
|
4211
|
-
const [mobileOpen, setMobileOpen] = (0,
|
|
4212
|
-
const [mobileLevelIndex, setMobileLevelIndex] = (0,
|
|
4213
|
-
const [mobileOptions, setMobileOptions] = (0,
|
|
4214
|
-
const [mobileLoading, setMobileLoading] = (0,
|
|
4215
|
-
const [tempValue, setTempValue] = (0,
|
|
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)();
|
|
4216
4328
|
const depth = modeDepth(mode);
|
|
4217
|
-
const levels = (0,
|
|
4329
|
+
const levels = (0, import_react32.useMemo)(() => activeLevels(mode), [mode]);
|
|
4218
4330
|
const detailEnabled = mode === "province-city-district-street-detail";
|
|
4219
4331
|
const disabled = behavior === "DISABLED";
|
|
4220
4332
|
const MobilePopup = getMobileComponent3("Popup");
|
|
4221
|
-
(0,
|
|
4333
|
+
(0, import_react32.useEffect)(() => {
|
|
4222
4334
|
registerField(fieldId);
|
|
4223
4335
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
4224
4336
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -4229,11 +4341,11 @@ function AddressField(props) {
|
|
|
4229
4341
|
const list = await api.getChinaDivisions(parentAdcode);
|
|
4230
4342
|
return list.map((item) => normalizeDivision(item, level, depth, index));
|
|
4231
4343
|
};
|
|
4232
|
-
(0,
|
|
4344
|
+
(0, import_react32.useEffect)(() => {
|
|
4233
4345
|
setLoadingRoots(true);
|
|
4234
4346
|
loadDivisions(void 0, "province", 0).then(setOptions).finally(() => setLoadingRoots(false));
|
|
4235
4347
|
}, [api, depth]);
|
|
4236
|
-
(0,
|
|
4348
|
+
(0, import_react32.useEffect)(() => {
|
|
4237
4349
|
if (!mobileOpen) return;
|
|
4238
4350
|
const level = levels[mobileLevelIndex] || "province";
|
|
4239
4351
|
const parentLevel = levels[mobileLevelIndex - 1];
|
|
@@ -4402,7 +4514,7 @@ function AddressField(props) {
|
|
|
4402
4514
|
}
|
|
4403
4515
|
|
|
4404
4516
|
// src/fields/AssociationFormField/index.tsx
|
|
4405
|
-
var
|
|
4517
|
+
var import_react33 = require("react");
|
|
4406
4518
|
var import_antd18 = require("antd");
|
|
4407
4519
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
4408
4520
|
var DEFAULT_PAGE_SIZE = 10;
|
|
@@ -4452,22 +4564,22 @@ function AssociationFormField(props) {
|
|
|
4452
4564
|
const { isMobile } = useDeviceDetect();
|
|
4453
4565
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
4454
4566
|
const rawValue = formData[fieldId];
|
|
4455
|
-
const value = (0,
|
|
4567
|
+
const value = (0, import_react33.useMemo)(() => normalizeValues(rawValue), [rawValue]);
|
|
4456
4568
|
const disabled = behavior === "DISABLED";
|
|
4457
|
-
const [options, setOptions] = (0,
|
|
4458
|
-
const [selectLoading, setSelectLoading] = (0,
|
|
4459
|
-
const [selectorOpen, setSelectorOpen] = (0,
|
|
4460
|
-
const [tableLoading, setTableLoading] = (0,
|
|
4461
|
-
const [tableData, setTableData] = (0,
|
|
4462
|
-
const [keyword, setKeyword] = (0,
|
|
4463
|
-
const [pagination, setPagination] = (0,
|
|
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)({
|
|
4464
4576
|
current: 1,
|
|
4465
4577
|
pageSize: DEFAULT_PAGE_SIZE,
|
|
4466
4578
|
total: 0
|
|
4467
4579
|
});
|
|
4468
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
4469
|
-
const [selectedRecords, setSelectedRecords] = (0,
|
|
4470
|
-
(0,
|
|
4580
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react33.useState)([]);
|
|
4581
|
+
const [selectedRecords, setSelectedRecords] = (0, import_react33.useState)([]);
|
|
4582
|
+
(0, import_react33.useEffect)(() => {
|
|
4471
4583
|
registerField(fieldId);
|
|
4472
4584
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
4473
4585
|
setFieldValue(fieldId, normalizeValues(defaultValue));
|
|
@@ -4475,7 +4587,7 @@ function AssociationFormField(props) {
|
|
|
4475
4587
|
return () => unregisterField(fieldId);
|
|
4476
4588
|
}, [fieldId]);
|
|
4477
4589
|
const canQuery = Boolean(associationForm?.appType && associationForm?.formUuid);
|
|
4478
|
-
const normalizeRecord = (0,
|
|
4590
|
+
const normalizeRecord = (0, import_react33.useCallback)(
|
|
4479
4591
|
(record) => {
|
|
4480
4592
|
const mainFieldValue = associationForm?.mainFieldId ? record?.[associationForm.mainFieldId] : void 0;
|
|
4481
4593
|
const labelText = normalizeCellValue(mainFieldValue);
|
|
@@ -4488,7 +4600,7 @@ function AssociationFormField(props) {
|
|
|
4488
4600
|
},
|
|
4489
4601
|
[associationForm?.mainFieldId]
|
|
4490
4602
|
);
|
|
4491
|
-
const toValue = (0,
|
|
4603
|
+
const toValue = (0, import_react33.useCallback)(
|
|
4492
4604
|
(record) => ({
|
|
4493
4605
|
label: record.__associationLabel,
|
|
4494
4606
|
value: record.__associationValue,
|
|
@@ -4496,7 +4608,7 @@ function AssociationFormField(props) {
|
|
|
4496
4608
|
}),
|
|
4497
4609
|
[]
|
|
4498
4610
|
);
|
|
4499
|
-
const buildFilters = (0,
|
|
4611
|
+
const buildFilters = (0, import_react33.useCallback)(() => {
|
|
4500
4612
|
const rules = associationForm?.dataFilterRules || [];
|
|
4501
4613
|
return rules.map((rule) => {
|
|
4502
4614
|
if (!rule?.key) return null;
|
|
@@ -4510,7 +4622,7 @@ function AssociationFormField(props) {
|
|
|
4510
4622
|
};
|
|
4511
4623
|
}).filter(Boolean);
|
|
4512
4624
|
}, [associationForm?.dataFilterRules, formData]);
|
|
4513
|
-
const fetchRecords = (0,
|
|
4625
|
+
const fetchRecords = (0, import_react33.useCallback)(
|
|
4514
4626
|
async (params) => {
|
|
4515
4627
|
if (!canQuery) return { list: [], total: 0 };
|
|
4516
4628
|
const filters = buildFilters();
|
|
@@ -4533,7 +4645,7 @@ function AssociationFormField(props) {
|
|
|
4533
4645
|
},
|
|
4534
4646
|
[api, associationForm, buildFilters, canQuery, normalizeRecord]
|
|
4535
4647
|
);
|
|
4536
|
-
const loadOptions = (0,
|
|
4648
|
+
const loadOptions = (0, import_react33.useCallback)(
|
|
4537
4649
|
async (searchKeyWord) => {
|
|
4538
4650
|
setSelectLoading(true);
|
|
4539
4651
|
try {
|
|
@@ -4545,7 +4657,7 @@ function AssociationFormField(props) {
|
|
|
4545
4657
|
},
|
|
4546
4658
|
[fetchRecords, toValue]
|
|
4547
4659
|
);
|
|
4548
|
-
const loadTable = (0,
|
|
4660
|
+
const loadTable = (0, import_react33.useCallback)(
|
|
4549
4661
|
async (next) => {
|
|
4550
4662
|
setTableLoading(true);
|
|
4551
4663
|
const current = next?.current || 1;
|
|
@@ -4564,10 +4676,10 @@ function AssociationFormField(props) {
|
|
|
4564
4676
|
},
|
|
4565
4677
|
[fetchRecords, keyword, pagination.pageSize]
|
|
4566
4678
|
);
|
|
4567
|
-
(0,
|
|
4679
|
+
(0, import_react33.useEffect)(() => {
|
|
4568
4680
|
void loadOptions();
|
|
4569
4681
|
}, [loadOptions]);
|
|
4570
|
-
(0,
|
|
4682
|
+
(0, import_react33.useEffect)(() => {
|
|
4571
4683
|
setSelectedRowKeys(value.map((item) => item.value));
|
|
4572
4684
|
setSelectedRecords(
|
|
4573
4685
|
value.map(
|
|
@@ -4575,7 +4687,7 @@ function AssociationFormField(props) {
|
|
|
4575
4687
|
).filter(Boolean)
|
|
4576
4688
|
);
|
|
4577
4689
|
}, [normalizeRecord, value]);
|
|
4578
|
-
const applyDataFilling = (0,
|
|
4690
|
+
const applyDataFilling = (0, import_react33.useCallback)(
|
|
4579
4691
|
(next) => {
|
|
4580
4692
|
if (!associationForm?.dataFillingEnabled && !associationForm?.dataFillingRules?.mainRules) {
|
|
4581
4693
|
return;
|
|
@@ -4589,7 +4701,7 @@ function AssociationFormField(props) {
|
|
|
4589
4701
|
},
|
|
4590
4702
|
[associationForm?.dataFillingEnabled, associationForm?.dataFillingRules, setFieldValue]
|
|
4591
4703
|
);
|
|
4592
|
-
const commitSelection = (0,
|
|
4704
|
+
const commitSelection = (0, import_react33.useCallback)(
|
|
4593
4705
|
(next) => {
|
|
4594
4706
|
const normalized = multiple ? next : next.slice(0, 1);
|
|
4595
4707
|
setFieldValue(fieldId, normalized);
|
|
@@ -4598,7 +4710,7 @@ function AssociationFormField(props) {
|
|
|
4598
4710
|
},
|
|
4599
4711
|
[applyDataFilling, fieldId, multiple, onChange, setFieldValue]
|
|
4600
4712
|
);
|
|
4601
|
-
const selectorColumns = (0,
|
|
4713
|
+
const selectorColumns = (0, import_react33.useMemo)(() => {
|
|
4602
4714
|
const configured = associationForm?.selectorColumns || [];
|
|
4603
4715
|
if (configured.length) {
|
|
4604
4716
|
return configured.map((column) => {
|
|
@@ -4633,7 +4745,7 @@ function AssociationFormField(props) {
|
|
|
4633
4745
|
}
|
|
4634
4746
|
];
|
|
4635
4747
|
}, [associationForm?.mainFieldId, associationForm?.selectorColumns]);
|
|
4636
|
-
const selectOptions = (0,
|
|
4748
|
+
const selectOptions = (0, import_react33.useMemo)(
|
|
4637
4749
|
() => [...options, ...value].filter(
|
|
4638
4750
|
(item, index, list) => list.findIndex((candidate) => candidate.value === item.value) === index
|
|
4639
4751
|
).map((item) => ({ label: item.label, value: item.value })),
|
|
@@ -4841,8 +4953,8 @@ function AssociationFormField(props) {
|
|
|
4841
4953
|
}
|
|
4842
4954
|
|
|
4843
4955
|
// src/fields/EditorField/index.tsx
|
|
4844
|
-
var
|
|
4845
|
-
var
|
|
4956
|
+
var import_react34 = require("react");
|
|
4957
|
+
var import_react35 = require("@tiptap/react");
|
|
4846
4958
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
4847
4959
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
4848
4960
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
@@ -5163,19 +5275,19 @@ function EditorField(props) {
|
|
|
5163
5275
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
5164
5276
|
const value = formData[fieldId] ?? "";
|
|
5165
5277
|
const disabled = behavior === "DISABLED";
|
|
5166
|
-
const inputRef = (0,
|
|
5167
|
-
const [uploading, setUploading] = (0,
|
|
5168
|
-
const [uploadError, setUploadError] = (0,
|
|
5169
|
-
const [charCount, setCharCount] = (0,
|
|
5170
|
-
(0,
|
|
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)(() => {
|
|
5171
5283
|
registerField(fieldId);
|
|
5172
5284
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
5173
5285
|
setFieldValue(fieldId, defaultValue);
|
|
5174
5286
|
}
|
|
5175
5287
|
return () => unregisterField(fieldId);
|
|
5176
5288
|
}, [fieldId]);
|
|
5177
|
-
const actions = (0,
|
|
5178
|
-
const extensions = (0,
|
|
5289
|
+
const actions = (0, import_react34.useMemo)(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
|
|
5290
|
+
const extensions = (0, import_react34.useMemo)(
|
|
5179
5291
|
() => [
|
|
5180
5292
|
import_starter_kit.default.configure({
|
|
5181
5293
|
heading: { levels: [1, 2, 3] }
|
|
@@ -5198,14 +5310,14 @@ function EditorField(props) {
|
|
|
5198
5310
|
],
|
|
5199
5311
|
[placeholder]
|
|
5200
5312
|
);
|
|
5201
|
-
const updateHtml = (0,
|
|
5313
|
+
const updateHtml = (0, import_react34.useCallback)(
|
|
5202
5314
|
(next) => {
|
|
5203
5315
|
setFieldValue(fieldId, next);
|
|
5204
5316
|
onChange?.(next);
|
|
5205
5317
|
},
|
|
5206
5318
|
[fieldId, onChange, setFieldValue]
|
|
5207
5319
|
);
|
|
5208
|
-
const editor = (0,
|
|
5320
|
+
const editor = (0, import_react35.useEditor)(
|
|
5209
5321
|
{
|
|
5210
5322
|
extensions,
|
|
5211
5323
|
content: value || "",
|
|
@@ -5228,11 +5340,11 @@ function EditorField(props) {
|
|
|
5228
5340
|
},
|
|
5229
5341
|
[fieldId, extensions, disabled, maxLength, updateHtml]
|
|
5230
5342
|
);
|
|
5231
|
-
(0,
|
|
5343
|
+
(0, import_react34.useEffect)(() => {
|
|
5232
5344
|
if (!editor) return;
|
|
5233
5345
|
editor.setEditable(!disabled);
|
|
5234
5346
|
}, [disabled, editor]);
|
|
5235
|
-
(0,
|
|
5347
|
+
(0, import_react34.useEffect)(() => {
|
|
5236
5348
|
if (!editor) return;
|
|
5237
5349
|
const currentHtml = editor.isEmpty ? "" : editor.getHTML();
|
|
5238
5350
|
if ((value || "") !== currentHtml) {
|
|
@@ -5240,7 +5352,7 @@ function EditorField(props) {
|
|
|
5240
5352
|
setCharCount(editor.getText().length);
|
|
5241
5353
|
}
|
|
5242
5354
|
}, [editor, value]);
|
|
5243
|
-
const insertImageFiles = (0,
|
|
5355
|
+
const insertImageFiles = (0, import_react34.useCallback)(
|
|
5244
5356
|
async (files) => {
|
|
5245
5357
|
if (!editor || disabled || files.length === 0) return;
|
|
5246
5358
|
const validFiles = files.filter((file) => {
|
|
@@ -5323,7 +5435,7 @@ function EditorField(props) {
|
|
|
5323
5435
|
void insertImageFiles(files);
|
|
5324
5436
|
}
|
|
5325
5437
|
},
|
|
5326
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
5438
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_react35.EditorContent, { editor })
|
|
5327
5439
|
}
|
|
5328
5440
|
),
|
|
5329
5441
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
@@ -5356,7 +5468,7 @@ function EditorField(props) {
|
|
|
5356
5468
|
}
|
|
5357
5469
|
|
|
5358
5470
|
// src/fields/SerialNumberField/index.tsx
|
|
5359
|
-
var
|
|
5471
|
+
var import_react36 = require("react");
|
|
5360
5472
|
var import_antd19 = require("antd");
|
|
5361
5473
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
5362
5474
|
function SerialNumberField(props) {
|
|
@@ -5376,7 +5488,7 @@ function SerialNumberField(props) {
|
|
|
5376
5488
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
5377
5489
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
5378
5490
|
const value = formData[fieldId] ?? "";
|
|
5379
|
-
(0,
|
|
5491
|
+
(0, import_react36.useEffect)(() => {
|
|
5380
5492
|
registerField(fieldId);
|
|
5381
5493
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
5382
5494
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -5418,7 +5530,7 @@ function SerialNumberField(props) {
|
|
|
5418
5530
|
}
|
|
5419
5531
|
|
|
5420
5532
|
// src/fields/LocationField/index.tsx
|
|
5421
|
-
var
|
|
5533
|
+
var import_react37 = require("react");
|
|
5422
5534
|
var import_antd20 = require("antd");
|
|
5423
5535
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
5424
5536
|
var getDingTalkApi = () => {
|
|
@@ -5460,9 +5572,9 @@ function LocationField(props) {
|
|
|
5460
5572
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
5461
5573
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
5462
5574
|
const value = formData[fieldId];
|
|
5463
|
-
const [locating, setLocating] = (0,
|
|
5464
|
-
const [error, setError] = (0,
|
|
5465
|
-
(0,
|
|
5575
|
+
const [locating, setLocating] = (0, import_react37.useState)(false);
|
|
5576
|
+
const [error, setError] = (0, import_react37.useState)("");
|
|
5577
|
+
(0, import_react37.useEffect)(() => {
|
|
5466
5578
|
registerField(fieldId);
|
|
5467
5579
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
5468
5580
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -5603,7 +5715,7 @@ function LocationField(props) {
|
|
|
5603
5715
|
}
|
|
5604
5716
|
|
|
5605
5717
|
// src/fields/DigitalSignatureField/index.tsx
|
|
5606
|
-
var
|
|
5718
|
+
var import_react38 = require("react");
|
|
5607
5719
|
var import_antd21 = require("antd");
|
|
5608
5720
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
5609
5721
|
var CANVAS_HEIGHT = 260;
|
|
@@ -5637,21 +5749,21 @@ function DigitalSignatureField(props) {
|
|
|
5637
5749
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField, api } = useFormContext();
|
|
5638
5750
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
5639
5751
|
const value = formData[fieldId];
|
|
5640
|
-
const [open, setOpen] = (0,
|
|
5641
|
-
const [saving, setSaving] = (0,
|
|
5642
|
-
const [drawn, setDrawn] = (0,
|
|
5643
|
-
const [error, setError] = (0,
|
|
5644
|
-
const canvasRef = (0,
|
|
5645
|
-
const drawingRef = (0,
|
|
5646
|
-
const pointsRef = (0,
|
|
5647
|
-
(0,
|
|
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)(() => {
|
|
5648
5760
|
registerField(fieldId);
|
|
5649
5761
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
5650
5762
|
setFieldValue(fieldId, defaultValue);
|
|
5651
5763
|
}
|
|
5652
5764
|
return () => unregisterField(fieldId);
|
|
5653
5765
|
}, [fieldId]);
|
|
5654
|
-
const prepareCanvas = (0,
|
|
5766
|
+
const prepareCanvas = (0, import_react38.useCallback)(() => {
|
|
5655
5767
|
const canvas = canvasRef.current;
|
|
5656
5768
|
if (!canvas) return;
|
|
5657
5769
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -5671,7 +5783,7 @@ function DigitalSignatureField(props) {
|
|
|
5671
5783
|
ctx.lineJoin = "round";
|
|
5672
5784
|
ctx.strokeStyle = "#111827";
|
|
5673
5785
|
}, []);
|
|
5674
|
-
(0,
|
|
5786
|
+
(0, import_react38.useEffect)(() => {
|
|
5675
5787
|
if (!open) return;
|
|
5676
5788
|
pointsRef.current = [];
|
|
5677
5789
|
setDrawn(false);
|
|
@@ -5814,7 +5926,7 @@ function DigitalSignatureField(props) {
|
|
|
5814
5926
|
}
|
|
5815
5927
|
|
|
5816
5928
|
// src/fields/JSONField/index.tsx
|
|
5817
|
-
var
|
|
5929
|
+
var import_react39 = require("react");
|
|
5818
5930
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
5819
5931
|
var formatJson = (value) => {
|
|
5820
5932
|
if (value === void 0 || value === null || value === "") return "--";
|
|
@@ -5841,7 +5953,7 @@ function JSONField(props) {
|
|
|
5841
5953
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
5842
5954
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
5843
5955
|
const value = formData[fieldId];
|
|
5844
|
-
(0,
|
|
5956
|
+
(0, import_react39.useEffect)(() => {
|
|
5845
5957
|
registerField(fieldId);
|
|
5846
5958
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
5847
5959
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -6341,7 +6453,7 @@ function FormProvider({
|
|
|
6341
6453
|
components,
|
|
6342
6454
|
children
|
|
6343
6455
|
}) {
|
|
6344
|
-
const computedInitialValues = (0,
|
|
6456
|
+
const computedInitialValues = (0, import_react40.useMemo)(() => {
|
|
6345
6457
|
const values = {};
|
|
6346
6458
|
for (const field of schema.fields) {
|
|
6347
6459
|
if (field.defaultValue !== void 0) {
|
|
@@ -6350,12 +6462,12 @@ function FormProvider({
|
|
|
6350
6462
|
}
|
|
6351
6463
|
return { ...values, ...initialValues };
|
|
6352
6464
|
}, [schema, initialValues]);
|
|
6353
|
-
const initialValuesRef = (0,
|
|
6354
|
-
const [formData, setFormData] = (0,
|
|
6355
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
6356
|
-
const [registeredFields] = (0,
|
|
6357
|
-
const api = (0,
|
|
6358
|
-
const fieldBehaviors = (0,
|
|
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)(() => {
|
|
6359
6471
|
const baseBehaviors = {};
|
|
6360
6472
|
for (const field of schema.fields) {
|
|
6361
6473
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -6378,7 +6490,7 @@ function FormProvider({
|
|
|
6378
6490
|
}
|
|
6379
6491
|
return computed;
|
|
6380
6492
|
}, [schema, config.effects, config.permissions, config.mode, formData]);
|
|
6381
|
-
const setFieldValue = (0,
|
|
6493
|
+
const setFieldValue = (0, import_react40.useCallback)((fieldId, value) => {
|
|
6382
6494
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
6383
6495
|
setFieldErrors((prev) => {
|
|
6384
6496
|
if (prev[fieldId]) {
|
|
@@ -6389,9 +6501,9 @@ function FormProvider({
|
|
|
6389
6501
|
return prev;
|
|
6390
6502
|
});
|
|
6391
6503
|
}, []);
|
|
6392
|
-
const getFieldValue = (0,
|
|
6393
|
-
const getFormData2 = (0,
|
|
6394
|
-
const validateFieldById = (0,
|
|
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)(
|
|
6395
6507
|
async (fieldId) => {
|
|
6396
6508
|
const field = schema.fields.find((f) => f.fieldId === fieldId);
|
|
6397
6509
|
if (!field) return true;
|
|
@@ -6416,7 +6528,7 @@ function FormProvider({
|
|
|
6416
6528
|
},
|
|
6417
6529
|
[schema, formData]
|
|
6418
6530
|
);
|
|
6419
|
-
const validateAll = (0,
|
|
6531
|
+
const validateAll = (0, import_react40.useCallback)(async () => {
|
|
6420
6532
|
const fieldRules = {};
|
|
6421
6533
|
for (const field of schema.fields) {
|
|
6422
6534
|
const rules = [];
|
|
@@ -6434,23 +6546,23 @@ function FormProvider({
|
|
|
6434
6546
|
setFieldErrors(errors);
|
|
6435
6547
|
return Object.keys(errors).length === 0;
|
|
6436
6548
|
}, [schema, formData]);
|
|
6437
|
-
const resetForm = (0,
|
|
6549
|
+
const resetForm = (0, import_react40.useCallback)(() => {
|
|
6438
6550
|
setFormData({ ...initialValuesRef.current });
|
|
6439
6551
|
setFieldErrors({});
|
|
6440
6552
|
}, []);
|
|
6441
|
-
const registerField = (0,
|
|
6553
|
+
const registerField = (0, import_react40.useCallback)(
|
|
6442
6554
|
(fieldId) => {
|
|
6443
6555
|
registeredFields.add(fieldId);
|
|
6444
6556
|
},
|
|
6445
6557
|
[registeredFields]
|
|
6446
6558
|
);
|
|
6447
|
-
const unregisterField = (0,
|
|
6559
|
+
const unregisterField = (0, import_react40.useCallback)(
|
|
6448
6560
|
(fieldId) => {
|
|
6449
6561
|
registeredFields.delete(fieldId);
|
|
6450
6562
|
},
|
|
6451
6563
|
[registeredFields]
|
|
6452
6564
|
);
|
|
6453
|
-
const contextValue = (0,
|
|
6565
|
+
const contextValue = (0, import_react40.useMemo)(
|
|
6454
6566
|
() => ({
|
|
6455
6567
|
mode: config.mode,
|
|
6456
6568
|
schema,
|
|
@@ -6496,15 +6608,15 @@ function FormProvider({
|
|
|
6496
6608
|
]
|
|
6497
6609
|
);
|
|
6498
6610
|
const registryComponents = components ?? defaultComponentRegistry;
|
|
6499
|
-
return
|
|
6611
|
+
return import_react40.default.createElement(
|
|
6500
6612
|
FormContext.Provider,
|
|
6501
6613
|
{ value: contextValue },
|
|
6502
|
-
|
|
6614
|
+
import_react40.default.createElement(ComponentRegistryProvider, { components: registryComponents, children })
|
|
6503
6615
|
);
|
|
6504
6616
|
}
|
|
6505
6617
|
|
|
6506
6618
|
// src/core/FormRenderer.tsx
|
|
6507
|
-
var
|
|
6619
|
+
var import_react41 = __toESM(require("react"));
|
|
6508
6620
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
6509
6621
|
var columnsClassMap = {
|
|
6510
6622
|
1: "sy-grid-cols-1",
|
|
@@ -6528,7 +6640,7 @@ function FieldRenderer({ field, fieldClassName }) {
|
|
|
6528
6640
|
return null;
|
|
6529
6641
|
}
|
|
6530
6642
|
const { fieldId, componentName: _, ...fieldProps } = field;
|
|
6531
|
-
return
|
|
6643
|
+
return import_react41.default.createElement(Component, {
|
|
6532
6644
|
...fieldProps,
|
|
6533
6645
|
fieldId,
|
|
6534
6646
|
className: fieldClassName ?? fieldProps.className
|
|
@@ -6548,7 +6660,7 @@ function FormRenderer({
|
|
|
6548
6660
|
}
|
|
6549
6661
|
|
|
6550
6662
|
// src/core/FormActions.tsx
|
|
6551
|
-
var
|
|
6663
|
+
var import_react42 = require("react");
|
|
6552
6664
|
var import_antd22 = require("antd");
|
|
6553
6665
|
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
6554
6666
|
function FormActions({
|
|
@@ -6559,9 +6671,9 @@ function FormActions({
|
|
|
6559
6671
|
onSubmit
|
|
6560
6672
|
}) {
|
|
6561
6673
|
const { mode, validateAll, getFormData: getFormData2, resetForm, api, config } = useFormContext();
|
|
6562
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
6563
|
-
const [submitError, setSubmitError] = (0,
|
|
6564
|
-
const handleSubmit = (0,
|
|
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 () => {
|
|
6565
6677
|
setSubmitError(null);
|
|
6566
6678
|
const valid = await validateAll();
|
|
6567
6679
|
if (!valid) return;
|
|
@@ -6597,7 +6709,7 @@ function FormActions({
|
|
|
6597
6709
|
setIsSubmitting(false);
|
|
6598
6710
|
}
|
|
6599
6711
|
}, [api, config, getFormData2, mode, onSubmit, validateAll]);
|
|
6600
|
-
const handleReset = (0,
|
|
6712
|
+
const handleReset = (0, import_react42.useCallback)(() => {
|
|
6601
6713
|
resetForm();
|
|
6602
6714
|
}, [resetForm]);
|
|
6603
6715
|
if (mode === "readonly") return null;
|
|
@@ -7216,7 +7328,7 @@ async function getDataManagementTransferRecords(request, params) {
|
|
|
7216
7328
|
}
|
|
7217
7329
|
|
|
7218
7330
|
// src/layout/FormSection/index.tsx
|
|
7219
|
-
var
|
|
7331
|
+
var import_react43 = require("react");
|
|
7220
7332
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
7221
7333
|
function FormSection({
|
|
7222
7334
|
title,
|
|
@@ -7228,7 +7340,7 @@ function FormSection({
|
|
|
7228
7340
|
contentClassName,
|
|
7229
7341
|
children
|
|
7230
7342
|
}) {
|
|
7231
|
-
const [collapsed, setCollapsed] = (0,
|
|
7343
|
+
const [collapsed, setCollapsed] = (0, import_react43.useState)(defaultCollapsed);
|
|
7232
7344
|
const handleToggle = () => {
|
|
7233
7345
|
if (collapsible) {
|
|
7234
7346
|
setCollapsed((prev) => !prev);
|
|
@@ -7296,10 +7408,10 @@ function FormGrid({ columns = 2, gap = 4, className, children }) {
|
|
|
7296
7408
|
}
|
|
7297
7409
|
|
|
7298
7410
|
// src/layout/FormTabs/index.tsx
|
|
7299
|
-
var
|
|
7411
|
+
var import_react44 = require("react");
|
|
7300
7412
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
7301
7413
|
function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
7302
|
-
const [activeKey, setActiveKey] = (0,
|
|
7414
|
+
const [activeKey, setActiveKey] = (0, import_react44.useState)(defaultActiveKey || items[0]?.key || "");
|
|
7303
7415
|
const activeItem = items.find((item) => item.key === activeKey);
|
|
7304
7416
|
return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-tabs", children: [
|
|
7305
7417
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
@@ -7328,10 +7440,10 @@ function FormTabs({ items, defaultActiveKey, className, tabClassName }) {
|
|
|
7328
7440
|
}
|
|
7329
7441
|
|
|
7330
7442
|
// src/layout/FormSteps/index.tsx
|
|
7331
|
-
var
|
|
7443
|
+
var import_react45 = __toESM(require("react"));
|
|
7332
7444
|
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
7333
7445
|
function FormSteps({ items, className, onStepChange }) {
|
|
7334
|
-
const [currentStep, setCurrentStep] = (0,
|
|
7446
|
+
const [currentStep, setCurrentStep] = (0, import_react45.useState)(0);
|
|
7335
7447
|
const goTo = (step) => {
|
|
7336
7448
|
setCurrentStep(step);
|
|
7337
7449
|
onStepChange?.(step);
|
|
@@ -7347,7 +7459,7 @@ function FormSteps({ items, className, onStepChange }) {
|
|
|
7347
7459
|
}
|
|
7348
7460
|
};
|
|
7349
7461
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: className ?? "w-full", "data-testid": "form-steps", children: [
|
|
7350
|
-
/* @__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)(
|
|
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: [
|
|
7351
7463
|
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center", children: [
|
|
7352
7464
|
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
7353
7465
|
"div",
|
|
@@ -7439,9 +7551,9 @@ function FormSummary({
|
|
|
7439
7551
|
}
|
|
7440
7552
|
|
|
7441
7553
|
// src/hooks/useFormEngine.ts
|
|
7442
|
-
var
|
|
7554
|
+
var import_react46 = require("react");
|
|
7443
7555
|
function useFormEngine(schema, config) {
|
|
7444
|
-
const initialValues = (0,
|
|
7556
|
+
const initialValues = (0, import_react46.useMemo)(() => {
|
|
7445
7557
|
const values = {};
|
|
7446
7558
|
for (const field of schema.fields) {
|
|
7447
7559
|
if (field.defaultValue !== void 0) {
|
|
@@ -7450,10 +7562,10 @@ function useFormEngine(schema, config) {
|
|
|
7450
7562
|
}
|
|
7451
7563
|
return values;
|
|
7452
7564
|
}, [schema]);
|
|
7453
|
-
const initialValuesRef = (0,
|
|
7454
|
-
const [formData, setFormData] = (0,
|
|
7455
|
-
const [fieldErrors, setFieldErrors] = (0,
|
|
7456
|
-
const fieldBehaviors = (0,
|
|
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)(() => {
|
|
7457
7569
|
const baseBehaviors = {};
|
|
7458
7570
|
for (const field of schema.fields) {
|
|
7459
7571
|
baseBehaviors[field.fieldId] = field.behavior || "NORMAL";
|
|
@@ -7476,7 +7588,7 @@ function useFormEngine(schema, config) {
|
|
|
7476
7588
|
}
|
|
7477
7589
|
return computed;
|
|
7478
7590
|
}, [schema, config.effects, config.permissions, config.mode, formData]);
|
|
7479
|
-
const setFieldValue = (0,
|
|
7591
|
+
const setFieldValue = (0, import_react46.useCallback)((fieldId, value) => {
|
|
7480
7592
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
7481
7593
|
setFieldErrors((prev) => {
|
|
7482
7594
|
if (prev[fieldId]) {
|
|
@@ -7487,9 +7599,9 @@ function useFormEngine(schema, config) {
|
|
|
7487
7599
|
return prev;
|
|
7488
7600
|
});
|
|
7489
7601
|
}, []);
|
|
7490
|
-
const getFieldValue = (0,
|
|
7491
|
-
const getFormData2 = (0,
|
|
7492
|
-
const validateAll = (0,
|
|
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 () => {
|
|
7493
7605
|
const fieldRules = {};
|
|
7494
7606
|
for (const field of schema.fields) {
|
|
7495
7607
|
const rules = [];
|
|
@@ -7507,7 +7619,7 @@ function useFormEngine(schema, config) {
|
|
|
7507
7619
|
setFieldErrors(errors);
|
|
7508
7620
|
return Object.keys(errors).length === 0;
|
|
7509
7621
|
}, [schema, formData]);
|
|
7510
|
-
const resetForm = (0,
|
|
7622
|
+
const resetForm = (0, import_react46.useCallback)(() => {
|
|
7511
7623
|
setFormData({ ...initialValuesRef.current });
|
|
7512
7624
|
setFieldErrors({});
|
|
7513
7625
|
}, []);
|
|
@@ -7525,12 +7637,12 @@ function useFormEngine(schema, config) {
|
|
|
7525
7637
|
}
|
|
7526
7638
|
|
|
7527
7639
|
// src/hooks/useFormData.ts
|
|
7528
|
-
var
|
|
7640
|
+
var import_react47 = require("react");
|
|
7529
7641
|
function useFormData(initialValues = {}) {
|
|
7530
|
-
const [formData, setFormData] = (0,
|
|
7531
|
-
const [dirtyFields, setDirtyFields] = (0,
|
|
7532
|
-
const initialValuesRef = (0,
|
|
7533
|
-
const setFieldValue = (0,
|
|
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) => {
|
|
7534
7646
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
7535
7647
|
setDirtyFields((prev) => {
|
|
7536
7648
|
const next = new Set(prev);
|
|
@@ -7538,16 +7650,16 @@ function useFormData(initialValues = {}) {
|
|
|
7538
7650
|
return next;
|
|
7539
7651
|
});
|
|
7540
7652
|
}, []);
|
|
7541
|
-
const getFieldValue = (0,
|
|
7653
|
+
const getFieldValue = (0, import_react47.useCallback)(
|
|
7542
7654
|
(fieldId) => {
|
|
7543
7655
|
return formData[fieldId];
|
|
7544
7656
|
},
|
|
7545
7657
|
[formData]
|
|
7546
7658
|
);
|
|
7547
|
-
const getFormData2 = (0,
|
|
7659
|
+
const getFormData2 = (0, import_react47.useCallback)(() => {
|
|
7548
7660
|
return { ...formData };
|
|
7549
7661
|
}, [formData]);
|
|
7550
|
-
const resetForm = (0,
|
|
7662
|
+
const resetForm = (0, import_react47.useCallback)(() => {
|
|
7551
7663
|
setFormData({ ...initialValuesRef.current });
|
|
7552
7664
|
setDirtyFields(/* @__PURE__ */ new Set());
|
|
7553
7665
|
}, []);
|
|
@@ -7562,7 +7674,7 @@ function useFormData(initialValues = {}) {
|
|
|
7562
7674
|
}
|
|
7563
7675
|
|
|
7564
7676
|
// src/hooks/useFieldBehavior.ts
|
|
7565
|
-
var
|
|
7677
|
+
var import_react48 = require("react");
|
|
7566
7678
|
function useFieldBehavior({
|
|
7567
7679
|
fieldId,
|
|
7568
7680
|
permissions,
|
|
@@ -7570,7 +7682,7 @@ function useFieldBehavior({
|
|
|
7570
7682
|
formData,
|
|
7571
7683
|
defaultBehavior = "NORMAL"
|
|
7572
7684
|
}) {
|
|
7573
|
-
return (0,
|
|
7685
|
+
return (0, import_react48.useMemo)(() => {
|
|
7574
7686
|
if (permissions && permissions[fieldId]) {
|
|
7575
7687
|
return permissions[fieldId];
|
|
7576
7688
|
}
|
|
@@ -7584,11 +7696,11 @@ function useFieldBehavior({
|
|
|
7584
7696
|
}
|
|
7585
7697
|
|
|
7586
7698
|
// src/hooks/useFormSubmit.ts
|
|
7587
|
-
var
|
|
7699
|
+
var import_react49 = require("react");
|
|
7588
7700
|
function useFormSubmit(config) {
|
|
7589
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
7590
|
-
const [submitError, setSubmitError] = (0,
|
|
7591
|
-
const submit = (0,
|
|
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)(
|
|
7592
7704
|
async (formData, validateFn) => {
|
|
7593
7705
|
setSubmitError(null);
|
|
7594
7706
|
const isValid = await validateFn();
|
|
@@ -7620,7 +7732,7 @@ function useFormSubmit(config) {
|
|
|
7620
7732
|
}
|
|
7621
7733
|
|
|
7622
7734
|
// src/hooks/useFieldPermission.ts
|
|
7623
|
-
var
|
|
7735
|
+
var import_react50 = require("react");
|
|
7624
7736
|
|
|
7625
7737
|
// src/utils/permissions.ts
|
|
7626
7738
|
var OPERATION_ALIASES = {
|
|
@@ -7693,7 +7805,7 @@ var normalizeFlowConfig = (config) => {
|
|
|
7693
7805
|
};
|
|
7694
7806
|
function useFieldPermission(options) {
|
|
7695
7807
|
const { viewPermissions, processDefinition, currentTask, isApprover, mode } = options;
|
|
7696
|
-
const computeBehaviors = (0,
|
|
7808
|
+
const computeBehaviors = (0, import_react50.useCallback)(() => {
|
|
7697
7809
|
const behaviors = {};
|
|
7698
7810
|
if (!currentTask && viewPermissions) {
|
|
7699
7811
|
return normalizeFieldBehaviors(viewPermissions, mode);
|
|
@@ -7738,12 +7850,12 @@ function useFieldPermission(options) {
|
|
|
7738
7850
|
}
|
|
7739
7851
|
return behaviors;
|
|
7740
7852
|
}, [viewPermissions, processDefinition, currentTask, isApprover, mode]);
|
|
7741
|
-
const fieldBehaviors = (0,
|
|
7853
|
+
const fieldBehaviors = (0, import_react50.useMemo)(() => computeBehaviors(), [computeBehaviors]);
|
|
7742
7854
|
return { fieldBehaviors, computeBehaviors };
|
|
7743
7855
|
}
|
|
7744
7856
|
|
|
7745
7857
|
// src/hooks/useFormDetail.ts
|
|
7746
|
-
var
|
|
7858
|
+
var import_react51 = require("react");
|
|
7747
7859
|
|
|
7748
7860
|
// src/utils/formInstanceData.ts
|
|
7749
7861
|
var FORM_INSTANCE_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -7902,24 +8014,24 @@ function useFormDetail(options) {
|
|
|
7902
8014
|
const { formUuid, appType, formInstanceId, fieldIds, onPermissionDenied } = options;
|
|
7903
8015
|
const { api } = useFormContext();
|
|
7904
8016
|
const request = api.request;
|
|
7905
|
-
const [loading, setLoading] = (0,
|
|
7906
|
-
const [mode, setMode] = (0,
|
|
7907
|
-
const [formData, setFormData] = (0,
|
|
7908
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
7909
|
-
const [permissions, setPermissions] = (0,
|
|
7910
|
-
const mountedRef = (0,
|
|
7911
|
-
const onPermissionDeniedRef = (0,
|
|
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);
|
|
7912
8024
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
7913
|
-
(0,
|
|
8025
|
+
(0, import_react51.useEffect)(() => {
|
|
7914
8026
|
mountedRef.current = true;
|
|
7915
8027
|
return () => {
|
|
7916
8028
|
mountedRef.current = false;
|
|
7917
8029
|
};
|
|
7918
8030
|
}, []);
|
|
7919
|
-
(0,
|
|
8031
|
+
(0, import_react51.useEffect)(() => {
|
|
7920
8032
|
onPermissionDeniedRef.current = onPermissionDenied;
|
|
7921
8033
|
}, [onPermissionDenied]);
|
|
7922
|
-
const loadData = (0,
|
|
8034
|
+
const loadData = (0, import_react51.useCallback)(async () => {
|
|
7923
8035
|
if (!mountedRef.current) return;
|
|
7924
8036
|
setLoading(true);
|
|
7925
8037
|
try {
|
|
@@ -7954,21 +8066,21 @@ function useFormDetail(options) {
|
|
|
7954
8066
|
}
|
|
7955
8067
|
}
|
|
7956
8068
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
7957
|
-
(0,
|
|
8069
|
+
(0, import_react51.useEffect)(() => {
|
|
7958
8070
|
loadData();
|
|
7959
8071
|
}, [loadData]);
|
|
7960
8072
|
const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
|
|
7961
8073
|
const canEdit = hasViewOperation(permissions?.operations, "edit");
|
|
7962
8074
|
const canDelete = hasViewOperation(permissions?.operations, "delete");
|
|
7963
8075
|
const canViewChangeRecords = hasViewOperation(permissions?.operations, "change_records");
|
|
7964
|
-
const switchToEdit = (0,
|
|
8076
|
+
const switchToEdit = (0, import_react51.useCallback)(() => {
|
|
7965
8077
|
setMode("edit");
|
|
7966
8078
|
loadData();
|
|
7967
8079
|
}, [loadData]);
|
|
7968
|
-
const switchToReadonly = (0,
|
|
8080
|
+
const switchToReadonly = (0, import_react51.useCallback)(() => {
|
|
7969
8081
|
setMode("readonly");
|
|
7970
8082
|
}, []);
|
|
7971
|
-
const saveChanges = (0,
|
|
8083
|
+
const saveChanges = (0, import_react51.useCallback)(
|
|
7972
8084
|
async (values) => {
|
|
7973
8085
|
try {
|
|
7974
8086
|
await api.updateFormData({
|
|
@@ -7989,7 +8101,7 @@ function useFormDetail(options) {
|
|
|
7989
8101
|
},
|
|
7990
8102
|
[api, formInstanceId, formUuid, appType]
|
|
7991
8103
|
);
|
|
7992
|
-
const deleteInstance = (0,
|
|
8104
|
+
const deleteInstance = (0, import_react51.useCallback)(async () => {
|
|
7993
8105
|
try {
|
|
7994
8106
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
7995
8107
|
return true;
|
|
@@ -8016,7 +8128,7 @@ function useFormDetail(options) {
|
|
|
8016
8128
|
}
|
|
8017
8129
|
|
|
8018
8130
|
// src/hooks/useProcessDetail.ts
|
|
8019
|
-
var
|
|
8131
|
+
var import_react52 = require("react");
|
|
8020
8132
|
var DEFAULT_APPROVAL_ACTIONS = [
|
|
8021
8133
|
{ action: "agree", name: { zh_CN: "\u540C\u610F" } },
|
|
8022
8134
|
{ action: "rejected", name: { zh_CN: "\u62D2\u7EDD" } }
|
|
@@ -8044,29 +8156,29 @@ function useProcessDetail(options) {
|
|
|
8044
8156
|
const { formUuid, appType, formInstanceId, fieldIds } = options;
|
|
8045
8157
|
const { api } = useFormContext();
|
|
8046
8158
|
const request = api.request;
|
|
8047
|
-
const [loading, setLoading] = (0,
|
|
8048
|
-
const [mode, setMode] = (0,
|
|
8049
|
-
const [processInfo, setProcessInfo] = (0,
|
|
8050
|
-
const [progressList, setProgressList] = (0,
|
|
8051
|
-
const [formData, setFormData] = (0,
|
|
8052
|
-
const [instanceInfo, setInstanceInfo] = (0,
|
|
8053
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
8054
|
-
const [loadError, setLoadError] = (0,
|
|
8055
|
-
const [isApprover, setIsApprover] = (0,
|
|
8056
|
-
const [canWithdraw, setCanWithdraw] = (0,
|
|
8057
|
-
const [approvalTasks, setApprovalTasks] = (0,
|
|
8058
|
-
const [permissions, setPermissions] = (0,
|
|
8059
|
-
const [processDefinition, setProcessDefinition] = (0,
|
|
8060
|
-
const [dataVersion, setDataVersion] = (0,
|
|
8061
|
-
const mountedRef = (0,
|
|
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);
|
|
8062
8174
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
8063
|
-
(0,
|
|
8175
|
+
(0, import_react52.useEffect)(() => {
|
|
8064
8176
|
mountedRef.current = true;
|
|
8065
8177
|
return () => {
|
|
8066
8178
|
mountedRef.current = false;
|
|
8067
8179
|
};
|
|
8068
8180
|
}, []);
|
|
8069
|
-
const currentTask = (0,
|
|
8181
|
+
const currentTask = (0, import_react52.useMemo)(
|
|
8070
8182
|
() => mergeCurrentTask(processInfo?.currentTask, approvalTasks[0]),
|
|
8071
8183
|
[processInfo?.currentTask, approvalTasks]
|
|
8072
8184
|
);
|
|
@@ -8086,7 +8198,7 @@ function useProcessDetail(options) {
|
|
|
8086
8198
|
isApprover: isProcessFinal ? false : isApprover,
|
|
8087
8199
|
mode
|
|
8088
8200
|
});
|
|
8089
|
-
const activeActions = (0,
|
|
8201
|
+
const activeActions = (0, import_react52.useMemo)(() => {
|
|
8090
8202
|
if (!isApprover || isProcessFinal) return [];
|
|
8091
8203
|
const actions = currentTask?.actions && currentTask.actions.length > 0 ? [...currentTask.actions] : [...DEFAULT_APPROVAL_ACTIONS];
|
|
8092
8204
|
if (canWithdraw && !actions.some((action) => action.action === "withdraw")) {
|
|
@@ -8094,7 +8206,7 @@ function useProcessDetail(options) {
|
|
|
8094
8206
|
}
|
|
8095
8207
|
return actions;
|
|
8096
8208
|
}, [isApprover, isProcessFinal, currentTask?.actions, canWithdraw]);
|
|
8097
|
-
const loadData = (0,
|
|
8209
|
+
const loadData = (0, import_react52.useCallback)(async () => {
|
|
8098
8210
|
if (!mountedRef.current) return;
|
|
8099
8211
|
setLoading(true);
|
|
8100
8212
|
setAccessDenied(false);
|
|
@@ -8176,24 +8288,24 @@ function useProcessDetail(options) {
|
|
|
8176
8288
|
}
|
|
8177
8289
|
}
|
|
8178
8290
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
8179
|
-
(0,
|
|
8291
|
+
(0, import_react52.useEffect)(() => {
|
|
8180
8292
|
loadData();
|
|
8181
8293
|
}, [loadData]);
|
|
8182
|
-
const switchToEdit = (0,
|
|
8294
|
+
const switchToEdit = (0, import_react52.useCallback)(() => {
|
|
8183
8295
|
setMode("edit");
|
|
8184
8296
|
void loadData();
|
|
8185
8297
|
}, [loadData]);
|
|
8186
|
-
const switchToReadonly = (0,
|
|
8298
|
+
const switchToReadonly = (0, import_react52.useCallback)(() => {
|
|
8187
8299
|
setMode("readonly");
|
|
8188
8300
|
}, []);
|
|
8189
|
-
const refreshDetail = (0,
|
|
8301
|
+
const refreshDetail = (0, import_react52.useCallback)(async () => {
|
|
8190
8302
|
setMode("readonly");
|
|
8191
8303
|
await loadData();
|
|
8192
8304
|
}, [loadData]);
|
|
8193
|
-
const refreshProgress = (0,
|
|
8305
|
+
const refreshProgress = (0, import_react52.useCallback)(async () => {
|
|
8194
8306
|
await refreshDetail();
|
|
8195
8307
|
}, [refreshDetail]);
|
|
8196
|
-
const saveChanges = (0,
|
|
8308
|
+
const saveChanges = (0, import_react52.useCallback)(
|
|
8197
8309
|
async (values) => {
|
|
8198
8310
|
try {
|
|
8199
8311
|
await api.updateFormData({
|
|
@@ -8212,7 +8324,7 @@ function useProcessDetail(options) {
|
|
|
8212
8324
|
},
|
|
8213
8325
|
[api, formInstanceId, formUuid, appType, loadData]
|
|
8214
8326
|
);
|
|
8215
|
-
const deleteInstance = (0,
|
|
8327
|
+
const deleteInstance = (0, import_react52.useCallback)(async () => {
|
|
8216
8328
|
try {
|
|
8217
8329
|
await deleteFormData(request, { formInstanceId, appType, formUuid });
|
|
8218
8330
|
return true;
|
|
@@ -8253,29 +8365,29 @@ function useProcessDetail(options) {
|
|
|
8253
8365
|
}
|
|
8254
8366
|
|
|
8255
8367
|
// src/hooks/useApprovalActions.ts
|
|
8256
|
-
var
|
|
8368
|
+
var import_react53 = require("react");
|
|
8257
8369
|
function useApprovalActions(options) {
|
|
8258
8370
|
const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
|
|
8259
8371
|
const { api } = useFormContext();
|
|
8260
8372
|
const request = api.request;
|
|
8261
|
-
const [isLoading, setIsLoading] = (0,
|
|
8262
|
-
const [currentAction, setCurrentAction] = (0,
|
|
8263
|
-
const [returnableNodes, setReturnableNodes] = (0,
|
|
8264
|
-
const [returnPolicy, setReturnPolicy] = (0,
|
|
8265
|
-
const mountedRef = (0,
|
|
8266
|
-
(0,
|
|
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)(() => {
|
|
8267
8379
|
mountedRef.current = true;
|
|
8268
8380
|
return () => {
|
|
8269
8381
|
mountedRef.current = false;
|
|
8270
8382
|
};
|
|
8271
8383
|
}, []);
|
|
8272
|
-
const resetLoading = (0,
|
|
8384
|
+
const resetLoading = (0, import_react53.useCallback)(() => {
|
|
8273
8385
|
if (mountedRef.current) {
|
|
8274
8386
|
setIsLoading(false);
|
|
8275
8387
|
setCurrentAction(null);
|
|
8276
8388
|
}
|
|
8277
8389
|
}, []);
|
|
8278
|
-
const approve = (0,
|
|
8390
|
+
const approve = (0, import_react53.useCallback)(
|
|
8279
8391
|
async (comments) => {
|
|
8280
8392
|
setIsLoading(true);
|
|
8281
8393
|
setCurrentAction("approve");
|
|
@@ -8300,7 +8412,7 @@ function useApprovalActions(options) {
|
|
|
8300
8412
|
},
|
|
8301
8413
|
[request, formInstanceId, appType, formUuid, getFormValues, onActionComplete, resetLoading]
|
|
8302
8414
|
);
|
|
8303
|
-
const reject = (0,
|
|
8415
|
+
const reject = (0, import_react53.useCallback)(
|
|
8304
8416
|
async (comments) => {
|
|
8305
8417
|
setIsLoading(true);
|
|
8306
8418
|
setCurrentAction("reject");
|
|
@@ -8321,7 +8433,7 @@ function useApprovalActions(options) {
|
|
|
8321
8433
|
},
|
|
8322
8434
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
8323
8435
|
);
|
|
8324
|
-
const transfer = (0,
|
|
8436
|
+
const transfer = (0, import_react53.useCallback)(
|
|
8325
8437
|
async (userId, reason) => {
|
|
8326
8438
|
if (!currentTaskId) {
|
|
8327
8439
|
console.error("[useApprovalActions] transfer failed: no currentTaskId");
|
|
@@ -8346,7 +8458,7 @@ function useApprovalActions(options) {
|
|
|
8346
8458
|
},
|
|
8347
8459
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
8348
8460
|
);
|
|
8349
|
-
const returnTo = (0,
|
|
8461
|
+
const returnTo = (0, import_react53.useCallback)(
|
|
8350
8462
|
async (nodeId, reason) => {
|
|
8351
8463
|
if (!currentTaskId) {
|
|
8352
8464
|
console.error("[useApprovalActions] returnTo failed: no currentTaskId");
|
|
@@ -8371,7 +8483,7 @@ function useApprovalActions(options) {
|
|
|
8371
8483
|
},
|
|
8372
8484
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
8373
8485
|
);
|
|
8374
|
-
const withdraw = (0,
|
|
8486
|
+
const withdraw = (0, import_react53.useCallback)(
|
|
8375
8487
|
async (reason) => {
|
|
8376
8488
|
setIsLoading(true);
|
|
8377
8489
|
setCurrentAction("withdraw");
|
|
@@ -8391,7 +8503,7 @@ function useApprovalActions(options) {
|
|
|
8391
8503
|
},
|
|
8392
8504
|
[request, formInstanceId, onActionComplete, resetLoading]
|
|
8393
8505
|
);
|
|
8394
|
-
const save = (0,
|
|
8506
|
+
const save = (0, import_react53.useCallback)(async () => {
|
|
8395
8507
|
setIsLoading(true);
|
|
8396
8508
|
setCurrentAction("save");
|
|
8397
8509
|
try {
|
|
@@ -8411,7 +8523,7 @@ function useApprovalActions(options) {
|
|
|
8411
8523
|
return false;
|
|
8412
8524
|
}
|
|
8413
8525
|
}, [request, formInstanceId, formUuid, appType, getFormValues, onActionComplete, resetLoading]);
|
|
8414
|
-
const resubmit = (0,
|
|
8526
|
+
const resubmit = (0, import_react53.useCallback)(
|
|
8415
8527
|
async (comments) => {
|
|
8416
8528
|
if (!currentTaskId) {
|
|
8417
8529
|
console.error("[useApprovalActions] resubmit failed: no currentTaskId");
|
|
@@ -8439,7 +8551,7 @@ function useApprovalActions(options) {
|
|
|
8439
8551
|
},
|
|
8440
8552
|
[request, currentTaskId, formUuid, appType, getFormValues, onActionComplete, resetLoading]
|
|
8441
8553
|
);
|
|
8442
|
-
const callbackTask = (0,
|
|
8554
|
+
const callbackTask = (0, import_react53.useCallback)(
|
|
8443
8555
|
async (payload) => {
|
|
8444
8556
|
if (!currentTaskId) {
|
|
8445
8557
|
console.error("[useApprovalActions] callbackTask failed: no currentTaskId");
|
|
@@ -8463,7 +8575,7 @@ function useApprovalActions(options) {
|
|
|
8463
8575
|
},
|
|
8464
8576
|
[request, currentTaskId, onActionComplete, resetLoading]
|
|
8465
8577
|
);
|
|
8466
|
-
const loadReturnableNodes = (0,
|
|
8578
|
+
const loadReturnableNodes = (0, import_react53.useCallback)(async () => {
|
|
8467
8579
|
if (!currentTaskId) return [];
|
|
8468
8580
|
try {
|
|
8469
8581
|
const result = await getReturnableNodeResult(request, currentTaskId);
|
|
@@ -8499,7 +8611,7 @@ function useApprovalActions(options) {
|
|
|
8499
8611
|
}
|
|
8500
8612
|
|
|
8501
8613
|
// src/hooks/useChangeRecords.ts
|
|
8502
|
-
var
|
|
8614
|
+
var import_react54 = require("react");
|
|
8503
8615
|
var normalizeChangeRecordList = (value) => {
|
|
8504
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;
|
|
8505
8617
|
const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
|
|
@@ -8514,18 +8626,18 @@ function useChangeRecords(options) {
|
|
|
8514
8626
|
const { formUuid, appType, formInstanceId, pageSize = 20, autoLoad = true } = options;
|
|
8515
8627
|
const { api } = useFormContext();
|
|
8516
8628
|
const request = api.request;
|
|
8517
|
-
const [records, setRecords] = (0,
|
|
8518
|
-
const [loading, setLoading] = (0,
|
|
8519
|
-
const [total, setTotal] = (0,
|
|
8520
|
-
const [page, setPage] = (0,
|
|
8521
|
-
const mountedRef = (0,
|
|
8522
|
-
(0,
|
|
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)(() => {
|
|
8523
8635
|
mountedRef.current = true;
|
|
8524
8636
|
return () => {
|
|
8525
8637
|
mountedRef.current = false;
|
|
8526
8638
|
};
|
|
8527
8639
|
}, []);
|
|
8528
|
-
const fetchRecords = (0,
|
|
8640
|
+
const fetchRecords = (0, import_react54.useCallback)(
|
|
8529
8641
|
async (pageNum, append) => {
|
|
8530
8642
|
if (!mountedRef.current) return;
|
|
8531
8643
|
setLoading(true);
|
|
@@ -8556,18 +8668,18 @@ function useChangeRecords(options) {
|
|
|
8556
8668
|
},
|
|
8557
8669
|
[request, formUuid, appType, formInstanceId, pageSize]
|
|
8558
8670
|
);
|
|
8559
|
-
(0,
|
|
8671
|
+
(0, import_react54.useEffect)(() => {
|
|
8560
8672
|
if (autoLoad) {
|
|
8561
8673
|
fetchRecords(1, false);
|
|
8562
8674
|
}
|
|
8563
8675
|
}, [autoLoad, fetchRecords]);
|
|
8564
8676
|
const safeRecords = Array.isArray(records) ? records : [];
|
|
8565
8677
|
const hasMore = safeRecords.length < total;
|
|
8566
|
-
const loadMore = (0,
|
|
8678
|
+
const loadMore = (0, import_react54.useCallback)(async () => {
|
|
8567
8679
|
if (!hasMore || loading) return;
|
|
8568
8680
|
await fetchRecords(page + 1, true);
|
|
8569
8681
|
}, [hasMore, loading, page, fetchRecords]);
|
|
8570
|
-
const refresh = (0,
|
|
8682
|
+
const refresh = (0, import_react54.useCallback)(async () => {
|
|
8571
8683
|
setRecords([]);
|
|
8572
8684
|
setPage(1);
|
|
8573
8685
|
setTotal(0);
|
|
@@ -8585,7 +8697,7 @@ function useChangeRecords(options) {
|
|
|
8585
8697
|
}
|
|
8586
8698
|
|
|
8587
8699
|
// src/hooks/useFormNavigation.ts
|
|
8588
|
-
var
|
|
8700
|
+
var import_react55 = require("react");
|
|
8589
8701
|
var normalizeBasePath = (basePath) => {
|
|
8590
8702
|
const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
|
|
8591
8703
|
return normalized ? `/${normalized}` : "";
|
|
@@ -8612,12 +8724,12 @@ function useFormNavigation(options) {
|
|
|
8612
8724
|
basePath,
|
|
8613
8725
|
onStay
|
|
8614
8726
|
} = options;
|
|
8615
|
-
const [isRedirecting, setIsRedirecting] = (0,
|
|
8616
|
-
const [countdown, setCountdown] = (0,
|
|
8617
|
-
const timerRef = (0,
|
|
8618
|
-
const redirectTargetRef = (0,
|
|
8619
|
-
const mountedRef = (0,
|
|
8620
|
-
(0,
|
|
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)(() => {
|
|
8621
8733
|
mountedRef.current = true;
|
|
8622
8734
|
return () => {
|
|
8623
8735
|
mountedRef.current = false;
|
|
@@ -8627,13 +8739,13 @@ function useFormNavigation(options) {
|
|
|
8627
8739
|
}
|
|
8628
8740
|
};
|
|
8629
8741
|
}, []);
|
|
8630
|
-
const navigateToDetail = (0,
|
|
8742
|
+
const navigateToDetail = (0, import_react55.useCallback)(
|
|
8631
8743
|
(formInstId) => {
|
|
8632
8744
|
window.location.href = buildDetailUrl(appType, formUuid, formInstId, "formDetail", basePath);
|
|
8633
8745
|
},
|
|
8634
8746
|
[appType, basePath, formUuid]
|
|
8635
8747
|
);
|
|
8636
|
-
const navigateToProcessDetail = (0,
|
|
8748
|
+
const navigateToProcessDetail = (0, import_react55.useCallback)(
|
|
8637
8749
|
(formInstId) => {
|
|
8638
8750
|
window.location.href = buildDetailUrl(
|
|
8639
8751
|
appType,
|
|
@@ -8645,7 +8757,7 @@ function useFormNavigation(options) {
|
|
|
8645
8757
|
},
|
|
8646
8758
|
[appType, basePath, formUuid]
|
|
8647
8759
|
);
|
|
8648
|
-
const startRedirectCountdown = (0,
|
|
8760
|
+
const startRedirectCountdown = (0, import_react55.useCallback)(
|
|
8649
8761
|
(targetUrl) => {
|
|
8650
8762
|
const totalSeconds = Math.ceil(redirectDelay / 1e3);
|
|
8651
8763
|
setIsRedirecting(true);
|
|
@@ -8678,7 +8790,7 @@ function useFormNavigation(options) {
|
|
|
8678
8790
|
},
|
|
8679
8791
|
[redirectDelay]
|
|
8680
8792
|
);
|
|
8681
|
-
const cancelRedirect = (0,
|
|
8793
|
+
const cancelRedirect = (0, import_react55.useCallback)(() => {
|
|
8682
8794
|
if (timerRef.current) {
|
|
8683
8795
|
clearInterval(timerRef.current);
|
|
8684
8796
|
timerRef.current = null;
|
|
@@ -8687,7 +8799,7 @@ function useFormNavigation(options) {
|
|
|
8687
8799
|
setCountdown(0);
|
|
8688
8800
|
redirectTargetRef.current = null;
|
|
8689
8801
|
}, []);
|
|
8690
|
-
const handlePostSubmit = (0,
|
|
8802
|
+
const handlePostSubmit = (0, import_react55.useCallback)(
|
|
8691
8803
|
(formInstId) => {
|
|
8692
8804
|
if (mode === "stay") {
|
|
8693
8805
|
onStay?.(formInstId);
|
|
@@ -8719,7 +8831,7 @@ function useFormNavigation(options) {
|
|
|
8719
8831
|
}
|
|
8720
8832
|
|
|
8721
8833
|
// src/hooks/useDraftStorage.ts
|
|
8722
|
-
var
|
|
8834
|
+
var import_react56 = require("react");
|
|
8723
8835
|
function getDraftKey(appType, formUuid) {
|
|
8724
8836
|
return `${appType}__${formUuid}__draft`;
|
|
8725
8837
|
}
|
|
@@ -8739,10 +8851,10 @@ function readDraft(key) {
|
|
|
8739
8851
|
function useDraftStorage(options) {
|
|
8740
8852
|
const { appType, formUuid, autoRestore = false } = options;
|
|
8741
8853
|
const key = getDraftKey(appType, formUuid);
|
|
8742
|
-
const [hasDraft, setHasDraft] = (0,
|
|
8743
|
-
const [draftData, setDraftData] = (0,
|
|
8744
|
-
const [draftTimestamp, setDraftTimestamp] = (0,
|
|
8745
|
-
(0,
|
|
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)(() => {
|
|
8746
8858
|
const stored = readDraft(key);
|
|
8747
8859
|
if (stored) {
|
|
8748
8860
|
setHasDraft(true);
|
|
@@ -8756,7 +8868,7 @@ function useDraftStorage(options) {
|
|
|
8756
8868
|
setDraftTimestamp(null);
|
|
8757
8869
|
}
|
|
8758
8870
|
}, [key, autoRestore]);
|
|
8759
|
-
const saveDraft = (0,
|
|
8871
|
+
const saveDraft = (0, import_react56.useCallback)(
|
|
8760
8872
|
(data) => {
|
|
8761
8873
|
const payload = { data, ts: Date.now() };
|
|
8762
8874
|
try {
|
|
@@ -8770,7 +8882,7 @@ function useDraftStorage(options) {
|
|
|
8770
8882
|
},
|
|
8771
8883
|
[key]
|
|
8772
8884
|
);
|
|
8773
|
-
const restoreDraft = (0,
|
|
8885
|
+
const restoreDraft = (0, import_react56.useCallback)(() => {
|
|
8774
8886
|
const stored = readDraft(key);
|
|
8775
8887
|
if (stored) {
|
|
8776
8888
|
setDraftData(stored.data);
|
|
@@ -8778,7 +8890,7 @@ function useDraftStorage(options) {
|
|
|
8778
8890
|
}
|
|
8779
8891
|
return null;
|
|
8780
8892
|
}, [key]);
|
|
8781
|
-
const clearDraft = (0,
|
|
8893
|
+
const clearDraft = (0, import_react56.useCallback)(() => {
|
|
8782
8894
|
try {
|
|
8783
8895
|
localStorage.removeItem(key);
|
|
8784
8896
|
} catch (error) {
|
|
@@ -8871,7 +8983,7 @@ var FormSummaryCard = ({
|
|
|
8871
8983
|
};
|
|
8872
8984
|
|
|
8873
8985
|
// src/modules/RecordChangePanel.tsx
|
|
8874
|
-
var
|
|
8986
|
+
var import_react57 = require("react");
|
|
8875
8987
|
var import_antd23 = require("antd");
|
|
8876
8988
|
var import_icons3 = require("@ant-design/icons");
|
|
8877
8989
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
@@ -8917,7 +9029,7 @@ var RecordChangePanel = ({
|
|
|
8917
9029
|
onPageChange,
|
|
8918
9030
|
className = ""
|
|
8919
9031
|
}) => {
|
|
8920
|
-
const [expanded, setExpanded] = (0,
|
|
9032
|
+
const [expanded, setExpanded] = (0, import_react57.useState)(defaultExpanded);
|
|
8921
9033
|
const count = total ?? records.length;
|
|
8922
9034
|
const handleToggle = () => {
|
|
8923
9035
|
const next = !expanded;
|
|
@@ -9087,7 +9199,7 @@ var ChangeRecords = ({
|
|
|
9087
9199
|
};
|
|
9088
9200
|
|
|
9089
9201
|
// src/modules/ApprovalTimeline.tsx
|
|
9090
|
-
var
|
|
9202
|
+
var import_react58 = require("react");
|
|
9091
9203
|
var import_icons4 = require("@ant-design/icons");
|
|
9092
9204
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
9093
9205
|
var systemNodeTypes = /* @__PURE__ */ new Set([
|
|
@@ -9236,8 +9348,8 @@ var ApprovalTimeline = ({
|
|
|
9236
9348
|
compactMode = false,
|
|
9237
9349
|
showApproverInfo = true
|
|
9238
9350
|
}) => {
|
|
9239
|
-
const taskList = (0,
|
|
9240
|
-
const groups = (0,
|
|
9351
|
+
const taskList = (0, import_react58.useMemo)(() => Array.isArray(tasks) ? tasks : [], [tasks]);
|
|
9352
|
+
const groups = (0, import_react58.useMemo)(() => groupTasks(taskList), [taskList]);
|
|
9241
9353
|
if (taskList.length === 0) {
|
|
9242
9354
|
return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
9243
9355
|
"div",
|
|
@@ -9332,12 +9444,12 @@ var ApprovalTimeline = ({
|
|
|
9332
9444
|
};
|
|
9333
9445
|
|
|
9334
9446
|
// src/modules/ApprovalActionBar.tsx
|
|
9335
|
-
var
|
|
9447
|
+
var import_react60 = __toESM(require("react"));
|
|
9336
9448
|
var import_antd25 = require("antd");
|
|
9337
9449
|
var import_icons6 = require("@ant-design/icons");
|
|
9338
9450
|
|
|
9339
9451
|
// src/modules/StickyActionBar.tsx
|
|
9340
|
-
var
|
|
9452
|
+
var import_react59 = require("react");
|
|
9341
9453
|
var import_antd24 = require("antd");
|
|
9342
9454
|
var import_icons5 = require("@ant-design/icons");
|
|
9343
9455
|
|
|
@@ -9371,14 +9483,14 @@ var StickyActionBar = ({
|
|
|
9371
9483
|
maxWidth = 1120,
|
|
9372
9484
|
position = "sticky"
|
|
9373
9485
|
}) => {
|
|
9374
|
-
const [isMobile, setIsMobile] = (0,
|
|
9375
|
-
(0,
|
|
9486
|
+
const [isMobile, setIsMobile] = (0, import_react59.useState)(false);
|
|
9487
|
+
(0, import_react59.useEffect)(() => {
|
|
9376
9488
|
const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
9377
9489
|
update();
|
|
9378
9490
|
window.addEventListener("resize", update);
|
|
9379
9491
|
return () => window.removeEventListener("resize", update);
|
|
9380
9492
|
}, []);
|
|
9381
|
-
const visibleActions = (0,
|
|
9493
|
+
const visibleActions = (0, import_react59.useMemo)(
|
|
9382
9494
|
() => actions.filter((action) => action.visible !== false).sort((left, right) => getActionPriority(left) - getActionPriority(right)),
|
|
9383
9495
|
[actions]
|
|
9384
9496
|
);
|
|
@@ -9495,9 +9607,9 @@ function DefaultTransferSelector({
|
|
|
9495
9607
|
value,
|
|
9496
9608
|
onChange
|
|
9497
9609
|
}) {
|
|
9498
|
-
const formContext =
|
|
9499
|
-
const [open, setOpen] = (0,
|
|
9500
|
-
const [selectedUsers, setSelectedUsers] = (0,
|
|
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)([]);
|
|
9501
9613
|
if (!formContext) {
|
|
9502
9614
|
return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_antd25.Input, { value, onChange: (event) => onChange(event.target.value) });
|
|
9503
9615
|
}
|
|
@@ -9552,10 +9664,10 @@ var ApprovalActionBar = ({
|
|
|
9552
9664
|
inDrawer = false
|
|
9553
9665
|
}) => {
|
|
9554
9666
|
const [form] = import_antd25.Form.useForm();
|
|
9555
|
-
const [modalAction, setModalAction] = (0,
|
|
9556
|
-
const [activeAction, setActiveAction] = (0,
|
|
9557
|
-
const [loading, setLoading] = (0,
|
|
9558
|
-
const visibleActions = (0,
|
|
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)(
|
|
9559
9671
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (actionPriority[a.action] ?? 50) - (actionPriority[b.action] ?? 50)),
|
|
9560
9672
|
[actions]
|
|
9561
9673
|
);
|
|
@@ -9731,7 +9843,7 @@ var ApprovalActionBar = ({
|
|
|
9731
9843
|
};
|
|
9732
9844
|
|
|
9733
9845
|
// src/modules/ApprovalActions.tsx
|
|
9734
|
-
var
|
|
9846
|
+
var import_react61 = require("react");
|
|
9735
9847
|
var import_antd26 = require("antd");
|
|
9736
9848
|
var import_icons7 = require("@ant-design/icons");
|
|
9737
9849
|
var import_jsx_runtime83 = require("react/jsx-runtime");
|
|
@@ -9759,12 +9871,12 @@ var ApprovalActions = ({
|
|
|
9759
9871
|
className = ""
|
|
9760
9872
|
}) => {
|
|
9761
9873
|
const [form] = import_antd26.Form.useForm();
|
|
9762
|
-
const [modalAction, setModalAction] = (0,
|
|
9763
|
-
const [activeAction, setActiveAction] = (0,
|
|
9764
|
-
const [loading, setLoading] = (0,
|
|
9765
|
-
const [saveLoading, setSaveLoading] = (0,
|
|
9766
|
-
const [directLoading, setDirectLoading] = (0,
|
|
9767
|
-
const renderableActions = (0,
|
|
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)(
|
|
9768
9880
|
() => actions.filter((action) => !action.hidden).sort((a, b) => (priority[a.action] ?? 50) - (priority[b.action] ?? 50)),
|
|
9769
9881
|
[actions]
|
|
9770
9882
|
);
|
|
@@ -9910,7 +10022,7 @@ var ApprovalActions = ({
|
|
|
9910
10022
|
};
|
|
9911
10023
|
|
|
9912
10024
|
// src/modules/FormActionBar.tsx
|
|
9913
|
-
var
|
|
10025
|
+
var import_react62 = require("react");
|
|
9914
10026
|
var import_antd27 = require("antd");
|
|
9915
10027
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
9916
10028
|
var FormActionBar = ({
|
|
@@ -9918,7 +10030,7 @@ var FormActionBar = ({
|
|
|
9918
10030
|
position = "bottom-fixed",
|
|
9919
10031
|
className = ""
|
|
9920
10032
|
}) => {
|
|
9921
|
-
const [loadingKeys, setLoadingKeys] = (0,
|
|
10033
|
+
const [loadingKeys, setLoadingKeys] = (0, import_react62.useState)(/* @__PURE__ */ new Set());
|
|
9922
10034
|
const visibleActions = actions.filter((a) => a.visible !== false);
|
|
9923
10035
|
const sortedActions = [...visibleActions].sort((a, b) => {
|
|
9924
10036
|
if (a.type === "danger" && b.type !== "danger") return -1;
|
|
@@ -10201,7 +10313,7 @@ var ProcessPreview = ({
|
|
|
10201
10313
|
};
|
|
10202
10314
|
|
|
10203
10315
|
// src/modules/DataManagementList.tsx
|
|
10204
|
-
var
|
|
10316
|
+
var import_react63 = require("react");
|
|
10205
10317
|
var import_antd32 = require("antd");
|
|
10206
10318
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
10207
10319
|
var import_icons11 = require("@ant-design/icons");
|
|
@@ -10525,7 +10637,7 @@ function ResizableColumnTitle({
|
|
|
10525
10637
|
onResize,
|
|
10526
10638
|
onResizeEnd
|
|
10527
10639
|
}) {
|
|
10528
|
-
const dragRef = (0,
|
|
10640
|
+
const dragRef = (0, import_react63.useRef)({ startX: 0, startWidth: width, latestWidth: width });
|
|
10529
10641
|
const handleMouseDown = (event) => {
|
|
10530
10642
|
event.preventDefault();
|
|
10531
10643
|
event.stopPropagation();
|
|
@@ -10586,71 +10698,71 @@ var DataManagementList = ({
|
|
|
10586
10698
|
requestOverride,
|
|
10587
10699
|
rowActions = []
|
|
10588
10700
|
}) => {
|
|
10589
|
-
const rootRef = (0,
|
|
10590
|
-
const api = (0,
|
|
10701
|
+
const rootRef = (0, import_react63.useRef)(null);
|
|
10702
|
+
const api = (0, import_react63.useMemo)(() => {
|
|
10591
10703
|
if (typeof requestOverride === "function") {
|
|
10592
10704
|
return createFormRuntimeApi({ request: requestOverride });
|
|
10593
10705
|
}
|
|
10594
10706
|
return createFormRuntimeApi(requestOverride);
|
|
10595
10707
|
}, [requestOverride]);
|
|
10596
|
-
const [fields, setFields] = (0,
|
|
10597
|
-
const [config, setConfig] = (0,
|
|
10598
|
-
const [formType, setFormType] = (0,
|
|
10599
|
-
const [showFields, setShowFields] = (0,
|
|
10600
|
-
const [lockFieldIds, setLockFieldIds] = (0,
|
|
10601
|
-
const [widths, setWidths] = (0,
|
|
10602
|
-
const widthsRef = (0,
|
|
10603
|
-
const [sort, setSort] = (0,
|
|
10604
|
-
const [density, setDensity] = (0,
|
|
10605
|
-
const [detailOpenMode, setDetailOpenMode] = (0,
|
|
10606
|
-
const [searchKeyWord, setSearchKeyWord] = (0,
|
|
10607
|
-
const [filterGroup, setFilterGroup] = (0,
|
|
10608
|
-
const [dataSource, setDataSource] = (0,
|
|
10609
|
-
const [total, setTotal] = (0,
|
|
10610
|
-
const [current, setCurrent] = (0,
|
|
10611
|
-
const [pageSize, setPageSize] = (0,
|
|
10612
|
-
const [loading, setLoading] = (0,
|
|
10613
|
-
const [schemaLoading, setSchemaLoading] = (0,
|
|
10614
|
-
const [selectedRowKeys, setSelectedRowKeys] = (0,
|
|
10615
|
-
const [filterOpen, setFilterOpen] = (0,
|
|
10616
|
-
const [columnOpen, setColumnOpen] = (0,
|
|
10617
|
-
const [exportOpen, setExportOpen] = (0,
|
|
10618
|
-
const [exportScope, setExportScope] = (0,
|
|
10619
|
-
const [exportFields, setExportFields] = (0,
|
|
10620
|
-
const [exporting, setExporting] = (0,
|
|
10621
|
-
const [importOpen, setImportOpen] = (0,
|
|
10622
|
-
const [importPreview, setImportPreview] = (0,
|
|
10623
|
-
const [importBase64, setImportBase64] = (0,
|
|
10624
|
-
const [templateDownloading, setTemplateDownloading] = (0,
|
|
10625
|
-
const [recordsOpen, setRecordsOpen] = (0,
|
|
10626
|
-
const [recordTab, setRecordTab] = (0,
|
|
10627
|
-
const [transferRecords, setTransferRecords] = (0,
|
|
10628
|
-
const [batchApprovalOpen, setBatchApprovalOpen] = (0,
|
|
10629
|
-
const [batchApprovalAction, setBatchApprovalAction] = (0,
|
|
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)(
|
|
10630
10742
|
"approved"
|
|
10631
10743
|
);
|
|
10632
|
-
const [batchApprovalComments, setBatchApprovalComments] = (0,
|
|
10633
|
-
const [batchApproving, setBatchApproving] = (0,
|
|
10634
|
-
const [activeRecord, setActiveRecord] = (0,
|
|
10635
|
-
const [detailOpen, setDetailOpen] = (0,
|
|
10636
|
-
const [submitOpen, setSubmitOpen] = (0,
|
|
10637
|
-
const fetchStateRef = (0,
|
|
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)({});
|
|
10638
10750
|
const request = api.request;
|
|
10639
|
-
const getPopupContainer = (0,
|
|
10751
|
+
const getPopupContainer = (0, import_react63.useCallback)(
|
|
10640
10752
|
(triggerNode) => rootRef.current || triggerNode?.ownerDocument?.body || (typeof document !== "undefined" ? document.body : triggerNode?.parentElement),
|
|
10641
10753
|
[]
|
|
10642
10754
|
);
|
|
10643
|
-
const confirmDanger = (0,
|
|
10755
|
+
const confirmDanger = (0, import_react63.useCallback)((title2, content, onOk) => {
|
|
10644
10756
|
if (confirmAction(title2, content)) onOk();
|
|
10645
10757
|
}, []);
|
|
10646
|
-
const visibleFields = (0,
|
|
10758
|
+
const visibleFields = (0, import_react63.useMemo)(
|
|
10647
10759
|
() => showFields.map((fieldId) => fields.find((field) => field.fieldId === fieldId)).filter(Boolean),
|
|
10648
10760
|
[fields, showFields]
|
|
10649
10761
|
);
|
|
10650
|
-
(0,
|
|
10762
|
+
(0, import_react63.useEffect)(() => {
|
|
10651
10763
|
widthsRef.current = widths;
|
|
10652
10764
|
}, [widths]);
|
|
10653
|
-
(0,
|
|
10765
|
+
(0, import_react63.useEffect)(() => {
|
|
10654
10766
|
fetchStateRef.current = {
|
|
10655
10767
|
current,
|
|
10656
10768
|
pageSize,
|
|
@@ -10659,7 +10771,7 @@ var DataManagementList = ({
|
|
|
10659
10771
|
sort
|
|
10660
10772
|
};
|
|
10661
10773
|
}, [current, filterGroup, pageSize, searchKeyWord, sort]);
|
|
10662
|
-
const loadData = (0,
|
|
10774
|
+
const loadData = (0, import_react63.useCallback)(
|
|
10663
10775
|
async (overrides = {}) => {
|
|
10664
10776
|
if (!appType || !formUuid) return;
|
|
10665
10777
|
const fetchState = { ...fetchStateRef.current, ...overrides };
|
|
@@ -10694,7 +10806,7 @@ var DataManagementList = ({
|
|
|
10694
10806
|
},
|
|
10695
10807
|
[appType, formUuid, request]
|
|
10696
10808
|
);
|
|
10697
|
-
(0,
|
|
10809
|
+
(0, import_react63.useEffect)(() => {
|
|
10698
10810
|
let mounted = true;
|
|
10699
10811
|
const loadSchemaAndConfig = async () => {
|
|
10700
10812
|
if (!appType || !formUuid) return;
|
|
@@ -10750,7 +10862,7 @@ var DataManagementList = ({
|
|
|
10750
10862
|
mounted = false;
|
|
10751
10863
|
};
|
|
10752
10864
|
}, [appType, configScope, formUuid, loadData, menuFormUuid, request]);
|
|
10753
|
-
const persistConfig = (0,
|
|
10865
|
+
const persistConfig = (0, import_react63.useCallback)(
|
|
10754
10866
|
async (patch) => {
|
|
10755
10867
|
const nextConfig = { ...config, ...patch };
|
|
10756
10868
|
setConfig(nextConfig);
|
|
@@ -10793,12 +10905,12 @@ var DataManagementList = ({
|
|
|
10793
10905
|
const handleRemoveSort = (index) => {
|
|
10794
10906
|
setSort((prev) => prev.filter((_, itemIndex) => itemIndex !== index));
|
|
10795
10907
|
};
|
|
10796
|
-
const updateColumnWidth = (0,
|
|
10908
|
+
const updateColumnWidth = (0, import_react63.useCallback)((fieldId, width) => {
|
|
10797
10909
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
10798
10910
|
widthsRef.current = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
10799
10911
|
setWidths(widthsRef.current);
|
|
10800
10912
|
}, []);
|
|
10801
|
-
const commitColumnWidth = (0,
|
|
10913
|
+
const commitColumnWidth = (0, import_react63.useCallback)(
|
|
10802
10914
|
(fieldId, width) => {
|
|
10803
10915
|
const nextWidth = Math.round(Math.max(96, Math.min(520, width)));
|
|
10804
10916
|
const nextWidths = { ...widthsRef.current, [fieldId]: nextWidth };
|
|
@@ -10808,7 +10920,7 @@ var DataManagementList = ({
|
|
|
10808
10920
|
},
|
|
10809
10921
|
[persistConfig]
|
|
10810
10922
|
);
|
|
10811
|
-
const handleDetail = (0,
|
|
10923
|
+
const handleDetail = (0, import_react63.useCallback)(
|
|
10812
10924
|
(record) => {
|
|
10813
10925
|
const formInstanceId = getRecordId(record);
|
|
10814
10926
|
if (!formInstanceId) {
|
|
@@ -10833,7 +10945,7 @@ var DataManagementList = ({
|
|
|
10833
10945
|
},
|
|
10834
10946
|
[appType, detailBasePath, detailOpenMode, detailPageUrlBuilder, formType, formUuid]
|
|
10835
10947
|
);
|
|
10836
|
-
const handleDelete = (0,
|
|
10948
|
+
const handleDelete = (0, import_react63.useCallback)(
|
|
10837
10949
|
async (ids) => {
|
|
10838
10950
|
if (ids.length === 0) return;
|
|
10839
10951
|
await deleteDataManagementRows(request, { appType, formUuid, formInstanceIds: ids });
|
|
@@ -10842,7 +10954,7 @@ var DataManagementList = ({
|
|
|
10842
10954
|
},
|
|
10843
10955
|
[appType, current, formUuid, loadData, pageSize, request]
|
|
10844
10956
|
);
|
|
10845
|
-
const getSelectedRecordIds = (0,
|
|
10957
|
+
const getSelectedRecordIds = (0, import_react63.useCallback)(
|
|
10846
10958
|
() => selectedRowKeys.map((key) => {
|
|
10847
10959
|
const record = dataSource.find((item) => String(getRecordId(item)) === String(key));
|
|
10848
10960
|
return String(getSelectedRecordId(record, key));
|
|
@@ -10959,7 +11071,7 @@ var DataManagementList = ({
|
|
|
10959
11071
|
setImportBase64("");
|
|
10960
11072
|
await loadData({ current: 1, pageSize });
|
|
10961
11073
|
};
|
|
10962
|
-
const columns = (0,
|
|
11074
|
+
const columns = (0, import_react63.useMemo)(() => {
|
|
10963
11075
|
const baseColumns = visibleFields.map((field) => {
|
|
10964
11076
|
const columnWidth = widths[field.fieldId] || field.width || 160;
|
|
10965
11077
|
return {
|
|
@@ -11050,7 +11162,7 @@ var DataManagementList = ({
|
|
|
11050
11162
|
900,
|
|
11051
11163
|
visibleFields.reduce((sum, field) => sum + (widths[field.fieldId] || field.width || 160), 136)
|
|
11052
11164
|
);
|
|
11053
|
-
const importPreviewColumns = (0,
|
|
11165
|
+
const importPreviewColumns = (0, import_react63.useMemo)(() => {
|
|
11054
11166
|
const keys = Array.from(
|
|
11055
11167
|
new Set(importPreview.flatMap((record) => Object.keys(record || {})))
|
|
11056
11168
|
).slice(0, 16);
|
|
@@ -11575,7 +11687,7 @@ var DataManagementList = ({
|
|
|
11575
11687
|
};
|
|
11576
11688
|
|
|
11577
11689
|
// src/templates/FormSubmitTemplate.tsx
|
|
11578
|
-
var
|
|
11690
|
+
var import_react64 = require("react");
|
|
11579
11691
|
var import_antd33 = require("antd");
|
|
11580
11692
|
var import_icons12 = require("@ant-design/icons");
|
|
11581
11693
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
@@ -11640,14 +11752,14 @@ var InnerFormContent = ({
|
|
|
11640
11752
|
inDrawer = false
|
|
11641
11753
|
}) => {
|
|
11642
11754
|
const { validateAll, getFormData: getFormData2, setFieldValue, resetForm, api } = useFormContext();
|
|
11643
|
-
const [submitted, setSubmitted] = (0,
|
|
11644
|
-
const [successInfo, setSuccessInfo] = (0,
|
|
11645
|
-
const [submitting, setSubmitting] = (0,
|
|
11646
|
-
const [departmentId, setDepartmentId] = (0,
|
|
11647
|
-
const [previewOpen, setPreviewOpen] = (0,
|
|
11648
|
-
const [previewLoading, setPreviewLoading] = (0,
|
|
11649
|
-
const [previewRoutes, setPreviewRoutes] = (0,
|
|
11650
|
-
const [pendingFormData, setPendingFormData] = (0,
|
|
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);
|
|
11651
11763
|
const { hasDraft, draftTimestamp, saveDraft, restoreDraft, clearDraft } = useDraftStorage({
|
|
11652
11764
|
appType: config.appType,
|
|
11653
11765
|
formUuid: config.formUuid
|
|
@@ -11659,7 +11771,7 @@ var InnerFormContent = ({
|
|
|
11659
11771
|
mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
|
|
11660
11772
|
basePath: config.navigation?.basePath
|
|
11661
11773
|
});
|
|
11662
|
-
const performSubmit = (0,
|
|
11774
|
+
const performSubmit = (0, import_react64.useCallback)(
|
|
11663
11775
|
async (formData) => {
|
|
11664
11776
|
setSubmitting(true);
|
|
11665
11777
|
try {
|
|
@@ -11712,7 +11824,7 @@ var InnerFormContent = ({
|
|
|
11712
11824
|
submitSuccessMode
|
|
11713
11825
|
]
|
|
11714
11826
|
);
|
|
11715
|
-
const prepareSubmit = (0,
|
|
11827
|
+
const prepareSubmit = (0, import_react64.useCallback)(async () => {
|
|
11716
11828
|
const valid = await validateAll();
|
|
11717
11829
|
if (!valid) return;
|
|
11718
11830
|
const formData = getFormData2();
|
|
@@ -11753,29 +11865,29 @@ var InnerFormContent = ({
|
|
|
11753
11865
|
departmentId,
|
|
11754
11866
|
performSubmit
|
|
11755
11867
|
]);
|
|
11756
|
-
const handlePreviewConfirm = (0,
|
|
11868
|
+
const handlePreviewConfirm = (0, import_react64.useCallback)(async () => {
|
|
11757
11869
|
const data = pendingFormData ?? getFormData2();
|
|
11758
11870
|
setPreviewOpen(false);
|
|
11759
11871
|
setPendingFormData(null);
|
|
11760
11872
|
await performSubmit(data);
|
|
11761
11873
|
}, [getFormData2, pendingFormData, performSubmit]);
|
|
11762
|
-
const handleSaveDraft = (0,
|
|
11874
|
+
const handleSaveDraft = (0, import_react64.useCallback)(() => {
|
|
11763
11875
|
const data = getFormData2();
|
|
11764
11876
|
saveDraft(data);
|
|
11765
11877
|
}, [getFormData2, saveDraft]);
|
|
11766
|
-
const handleRestoreDraft = (0,
|
|
11878
|
+
const handleRestoreDraft = (0, import_react64.useCallback)(() => {
|
|
11767
11879
|
const data = restoreDraft();
|
|
11768
11880
|
if (!data) return;
|
|
11769
11881
|
Object.entries(data).forEach(([fieldId, value]) => {
|
|
11770
11882
|
setFieldValue(fieldId, value);
|
|
11771
11883
|
});
|
|
11772
11884
|
}, [restoreDraft, setFieldValue]);
|
|
11773
|
-
const handleContinue = (0,
|
|
11885
|
+
const handleContinue = (0, import_react64.useCallback)(() => {
|
|
11774
11886
|
setSubmitted(false);
|
|
11775
11887
|
setSuccessInfo(null);
|
|
11776
11888
|
resetForm();
|
|
11777
11889
|
}, [resetForm]);
|
|
11778
|
-
const handleViewDetail = (0,
|
|
11890
|
+
const handleViewDetail = (0, import_react64.useCallback)(() => {
|
|
11779
11891
|
if (!successInfo) return;
|
|
11780
11892
|
if (formType === "process") {
|
|
11781
11893
|
navigateToProcessDetail(successInfo.formInstanceId);
|
|
@@ -11934,7 +12046,7 @@ var FormSubmitTemplate = ({
|
|
|
11934
12046
|
};
|
|
11935
12047
|
|
|
11936
12048
|
// src/templates/FormDetailTemplate.tsx
|
|
11937
|
-
var
|
|
12049
|
+
var import_react65 = require("react");
|
|
11938
12050
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
11939
12051
|
|
|
11940
12052
|
// src/templates/PageSkeleton.tsx
|
|
@@ -12028,9 +12140,9 @@ var InnerDetailContent = ({
|
|
|
12028
12140
|
onSave,
|
|
12029
12141
|
inDrawer = false
|
|
12030
12142
|
}) => {
|
|
12031
|
-
const formDataRef = (0,
|
|
12032
|
-
const [accessDenied, setAccessDenied] = (0,
|
|
12033
|
-
const fieldIds = (0,
|
|
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]);
|
|
12034
12146
|
const {
|
|
12035
12147
|
loading,
|
|
12036
12148
|
mode,
|
|
@@ -12065,7 +12177,7 @@ var InnerDetailContent = ({
|
|
|
12065
12177
|
formInstanceId,
|
|
12066
12178
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
12067
12179
|
});
|
|
12068
|
-
const handleSave = (0,
|
|
12180
|
+
const handleSave = (0, import_react65.useCallback)(async () => {
|
|
12069
12181
|
const values = formDataRef.current?.() ?? formData;
|
|
12070
12182
|
if (!values) return;
|
|
12071
12183
|
const success = await saveChanges(values);
|
|
@@ -12073,13 +12185,13 @@ var InnerDetailContent = ({
|
|
|
12073
12185
|
onSave?.(values);
|
|
12074
12186
|
}
|
|
12075
12187
|
}, [formData, saveChanges, onSave]);
|
|
12076
|
-
const handleDelete = (0,
|
|
12188
|
+
const handleDelete = (0, import_react65.useCallback)(async () => {
|
|
12077
12189
|
const success = await deleteInstance();
|
|
12078
12190
|
if (success) {
|
|
12079
12191
|
onDelete?.();
|
|
12080
12192
|
}
|
|
12081
12193
|
}, [deleteInstance, onDelete]);
|
|
12082
|
-
const handleCancel = (0,
|
|
12194
|
+
const handleCancel = (0, import_react65.useCallback)(() => {
|
|
12083
12195
|
switchToReadonly();
|
|
12084
12196
|
}, [switchToReadonly]);
|
|
12085
12197
|
const readonlyActions = [];
|
|
@@ -12190,7 +12302,7 @@ var FormDetailTemplate = (props) => {
|
|
|
12190
12302
|
};
|
|
12191
12303
|
|
|
12192
12304
|
// src/templates/ProcessDetailTemplate.tsx
|
|
12193
|
-
var
|
|
12305
|
+
var import_react66 = require("react");
|
|
12194
12306
|
var import_antd35 = require("antd");
|
|
12195
12307
|
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
12196
12308
|
function FormDataBridge2({
|
|
@@ -12225,14 +12337,14 @@ var InnerProcessContent = ({
|
|
|
12225
12337
|
onDelete,
|
|
12226
12338
|
inDrawer = false
|
|
12227
12339
|
}) => {
|
|
12228
|
-
const formDataRef = (0,
|
|
12229
|
-
const validateRef = (0,
|
|
12340
|
+
const formDataRef = (0, import_react66.useRef)(void 0);
|
|
12341
|
+
const validateRef = (0, import_react66.useRef)(void 0);
|
|
12230
12342
|
const [withdrawForm] = import_antd35.Form.useForm();
|
|
12231
|
-
const [withdrawOpen, setWithdrawOpen] = (0,
|
|
12232
|
-
const [withdrawLoading, setWithdrawLoading] = (0,
|
|
12233
|
-
const [saveLoading, setSaveLoading] = (0,
|
|
12234
|
-
const [deleteLoading, setDeleteLoading] = (0,
|
|
12235
|
-
const fieldIds = (0,
|
|
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]);
|
|
12236
12348
|
const {
|
|
12237
12349
|
loading,
|
|
12238
12350
|
processInfo,
|
|
@@ -12298,55 +12410,55 @@ var InnerProcessContent = ({
|
|
|
12298
12410
|
formInstanceId,
|
|
12299
12411
|
autoLoad: enableChangeRecords && canViewChangeRecords
|
|
12300
12412
|
});
|
|
12301
|
-
const validateForm = (0,
|
|
12413
|
+
const validateForm = (0, import_react66.useCallback)(async () => {
|
|
12302
12414
|
return validateRef.current ? validateRef.current() : true;
|
|
12303
12415
|
}, []);
|
|
12304
|
-
const handleApprove = (0,
|
|
12416
|
+
const handleApprove = (0, import_react66.useCallback)(
|
|
12305
12417
|
async (comments) => {
|
|
12306
12418
|
if (!await validateForm()) return;
|
|
12307
12419
|
await approve(comments);
|
|
12308
12420
|
},
|
|
12309
12421
|
[approve, validateForm]
|
|
12310
12422
|
);
|
|
12311
|
-
const handleReject = (0,
|
|
12423
|
+
const handleReject = (0, import_react66.useCallback)(
|
|
12312
12424
|
async (comments) => {
|
|
12313
12425
|
await reject(comments);
|
|
12314
12426
|
},
|
|
12315
12427
|
[reject]
|
|
12316
12428
|
);
|
|
12317
|
-
const handleTransfer = (0,
|
|
12429
|
+
const handleTransfer = (0, import_react66.useCallback)(
|
|
12318
12430
|
async (userId, reason) => {
|
|
12319
12431
|
await transfer(userId, reason);
|
|
12320
12432
|
},
|
|
12321
12433
|
[transfer]
|
|
12322
12434
|
);
|
|
12323
|
-
const handleReturn = (0,
|
|
12435
|
+
const handleReturn = (0, import_react66.useCallback)(
|
|
12324
12436
|
async (nodeId, reason) => {
|
|
12325
12437
|
await returnTo(nodeId, reason);
|
|
12326
12438
|
},
|
|
12327
12439
|
[returnTo]
|
|
12328
12440
|
);
|
|
12329
|
-
const handleWithdraw = (0,
|
|
12441
|
+
const handleWithdraw = (0, import_react66.useCallback)(
|
|
12330
12442
|
async (reason) => {
|
|
12331
12443
|
await withdraw(reason);
|
|
12332
12444
|
},
|
|
12333
12445
|
[withdraw]
|
|
12334
12446
|
);
|
|
12335
|
-
const handleSave = (0,
|
|
12447
|
+
const handleSave = (0, import_react66.useCallback)(async () => {
|
|
12336
12448
|
if (!await validateForm()) return;
|
|
12337
12449
|
await save();
|
|
12338
12450
|
}, [save, validateForm]);
|
|
12339
|
-
const handleResubmit = (0,
|
|
12451
|
+
const handleResubmit = (0, import_react66.useCallback)(
|
|
12340
12452
|
async (comments) => {
|
|
12341
12453
|
if (!await validateForm()) return;
|
|
12342
12454
|
await resubmit(comments);
|
|
12343
12455
|
},
|
|
12344
12456
|
[resubmit, validateForm]
|
|
12345
12457
|
);
|
|
12346
|
-
const handleCallback = (0,
|
|
12458
|
+
const handleCallback = (0, import_react66.useCallback)(async () => {
|
|
12347
12459
|
await callbackTask();
|
|
12348
12460
|
}, [callbackTask]);
|
|
12349
|
-
const handleCompletedSave = (0,
|
|
12461
|
+
const handleCompletedSave = (0, import_react66.useCallback)(async () => {
|
|
12350
12462
|
if (!await validateForm()) return;
|
|
12351
12463
|
const values = formDataRef.current?.() ?? formData;
|
|
12352
12464
|
if (!values) return;
|
|
@@ -12360,7 +12472,7 @@ var InnerProcessContent = ({
|
|
|
12360
12472
|
setSaveLoading(false);
|
|
12361
12473
|
}
|
|
12362
12474
|
}, [formData, onSave, saveChanges, validateForm]);
|
|
12363
|
-
const handleCompletedDelete = (0,
|
|
12475
|
+
const handleCompletedDelete = (0, import_react66.useCallback)(async () => {
|
|
12364
12476
|
setDeleteLoading(true);
|
|
12365
12477
|
try {
|
|
12366
12478
|
const success = await deleteInstance();
|
|
@@ -12371,7 +12483,7 @@ var InnerProcessContent = ({
|
|
|
12371
12483
|
setDeleteLoading(false);
|
|
12372
12484
|
}
|
|
12373
12485
|
}, [deleteInstance, onDelete]);
|
|
12374
|
-
const handleFooterWithdraw = (0,
|
|
12486
|
+
const handleFooterWithdraw = (0, import_react66.useCallback)(async () => {
|
|
12375
12487
|
const values = await withdrawForm.validateFields();
|
|
12376
12488
|
setWithdrawLoading(true);
|
|
12377
12489
|
try {
|
|
@@ -12382,11 +12494,11 @@ var InnerProcessContent = ({
|
|
|
12382
12494
|
setWithdrawLoading(false);
|
|
12383
12495
|
}
|
|
12384
12496
|
}, [handleWithdraw, withdrawForm]);
|
|
12385
|
-
const handleFooterWithdrawCancel = (0,
|
|
12497
|
+
const handleFooterWithdrawCancel = (0, import_react66.useCallback)(() => {
|
|
12386
12498
|
setWithdrawOpen(false);
|
|
12387
12499
|
withdrawForm.resetFields();
|
|
12388
12500
|
}, [withdrawForm]);
|
|
12389
|
-
const bottomActions = (0,
|
|
12501
|
+
const bottomActions = (0, import_react66.useMemo)(() => {
|
|
12390
12502
|
if (isApprover && !isOriginatorReturn && activeActions.length > 0) return [];
|
|
12391
12503
|
if (isProcessCompleted) {
|
|
12392
12504
|
if (mode === "readonly") {
|