sy-form-components 0.2.10 → 0.2.12
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 +38 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6079,6 +6079,20 @@ var createDefaultRequest = (baseUrl) => async (config) => {
|
|
|
6079
6079
|
return parseResponse(response);
|
|
6080
6080
|
};
|
|
6081
6081
|
var generateUid = () => `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
|
|
6082
|
+
var normalizeFormInstancePayload = (payload) => {
|
|
6083
|
+
const { formInstanceId, ...rest } = payload || {};
|
|
6084
|
+
return {
|
|
6085
|
+
...rest,
|
|
6086
|
+
formInstId: payload?.formInstId || formInstanceId
|
|
6087
|
+
};
|
|
6088
|
+
};
|
|
6089
|
+
var unwrapBusinessResponse = (response) => {
|
|
6090
|
+
const result = response?.data || response?.result || response;
|
|
6091
|
+
if (result?.success === false) {
|
|
6092
|
+
throw new Error(result.message || response?.message || "\u8BF7\u6C42\u5931\u8D25");
|
|
6093
|
+
}
|
|
6094
|
+
return result;
|
|
6095
|
+
};
|
|
6082
6096
|
var normalizeUploadData = (data, file, bucketName) => {
|
|
6083
6097
|
const item = Array.isArray(data) ? data[0] : data;
|
|
6084
6098
|
const objectName = item?.objectName || item?.objectKey || item?.key;
|
|
@@ -6306,12 +6320,13 @@ function createFormRuntimeApi(config) {
|
|
|
6306
6320
|
return response.data || response.result || response;
|
|
6307
6321
|
},
|
|
6308
6322
|
updateFormData: async (payload) => {
|
|
6323
|
+
const data = normalizeFormInstancePayload(payload);
|
|
6309
6324
|
const response = await request({
|
|
6310
|
-
url: `/${
|
|
6325
|
+
url: `/${data.appType}/v1/form/updateFormData.json`,
|
|
6311
6326
|
method: "post",
|
|
6312
|
-
data
|
|
6327
|
+
data
|
|
6313
6328
|
});
|
|
6314
|
-
return response
|
|
6329
|
+
return unwrapBusinessResponse(response);
|
|
6315
6330
|
}
|
|
6316
6331
|
};
|
|
6317
6332
|
return { ...defaults, ...overrides, request };
|
|
@@ -6854,7 +6869,11 @@ async function deleteFormData(request, params) {
|
|
|
6854
6869
|
const response = await request({
|
|
6855
6870
|
url: `/${params.appType}/v1/form/deleteFormData.json`,
|
|
6856
6871
|
method: "post",
|
|
6857
|
-
data:
|
|
6872
|
+
data: {
|
|
6873
|
+
appType: params.appType,
|
|
6874
|
+
formUuid: params.formUuid,
|
|
6875
|
+
formInstId: params.formInstanceId
|
|
6876
|
+
}
|
|
6858
6877
|
});
|
|
6859
6878
|
return response.data || response.result;
|
|
6860
6879
|
}
|
|
@@ -7876,12 +7895,17 @@ function useFormDetail(options) {
|
|
|
7876
7895
|
const [instanceInfo, setInstanceInfo] = (0, import_react49.useState)(null);
|
|
7877
7896
|
const [permissions, setPermissions] = (0, import_react49.useState)(null);
|
|
7878
7897
|
const mountedRef = (0, import_react49.useRef)(true);
|
|
7898
|
+
const onPermissionDeniedRef = (0, import_react49.useRef)(onPermissionDenied);
|
|
7899
|
+
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
7879
7900
|
(0, import_react49.useEffect)(() => {
|
|
7880
7901
|
mountedRef.current = true;
|
|
7881
7902
|
return () => {
|
|
7882
7903
|
mountedRef.current = false;
|
|
7883
7904
|
};
|
|
7884
7905
|
}, []);
|
|
7906
|
+
(0, import_react49.useEffect)(() => {
|
|
7907
|
+
onPermissionDeniedRef.current = onPermissionDenied;
|
|
7908
|
+
}, [onPermissionDenied]);
|
|
7885
7909
|
const loadData = (0, import_react49.useCallback)(async () => {
|
|
7886
7910
|
if (!mountedRef.current) return;
|
|
7887
7911
|
setLoading(true);
|
|
@@ -7892,7 +7916,7 @@ function useFormDetail(options) {
|
|
|
7892
7916
|
]);
|
|
7893
7917
|
if (!mountedRef.current) return;
|
|
7894
7918
|
if (!permResult || !hasViewOperation(permResult.operations, "view")) {
|
|
7895
|
-
|
|
7919
|
+
onPermissionDeniedRef.current?.();
|
|
7896
7920
|
}
|
|
7897
7921
|
const normalizedInfo = normalizeFormInstanceInfo(formResult, {
|
|
7898
7922
|
formUuid,
|
|
@@ -7901,7 +7925,9 @@ function useFormDetail(options) {
|
|
|
7901
7925
|
});
|
|
7902
7926
|
setPermissions(permResult);
|
|
7903
7927
|
setInstanceInfo(normalizedInfo);
|
|
7904
|
-
setFormData(
|
|
7928
|
+
setFormData(
|
|
7929
|
+
extractFormValues(formResult, fieldIdsKey ? fieldIdsKey.split("") : void 0)
|
|
7930
|
+
);
|
|
7905
7931
|
} catch (error) {
|
|
7906
7932
|
console.error("[useFormDetail] Failed to load data:", error);
|
|
7907
7933
|
if (mountedRef.current) {
|
|
@@ -7914,7 +7940,7 @@ function useFormDetail(options) {
|
|
|
7914
7940
|
setLoading(false);
|
|
7915
7941
|
}
|
|
7916
7942
|
}
|
|
7917
|
-
}, [request, formUuid, appType, formInstanceId,
|
|
7943
|
+
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
7918
7944
|
(0, import_react49.useEffect)(() => {
|
|
7919
7945
|
loadData();
|
|
7920
7946
|
}, [loadData]);
|
|
@@ -8010,6 +8036,7 @@ function useProcessDetail(options) {
|
|
|
8010
8036
|
const [permissions, setPermissions] = (0, import_react50.useState)(null);
|
|
8011
8037
|
const [processDefinition, setProcessDefinition] = (0, import_react50.useState)(null);
|
|
8012
8038
|
const mountedRef = (0, import_react50.useRef)(true);
|
|
8039
|
+
const fieldIdsKey = fieldIds?.join("") ?? "";
|
|
8013
8040
|
(0, import_react50.useEffect)(() => {
|
|
8014
8041
|
mountedRef.current = true;
|
|
8015
8042
|
return () => {
|
|
@@ -8055,7 +8082,9 @@ function useProcessDetail(options) {
|
|
|
8055
8082
|
setApprovalTasks(approvalResult?.currentTasks ?? []);
|
|
8056
8083
|
setPermissions(permResult);
|
|
8057
8084
|
setInstanceInfo(formResult);
|
|
8058
|
-
setFormData(
|
|
8085
|
+
setFormData(
|
|
8086
|
+
extractFormValues(formResult, fieldIdsKey ? fieldIdsKey.split("") : void 0)
|
|
8087
|
+
);
|
|
8059
8088
|
if (permResult?.operations?.includes("VIEW_PROCESS") || permResult?.operations?.length > 0) {
|
|
8060
8089
|
try {
|
|
8061
8090
|
const progress = await getProcessProgress(request, formInstanceId);
|
|
@@ -8090,7 +8119,7 @@ function useProcessDetail(options) {
|
|
|
8090
8119
|
setLoading(false);
|
|
8091
8120
|
}
|
|
8092
8121
|
}
|
|
8093
|
-
}, [request, formUuid, appType, formInstanceId,
|
|
8122
|
+
}, [request, formUuid, appType, formInstanceId, fieldIdsKey]);
|
|
8094
8123
|
(0, import_react50.useEffect)(() => {
|
|
8095
8124
|
loadData();
|
|
8096
8125
|
}, [loadData]);
|