openxiangda 1.0.145 → 1.0.147
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/lib/cli.js +44 -11
- package/package.json +3 -3
- package/packages/sdk/dist/{ProcessPreview-CUQFUDvw.d.mts → ProcessPreview-BoblxCUt.d.mts} +24 -1
- package/packages/sdk/dist/{ProcessPreview-CUQFUDvw.d.ts → ProcessPreview-BoblxCUt.d.ts} +24 -1
- package/packages/sdk/dist/components/index.cjs +305 -24
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.d.mts +4 -4
- package/packages/sdk/dist/components/index.d.ts +4 -4
- package/packages/sdk/dist/components/index.mjs +416 -135
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/{dataManagementApi-DQKInwWS.d.mts → dataManagementApi-BCzfV88G.d.mts} +1 -1
- package/packages/sdk/dist/{dataManagementApi-CwBEmnXg.d.ts → dataManagementApi-_FFNPv2e.d.ts} +1 -1
- package/packages/sdk/dist/runtime/index.cjs +305 -24
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +2 -2
- package/packages/sdk/dist/runtime/index.d.ts +2 -2
- package/packages/sdk/dist/runtime/index.mjs +407 -126
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +1 -1
- package/packages/sdk/dist/runtime/react.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/sdk/src/components/core/FormProvider.tsx
|
|
2
|
-
import React45, { useCallback as useCallback8, useEffect as
|
|
2
|
+
import React45, { useCallback as useCallback8, useEffect as useEffect33, useRef as useRef9, useState as useState18, useMemo as useMemo18 } from "react";
|
|
3
3
|
|
|
4
4
|
// packages/sdk/src/components/core/FormContext.ts
|
|
5
5
|
import { createContext, useContext } from "react";
|
|
@@ -6178,14 +6178,29 @@ function UserSelectField(props) {
|
|
|
6178
6178
|
}
|
|
6179
6179
|
|
|
6180
6180
|
// packages/sdk/src/components/fields/DepartmentSelectField/index.tsx
|
|
6181
|
-
import { useEffect as
|
|
6181
|
+
import { useEffect as useEffect24 } from "react";
|
|
6182
6182
|
|
|
6183
6183
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldPC.tsx
|
|
6184
|
-
import { useEffect as
|
|
6184
|
+
import { useEffect as useEffect22, useMemo as useMemo12, useRef as useRef4, useState as useState11 } from "react";
|
|
6185
6185
|
import { TreeSelect } from "antd";
|
|
6186
6186
|
|
|
6187
|
+
// packages/sdk/src/components/fields/shared/departmentSearch.ts
|
|
6188
|
+
function canSearchAllDepartments(api, configuredTreeData) {
|
|
6189
|
+
return !configuredTreeData?.length && typeof api.searchDepartments === "function";
|
|
6190
|
+
}
|
|
6191
|
+
function normalizeDepartmentSearchItems(result) {
|
|
6192
|
+
const data = result?.data || result?.result || result;
|
|
6193
|
+
const source = Array.isArray(data) ? data : data?.items || data?.list || [];
|
|
6194
|
+
return source.map((item) => normalizeDepartmentNode(item)).filter((item) => item.id);
|
|
6195
|
+
}
|
|
6196
|
+
function getDepartmentPathText(department, separator = "/") {
|
|
6197
|
+
const path = Array.isArray(department?.path) ? department.path : [];
|
|
6198
|
+
const pathText = path.map((item) => item?.name).filter(Boolean).join(separator);
|
|
6199
|
+
return pathText || String(department?.fullPath || getDepartmentName(department) || "");
|
|
6200
|
+
}
|
|
6201
|
+
|
|
6187
6202
|
// packages/sdk/src/components/fields/shared/DepartmentPicker.tsx
|
|
6188
|
-
import { useMemo as useMemo11, useState as useState10 } from "react";
|
|
6203
|
+
import { useEffect as useEffect21, useMemo as useMemo11, useRef as useRef3, useState as useState10 } from "react";
|
|
6189
6204
|
import { Button as Button2, Checkbox as Checkbox3, Empty as Empty2, Input as Input6, List as List2, Modal as Modal2, Space as Space2, Spin as Spin2, Tag as Tag3, Tree as Tree2 } from "antd";
|
|
6190
6205
|
import { ApartmentOutlined, SearchOutlined as SearchOutlined3 } from "@ant-design/icons";
|
|
6191
6206
|
import * as MobileAntd3 from "antd-mobile";
|
|
@@ -6198,7 +6213,11 @@ var getMobileComponent2 = (name) => {
|
|
|
6198
6213
|
}
|
|
6199
6214
|
};
|
|
6200
6215
|
function normalizeSelection(items) {
|
|
6201
|
-
return items.map((item) => ({
|
|
6216
|
+
return items.map((item) => ({
|
|
6217
|
+
id: String(item.id || ""),
|
|
6218
|
+
name: String(item.name || item.id || ""),
|
|
6219
|
+
fullPath: item.fullPath
|
|
6220
|
+
})).filter((item) => item.id);
|
|
6202
6221
|
}
|
|
6203
6222
|
function matchSearch(nodes, keyword) {
|
|
6204
6223
|
if (!keyword) return nodes;
|
|
@@ -6219,7 +6238,12 @@ function DepartmentPickerPanel({
|
|
|
6219
6238
|
treeData,
|
|
6220
6239
|
onConfirm,
|
|
6221
6240
|
onCancel,
|
|
6222
|
-
mobile = false
|
|
6241
|
+
mobile = false,
|
|
6242
|
+
showSearch = true,
|
|
6243
|
+
searchScope = "loaded",
|
|
6244
|
+
showFullPath = false,
|
|
6245
|
+
searchMinLength = 1,
|
|
6246
|
+
searchDebounceMs = 300
|
|
6223
6247
|
}) {
|
|
6224
6248
|
const {
|
|
6225
6249
|
treeData: loadedTreeData,
|
|
@@ -6233,11 +6257,53 @@ function DepartmentPickerPanel({
|
|
|
6233
6257
|
const [selected, setSelected] = useState10(() => normalizeSelection(value));
|
|
6234
6258
|
const [expandedKeys, setExpandedKeys] = useState10([]);
|
|
6235
6259
|
const [currentDeptId, setCurrentDeptId] = useState10(null);
|
|
6260
|
+
const [remoteSearchResults, setRemoteSearchResults] = useState10([]);
|
|
6261
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = useState10(false);
|
|
6262
|
+
const [remoteSearchError, setRemoteSearchError] = useState10("");
|
|
6263
|
+
const searchSeqRef = useRef3(0);
|
|
6236
6264
|
const selectedIds = selected.map((item) => item.id);
|
|
6237
6265
|
const MobileSearchBar = getMobileComponent2("SearchBar");
|
|
6266
|
+
const trimmedKeyword = keyword.trim();
|
|
6267
|
+
const canRemoteSearch = showSearch && searchScope === "all" && trimmedKeyword.length >= searchMinLength && canSearchAllDepartments(api, treeData);
|
|
6268
|
+
const spinning = treeLoading || remoteSearchLoading;
|
|
6269
|
+
useEffect21(() => {
|
|
6270
|
+
if (!canRemoteSearch) {
|
|
6271
|
+
searchSeqRef.current += 1;
|
|
6272
|
+
setRemoteSearchResults([]);
|
|
6273
|
+
setRemoteSearchLoading(false);
|
|
6274
|
+
setRemoteSearchError("");
|
|
6275
|
+
return;
|
|
6276
|
+
}
|
|
6277
|
+
const seq = searchSeqRef.current + 1;
|
|
6278
|
+
searchSeqRef.current = seq;
|
|
6279
|
+
setRemoteSearchLoading(true);
|
|
6280
|
+
setRemoteSearchError("");
|
|
6281
|
+
const timer = window.setTimeout(() => {
|
|
6282
|
+
api.searchDepartments?.({
|
|
6283
|
+
keyword: trimmedKeyword,
|
|
6284
|
+
page: 1,
|
|
6285
|
+
pageSize: 50,
|
|
6286
|
+
includePath: true
|
|
6287
|
+
}).then((result) => {
|
|
6288
|
+
if (searchSeqRef.current !== seq) return;
|
|
6289
|
+
setRemoteSearchResults(normalizeDepartmentSearchItems(result));
|
|
6290
|
+
}).catch((error) => {
|
|
6291
|
+
if (searchSeqRef.current !== seq) return;
|
|
6292
|
+
setRemoteSearchResults([]);
|
|
6293
|
+
setRemoteSearchError(error?.message || "\u641C\u7D22\u5931\u8D25");
|
|
6294
|
+
}).finally(() => {
|
|
6295
|
+
if (searchSeqRef.current === seq) {
|
|
6296
|
+
setRemoteSearchLoading(false);
|
|
6297
|
+
}
|
|
6298
|
+
});
|
|
6299
|
+
}, searchDebounceMs);
|
|
6300
|
+
return () => {
|
|
6301
|
+
window.clearTimeout(timer);
|
|
6302
|
+
};
|
|
6303
|
+
}, [api, canRemoteSearch, searchDebounceMs, trimmedKeyword]);
|
|
6238
6304
|
const filteredTreeData = useMemo11(
|
|
6239
|
-
() => matchSearch(loadedTreeData,
|
|
6240
|
-
[
|
|
6305
|
+
() => showSearch ? matchSearch(loadedTreeData, trimmedKeyword) : loadedTreeData,
|
|
6306
|
+
[loadedTreeData, showSearch, trimmedKeyword]
|
|
6241
6307
|
);
|
|
6242
6308
|
const currentPath = useMemo11(() => {
|
|
6243
6309
|
if (!currentDeptId) return [];
|
|
@@ -6252,13 +6318,36 @@ function DepartmentPickerPanel({
|
|
|
6252
6318
|
return path;
|
|
6253
6319
|
}, [currentDeptId, nodeMap, parentMap]);
|
|
6254
6320
|
const mobileList = useMemo11(() => {
|
|
6255
|
-
if (
|
|
6256
|
-
|
|
6321
|
+
if (canRemoteSearch) {
|
|
6322
|
+
return remoteSearchResults;
|
|
6323
|
+
}
|
|
6324
|
+
if (showSearch && trimmedKeyword) {
|
|
6325
|
+
const lower = trimmedKeyword.toLowerCase();
|
|
6257
6326
|
return flatNodes.filter((item) => item.name.toLowerCase().includes(lower)).map((item) => item.node);
|
|
6258
6327
|
}
|
|
6259
6328
|
if (!currentDeptId) return loadedTreeData;
|
|
6260
6329
|
return nodeMap.get(currentDeptId)?.children || [];
|
|
6261
|
-
}, [
|
|
6330
|
+
}, [
|
|
6331
|
+
canRemoteSearch,
|
|
6332
|
+
currentDeptId,
|
|
6333
|
+
flatNodes,
|
|
6334
|
+
loadedTreeData,
|
|
6335
|
+
nodeMap,
|
|
6336
|
+
remoteSearchResults,
|
|
6337
|
+
showSearch,
|
|
6338
|
+
trimmedKeyword
|
|
6339
|
+
]);
|
|
6340
|
+
const getNodeValue = (node) => {
|
|
6341
|
+
const id = getDepartmentId(node);
|
|
6342
|
+
const name = getDepartmentName(node);
|
|
6343
|
+
const fullPath = getDepartmentPathText(node);
|
|
6344
|
+
return {
|
|
6345
|
+
id,
|
|
6346
|
+
name,
|
|
6347
|
+
...fullPath && fullPath !== name ? { fullPath } : {}
|
|
6348
|
+
};
|
|
6349
|
+
};
|
|
6350
|
+
const getSelectedLabel = (item) => showFullPath ? item.fullPath || item.name : item.name;
|
|
6262
6351
|
const upsertSelected = (department, checked) => {
|
|
6263
6352
|
if (multiple) {
|
|
6264
6353
|
setSelected((prev) => {
|
|
@@ -6275,14 +6364,14 @@ function DepartmentPickerPanel({
|
|
|
6275
6364
|
const checkedKeys = Array.isArray(keys) ? keys : keys.checked;
|
|
6276
6365
|
const next = checkedKeys.map((key) => {
|
|
6277
6366
|
const node = nodeMap.get(String(key));
|
|
6278
|
-
return node ?
|
|
6367
|
+
return node ? getNodeValue(node) : void 0;
|
|
6279
6368
|
}).filter(Boolean);
|
|
6280
6369
|
setSelected(next);
|
|
6281
6370
|
};
|
|
6282
6371
|
const handleTreeSelect = (keys) => {
|
|
6283
6372
|
const id = String(keys[0] || "");
|
|
6284
6373
|
const node = id ? nodeMap.get(id) : void 0;
|
|
6285
|
-
setSelected(node ? [
|
|
6374
|
+
setSelected(node ? [getNodeValue(node)] : []);
|
|
6286
6375
|
};
|
|
6287
6376
|
const renderSelected = () => /* @__PURE__ */ jsxs24("div", { className: "sy-org-picker-selected", children: [
|
|
6288
6377
|
/* @__PURE__ */ jsxs24("div", { className: "sy-org-picker-selected-head", children: [
|
|
@@ -6292,8 +6381,51 @@ function DepartmentPickerPanel({
|
|
|
6292
6381
|
] }),
|
|
6293
6382
|
/* @__PURE__ */ jsx61("button", { type: "button", onClick: () => setSelected([]), disabled: !selected.length, children: "\u6E05\u7A7A" })
|
|
6294
6383
|
] }),
|
|
6295
|
-
selected.length ? /* @__PURE__ */ jsx61("div", { className: "sy-org-picker-tags", children: selected.map((item) => /* @__PURE__ */ jsx61(Tag3, { closable: true, onClose: () => upsertSelected(item, false), children: item
|
|
6384
|
+
selected.length ? /* @__PURE__ */ jsx61("div", { className: "sy-org-picker-tags", children: selected.map((item) => /* @__PURE__ */ jsx61(Tag3, { closable: true, onClose: () => upsertSelected(item, false), children: getSelectedLabel(item) }, item.id)) }) : /* @__PURE__ */ jsx61(Empty2, { image: Empty2.PRESENTED_IMAGE_SIMPLE, description: "\u6682\u65E0\u9009\u62E9" })
|
|
6296
6385
|
] });
|
|
6386
|
+
const renderRemoteSearchResults = () => /* @__PURE__ */ jsx61(
|
|
6387
|
+
List2,
|
|
6388
|
+
{
|
|
6389
|
+
dataSource: remoteSearchResults,
|
|
6390
|
+
locale: { emptyText: remoteSearchError || "\u6682\u65E0\u90E8\u95E8" },
|
|
6391
|
+
renderItem: (node) => {
|
|
6392
|
+
const id = getDepartmentId(node);
|
|
6393
|
+
const name = getDepartmentName(node);
|
|
6394
|
+
const selectedNow = selectedIds.includes(id);
|
|
6395
|
+
const pathText = getDepartmentPathText(node);
|
|
6396
|
+
return /* @__PURE__ */ jsx61(
|
|
6397
|
+
List2.Item,
|
|
6398
|
+
{
|
|
6399
|
+
onClick: () => upsertSelected(getNodeValue(node), true),
|
|
6400
|
+
actions: [
|
|
6401
|
+
/* @__PURE__ */ jsx61(
|
|
6402
|
+
Checkbox3,
|
|
6403
|
+
{
|
|
6404
|
+
checked: selectedNow,
|
|
6405
|
+
onChange: (event) => upsertSelected(getNodeValue(node), event.target.checked)
|
|
6406
|
+
},
|
|
6407
|
+
"select"
|
|
6408
|
+
)
|
|
6409
|
+
],
|
|
6410
|
+
children: /* @__PURE__ */ jsx61(
|
|
6411
|
+
List2.Item.Meta,
|
|
6412
|
+
{
|
|
6413
|
+
avatar: /* @__PURE__ */ jsx61(ApartmentOutlined, {}),
|
|
6414
|
+
title: /* @__PURE__ */ jsxs24("span", { children: [
|
|
6415
|
+
/* @__PURE__ */ jsx61("span", { children: name }),
|
|
6416
|
+
showFullPath && pathText && pathText !== name ? /* @__PURE__ */ jsxs24("span", { className: "sy-org-picker-path", children: [
|
|
6417
|
+
" ",
|
|
6418
|
+
pathText
|
|
6419
|
+
] }) : null
|
|
6420
|
+
] })
|
|
6421
|
+
}
|
|
6422
|
+
)
|
|
6423
|
+
},
|
|
6424
|
+
id
|
|
6425
|
+
);
|
|
6426
|
+
}
|
|
6427
|
+
}
|
|
6428
|
+
);
|
|
6297
6429
|
if (mobile) {
|
|
6298
6430
|
return /* @__PURE__ */ jsxs24("div", { className: "sy-org-picker sy-org-picker-mobile", children: [
|
|
6299
6431
|
/* @__PURE__ */ jsxs24("div", { className: "sy-org-picker-mobile-head", children: [
|
|
@@ -6301,7 +6433,7 @@ function DepartmentPickerPanel({
|
|
|
6301
6433
|
/* @__PURE__ */ jsx61("strong", { children: "\u9009\u62E9\u90E8\u95E8" }),
|
|
6302
6434
|
/* @__PURE__ */ jsx61("button", { type: "button", onClick: () => onConfirm(selected), children: "\u786E\u5B9A" })
|
|
6303
6435
|
] }),
|
|
6304
|
-
MobileSearchBar ? /* @__PURE__ */ jsx61(MobileSearchBar, { placeholder: "\u641C\u7D22\u90E8\u95E8", value: keyword, onChange: setKeyword }) : /* @__PURE__ */ jsx61("input", { value: keyword, onChange: (event) => setKeyword(event.target.value) }),
|
|
6436
|
+
showSearch ? MobileSearchBar ? /* @__PURE__ */ jsx61(MobileSearchBar, { placeholder: "\u641C\u7D22\u90E8\u95E8", value: keyword, onChange: setKeyword }) : /* @__PURE__ */ jsx61("input", { value: keyword, onChange: (event) => setKeyword(event.target.value) }) : null,
|
|
6305
6437
|
/* @__PURE__ */ jsxs24("div", { className: "sy-org-picker-breadcrumb", children: [
|
|
6306
6438
|
/* @__PURE__ */ jsx61("button", { type: "button", onClick: () => setCurrentDeptId(null), children: "\u90E8\u95E8" }),
|
|
6307
6439
|
currentPath.map((item) => /* @__PURE__ */ jsxs24("button", { type: "button", onClick: () => setCurrentDeptId(item.id), children: [
|
|
@@ -6309,16 +6441,17 @@ function DepartmentPickerPanel({
|
|
|
6309
6441
|
item.name
|
|
6310
6442
|
] }, item.id))
|
|
6311
6443
|
] }),
|
|
6312
|
-
/* @__PURE__ */ jsx61(Spin2, { spinning
|
|
6444
|
+
/* @__PURE__ */ jsx61(Spin2, { spinning, children: /* @__PURE__ */ jsx61(
|
|
6313
6445
|
List2,
|
|
6314
6446
|
{
|
|
6315
6447
|
dataSource: mobileList,
|
|
6316
|
-
locale: { emptyText: "\u6682\u65E0\u90E8\u95E8" },
|
|
6448
|
+
locale: { emptyText: remoteSearchError || "\u6682\u65E0\u90E8\u95E8" },
|
|
6317
6449
|
renderItem: (node) => {
|
|
6318
6450
|
const id = getDepartmentId(node);
|
|
6319
6451
|
const name = getDepartmentName(node);
|
|
6320
6452
|
const selectedNow = selectedIds.includes(id);
|
|
6321
|
-
const hasChildren = Boolean(node.hasChildren && !node.isLeaf);
|
|
6453
|
+
const hasChildren = !canRemoteSearch && Boolean(node.hasChildren && !node.isLeaf);
|
|
6454
|
+
const pathText = getDepartmentPathText(node);
|
|
6322
6455
|
return /* @__PURE__ */ jsx61(
|
|
6323
6456
|
List2.Item,
|
|
6324
6457
|
{
|
|
@@ -6327,7 +6460,7 @@ function DepartmentPickerPanel({
|
|
|
6327
6460
|
Checkbox3,
|
|
6328
6461
|
{
|
|
6329
6462
|
checked: selectedNow,
|
|
6330
|
-
onChange: (event) => upsertSelected(
|
|
6463
|
+
onChange: (event) => upsertSelected(getNodeValue(node), event.target.checked)
|
|
6331
6464
|
},
|
|
6332
6465
|
"select"
|
|
6333
6466
|
),
|
|
@@ -6345,7 +6478,19 @@ function DepartmentPickerPanel({
|
|
|
6345
6478
|
"children"
|
|
6346
6479
|
) : null
|
|
6347
6480
|
],
|
|
6348
|
-
children: /* @__PURE__ */ jsx61(
|
|
6481
|
+
children: /* @__PURE__ */ jsx61(
|
|
6482
|
+
List2.Item.Meta,
|
|
6483
|
+
{
|
|
6484
|
+
avatar: /* @__PURE__ */ jsx61(ApartmentOutlined, {}),
|
|
6485
|
+
title: /* @__PURE__ */ jsxs24("span", { children: [
|
|
6486
|
+
/* @__PURE__ */ jsx61("span", { children: name }),
|
|
6487
|
+
showFullPath && pathText && pathText !== name ? /* @__PURE__ */ jsxs24("span", { className: "sy-org-picker-path", children: [
|
|
6488
|
+
" ",
|
|
6489
|
+
pathText
|
|
6490
|
+
] }) : null
|
|
6491
|
+
] })
|
|
6492
|
+
}
|
|
6493
|
+
)
|
|
6349
6494
|
},
|
|
6350
6495
|
id
|
|
6351
6496
|
);
|
|
@@ -6358,7 +6503,7 @@ function DepartmentPickerPanel({
|
|
|
6358
6503
|
return /* @__PURE__ */ jsxs24("div", { className: "sy-org-picker", children: [
|
|
6359
6504
|
/* @__PURE__ */ jsxs24("div", { className: "sy-org-picker-main", children: [
|
|
6360
6505
|
/* @__PURE__ */ jsxs24("div", { className: "sy-org-picker-tree", children: [
|
|
6361
|
-
/* @__PURE__ */ jsx61(
|
|
6506
|
+
showSearch ? /* @__PURE__ */ jsx61(
|
|
6362
6507
|
Input6,
|
|
6363
6508
|
{
|
|
6364
6509
|
allowClear: true,
|
|
@@ -6367,8 +6512,8 @@ function DepartmentPickerPanel({
|
|
|
6367
6512
|
value: keyword,
|
|
6368
6513
|
onChange: (event) => setKeyword(event.target.value)
|
|
6369
6514
|
}
|
|
6370
|
-
),
|
|
6371
|
-
/* @__PURE__ */ jsx61(Spin2, { spinning
|
|
6515
|
+
) : null,
|
|
6516
|
+
/* @__PURE__ */ jsx61(Spin2, { spinning, children: canRemoteSearch ? renderRemoteSearchResults() : /* @__PURE__ */ jsx61(
|
|
6372
6517
|
Tree2,
|
|
6373
6518
|
{
|
|
6374
6519
|
checkable: multiple,
|
|
@@ -6458,6 +6603,17 @@ function convertTreeData(nodes) {
|
|
|
6458
6603
|
children: node.children ? convertTreeData(node.children) : void 0
|
|
6459
6604
|
}));
|
|
6460
6605
|
}
|
|
6606
|
+
function convertSearchTreeData(nodes, showFullPath) {
|
|
6607
|
+
return nodes.map((node) => {
|
|
6608
|
+
const name = getDepartmentName(node);
|
|
6609
|
+
const pathText = getDepartmentPathText(node);
|
|
6610
|
+
return {
|
|
6611
|
+
value: getDepartmentId(node),
|
|
6612
|
+
title: showFullPath && pathText ? pathText : name,
|
|
6613
|
+
isLeaf: true
|
|
6614
|
+
};
|
|
6615
|
+
});
|
|
6616
|
+
}
|
|
6461
6617
|
function DepartmentSelectFieldPC({
|
|
6462
6618
|
fieldId,
|
|
6463
6619
|
behavior,
|
|
@@ -6467,6 +6623,11 @@ function DepartmentSelectFieldPC({
|
|
|
6467
6623
|
treeData,
|
|
6468
6624
|
allowClear = true,
|
|
6469
6625
|
maxCount,
|
|
6626
|
+
notFoundContent,
|
|
6627
|
+
showSearch = true,
|
|
6628
|
+
searchScope = "loaded",
|
|
6629
|
+
searchMinLength = 1,
|
|
6630
|
+
searchDebounceMs = 300,
|
|
6470
6631
|
showFullPath,
|
|
6471
6632
|
scopeType,
|
|
6472
6633
|
specifiedDepts,
|
|
@@ -6477,10 +6638,15 @@ function DepartmentSelectFieldPC({
|
|
|
6477
6638
|
const value = useMemo12(() => normalizeDepartmentArray(rawValue), [rawValue]);
|
|
6478
6639
|
const disabled = behavior === "DISABLED";
|
|
6479
6640
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA;
|
|
6480
|
-
const remoteLoadedRef =
|
|
6641
|
+
const remoteLoadedRef = useRef4(false);
|
|
6481
6642
|
const [loadedTreeData, setLoadedTreeData] = useState11(configuredTreeData);
|
|
6482
6643
|
const [pickerOpen, setPickerOpen] = useState11(false);
|
|
6483
|
-
|
|
6644
|
+
const [searchKeyword, setSearchKeyword] = useState11("");
|
|
6645
|
+
const [remoteSearchResults, setRemoteSearchResults] = useState11([]);
|
|
6646
|
+
const [remoteSearchLoading, setRemoteSearchLoading] = useState11(false);
|
|
6647
|
+
const [selectedPathMap, setSelectedPathMap] = useState11({});
|
|
6648
|
+
const searchSeqRef = useRef4(0);
|
|
6649
|
+
useEffect22(() => {
|
|
6484
6650
|
if (configuredTreeData.length) {
|
|
6485
6651
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
6486
6652
|
return;
|
|
@@ -6491,22 +6657,87 @@ function DepartmentSelectFieldPC({
|
|
|
6491
6657
|
(nodes) => setLoadedTreeData(nodes.map(normalizeDepartmentNode))
|
|
6492
6658
|
);
|
|
6493
6659
|
}, [api, configuredTreeData]);
|
|
6660
|
+
const trimmedSearchKeyword = searchKeyword.trim();
|
|
6661
|
+
const canRemoteSearch = showSearch && searchScope === "all" && trimmedSearchKeyword.length >= searchMinLength && canSearchAllDepartments(api, configuredTreeData);
|
|
6662
|
+
useEffect22(() => {
|
|
6663
|
+
if (!canRemoteSearch) {
|
|
6664
|
+
searchSeqRef.current += 1;
|
|
6665
|
+
setRemoteSearchResults([]);
|
|
6666
|
+
setRemoteSearchLoading(false);
|
|
6667
|
+
return;
|
|
6668
|
+
}
|
|
6669
|
+
const seq = searchSeqRef.current + 1;
|
|
6670
|
+
searchSeqRef.current = seq;
|
|
6671
|
+
setRemoteSearchLoading(true);
|
|
6672
|
+
const timer = window.setTimeout(() => {
|
|
6673
|
+
api.searchDepartments?.({
|
|
6674
|
+
keyword: trimmedSearchKeyword,
|
|
6675
|
+
page: 1,
|
|
6676
|
+
pageSize: 50,
|
|
6677
|
+
includePath: true
|
|
6678
|
+
}).then((result) => {
|
|
6679
|
+
if (searchSeqRef.current !== seq) return;
|
|
6680
|
+
setRemoteSearchResults(normalizeDepartmentSearchItems(result));
|
|
6681
|
+
}).catch(() => {
|
|
6682
|
+
if (searchSeqRef.current !== seq) return;
|
|
6683
|
+
setRemoteSearchResults([]);
|
|
6684
|
+
}).finally(() => {
|
|
6685
|
+
if (searchSeqRef.current === seq) {
|
|
6686
|
+
setRemoteSearchLoading(false);
|
|
6687
|
+
}
|
|
6688
|
+
});
|
|
6689
|
+
}, searchDebounceMs);
|
|
6690
|
+
return () => {
|
|
6691
|
+
window.clearTimeout(timer);
|
|
6692
|
+
};
|
|
6693
|
+
}, [api, canRemoteSearch, searchDebounceMs, trimmedSearchKeyword]);
|
|
6494
6694
|
const scopedTreeData = filterTreeByScope(loadedTreeData, scopeType, specifiedDepts);
|
|
6495
6695
|
const allDepts = flattenDepartments(scopedTreeData);
|
|
6696
|
+
const scopedRemoteSearchResults = useMemo12(() => {
|
|
6697
|
+
if (scopeType !== "specified" || !specifiedDepts?.length) {
|
|
6698
|
+
return remoteSearchResults;
|
|
6699
|
+
}
|
|
6700
|
+
const specifiedSet = new Set(specifiedDepts);
|
|
6701
|
+
return remoteSearchResults.filter((node) => {
|
|
6702
|
+
const id = getDepartmentId(node);
|
|
6703
|
+
if (specifiedSet.has(id)) return true;
|
|
6704
|
+
return node.path?.some((item) => specifiedSet.has(item.id));
|
|
6705
|
+
});
|
|
6706
|
+
}, [remoteSearchResults, scopeType, specifiedDepts]);
|
|
6707
|
+
const remoteDeptMap = useMemo12(() => {
|
|
6708
|
+
const map = /* @__PURE__ */ new Map();
|
|
6709
|
+
scopedRemoteSearchResults.forEach((node) => map.set(getDepartmentId(node), node));
|
|
6710
|
+
return map;
|
|
6711
|
+
}, [scopedRemoteSearchResults]);
|
|
6496
6712
|
const handleChange = (selectedValue) => {
|
|
6497
6713
|
const selectedValues = Array.isArray(selectedValue) ? selectedValue : selectedValue ? [selectedValue] : [];
|
|
6714
|
+
const nextPathMap = { ...selectedPathMap };
|
|
6498
6715
|
const selected = selectedValues.map((item) => {
|
|
6499
6716
|
const id = String(item?.value ?? item);
|
|
6500
6717
|
const label = item?.label;
|
|
6501
|
-
const
|
|
6718
|
+
const remoteDept = remoteDeptMap.get(id);
|
|
6719
|
+
const matched = remoteDept ?? allDepts.find((dept) => dept.id === id)?.node ?? value.find((dept) => getDepartmentId(dept) === id);
|
|
6720
|
+
if (remoteDept) {
|
|
6721
|
+
nextPathMap[id] = getDepartmentPathText(remoteDept);
|
|
6722
|
+
}
|
|
6502
6723
|
const labelText = typeof label === "string" || typeof label === "number" ? String(label) : void 0;
|
|
6503
|
-
return { id, name:
|
|
6724
|
+
return { id, name: getDepartmentName(matched) || labelText || id };
|
|
6504
6725
|
}).filter((item) => item.id);
|
|
6505
6726
|
const result = (multiple ? selected.slice(0, maxCount ?? selected.length) : selected.slice(0, 1)).map(toDepartmentValue);
|
|
6727
|
+
setSelectedPathMap(nextPathMap);
|
|
6506
6728
|
setFieldValue(fieldId, result);
|
|
6507
6729
|
onChange?.(result);
|
|
6508
6730
|
};
|
|
6509
6731
|
const handlePickerConfirm = (items) => {
|
|
6732
|
+
setSelectedPathMap((current) => {
|
|
6733
|
+
const next = { ...current };
|
|
6734
|
+
items.forEach((item) => {
|
|
6735
|
+
if (item.fullPath) {
|
|
6736
|
+
next[item.id] = String(item.fullPath);
|
|
6737
|
+
}
|
|
6738
|
+
});
|
|
6739
|
+
return next;
|
|
6740
|
+
});
|
|
6510
6741
|
const result = (multiple ? items.slice(0, maxCount ?? items.length) : items.slice(0, 1)).map(
|
|
6511
6742
|
toDepartmentValue
|
|
6512
6743
|
);
|
|
@@ -6514,12 +6745,19 @@ function DepartmentSelectFieldPC({
|
|
|
6514
6745
|
onChange?.(result);
|
|
6515
6746
|
};
|
|
6516
6747
|
const treeDataConverted = convertTreeData(scopedTreeData);
|
|
6748
|
+
const searchTreeDataConverted = convertSearchTreeData(scopedRemoteSearchResults, showFullPath);
|
|
6749
|
+
const renderedTreeData = canRemoteSearch ? searchTreeDataConverted : treeDataConverted;
|
|
6750
|
+
const getDisplayLabel2 = (dept) => {
|
|
6751
|
+
const id = getDepartmentId(dept);
|
|
6752
|
+
if (!showFullPath) return getDepartmentName(dept);
|
|
6753
|
+
return getDepartmentFullPath(id, scopedTreeData) || selectedPathMap[id] || (remoteDeptMap.has(id) ? getDepartmentPathText(remoteDeptMap.get(id)) : "") || getDepartmentName(dept);
|
|
6754
|
+
};
|
|
6517
6755
|
const selectValue = multiple ? value.map((d) => ({
|
|
6518
6756
|
value: getDepartmentId(d),
|
|
6519
|
-
label:
|
|
6757
|
+
label: getDisplayLabel2(d)
|
|
6520
6758
|
})) : value[0] ? {
|
|
6521
6759
|
value: getDepartmentId(value[0]),
|
|
6522
|
-
label:
|
|
6760
|
+
label: getDisplayLabel2(value[0])
|
|
6523
6761
|
} : void 0;
|
|
6524
6762
|
return /* @__PURE__ */ jsxs25("div", { className: "sy-select-with-picker", children: [
|
|
6525
6763
|
/* @__PURE__ */ jsx62(
|
|
@@ -6531,9 +6769,14 @@ function DepartmentSelectFieldPC({
|
|
|
6531
6769
|
maxCount,
|
|
6532
6770
|
allowClear,
|
|
6533
6771
|
labelInValue: true,
|
|
6534
|
-
|
|
6772
|
+
showSearch,
|
|
6773
|
+
searchValue: searchKeyword,
|
|
6774
|
+
onSearch: setSearchKeyword,
|
|
6775
|
+
filterTreeNode: canRemoteSearch ? false : void 0,
|
|
6776
|
+
treeData: renderedTreeData,
|
|
6535
6777
|
value: selectValue,
|
|
6536
6778
|
placeholder,
|
|
6779
|
+
notFoundContent: remoteSearchLoading ? "\u641C\u7D22\u4E2D..." : notFoundContent || "\u6682\u65E0\u90E8\u95E8",
|
|
6537
6780
|
disabled,
|
|
6538
6781
|
onChange: handleChange,
|
|
6539
6782
|
loadData: async (node) => {
|
|
@@ -6577,6 +6820,11 @@ function DepartmentSelectFieldPC({
|
|
|
6577
6820
|
multiple,
|
|
6578
6821
|
value,
|
|
6579
6822
|
treeData,
|
|
6823
|
+
showSearch,
|
|
6824
|
+
searchScope,
|
|
6825
|
+
showFullPath,
|
|
6826
|
+
searchMinLength,
|
|
6827
|
+
searchDebounceMs,
|
|
6580
6828
|
onConfirm: handlePickerConfirm,
|
|
6581
6829
|
onCancel: () => void 0
|
|
6582
6830
|
}
|
|
@@ -6585,7 +6833,7 @@ function DepartmentSelectFieldPC({
|
|
|
6585
6833
|
}
|
|
6586
6834
|
|
|
6587
6835
|
// packages/sdk/src/components/fields/DepartmentSelectField/DepartmentSelectFieldMobile.tsx
|
|
6588
|
-
import { useEffect as
|
|
6836
|
+
import { useEffect as useEffect23, useMemo as useMemo13, useRef as useRef5, useState as useState12 } from "react";
|
|
6589
6837
|
import * as MobileAntd4 from "antd-mobile";
|
|
6590
6838
|
import { jsx as jsx63, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6591
6839
|
var EMPTY_TREE_DATA2 = [];
|
|
@@ -6609,6 +6857,10 @@ function DepartmentSelectFieldMobile({
|
|
|
6609
6857
|
treeData,
|
|
6610
6858
|
allowClear = true,
|
|
6611
6859
|
maxCount,
|
|
6860
|
+
showSearch = true,
|
|
6861
|
+
searchScope = "loaded",
|
|
6862
|
+
searchMinLength = 1,
|
|
6863
|
+
searchDebounceMs = 300,
|
|
6612
6864
|
showFullPath,
|
|
6613
6865
|
scopeType,
|
|
6614
6866
|
specifiedDepts,
|
|
@@ -6620,9 +6872,9 @@ function DepartmentSelectFieldMobile({
|
|
|
6620
6872
|
const disabled = behavior === "DISABLED";
|
|
6621
6873
|
const [showPicker, setShowPicker] = useState12(false);
|
|
6622
6874
|
const configuredTreeData = treeData ?? EMPTY_TREE_DATA2;
|
|
6623
|
-
const remoteLoadedRef =
|
|
6875
|
+
const remoteLoadedRef = useRef5(false);
|
|
6624
6876
|
const [loadedTreeData, setLoadedTreeData] = useState12(configuredTreeData);
|
|
6625
|
-
|
|
6877
|
+
useEffect23(() => {
|
|
6626
6878
|
if (configuredTreeData.length) {
|
|
6627
6879
|
setLoadedTreeData(configuredTreeData.map(normalizeDepartmentNode));
|
|
6628
6880
|
}
|
|
@@ -6696,6 +6948,11 @@ function DepartmentSelectFieldMobile({
|
|
|
6696
6948
|
multiple,
|
|
6697
6949
|
value,
|
|
6698
6950
|
treeData,
|
|
6951
|
+
showSearch,
|
|
6952
|
+
searchScope,
|
|
6953
|
+
showFullPath,
|
|
6954
|
+
searchMinLength,
|
|
6955
|
+
searchDebounceMs,
|
|
6699
6956
|
onConfirm: handleConfirm,
|
|
6700
6957
|
onCancel: () => setShowPicker(false)
|
|
6701
6958
|
}
|
|
@@ -6757,7 +7014,7 @@ function DepartmentSelectField(props) {
|
|
|
6757
7014
|
const { fieldBehaviors, setFieldValue, formData, registerField, unregisterField } = useFormContext();
|
|
6758
7015
|
const { isMobile } = useDeviceDetect();
|
|
6759
7016
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
6760
|
-
|
|
7017
|
+
useEffect24(() => {
|
|
6761
7018
|
registerField(fieldId);
|
|
6762
7019
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
6763
7020
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -6782,7 +7039,7 @@ function DepartmentSelectField(props) {
|
|
|
6782
7039
|
}
|
|
6783
7040
|
|
|
6784
7041
|
// packages/sdk/src/components/fields/CascadeSelectField/index.tsx
|
|
6785
|
-
import { useEffect as
|
|
7042
|
+
import { useEffect as useEffect25 } from "react";
|
|
6786
7043
|
import { Cascader } from "antd";
|
|
6787
7044
|
import { jsx as jsx66 } from "react/jsx-runtime";
|
|
6788
7045
|
var toValuePath = (value, multiple) => {
|
|
@@ -6821,7 +7078,7 @@ function CascadeSelectField(props) {
|
|
|
6821
7078
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
6822
7079
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
6823
7080
|
const value = formData[fieldId] ?? (multiple ? [] : []);
|
|
6824
|
-
|
|
7081
|
+
useEffect25(() => {
|
|
6825
7082
|
registerField(fieldId);
|
|
6826
7083
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
6827
7084
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -6874,7 +7131,7 @@ function CascadeSelectField(props) {
|
|
|
6874
7131
|
}
|
|
6875
7132
|
|
|
6876
7133
|
// packages/sdk/src/components/fields/AddressField/index.tsx
|
|
6877
|
-
import { useCallback as useCallback4, useEffect as
|
|
7134
|
+
import { useCallback as useCallback4, useEffect as useEffect26, useMemo as useMemo15, useState as useState13 } from "react";
|
|
6878
7135
|
import { Button as Button3, Cascader as Cascader2, Input as Input7, Space as Space3, Spin as Spin3 } from "antd";
|
|
6879
7136
|
import * as MobileAntd5 from "antd-mobile";
|
|
6880
7137
|
import { jsx as jsx67, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
@@ -7038,11 +7295,11 @@ function AddressField(props) {
|
|
|
7038
7295
|
const detailEnabled = mode === "province-city-district-street-detail";
|
|
7039
7296
|
const disabled = behavior === "DISABLED";
|
|
7040
7297
|
const MobilePopup = getMobileComponent3("Popup");
|
|
7041
|
-
|
|
7298
|
+
useEffect26(() => {
|
|
7042
7299
|
registerField(fieldId);
|
|
7043
7300
|
return () => unregisterField(fieldId);
|
|
7044
7301
|
}, [fieldId, registerField, unregisterField]);
|
|
7045
|
-
|
|
7302
|
+
useEffect26(() => {
|
|
7046
7303
|
if (defaultValue !== void 0 && rawValue === void 0) {
|
|
7047
7304
|
setFieldValue(fieldId, defaultValue);
|
|
7048
7305
|
}
|
|
@@ -7054,7 +7311,7 @@ function AddressField(props) {
|
|
|
7054
7311
|
},
|
|
7055
7312
|
[api, depth]
|
|
7056
7313
|
);
|
|
7057
|
-
|
|
7314
|
+
useEffect26(() => {
|
|
7058
7315
|
let mounted = true;
|
|
7059
7316
|
setLoadingRoots(true);
|
|
7060
7317
|
loadDivisions(void 0, "province", 0).then((nextOptions) => {
|
|
@@ -7066,7 +7323,7 @@ function AddressField(props) {
|
|
|
7066
7323
|
mounted = false;
|
|
7067
7324
|
};
|
|
7068
7325
|
}, [loadDivisions]);
|
|
7069
|
-
|
|
7326
|
+
useEffect26(() => {
|
|
7070
7327
|
if (!value) return;
|
|
7071
7328
|
let cancelled = false;
|
|
7072
7329
|
const hydrateMissingLabels = async () => {
|
|
@@ -7102,7 +7359,7 @@ function AddressField(props) {
|
|
|
7102
7359
|
cancelled = true;
|
|
7103
7360
|
};
|
|
7104
7361
|
}, [fieldId, levels, loadDivisions, setFieldValue, value]);
|
|
7105
|
-
|
|
7362
|
+
useEffect26(() => {
|
|
7106
7363
|
if (!mobileOpen) return;
|
|
7107
7364
|
const level = levels[mobileLevelIndex] || "province";
|
|
7108
7365
|
const parentLevel = levels[mobileLevelIndex - 1];
|
|
@@ -7282,7 +7539,7 @@ function AddressField(props) {
|
|
|
7282
7539
|
}
|
|
7283
7540
|
|
|
7284
7541
|
// packages/sdk/src/components/fields/AssociationFormField/index.tsx
|
|
7285
|
-
import { useCallback as useCallback5, useEffect as
|
|
7542
|
+
import { useCallback as useCallback5, useEffect as useEffect27, useMemo as useMemo16, useRef as useRef6, useState as useState14 } from "react";
|
|
7286
7543
|
import { Button as Button4, Drawer, Input as Input8, Modal as Modal3, Select as Select4, Space as Space4, Spin as Spin4, Table, Tag as Tag4 } from "antd";
|
|
7287
7544
|
import { jsx as jsx68, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
7288
7545
|
var DEFAULT_PAGE_SIZE = 10;
|
|
@@ -7360,19 +7617,19 @@ function AssociationFormField(props) {
|
|
|
7360
7617
|
});
|
|
7361
7618
|
const [selectedRowKeys, setSelectedRowKeys] = useState14([]);
|
|
7362
7619
|
const [selectedRecords, setSelectedRecords] = useState14([]);
|
|
7363
|
-
const formDataRef =
|
|
7364
|
-
const associationFormRef =
|
|
7365
|
-
|
|
7620
|
+
const formDataRef = useRef6(formData);
|
|
7621
|
+
const associationFormRef = useRef6(associationForm);
|
|
7622
|
+
useEffect27(() => {
|
|
7366
7623
|
registerField(fieldId);
|
|
7367
7624
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
7368
7625
|
setFieldValue(fieldId, normalizeValues(defaultValue));
|
|
7369
7626
|
}
|
|
7370
7627
|
return () => unregisterField(fieldId);
|
|
7371
7628
|
}, [fieldId]);
|
|
7372
|
-
|
|
7629
|
+
useEffect27(() => {
|
|
7373
7630
|
formDataRef.current = formData;
|
|
7374
7631
|
}, [formData]);
|
|
7375
|
-
|
|
7632
|
+
useEffect27(() => {
|
|
7376
7633
|
associationFormRef.current = associationForm;
|
|
7377
7634
|
}, [associationForm]);
|
|
7378
7635
|
const associationAppType = associationForm?.appType;
|
|
@@ -7487,10 +7744,10 @@ function AssociationFormField(props) {
|
|
|
7487
7744
|
},
|
|
7488
7745
|
[fetchRecords, keyword, pagination.pageSize]
|
|
7489
7746
|
);
|
|
7490
|
-
|
|
7747
|
+
useEffect27(() => {
|
|
7491
7748
|
void loadOptions();
|
|
7492
7749
|
}, [loadOptions]);
|
|
7493
|
-
|
|
7750
|
+
useEffect27(() => {
|
|
7494
7751
|
setSelectedRowKeys(value.map((item) => item.value));
|
|
7495
7752
|
setSelectedRecords(
|
|
7496
7753
|
value.map(
|
|
@@ -7764,7 +8021,7 @@ function AssociationFormField(props) {
|
|
|
7764
8021
|
}
|
|
7765
8022
|
|
|
7766
8023
|
// packages/sdk/src/components/fields/EditorField/index.tsx
|
|
7767
|
-
import { useCallback as useCallback6, useEffect as
|
|
8024
|
+
import { useCallback as useCallback6, useEffect as useEffect28, useMemo as useMemo17, useRef as useRef7, useState as useState15 } from "react";
|
|
7768
8025
|
import { Extension } from "@tiptap/core";
|
|
7769
8026
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
7770
8027
|
import StarterKit from "@tiptap/starter-kit";
|
|
@@ -8418,7 +8675,7 @@ function RichTextEditorCore({
|
|
|
8418
8675
|
fieldId = "richText",
|
|
8419
8676
|
mobile = false
|
|
8420
8677
|
}) {
|
|
8421
|
-
const inputRef =
|
|
8678
|
+
const inputRef = useRef7(null);
|
|
8422
8679
|
const [uploading, setUploading] = useState15(false);
|
|
8423
8680
|
const [uploadError, setUploadError] = useState15("");
|
|
8424
8681
|
const [charCount, setCharCount] = useState15(0);
|
|
@@ -8433,8 +8690,8 @@ function RichTextEditorCore({
|
|
|
8433
8690
|
const [tableOpen, setTableOpen] = useState15(false);
|
|
8434
8691
|
const [tableRows, setTableRows] = useState15(3);
|
|
8435
8692
|
const [tableCols, setTableCols] = useState15(3);
|
|
8436
|
-
const onChangeRef =
|
|
8437
|
-
|
|
8693
|
+
const onChangeRef = useRef7(onChange);
|
|
8694
|
+
useEffect28(() => {
|
|
8438
8695
|
onChangeRef.current = onChange;
|
|
8439
8696
|
}, [onChange]);
|
|
8440
8697
|
const actions = useMemo17(() => normalizeToolbarConfig(toolbarConfig), [toolbarConfig]);
|
|
@@ -8503,11 +8760,11 @@ function RichTextEditorCore({
|
|
|
8503
8760
|
},
|
|
8504
8761
|
[fieldId, extensions, disabled, maxLength, updateHtml]
|
|
8505
8762
|
);
|
|
8506
|
-
|
|
8763
|
+
useEffect28(() => {
|
|
8507
8764
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
8508
8765
|
editor.setEditable(!disabled);
|
|
8509
8766
|
}, [disabled, editor]);
|
|
8510
|
-
|
|
8767
|
+
useEffect28(() => {
|
|
8511
8768
|
if (!editor || isEditorDestroyed(editor)) return;
|
|
8512
8769
|
const currentHtml = getSafeEditorHtml(editor);
|
|
8513
8770
|
if ((value || "") !== currentHtml) {
|
|
@@ -8821,14 +9078,14 @@ function EditorField(props) {
|
|
|
8821
9078
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "NORMAL";
|
|
8822
9079
|
const rawValue = formData[fieldId] ?? "";
|
|
8823
9080
|
const value = normalizeRichTextHtml(rawValue);
|
|
8824
|
-
|
|
9081
|
+
useEffect28(() => {
|
|
8825
9082
|
registerField(fieldId);
|
|
8826
9083
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
8827
9084
|
setFieldValue(fieldId, normalizeRichTextHtml(defaultValue));
|
|
8828
9085
|
}
|
|
8829
9086
|
return () => unregisterField(fieldId);
|
|
8830
9087
|
}, [fieldId]);
|
|
8831
|
-
|
|
9088
|
+
useEffect28(() => {
|
|
8832
9089
|
if (rawValue && rawValue !== value) {
|
|
8833
9090
|
setFieldValue(fieldId, value);
|
|
8834
9091
|
}
|
|
@@ -8886,7 +9143,7 @@ function EditorField(props) {
|
|
|
8886
9143
|
}
|
|
8887
9144
|
|
|
8888
9145
|
// packages/sdk/src/components/fields/SerialNumberField/index.tsx
|
|
8889
|
-
import { useEffect as
|
|
9146
|
+
import { useEffect as useEffect29 } from "react";
|
|
8890
9147
|
import { Input as Input10 } from "antd";
|
|
8891
9148
|
import { jsx as jsx70 } from "react/jsx-runtime";
|
|
8892
9149
|
function SerialNumberField(props) {
|
|
@@ -8906,7 +9163,7 @@ function SerialNumberField(props) {
|
|
|
8906
9163
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
8907
9164
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
8908
9165
|
const value = formData[fieldId] ?? "";
|
|
8909
|
-
|
|
9166
|
+
useEffect29(() => {
|
|
8910
9167
|
registerField(fieldId);
|
|
8911
9168
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
8912
9169
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -8948,7 +9205,7 @@ function SerialNumberField(props) {
|
|
|
8948
9205
|
}
|
|
8949
9206
|
|
|
8950
9207
|
// packages/sdk/src/components/fields/LocationField/index.tsx
|
|
8951
|
-
import { useEffect as
|
|
9208
|
+
import { useEffect as useEffect30, useState as useState16 } from "react";
|
|
8952
9209
|
import { Button as Button6, Space as Space6 } from "antd";
|
|
8953
9210
|
import { jsx as jsx71, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
8954
9211
|
var getDingTalkApi = () => {
|
|
@@ -8992,7 +9249,7 @@ function LocationField(props) {
|
|
|
8992
9249
|
const value = formData[fieldId];
|
|
8993
9250
|
const [locating, setLocating] = useState16(false);
|
|
8994
9251
|
const [error, setError] = useState16("");
|
|
8995
|
-
|
|
9252
|
+
useEffect30(() => {
|
|
8996
9253
|
registerField(fieldId);
|
|
8997
9254
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
8998
9255
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -9133,7 +9390,7 @@ function LocationField(props) {
|
|
|
9133
9390
|
}
|
|
9134
9391
|
|
|
9135
9392
|
// packages/sdk/src/components/fields/DigitalSignatureField/index.tsx
|
|
9136
|
-
import { useCallback as useCallback7, useEffect as
|
|
9393
|
+
import { useCallback as useCallback7, useEffect as useEffect31, useRef as useRef8, useState as useState17 } from "react";
|
|
9137
9394
|
import { Button as Button7, Modal as Modal5, Space as Space7 } from "antd";
|
|
9138
9395
|
import { jsx as jsx72, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
9139
9396
|
var CANVAS_HEIGHT = 260;
|
|
@@ -9171,10 +9428,10 @@ function DigitalSignatureField(props) {
|
|
|
9171
9428
|
const [saving, setSaving] = useState17(false);
|
|
9172
9429
|
const [drawn, setDrawn] = useState17(false);
|
|
9173
9430
|
const [error, setError] = useState17("");
|
|
9174
|
-
const canvasRef =
|
|
9175
|
-
const drawingRef =
|
|
9176
|
-
const pointsRef =
|
|
9177
|
-
|
|
9431
|
+
const canvasRef = useRef8(null);
|
|
9432
|
+
const drawingRef = useRef8(false);
|
|
9433
|
+
const pointsRef = useRef8([]);
|
|
9434
|
+
useEffect31(() => {
|
|
9178
9435
|
registerField(fieldId);
|
|
9179
9436
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
9180
9437
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -9203,7 +9460,7 @@ function DigitalSignatureField(props) {
|
|
|
9203
9460
|
ctx.lineJoin = "round";
|
|
9204
9461
|
ctx.strokeStyle = "#111827";
|
|
9205
9462
|
}, []);
|
|
9206
|
-
|
|
9463
|
+
useEffect31(() => {
|
|
9207
9464
|
if (!open) return;
|
|
9208
9465
|
pointsRef.current = [];
|
|
9209
9466
|
setDrawn(false);
|
|
@@ -9382,7 +9639,7 @@ function DigitalSignatureField(props) {
|
|
|
9382
9639
|
}
|
|
9383
9640
|
|
|
9384
9641
|
// packages/sdk/src/components/fields/JSONField/index.tsx
|
|
9385
|
-
import { useEffect as
|
|
9642
|
+
import { useEffect as useEffect32 } from "react";
|
|
9386
9643
|
import { jsx as jsx73 } from "react/jsx-runtime";
|
|
9387
9644
|
var formatJson = (value) => {
|
|
9388
9645
|
if (value === void 0 || value === null || value === "") return "--";
|
|
@@ -9409,7 +9666,7 @@ function JSONField(props) {
|
|
|
9409
9666
|
const { formData, fieldBehaviors, setFieldValue, registerField, unregisterField } = useFormContext();
|
|
9410
9667
|
const behavior = propBehavior ?? fieldBehaviors[fieldId] ?? "READONLY";
|
|
9411
9668
|
const value = formData[fieldId];
|
|
9412
|
-
|
|
9669
|
+
useEffect32(() => {
|
|
9413
9670
|
registerField(fieldId);
|
|
9414
9671
|
if (defaultValue !== void 0 && formData[fieldId] === void 0) {
|
|
9415
9672
|
setFieldValue(fieldId, defaultValue);
|
|
@@ -10484,6 +10741,30 @@ function createFormRuntimeApi(config) {
|
|
|
10484
10741
|
});
|
|
10485
10742
|
return response.data || response.result || [];
|
|
10486
10743
|
},
|
|
10744
|
+
searchDepartments: async (params) => {
|
|
10745
|
+
const page = params?.page ?? 1;
|
|
10746
|
+
const pageSize = params?.pageSize ?? 50;
|
|
10747
|
+
const response = await request({
|
|
10748
|
+
url: "/department/search",
|
|
10749
|
+
method: "get",
|
|
10750
|
+
params: {
|
|
10751
|
+
keyword: params?.keyword,
|
|
10752
|
+
page,
|
|
10753
|
+
pageSize,
|
|
10754
|
+
includePath: params?.includePath ?? true
|
|
10755
|
+
}
|
|
10756
|
+
});
|
|
10757
|
+
const data = response.data || response.result;
|
|
10758
|
+
if (Array.isArray(data)) {
|
|
10759
|
+
return { items: data, total: data.length, page, pageSize };
|
|
10760
|
+
}
|
|
10761
|
+
return {
|
|
10762
|
+
items: data?.items || data?.list || [],
|
|
10763
|
+
total: Number(data?.total ?? data?.count ?? data?.items?.length ?? 0),
|
|
10764
|
+
page: Number(data?.page ?? page),
|
|
10765
|
+
pageSize: Number(data?.pageSize ?? pageSize)
|
|
10766
|
+
};
|
|
10767
|
+
},
|
|
10487
10768
|
getDepartmentParentDepartments: async (id) => {
|
|
10488
10769
|
const response = await request({
|
|
10489
10770
|
url: `/department/${id}/parentDepartments`,
|
|
@@ -10735,11 +11016,11 @@ function FormProvider({
|
|
|
10735
11016
|
}
|
|
10736
11017
|
return { ...values, ...initialValues };
|
|
10737
11018
|
}, [schema, initialValues, mergedRuntime]);
|
|
10738
|
-
const initialValuesRef =
|
|
11019
|
+
const initialValuesRef = useRef9(computedInitialValues);
|
|
10739
11020
|
const [formData, setFormData] = useState18({ ...computedInitialValues });
|
|
10740
11021
|
const [fieldErrors, setFieldErrors] = useState18({});
|
|
10741
11022
|
const [registeredFields] = useState18(/* @__PURE__ */ new Set());
|
|
10742
|
-
|
|
11023
|
+
useEffect33(() => {
|
|
10743
11024
|
if (!schema.fields.some((field) => needsCurrentUserRuntime(field.defaultShortcut?.type)))
|
|
10744
11025
|
return;
|
|
10745
11026
|
if (mergedRuntime.currentUser && mergedRuntime.currentDepartment) return;
|
|
@@ -10763,7 +11044,7 @@ function FormProvider({
|
|
|
10763
11044
|
cancelled = true;
|
|
10764
11045
|
};
|
|
10765
11046
|
}, [api, mergedRuntime.currentDepartment, mergedRuntime.currentUser, schema.fields]);
|
|
10766
|
-
|
|
11047
|
+
useEffect33(() => {
|
|
10767
11048
|
setFormData((prev) => {
|
|
10768
11049
|
let changed = false;
|
|
10769
11050
|
const next = { ...prev };
|
|
@@ -10808,7 +11089,7 @@ function FormProvider({
|
|
|
10808
11089
|
() => evaluateLayoutBehaviors(effects, formData),
|
|
10809
11090
|
[effects, formData]
|
|
10810
11091
|
);
|
|
10811
|
-
|
|
11092
|
+
useEffect33(() => {
|
|
10812
11093
|
const valueActions = getValueActions(effects, formData);
|
|
10813
11094
|
if (valueActions.length === 0) return;
|
|
10814
11095
|
let changed = false;
|
|
@@ -10950,7 +11231,7 @@ function FormProvider({
|
|
|
10950
11231
|
[registeredFields]
|
|
10951
11232
|
);
|
|
10952
11233
|
const [dynamicOptions, setDynamicOptions] = useState18({});
|
|
10953
|
-
|
|
11234
|
+
useEffect33(() => {
|
|
10954
11235
|
const loadDynamicOptions = async () => {
|
|
10955
11236
|
const updates = {};
|
|
10956
11237
|
for (const field of schema.fields) {
|
|
@@ -10968,7 +11249,7 @@ function FormProvider({
|
|
|
10968
11249
|
};
|
|
10969
11250
|
loadDynamicOptions();
|
|
10970
11251
|
}, [schema.fields, mergedRuntime]);
|
|
10971
|
-
|
|
11252
|
+
useEffect33(() => {
|
|
10972
11253
|
let cancelled = false;
|
|
10973
11254
|
const loadDataLinkageOptions = async () => {
|
|
10974
11255
|
const updates = {};
|
|
@@ -10994,7 +11275,7 @@ function FormProvider({
|
|
|
10994
11275
|
window.clearTimeout(timer);
|
|
10995
11276
|
};
|
|
10996
11277
|
}, [schema.fields, mergedRuntime, formData]);
|
|
10997
|
-
|
|
11278
|
+
useEffect33(() => {
|
|
10998
11279
|
let cancelled = false;
|
|
10999
11280
|
const loadDefaultValueLinkages = async () => {
|
|
11000
11281
|
const fields = schema.fields.filter((field) => field.defaultValueLinkage);
|
|
@@ -11748,7 +12029,7 @@ function isLayoutVisible(visibleWhen, formData) {
|
|
|
11748
12029
|
}
|
|
11749
12030
|
|
|
11750
12031
|
// packages/sdk/src/components/core/FormShell.tsx
|
|
11751
|
-
import { useEffect as
|
|
12032
|
+
import { useEffect as useEffect34, useMemo as useMemo19 } from "react";
|
|
11752
12033
|
import * as Antd2 from "antd";
|
|
11753
12034
|
import { jsx as jsx79 } from "react/jsx-runtime";
|
|
11754
12035
|
function normalizeMaxWidth(maxWidth) {
|
|
@@ -11778,7 +12059,7 @@ function FormShell({ children, appearance, className }) {
|
|
|
11778
12059
|
const [form] = useAntForm();
|
|
11779
12060
|
const { formData, setFieldValue } = useFormContext();
|
|
11780
12061
|
const maxWidth = normalizeMaxWidth(appearance?.maxWidth);
|
|
11781
|
-
|
|
12062
|
+
useEffect34(() => {
|
|
11782
12063
|
form?.setFieldsValue?.(formData);
|
|
11783
12064
|
}, [form, formData]);
|
|
11784
12065
|
const style = useMemo19(() => {
|
|
@@ -12892,7 +13173,7 @@ function FormSummary({
|
|
|
12892
13173
|
}
|
|
12893
13174
|
|
|
12894
13175
|
// packages/sdk/src/components/hooks/useFormEngine.ts
|
|
12895
|
-
import { useState as useState23, useCallback as useCallback10, useMemo as useMemo20, useRef as
|
|
13176
|
+
import { useState as useState23, useCallback as useCallback10, useMemo as useMemo20, useRef as useRef10 } from "react";
|
|
12896
13177
|
function useFormEngine(schema, config) {
|
|
12897
13178
|
const initialValues = useMemo20(() => {
|
|
12898
13179
|
const values = {};
|
|
@@ -12903,7 +13184,7 @@ function useFormEngine(schema, config) {
|
|
|
12903
13184
|
}
|
|
12904
13185
|
return values;
|
|
12905
13186
|
}, [schema]);
|
|
12906
|
-
const initialValuesRef =
|
|
13187
|
+
const initialValuesRef = useRef10(initialValues);
|
|
12907
13188
|
const [formData, setFormData] = useState23({ ...initialValues });
|
|
12908
13189
|
const [fieldErrors, setFieldErrors] = useState23({});
|
|
12909
13190
|
const fieldBehaviors = useMemo20(() => {
|
|
@@ -12978,11 +13259,11 @@ function useFormEngine(schema, config) {
|
|
|
12978
13259
|
}
|
|
12979
13260
|
|
|
12980
13261
|
// packages/sdk/src/components/hooks/useFormData.ts
|
|
12981
|
-
import { useState as useState24, useCallback as useCallback11, useRef as
|
|
13262
|
+
import { useState as useState24, useCallback as useCallback11, useRef as useRef11 } from "react";
|
|
12982
13263
|
function useFormData(initialValues = {}) {
|
|
12983
13264
|
const [formData, setFormData] = useState24({ ...initialValues });
|
|
12984
13265
|
const [dirtyFields, setDirtyFields] = useState24(/* @__PURE__ */ new Set());
|
|
12985
|
-
const initialValuesRef =
|
|
13266
|
+
const initialValuesRef = useRef11(initialValues);
|
|
12986
13267
|
const setFieldValue = useCallback11((fieldId, value) => {
|
|
12987
13268
|
setFormData((prev) => ({ ...prev, [fieldId]: value }));
|
|
12988
13269
|
setDirtyFields((prev) => {
|
|
@@ -13196,7 +13477,7 @@ function useFieldPermission(options) {
|
|
|
13196
13477
|
}
|
|
13197
13478
|
|
|
13198
13479
|
// packages/sdk/src/components/hooks/useFormDetail.ts
|
|
13199
|
-
import { useState as useState26, useEffect as
|
|
13480
|
+
import { useState as useState26, useEffect as useEffect35, useCallback as useCallback14, useRef as useRef12 } from "react";
|
|
13200
13481
|
|
|
13201
13482
|
// packages/sdk/src/components/utils/formInstanceData.ts
|
|
13202
13483
|
var FORM_INSTANCE_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -13360,16 +13641,16 @@ function useFormDetail(options) {
|
|
|
13360
13641
|
const [formData, setFormData] = useState26(null);
|
|
13361
13642
|
const [instanceInfo, setInstanceInfo] = useState26(null);
|
|
13362
13643
|
const [permissions, setPermissions] = useState26(null);
|
|
13363
|
-
const mountedRef =
|
|
13364
|
-
const onPermissionDeniedRef =
|
|
13644
|
+
const mountedRef = useRef12(true);
|
|
13645
|
+
const onPermissionDeniedRef = useRef12(onPermissionDenied);
|
|
13365
13646
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
13366
|
-
|
|
13647
|
+
useEffect35(() => {
|
|
13367
13648
|
mountedRef.current = true;
|
|
13368
13649
|
return () => {
|
|
13369
13650
|
mountedRef.current = false;
|
|
13370
13651
|
};
|
|
13371
13652
|
}, []);
|
|
13372
|
-
|
|
13653
|
+
useEffect35(() => {
|
|
13373
13654
|
onPermissionDeniedRef.current = onPermissionDenied;
|
|
13374
13655
|
}, [onPermissionDenied]);
|
|
13375
13656
|
const loadData = useCallback14(async () => {
|
|
@@ -13407,7 +13688,7 @@ function useFormDetail(options) {
|
|
|
13407
13688
|
}
|
|
13408
13689
|
}
|
|
13409
13690
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
13410
|
-
|
|
13691
|
+
useEffect35(() => {
|
|
13411
13692
|
loadData();
|
|
13412
13693
|
}, [loadData]);
|
|
13413
13694
|
const fieldBehaviors = normalizeFieldBehaviors(permissions, mode);
|
|
@@ -13469,7 +13750,7 @@ function useFormDetail(options) {
|
|
|
13469
13750
|
}
|
|
13470
13751
|
|
|
13471
13752
|
// packages/sdk/src/components/hooks/useProcessDetail.ts
|
|
13472
|
-
import { useState as useState27, useEffect as
|
|
13753
|
+
import { useState as useState27, useEffect as useEffect36, useCallback as useCallback15, useRef as useRef13, useMemo as useMemo23 } from "react";
|
|
13473
13754
|
var DEFAULT_APPROVAL_ACTIONS = [
|
|
13474
13755
|
{ action: "agree", name: { zh_CN: "\u540C\u610F" } },
|
|
13475
13756
|
{ action: "rejected", name: { zh_CN: "\u62D2\u7EDD" } }
|
|
@@ -13511,9 +13792,9 @@ function useProcessDetail(options) {
|
|
|
13511
13792
|
const [permissions, setPermissions] = useState27(null);
|
|
13512
13793
|
const [processDefinition, setProcessDefinition] = useState27(null);
|
|
13513
13794
|
const [dataVersion, setDataVersion] = useState27(0);
|
|
13514
|
-
const mountedRef =
|
|
13795
|
+
const mountedRef = useRef13(true);
|
|
13515
13796
|
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
13516
|
-
|
|
13797
|
+
useEffect36(() => {
|
|
13517
13798
|
mountedRef.current = true;
|
|
13518
13799
|
return () => {
|
|
13519
13800
|
mountedRef.current = false;
|
|
@@ -13629,7 +13910,7 @@ function useProcessDetail(options) {
|
|
|
13629
13910
|
}
|
|
13630
13911
|
}
|
|
13631
13912
|
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
13632
|
-
|
|
13913
|
+
useEffect36(() => {
|
|
13633
13914
|
loadData();
|
|
13634
13915
|
}, [loadData]);
|
|
13635
13916
|
const switchToEdit = useCallback15(() => {
|
|
@@ -13706,7 +13987,7 @@ function useProcessDetail(options) {
|
|
|
13706
13987
|
}
|
|
13707
13988
|
|
|
13708
13989
|
// packages/sdk/src/components/hooks/useApprovalActions.ts
|
|
13709
|
-
import { useState as useState28, useCallback as useCallback16, useRef as
|
|
13990
|
+
import { useState as useState28, useCallback as useCallback16, useRef as useRef14, useEffect as useEffect37 } from "react";
|
|
13710
13991
|
function useApprovalActions(options) {
|
|
13711
13992
|
const { formInstanceId, formUuid, appType, currentTaskId, onActionComplete, getFormValues } = options;
|
|
13712
13993
|
const { api } = useFormContext();
|
|
@@ -13715,8 +13996,8 @@ function useApprovalActions(options) {
|
|
|
13715
13996
|
const [currentAction, setCurrentAction] = useState28(null);
|
|
13716
13997
|
const [returnableNodes, setReturnableNodes] = useState28([]);
|
|
13717
13998
|
const [returnPolicy, setReturnPolicy] = useState28(null);
|
|
13718
|
-
const mountedRef =
|
|
13719
|
-
|
|
13999
|
+
const mountedRef = useRef14(true);
|
|
14000
|
+
useEffect37(() => {
|
|
13720
14001
|
mountedRef.current = true;
|
|
13721
14002
|
return () => {
|
|
13722
14003
|
mountedRef.current = false;
|
|
@@ -13954,7 +14235,7 @@ function useApprovalActions(options) {
|
|
|
13954
14235
|
}
|
|
13955
14236
|
|
|
13956
14237
|
// packages/sdk/src/components/hooks/useChangeRecords.ts
|
|
13957
|
-
import { useState as useState29, useEffect as
|
|
14238
|
+
import { useState as useState29, useEffect as useEffect38, useCallback as useCallback17, useRef as useRef15 } from "react";
|
|
13958
14239
|
var normalizeChangeRecordList = (value) => {
|
|
13959
14240
|
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;
|
|
13960
14241
|
const records = Array.isArray(body) ? body : body?.records ?? body?.data ?? body?.list ?? body?.items ?? [];
|
|
@@ -13973,8 +14254,8 @@ function useChangeRecords(options) {
|
|
|
13973
14254
|
const [loading, setLoading] = useState29(false);
|
|
13974
14255
|
const [total, setTotal] = useState29(0);
|
|
13975
14256
|
const [page, setPage] = useState29(1);
|
|
13976
|
-
const mountedRef =
|
|
13977
|
-
|
|
14257
|
+
const mountedRef = useRef15(true);
|
|
14258
|
+
useEffect38(() => {
|
|
13978
14259
|
mountedRef.current = true;
|
|
13979
14260
|
return () => {
|
|
13980
14261
|
mountedRef.current = false;
|
|
@@ -14011,7 +14292,7 @@ function useChangeRecords(options) {
|
|
|
14011
14292
|
},
|
|
14012
14293
|
[request, formUuid, appType, formInstanceId, pageSize]
|
|
14013
14294
|
);
|
|
14014
|
-
|
|
14295
|
+
useEffect38(() => {
|
|
14015
14296
|
if (autoLoad) {
|
|
14016
14297
|
fetchRecords(1, false);
|
|
14017
14298
|
}
|
|
@@ -14040,7 +14321,7 @@ function useChangeRecords(options) {
|
|
|
14040
14321
|
}
|
|
14041
14322
|
|
|
14042
14323
|
// packages/sdk/src/components/hooks/useFormNavigation.ts
|
|
14043
|
-
import { useState as useState30, useCallback as useCallback18, useRef as
|
|
14324
|
+
import { useState as useState30, useCallback as useCallback18, useRef as useRef16, useEffect as useEffect39 } from "react";
|
|
14044
14325
|
var normalizeBasePath = (basePath) => {
|
|
14045
14326
|
const normalized = String(basePath || "").replace(/^\/+|\/+$/g, "");
|
|
14046
14327
|
return normalized ? `/${normalized}` : "";
|
|
@@ -14074,10 +14355,10 @@ function useFormNavigation(options) {
|
|
|
14074
14355
|
} = options;
|
|
14075
14356
|
const [isRedirecting, setIsRedirecting] = useState30(false);
|
|
14076
14357
|
const [countdown, setCountdown] = useState30(0);
|
|
14077
|
-
const timerRef =
|
|
14078
|
-
const redirectTargetRef =
|
|
14079
|
-
const mountedRef =
|
|
14080
|
-
|
|
14358
|
+
const timerRef = useRef16(null);
|
|
14359
|
+
const redirectTargetRef = useRef16(null);
|
|
14360
|
+
const mountedRef = useRef16(true);
|
|
14361
|
+
useEffect39(() => {
|
|
14081
14362
|
mountedRef.current = true;
|
|
14082
14363
|
return () => {
|
|
14083
14364
|
mountedRef.current = false;
|
|
@@ -14179,7 +14460,7 @@ function useFormNavigation(options) {
|
|
|
14179
14460
|
}
|
|
14180
14461
|
|
|
14181
14462
|
// packages/sdk/src/components/hooks/useDraftStorage.ts
|
|
14182
|
-
import { useState as useState31, useCallback as useCallback19, useEffect as
|
|
14463
|
+
import { useState as useState31, useCallback as useCallback19, useEffect as useEffect40 } from "react";
|
|
14183
14464
|
function getDraftKey(appType, formUuid) {
|
|
14184
14465
|
return `${appType}__${formUuid}__draft`;
|
|
14185
14466
|
}
|
|
@@ -14202,7 +14483,7 @@ function useDraftStorage(options) {
|
|
|
14202
14483
|
const [hasDraft, setHasDraft] = useState31(false);
|
|
14203
14484
|
const [draftData, setDraftData] = useState31(null);
|
|
14204
14485
|
const [draftTimestamp, setDraftTimestamp] = useState31(null);
|
|
14205
|
-
|
|
14486
|
+
useEffect40(() => {
|
|
14206
14487
|
const stored = readDraft(key);
|
|
14207
14488
|
if (stored) {
|
|
14208
14489
|
setHasDraft(true);
|
|
@@ -14823,7 +15104,7 @@ import {
|
|
|
14823
15104
|
} from "@ant-design/icons";
|
|
14824
15105
|
|
|
14825
15106
|
// packages/sdk/src/components/modules/StickyActionBar.tsx
|
|
14826
|
-
import { useEffect as
|
|
15107
|
+
import { useEffect as useEffect41, useMemo as useMemo25, useState as useState33 } from "react";
|
|
14827
15108
|
import { Button as Button10, Dropdown, Tooltip as Tooltip3 } from "antd";
|
|
14828
15109
|
import { MoreOutlined } from "@ant-design/icons";
|
|
14829
15110
|
|
|
@@ -14860,7 +15141,7 @@ var StickyActionBar = ({
|
|
|
14860
15141
|
surface = "default"
|
|
14861
15142
|
}) => {
|
|
14862
15143
|
const [isMobile, setIsMobile] = useState33(false);
|
|
14863
|
-
|
|
15144
|
+
useEffect41(() => {
|
|
14864
15145
|
const update = () => setIsMobile(typeof window !== "undefined" && window.innerWidth <= 768);
|
|
14865
15146
|
update();
|
|
14866
15147
|
window.addEventListener("resize", update);
|
|
@@ -15695,7 +15976,7 @@ var ProcessPreview = ({
|
|
|
15695
15976
|
};
|
|
15696
15977
|
|
|
15697
15978
|
// packages/sdk/src/components/modules/DataManagementList.tsx
|
|
15698
|
-
import { useCallback as useCallback24, useEffect as
|
|
15979
|
+
import { useCallback as useCallback24, useEffect as useEffect44, useMemo as useMemo32, useRef as useRef21, useState as useState41 } from "react";
|
|
15699
15980
|
import {
|
|
15700
15981
|
Alert as Alert2,
|
|
15701
15982
|
Button as Button17,
|
|
@@ -15737,7 +16018,7 @@ import {
|
|
|
15737
16018
|
import { useMemo as useMemo31 } from "react";
|
|
15738
16019
|
|
|
15739
16020
|
// packages/sdk/src/components/templates/FormDetailTemplate.tsx
|
|
15740
|
-
import { useCallback as useCallback20, useMemo as useMemo28, useRef as
|
|
16021
|
+
import { useCallback as useCallback20, useMemo as useMemo28, useRef as useRef17, useState as useState37 } from "react";
|
|
15741
16022
|
import dayjs9 from "dayjs";
|
|
15742
16023
|
|
|
15743
16024
|
// packages/sdk/src/components/templates/PageSkeleton.tsx
|
|
@@ -15833,8 +16114,8 @@ var InnerDetailContent = ({
|
|
|
15833
16114
|
onSave,
|
|
15834
16115
|
inDrawer = false
|
|
15835
16116
|
}) => {
|
|
15836
|
-
const formDataRef =
|
|
15837
|
-
const validateRef =
|
|
16117
|
+
const formDataRef = useRef17(void 0);
|
|
16118
|
+
const validateRef = useRef17(void 0);
|
|
15838
16119
|
const [accessDenied, setAccessDenied] = useState37(false);
|
|
15839
16120
|
const fieldIds = useMemo28(() => schema.fields.map((field) => field.fieldId), [schema.fields]);
|
|
15840
16121
|
const {
|
|
@@ -16013,12 +16294,12 @@ var FormDetailTemplate = (props) => {
|
|
|
16013
16294
|
};
|
|
16014
16295
|
|
|
16015
16296
|
// packages/sdk/src/components/templates/FormSubmitTemplate.tsx
|
|
16016
|
-
import { useEffect as
|
|
16297
|
+
import { useEffect as useEffect43, useRef as useRef19, useState as useState39, useCallback as useCallback22 } from "react";
|
|
16017
16298
|
import { Button as Button16, message as message3, Modal as Modal10, Select as Select8 } from "antd";
|
|
16018
16299
|
import { CheckCircleFilled as CheckCircleFilled2 } from "@ant-design/icons";
|
|
16019
16300
|
|
|
16020
16301
|
// packages/sdk/src/components/modules/InitiatorApproverSelector.tsx
|
|
16021
|
-
import { useCallback as useCallback21, useEffect as
|
|
16302
|
+
import { useCallback as useCallback21, useEffect as useEffect42, useMemo as useMemo29, useRef as useRef18, useState as useState38 } from "react";
|
|
16022
16303
|
import { Button as Button15, Empty as Empty5, Modal as Modal9, Select as Select7, Space as Space8, Tag as Tag6, Typography, message as message2 } from "antd";
|
|
16023
16304
|
import { jsx as jsx97, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
16024
16305
|
var scopeText = {
|
|
@@ -16061,7 +16342,7 @@ var RequirementSelect = ({
|
|
|
16061
16342
|
);
|
|
16062
16343
|
const [optionsSource, setOptionsSource] = useState38(initialCandidates);
|
|
16063
16344
|
const [loading, setLoading] = useState38(false);
|
|
16064
|
-
|
|
16345
|
+
useEffect42(() => {
|
|
16065
16346
|
setOptionsSource(
|
|
16066
16347
|
(current) => mergeUsers(initialCandidates, mergeUsers(current, selectedUsers))
|
|
16067
16348
|
);
|
|
@@ -16104,7 +16385,7 @@ var RequirementSelect = ({
|
|
|
16104
16385
|
},
|
|
16105
16386
|
[api, appType, formUuid, initialCandidates.length, requirement.nodeId, requirement.scope]
|
|
16106
16387
|
);
|
|
16107
|
-
|
|
16388
|
+
useEffect42(() => {
|
|
16108
16389
|
if (requirement.scope !== "all" && open && formUuid && appType && requirement.nodeId) {
|
|
16109
16390
|
void loadCandidates();
|
|
16110
16391
|
}
|
|
@@ -16195,8 +16476,8 @@ var InitiatorApproverSelector = ({
|
|
|
16195
16476
|
onCancel
|
|
16196
16477
|
}) => {
|
|
16197
16478
|
const [selected, setSelected] = useState38({});
|
|
16198
|
-
const wasOpenRef =
|
|
16199
|
-
|
|
16479
|
+
const wasOpenRef = useRef18(false);
|
|
16480
|
+
useEffect42(() => {
|
|
16200
16481
|
if (open && !wasOpenRef.current) {
|
|
16201
16482
|
setSelected(value || EMPTY_SELECTED_MAP);
|
|
16202
16483
|
}
|
|
@@ -16382,15 +16663,15 @@ var InnerFormContent = ({
|
|
|
16382
16663
|
const [submissionDepartmentModalOpen, setSubmissionDepartmentModalOpen] = useState39(false);
|
|
16383
16664
|
const [submissionDepartmentOptions, setSubmissionDepartmentOptions] = useState39([]);
|
|
16384
16665
|
const [selectedSubmissionDepartmentId, setSelectedSubmissionDepartmentId] = useState39();
|
|
16385
|
-
const submissionDepartmentResolverRef =
|
|
16666
|
+
const submissionDepartmentResolverRef = useRef19(null);
|
|
16386
16667
|
const [previewOpen, setPreviewOpen] = useState39(false);
|
|
16387
16668
|
const [previewLoading, setPreviewLoading] = useState39(false);
|
|
16388
16669
|
const [previewRoutes, setPreviewRoutes] = useState39([]);
|
|
16389
16670
|
const [pendingFormData, setPendingFormData] = useState39(null);
|
|
16390
16671
|
const [pendingSubmissionDepartmentId, setPendingSubmissionDepartmentId] = useState39();
|
|
16391
16672
|
const [pendingInitiatorSelectedApprovers, setPendingInitiatorSelectedApprovers] = useState39();
|
|
16392
|
-
const pendingSubmissionDepartmentIdRef =
|
|
16393
|
-
const pendingInitiatorSelectedApproversRef =
|
|
16673
|
+
const pendingSubmissionDepartmentIdRef = useRef19(void 0);
|
|
16674
|
+
const pendingInitiatorSelectedApproversRef = useRef19(
|
|
16394
16675
|
void 0
|
|
16395
16676
|
);
|
|
16396
16677
|
const [initiatorApproverOpen, setInitiatorApproverOpen] = useState39(false);
|
|
@@ -16406,7 +16687,7 @@ var InnerFormContent = ({
|
|
|
16406
16687
|
mode: submitSuccessMode === "continue" ? "stay" : submitSuccessMode,
|
|
16407
16688
|
basePath: config.navigation?.basePath
|
|
16408
16689
|
});
|
|
16409
|
-
|
|
16690
|
+
useEffect43(() => {
|
|
16410
16691
|
return () => {
|
|
16411
16692
|
submissionDepartmentResolverRef.current?.(null);
|
|
16412
16693
|
submissionDepartmentResolverRef.current = null;
|
|
@@ -16899,7 +17180,7 @@ var FormSubmitTemplate = ({
|
|
|
16899
17180
|
};
|
|
16900
17181
|
|
|
16901
17182
|
// packages/sdk/src/components/templates/ProcessDetailTemplate.tsx
|
|
16902
|
-
import { useCallback as useCallback23, useMemo as useMemo30, useRef as
|
|
17183
|
+
import { useCallback as useCallback23, useMemo as useMemo30, useRef as useRef20, useState as useState40 } from "react";
|
|
16903
17184
|
import dayjs10 from "dayjs";
|
|
16904
17185
|
import { Form as AntForm, Input as Input13, Modal as Modal11, message as message4 } from "antd";
|
|
16905
17186
|
import { jsx as jsx99, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
@@ -16992,8 +17273,8 @@ var InnerProcessContent = ({
|
|
|
16992
17273
|
onDelete,
|
|
16993
17274
|
inDrawer = false
|
|
16994
17275
|
}) => {
|
|
16995
|
-
const formDataRef =
|
|
16996
|
-
const validateRef =
|
|
17276
|
+
const formDataRef = useRef20(void 0);
|
|
17277
|
+
const validateRef = useRef20(void 0);
|
|
16997
17278
|
const [withdrawForm] = AntForm.useForm();
|
|
16998
17279
|
const [withdrawOpen, setWithdrawOpen] = useState40(false);
|
|
16999
17280
|
const [withdrawLoading, setWithdrawLoading] = useState40(false);
|
|
@@ -18202,7 +18483,7 @@ function AsyncEntityFilterSelect({
|
|
|
18202
18483
|
},
|
|
18203
18484
|
[api, entityType]
|
|
18204
18485
|
);
|
|
18205
|
-
|
|
18486
|
+
useEffect44(() => {
|
|
18206
18487
|
void loadOptions();
|
|
18207
18488
|
}, [loadOptions]);
|
|
18208
18489
|
return /* @__PURE__ */ jsx101(
|
|
@@ -18513,7 +18794,7 @@ function ResizableColumnTitle({
|
|
|
18513
18794
|
onResize,
|
|
18514
18795
|
onResizeEnd
|
|
18515
18796
|
}) {
|
|
18516
|
-
const dragRef =
|
|
18797
|
+
const dragRef = useRef21({ startX: 0, startWidth: width, latestWidth: width });
|
|
18517
18798
|
const handleMouseDown = (event) => {
|
|
18518
18799
|
event.preventDefault();
|
|
18519
18800
|
event.stopPropagation();
|
|
@@ -18582,7 +18863,7 @@ var DataManagementList = ({
|
|
|
18582
18863
|
permissionMode = "auto",
|
|
18583
18864
|
actionOverrides
|
|
18584
18865
|
}) => {
|
|
18585
|
-
const rootRef =
|
|
18866
|
+
const rootRef = useRef21(null);
|
|
18586
18867
|
const api = useMemo32(() => {
|
|
18587
18868
|
if (typeof requestOverride === "function") {
|
|
18588
18869
|
return createFormRuntimeApi({ request: requestOverride });
|
|
@@ -18596,7 +18877,7 @@ var DataManagementList = ({
|
|
|
18596
18877
|
const [showFields, setShowFields] = useState41([]);
|
|
18597
18878
|
const [lockFieldIds, setLockFieldIds] = useState41([]);
|
|
18598
18879
|
const [widths, setWidths] = useState41({});
|
|
18599
|
-
const widthsRef =
|
|
18880
|
+
const widthsRef = useRef21({});
|
|
18600
18881
|
const [sort, setSort] = useState41([]);
|
|
18601
18882
|
const [density, setDensity] = useState41("middle");
|
|
18602
18883
|
const [detailOpenMode, setDetailOpenMode] = useState41("drawer");
|
|
@@ -18634,7 +18915,7 @@ var DataManagementList = ({
|
|
|
18634
18915
|
const [actionSummary, setActionSummary] = useState41(null);
|
|
18635
18916
|
const [permissionLoading, setPermissionLoading] = useState41(permissionMode === "auto");
|
|
18636
18917
|
const [permissionError, setPermissionError] = useState41(null);
|
|
18637
|
-
const fetchStateRef =
|
|
18918
|
+
const fetchStateRef = useRef21({});
|
|
18638
18919
|
const isProcessForm = isProcessFormType(formType);
|
|
18639
18920
|
const request = api.request;
|
|
18640
18921
|
const getPopupContainer = useCallback24(
|
|
@@ -18649,7 +18930,7 @@ var DataManagementList = ({
|
|
|
18649
18930
|
const confirmDanger = useCallback24((title2, content, onOk) => {
|
|
18650
18931
|
if (confirmAction(title2, content)) onOk();
|
|
18651
18932
|
}, []);
|
|
18652
|
-
|
|
18933
|
+
useEffect44(() => {
|
|
18653
18934
|
let mounted = true;
|
|
18654
18935
|
if (permissionMode !== "auto") {
|
|
18655
18936
|
setActionSummary(null);
|
|
@@ -18722,10 +19003,10 @@ var DataManagementList = ({
|
|
|
18722
19003
|
() => new Set(forcedConfig?.lockFieldIds || []),
|
|
18723
19004
|
[forcedConfig?.lockFieldIds]
|
|
18724
19005
|
);
|
|
18725
|
-
|
|
19006
|
+
useEffect44(() => {
|
|
18726
19007
|
widthsRef.current = widths;
|
|
18727
19008
|
}, [widths]);
|
|
18728
|
-
|
|
19009
|
+
useEffect44(() => {
|
|
18729
19010
|
fetchStateRef.current = {
|
|
18730
19011
|
current,
|
|
18731
19012
|
pageSize,
|
|
@@ -18778,7 +19059,7 @@ var DataManagementList = ({
|
|
|
18778
19059
|
},
|
|
18779
19060
|
[appType, forcedConfig, formUuid, request]
|
|
18780
19061
|
);
|
|
18781
|
-
|
|
19062
|
+
useEffect44(() => {
|
|
18782
19063
|
let mounted = true;
|
|
18783
19064
|
const loadSchemaAndConfig = async () => {
|
|
18784
19065
|
if (!appType || !formUuid) return;
|