@rytass/bpm-core-react 0.8.0 → 0.9.0
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/CHANGELOG.md +82 -0
- package/README.md +18 -2
- package/dist/chunks/FormBuilderView-BPLwAJGv.cjs +3 -0
- package/dist/chunks/FormBuilderView-BPLwAJGv.cjs.map +1 -0
- package/dist/chunks/FormBuilderView-Do9-MIAe.js +1477 -0
- package/dist/chunks/FormBuilderView-Do9-MIAe.js.map +1 -0
- package/dist/chunks/FormRendererView-C5POZbWz.js +492 -0
- package/dist/chunks/FormRendererView-C5POZbWz.js.map +1 -0
- package/dist/chunks/FormRendererView-DNtNodNl.cjs +2 -0
- package/dist/chunks/FormRendererView-DNtNodNl.cjs.map +1 -0
- package/dist/chunks/{approval-instance-list-page-YZcGGDD8.js → approval-instance-list-page-BjX2kaoF.js} +56 -54
- package/dist/chunks/approval-instance-list-page-BjX2kaoF.js.map +1 -0
- package/dist/chunks/approval-instance-list-page-C408vxE2.cjs +2 -0
- package/dist/chunks/approval-instance-list-page-C408vxE2.cjs.map +1 -0
- package/dist/chunks/{categories-DBPoSrsi.js → categories-DGlxuC6X.js} +5 -5
- package/dist/chunks/{categories-DBPoSrsi.js.map → categories-DGlxuC6X.js.map} +1 -1
- package/dist/chunks/{categories-B6QZKZRt.cjs → categories-DUfldZ_9.cjs} +2 -2
- package/dist/chunks/{categories-B6QZKZRt.cjs.map → categories-DUfldZ_9.cjs.map} +1 -1
- package/dist/chunks/compose-CULMDsLS.cjs +2 -0
- package/dist/chunks/compose-CULMDsLS.cjs.map +1 -0
- package/dist/chunks/{compose-CQHDT7vh.js → compose-DJBlA5PD.js} +60 -58
- package/dist/chunks/compose-DJBlA5PD.js.map +1 -0
- package/dist/chunks/{delegations-DDEk-WI6.cjs → delegations-CGj-tZNO.cjs} +2 -2
- package/dist/chunks/{delegations-DDEk-WI6.cjs.map → delegations-CGj-tZNO.cjs.map} +1 -1
- package/dist/chunks/{delegations-iVnRi3QE.js → delegations-DLEEFBlH.js} +231 -231
- package/dist/chunks/{delegations-iVnRi3QE.js.map → delegations-DLEEFBlH.js.map} +1 -1
- package/dist/chunks/{delegations-ZNtodFaD.js → delegations-DqMpI_Nk.js} +168 -167
- package/dist/chunks/delegations-DqMpI_Nk.js.map +1 -0
- package/dist/chunks/delegations-kbMOSEif.cjs +2 -0
- package/dist/chunks/delegations-kbMOSEif.cjs.map +1 -0
- package/dist/chunks/{designer-CUbVXEtS.js → designer-BszXJ5RO.js} +1227 -990
- package/dist/chunks/designer-BszXJ5RO.js.map +1 -0
- package/dist/chunks/designer-CmqAU92b.cjs +65 -0
- package/dist/chunks/designer-CmqAU92b.cjs.map +1 -0
- package/dist/chunks/detail-CDexqBoU.cjs +2 -0
- package/dist/chunks/detail-CDexqBoU.cjs.map +1 -0
- package/dist/chunks/{detail-Cts5_gVp.js → detail-DAak2OXS.js} +704 -622
- package/dist/chunks/detail-DAak2OXS.js.map +1 -0
- package/dist/chunks/notifications--hwl-DR0.cjs +2 -0
- package/dist/chunks/{notifications-BKs4--96.cjs.map → notifications--hwl-DR0.cjs.map} +1 -1
- package/dist/chunks/{notifications-CSulztkU.js → notifications-DJ5wzCye.js} +7 -7
- package/dist/chunks/{notifications-CSulztkU.js.map → notifications-DJ5wzCye.js.map} +1 -1
- package/dist/chunks/{orgs-CrNxqlwp.js → orgs-DytLvZ_X.js} +243 -241
- package/dist/chunks/{orgs-CrNxqlwp.js.map → orgs-DytLvZ_X.js.map} +1 -1
- package/dist/chunks/orgs-Ni22buHs.cjs +2 -0
- package/dist/chunks/orgs-Ni22buHs.cjs.map +1 -0
- package/dist/chunks/providers-DEqcuXw9.js +506 -0
- package/dist/chunks/providers-DEqcuXw9.js.map +1 -0
- package/dist/chunks/providers-D_zTbkQH.cjs +2 -0
- package/dist/chunks/providers-D_zTbkQH.cjs.map +1 -0
- package/dist/chunks/{users-qghSMtLn.cjs → users-0HqlM_VQ.cjs} +2 -2
- package/dist/chunks/{users-qghSMtLn.cjs.map → users-0HqlM_VQ.cjs.map} +1 -1
- package/dist/chunks/{users-CUY139DF.js → users-FWrb3ehW.js} +5 -5
- package/dist/chunks/{users-CUY139DF.js.map → users-FWrb3ehW.js.map} +1 -1
- package/dist/components/notification-drawer.d.ts +4 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -428
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +16 -15
- package/dist/next/index.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/admin/orgs/index.cjs +1 -1
- package/dist/pages/admin/orgs/index.js +1 -1
- package/dist/pages/admin/users/index.cjs +1 -1
- package/dist/pages/admin/users/index.js +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.js +1 -1
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/settings/notifications/index.cjs +1 -1
- package/dist/pages/settings/notifications/index.js +1 -1
- package/dist/pages/templates/categories/index.cjs +1 -1
- package/dist/pages/templates/categories/index.js +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/views/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +3 -3
- package/dist/views/admin/orgs/index.cjs +1 -1
- package/dist/views/admin/orgs/index.js +1 -1
- package/dist/views/admin/users/index.cjs +1 -1
- package/dist/views/admin/users/index.js +1 -1
- package/dist/views/cc/index.cjs +1 -1
- package/dist/views/cc/index.js +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/FormRendererView.d.ts +7 -2
- package/dist/views/forms/renderer/form-data-source-field.d.ts +34 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.d.ts +1 -0
- package/dist/views/forms/renderer/index.js +2 -2
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +4 -1
- package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +5 -1
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +105 -86
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/search/index.cjs +1 -1
- package/dist/views/search/index.js +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.js +1 -1
- package/dist/views/settings/index.cjs +1 -1
- package/dist/views/settings/index.js +1 -1
- package/dist/views/settings/notifications/index.cjs +1 -1
- package/dist/views/settings/notifications/index.js +1 -1
- package/dist/views/templates/categories/index.cjs +1 -1
- package/dist/views/templates/categories/index.js +1 -1
- package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +3 -2
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/index.cjs +1 -1
- package/dist/views/templates/index.cjs.map +1 -1
- package/dist/views/templates/index.js +153 -112
- package/dist/views/templates/index.js.map +1 -1
- package/package.json +41 -5
- package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +0 -3
- package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +0 -1
- package/dist/chunks/FormBuilderView-D8DrQOXD.js +0 -1090
- package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +0 -1
- package/dist/chunks/FormRendererView-BwVsH2eX.cjs +0 -2
- package/dist/chunks/FormRendererView-BwVsH2eX.cjs.map +0 -1
- package/dist/chunks/FormRendererView-DrHsuSVo.js +0 -220
- package/dist/chunks/FormRendererView-DrHsuSVo.js.map +0 -1
- package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs +0 -2
- package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs.map +0 -1
- package/dist/chunks/approval-instance-list-page-YZcGGDD8.js.map +0 -1
- package/dist/chunks/compose-CQHDT7vh.js.map +0 -1
- package/dist/chunks/compose-Ds_cAefe.cjs +0 -2
- package/dist/chunks/compose-Ds_cAefe.cjs.map +0 -1
- package/dist/chunks/delegations-C2wLWsDQ.cjs +0 -2
- package/dist/chunks/delegations-C2wLWsDQ.cjs.map +0 -1
- package/dist/chunks/delegations-ZNtodFaD.js.map +0 -1
- package/dist/chunks/designer-CQ9hxSdD.cjs +0 -65
- package/dist/chunks/designer-CQ9hxSdD.cjs.map +0 -1
- package/dist/chunks/designer-CUbVXEtS.js.map +0 -1
- package/dist/chunks/detail-B-Q4W-iw.cjs +0 -2
- package/dist/chunks/detail-B-Q4W-iw.cjs.map +0 -1
- package/dist/chunks/detail-Cts5_gVp.js.map +0 -1
- package/dist/chunks/notifications-BKs4--96.cjs +0 -2
- package/dist/chunks/orgs-iNJ0QEcK.cjs +0 -2
- package/dist/chunks/orgs-iNJ0QEcK.cjs.map +0 -1
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { r as e } from "./router-adapter-DftlFTOd.js";
|
|
3
3
|
import { r as t } from "./routes-config-RBYQtUd0.js";
|
|
4
|
-
import { t as n } from "./FormRendererView-
|
|
5
|
-
import { t as r } from "./FormBuilderView-
|
|
6
|
-
import { t as i } from "./designer-
|
|
4
|
+
import { t as n } from "./FormRendererView-C5POZbWz.js";
|
|
5
|
+
import { t as r } from "./FormBuilderView-Do9-MIAe.js";
|
|
6
|
+
import { t as i } from "./designer-BszXJ5RO.js";
|
|
7
7
|
import { useCallback as a, useEffect as o, useState as s } from "react";
|
|
8
8
|
import { Button as c, Empty as l, FormField as u, Input as d, PageHeader as f, Section as p, SectionGroup as m, Select as h, Step as g, Stepper as _, Table as v, Tag as y, Typography as b } from "@mezzanine-ui/react";
|
|
9
9
|
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
10
|
-
import w from "@mezzanine-ui/
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
10
|
+
import { FormFieldLayout as w } from "@mezzanine-ui/core/form";
|
|
11
|
+
import T from "@mezzanine-ui/react/ContentHeader";
|
|
12
|
+
import { readFormSchemaLintMessage as E } from "@rytass/bpm-core-client/form";
|
|
13
|
+
import { composeApprovalTemplateWithForm as D, listApprovalTemplateCategoriesPage as O } from "@rytass/bpm-core-client/template";
|
|
13
14
|
//#region src/views/templates/compose/steps/ComposeFormStep.tsx
|
|
14
|
-
var
|
|
15
|
+
var k = {
|
|
15
16
|
id: "UNCATEGORIZED",
|
|
16
17
|
name: "未分類"
|
|
17
|
-
},
|
|
18
|
-
function
|
|
18
|
+
}, A = 100;
|
|
19
|
+
function j({ categoryId: e, formSchema: t, formUiSchema: n, name: i, onCategoryIdChange: a, onFormChange: c, onNameChange: l }) {
|
|
19
20
|
let [f, p] = s([]);
|
|
20
21
|
o(() => {
|
|
21
22
|
let e = !0;
|
|
22
23
|
return (async () => {
|
|
23
24
|
try {
|
|
24
|
-
let t = await
|
|
25
|
+
let t = await O({
|
|
25
26
|
page: 1,
|
|
26
|
-
pageSize:
|
|
27
|
+
pageSize: A,
|
|
27
28
|
searchText: "",
|
|
28
29
|
status: "ACTIVE"
|
|
29
30
|
});
|
|
@@ -35,16 +36,16 @@ function A({ categoryId: e, formSchema: t, formUiSchema: n, name: i, onCategoryI
|
|
|
35
36
|
e = !1;
|
|
36
37
|
};
|
|
37
38
|
}, []);
|
|
38
|
-
let m = [
|
|
39
|
+
let m = [k, ...f.map((e) => ({
|
|
39
40
|
id: e.id,
|
|
40
41
|
name: e.name
|
|
41
|
-
}))], g = m.find((t) => t.id === e) ??
|
|
42
|
+
}))], g = m.find((t) => t.id === e) ?? k;
|
|
42
43
|
return /* @__PURE__ */ C(x, { children: [
|
|
43
44
|
/* @__PURE__ */ C("div", {
|
|
44
|
-
style:
|
|
45
|
+
style: M,
|
|
45
46
|
children: [/* @__PURE__ */ S(u, {
|
|
46
47
|
label: "名稱",
|
|
47
|
-
layout:
|
|
48
|
+
layout: w.VERTICAL,
|
|
48
49
|
name: "composeName",
|
|
49
50
|
children: /* @__PURE__ */ S(d, {
|
|
50
51
|
fullWidth: !0,
|
|
@@ -54,12 +55,12 @@ function A({ categoryId: e, formSchema: t, formUiSchema: n, name: i, onCategoryI
|
|
|
54
55
|
})
|
|
55
56
|
}), /* @__PURE__ */ S(u, {
|
|
56
57
|
label: "分類(選填)",
|
|
57
|
-
layout:
|
|
58
|
+
layout: w.VERTICAL,
|
|
58
59
|
name: "composeCategory",
|
|
59
60
|
children: /* @__PURE__ */ S(h, {
|
|
60
61
|
clearable: !1,
|
|
61
62
|
fullWidth: !0,
|
|
62
|
-
onChange: (e) => a(e && e.id !==
|
|
63
|
+
onChange: (e) => a(e && e.id !== k.id ? e.id : null),
|
|
63
64
|
options: m,
|
|
64
65
|
placeholder: "未分類",
|
|
65
66
|
value: g
|
|
@@ -80,19 +81,19 @@ function A({ categoryId: e, formSchema: t, formUiSchema: n, name: i, onCategoryI
|
|
|
80
81
|
})
|
|
81
82
|
] });
|
|
82
83
|
}
|
|
83
|
-
var
|
|
84
|
+
var M = {
|
|
84
85
|
display: "grid",
|
|
85
86
|
gap: 16,
|
|
86
87
|
gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))"
|
|
87
88
|
};
|
|
88
89
|
//#endregion
|
|
89
90
|
//#region src/views/templates/compose/steps/ComposeReviewStep.tsx
|
|
90
|
-
function
|
|
91
|
+
function N({ formSchema: e, formUiSchema: t, initiatorPolicyCel: r, name: i, publishError: a, workflowDefinition: o }) {
|
|
91
92
|
let s = o?.nodes ?? [], c = o?.edges ?? [], u = e.fields.length, d = new Map(s.map((e) => [e.id, e.data.label])), f = s.map((e) => ({
|
|
92
|
-
detail:
|
|
93
|
+
detail: L(e) ?? "—",
|
|
93
94
|
key: e.id,
|
|
94
95
|
label: e.data.label,
|
|
95
|
-
typeLabel:
|
|
96
|
+
typeLabel: I(e)
|
|
96
97
|
})), p = c.filter((e) => !!e.data.condition).map((e) => ({
|
|
97
98
|
condition: e.data.condition ?? "",
|
|
98
99
|
key: e.id,
|
|
@@ -100,34 +101,35 @@ function M({ formSchema: e, formUiSchema: t, initiatorPolicyCel: r, name: i, pub
|
|
|
100
101
|
target: d.get(e.target) ?? e.target
|
|
101
102
|
}));
|
|
102
103
|
return /* @__PURE__ */ C("div", {
|
|
103
|
-
style:
|
|
104
|
+
style: R,
|
|
104
105
|
children: [
|
|
105
106
|
/* @__PURE__ */ S(b, {
|
|
106
107
|
component: "h2",
|
|
107
|
-
style:
|
|
108
|
+
style: z,
|
|
108
109
|
variant: "h2",
|
|
109
110
|
children: i || "(未命名)"
|
|
110
111
|
}),
|
|
111
112
|
/* @__PURE__ */ C("div", {
|
|
112
|
-
style:
|
|
113
|
+
style: R,
|
|
113
114
|
children: [/* @__PURE__ */ S(b, {
|
|
114
115
|
variant: "h3",
|
|
115
116
|
children: "表單預覽"
|
|
116
117
|
}), u > 0 ? /* @__PURE__ */ S(n, {
|
|
118
|
+
dataSourceContext: { kind: "preview" },
|
|
117
119
|
readonly: !0,
|
|
118
120
|
schema: e,
|
|
119
121
|
uiSchema: t
|
|
120
122
|
}) : /* @__PURE__ */ S(l, { title: "尚未設計表單欄位" })]
|
|
121
123
|
}),
|
|
122
124
|
/* @__PURE__ */ C("div", {
|
|
123
|
-
style:
|
|
125
|
+
style: R,
|
|
124
126
|
children: [
|
|
125
127
|
/* @__PURE__ */ S(b, {
|
|
126
128
|
variant: "h3",
|
|
127
129
|
children: "流程概覽"
|
|
128
130
|
}),
|
|
129
131
|
s.length > 0 ? /* @__PURE__ */ S(v, {
|
|
130
|
-
columns:
|
|
132
|
+
columns: P,
|
|
131
133
|
dataSource: f,
|
|
132
134
|
fullWidth: !0
|
|
133
135
|
}) : /* @__PURE__ */ S(l, { title: "尚未設計流程節點" }),
|
|
@@ -136,7 +138,7 @@ function M({ formSchema: e, formUiSchema: t, initiatorPolicyCel: r, name: i, pub
|
|
|
136
138
|
variant: "caption",
|
|
137
139
|
children: "條件分流"
|
|
138
140
|
}), /* @__PURE__ */ S(v, {
|
|
139
|
-
columns:
|
|
141
|
+
columns: F,
|
|
140
142
|
dataSource: p,
|
|
141
143
|
fullWidth: !0
|
|
142
144
|
})] }) : null,
|
|
@@ -155,7 +157,7 @@ function M({ formSchema: e, formUiSchema: t, initiatorPolicyCel: r, name: i, pub
|
|
|
155
157
|
]
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
|
-
var
|
|
160
|
+
var P = [
|
|
159
161
|
{
|
|
160
162
|
key: "type",
|
|
161
163
|
render: (e) => /* @__PURE__ */ S(y, {
|
|
@@ -177,7 +179,7 @@ var N = [
|
|
|
177
179
|
title: "簽核方式",
|
|
178
180
|
width: 160
|
|
179
181
|
}
|
|
180
|
-
],
|
|
182
|
+
], F = [
|
|
181
183
|
{
|
|
182
184
|
dataIndex: "source",
|
|
183
185
|
key: "source",
|
|
@@ -196,7 +198,7 @@ var N = [
|
|
|
196
198
|
title: "條件"
|
|
197
199
|
}
|
|
198
200
|
];
|
|
199
|
-
function
|
|
201
|
+
function I(e) {
|
|
200
202
|
switch (e.type) {
|
|
201
203
|
case "startEvent": return "開始";
|
|
202
204
|
case "endEvent": return e.data.endState === "REJECTED" ? "結束(駁回)" : "結束(核准)";
|
|
@@ -207,7 +209,7 @@ function F(e) {
|
|
|
207
209
|
default: return "節點";
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
|
-
function
|
|
212
|
+
function L(e) {
|
|
211
213
|
if (e.type !== "userTask") return null;
|
|
212
214
|
switch (e.data.approverResolver.type) {
|
|
213
215
|
case "DIRECT": return "指定成員";
|
|
@@ -221,13 +223,13 @@ function I(e) {
|
|
|
221
223
|
default: return "簽核人";
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
|
-
var
|
|
226
|
+
var R = {
|
|
225
227
|
display: "grid",
|
|
226
228
|
gap: 12
|
|
227
|
-
},
|
|
229
|
+
}, z = { marginTop: "var(--mzn-spacing-padding-vertical-spacious)" };
|
|
228
230
|
//#endregion
|
|
229
231
|
//#region src/views/templates/compose/steps/ComposeWorkflowStep.tsx
|
|
230
|
-
function
|
|
232
|
+
function B({ aiAssistantAvailable: e = !1, formSchema: t, initiatorPolicyCel: n, onInitiatorPolicyChange: r, onWorkflowChange: a, showAiAssistant: o = !1, workflowDefinition: s }) {
|
|
231
233
|
return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(b, {
|
|
232
234
|
color: "text-neutral",
|
|
233
235
|
variant: "caption",
|
|
@@ -245,15 +247,15 @@ function z({ aiAssistantAvailable: e = !1, formSchema: t, initiatorPolicyCel: n,
|
|
|
245
247
|
}
|
|
246
248
|
//#endregion
|
|
247
249
|
//#region src/views/templates/compose/use-template-compose-wizard.ts
|
|
248
|
-
var
|
|
250
|
+
var V = {
|
|
249
251
|
fields: [],
|
|
250
252
|
schemaVersion: 1
|
|
251
|
-
},
|
|
253
|
+
}, H = {
|
|
252
254
|
layout: [],
|
|
253
255
|
schemaVersion: 1
|
|
254
256
|
};
|
|
255
|
-
function
|
|
256
|
-
let [e, t] = s(0), [n, r] = s(""), [i, o] = s(null), [c, l] = s(
|
|
257
|
+
function U() {
|
|
258
|
+
let [e, t] = s(0), [n, r] = s(""), [i, o] = s(null), [c, l] = s(V), [u, d] = s(H), [f, p] = s(null), [m, h] = s(null), [g, _] = s("idle"), [v, y] = s(null), b = n.trim().length > 0 && c.fields.length > 0, x = a((e) => {
|
|
257
259
|
t(e);
|
|
258
260
|
}, []), S = a(() => {
|
|
259
261
|
t((e) => e < 2 ? e + 1 : e);
|
|
@@ -263,7 +265,7 @@ function H() {
|
|
|
263
265
|
l(e.schema), d(e.uiSchema);
|
|
264
266
|
}, []), T = a((e) => {
|
|
265
267
|
p(e);
|
|
266
|
-
}, []),
|
|
268
|
+
}, []), E = a((e) => {
|
|
267
269
|
h(e);
|
|
268
270
|
}, []);
|
|
269
271
|
return {
|
|
@@ -280,7 +282,7 @@ function H() {
|
|
|
280
282
|
publish: a(async () => {
|
|
281
283
|
_("submitting"), y(null);
|
|
282
284
|
try {
|
|
283
|
-
let e = await
|
|
285
|
+
let e = await D({
|
|
284
286
|
category: null,
|
|
285
287
|
categoryId: i,
|
|
286
288
|
formDefinitionId: null,
|
|
@@ -295,11 +297,11 @@ function H() {
|
|
|
295
297
|
templateId: null,
|
|
296
298
|
templateName: n,
|
|
297
299
|
uiSchema: u,
|
|
298
|
-
workflowDefinition: f ??
|
|
300
|
+
workflowDefinition: f ?? W
|
|
299
301
|
});
|
|
300
302
|
return _("success"), e;
|
|
301
303
|
} catch (e) {
|
|
302
|
-
return y(
|
|
304
|
+
return y(G(e)), _("error"), null;
|
|
303
305
|
}
|
|
304
306
|
}, [
|
|
305
307
|
i,
|
|
@@ -313,13 +315,13 @@ function H() {
|
|
|
313
315
|
publishPhase: g,
|
|
314
316
|
setCategoryId: o,
|
|
315
317
|
setFormValue: w,
|
|
316
|
-
setInitiatorPolicyCel:
|
|
318
|
+
setInitiatorPolicyCel: E,
|
|
317
319
|
setName: r,
|
|
318
320
|
setWorkflowDefinition: T,
|
|
319
321
|
workflowDefinition: f
|
|
320
322
|
};
|
|
321
323
|
}
|
|
322
|
-
var
|
|
324
|
+
var W = {
|
|
323
325
|
edges: [],
|
|
324
326
|
meta: { schemaVersion: 1 },
|
|
325
327
|
nodes: [{
|
|
@@ -344,18 +346,18 @@ var U = {
|
|
|
344
346
|
type: "endEvent"
|
|
345
347
|
}]
|
|
346
348
|
};
|
|
347
|
-
function
|
|
348
|
-
return e instanceof Error ? e.message : "發生未知錯誤";
|
|
349
|
+
function G(e) {
|
|
350
|
+
return e instanceof Error ? E(e.message) : "發生未知錯誤";
|
|
349
351
|
}
|
|
350
352
|
//#endregion
|
|
351
353
|
//#region src/views/templates/compose/TemplateComposeWizardView.tsx
|
|
352
|
-
function
|
|
353
|
-
let i = e(), a = t(), o =
|
|
354
|
+
function K({ aiAssistantAvailable: n = !1, showAiAssistant: r = !1 } = {}) {
|
|
355
|
+
let i = e(), a = t(), o = U(), s = o.publishPhase === "submitting";
|
|
354
356
|
async function l() {
|
|
355
357
|
let e = await o.publish();
|
|
356
358
|
e && i.push(a.templateDesigner(e.templateId));
|
|
357
359
|
}
|
|
358
|
-
return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(f, { children: /* @__PURE__ */ S(
|
|
360
|
+
return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(f, { children: /* @__PURE__ */ S(T, {
|
|
359
361
|
description: "一次完成表單與流程設計,發佈後即可直接發起。",
|
|
360
362
|
title: "建立模板(表單 + 流程)",
|
|
361
363
|
children: /* @__PURE__ */ S(c, {
|
|
@@ -382,7 +384,7 @@ function G({ aiAssistantAvailable: n = !1, showAiAssistant: r = !1 } = {}) {
|
|
|
382
384
|
})
|
|
383
385
|
]
|
|
384
386
|
}),
|
|
385
|
-
o.currentStep === 0 ? /* @__PURE__ */ S(
|
|
387
|
+
o.currentStep === 0 ? /* @__PURE__ */ S(j, {
|
|
386
388
|
categoryId: o.categoryId,
|
|
387
389
|
formSchema: o.formSchema,
|
|
388
390
|
formUiSchema: o.formUiSchema,
|
|
@@ -391,7 +393,7 @@ function G({ aiAssistantAvailable: n = !1, showAiAssistant: r = !1 } = {}) {
|
|
|
391
393
|
onFormChange: o.setFormValue,
|
|
392
394
|
onNameChange: o.setName
|
|
393
395
|
}) : null,
|
|
394
|
-
o.currentStep === 1 ? /* @__PURE__ */ S(
|
|
396
|
+
o.currentStep === 1 ? /* @__PURE__ */ S(B, {
|
|
395
397
|
aiAssistantAvailable: n,
|
|
396
398
|
formSchema: o.formSchema,
|
|
397
399
|
initiatorPolicyCel: o.initiatorPolicyCel,
|
|
@@ -400,7 +402,7 @@ function G({ aiAssistantAvailable: n = !1, showAiAssistant: r = !1 } = {}) {
|
|
|
400
402
|
showAiAssistant: r,
|
|
401
403
|
workflowDefinition: o.workflowDefinition
|
|
402
404
|
}) : null,
|
|
403
|
-
o.currentStep === 2 ? /* @__PURE__ */ S(
|
|
405
|
+
o.currentStep === 2 ? /* @__PURE__ */ S(N, {
|
|
404
406
|
formSchema: o.formSchema,
|
|
405
407
|
formUiSchema: o.formUiSchema,
|
|
406
408
|
initiatorPolicyCel: o.initiatorPolicyCel,
|
|
@@ -409,13 +411,13 @@ function G({ aiAssistantAvailable: n = !1, showAiAssistant: r = !1 } = {}) {
|
|
|
409
411
|
workflowDefinition: o.workflowDefinition
|
|
410
412
|
}) : null,
|
|
411
413
|
/* @__PURE__ */ C("div", {
|
|
412
|
-
style:
|
|
414
|
+
style: q,
|
|
413
415
|
children: [o.currentStep === 0 && !o.canLeaveBasics ? /* @__PURE__ */ S(b, {
|
|
414
416
|
color: "text-neutral",
|
|
415
417
|
variant: "caption",
|
|
416
418
|
children: "請填寫模板名稱、表單名稱,並至少新增一個表單欄位。"
|
|
417
419
|
}) : /* @__PURE__ */ S("span", {}), /* @__PURE__ */ C("div", {
|
|
418
|
-
style:
|
|
420
|
+
style: J,
|
|
419
421
|
children: [/* @__PURE__ */ S(c, {
|
|
420
422
|
disabled: o.currentStep === 0 || s,
|
|
421
423
|
onClick: o.goBack,
|
|
@@ -439,17 +441,17 @@ function G({ aiAssistantAvailable: n = !1, showAiAssistant: r = !1 } = {}) {
|
|
|
439
441
|
})
|
|
440
442
|
] }) })] });
|
|
441
443
|
}
|
|
442
|
-
var
|
|
444
|
+
var q = {
|
|
443
445
|
alignItems: "center",
|
|
444
446
|
display: "flex",
|
|
445
447
|
marginTop: "var(--mzn-spacing-padding-vertical-spacious)",
|
|
446
448
|
justifyContent: "space-between",
|
|
447
449
|
gap: 16
|
|
448
|
-
},
|
|
450
|
+
}, J = {
|
|
449
451
|
display: "flex",
|
|
450
452
|
gap: 8
|
|
451
453
|
};
|
|
452
454
|
//#endregion
|
|
453
|
-
export {
|
|
455
|
+
export { U as i, V as n, H as r, K as t };
|
|
454
456
|
|
|
455
|
-
//# sourceMappingURL=compose-
|
|
457
|
+
//# sourceMappingURL=compose-DJBlA5PD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-DJBlA5PD.js","names":[],"sources":["../../src/views/templates/compose/steps/ComposeFormStep.tsx","../../src/views/templates/compose/steps/ComposeReviewStep.tsx","../../src/views/templates/compose/steps/ComposeWorkflowStep.tsx","../../src/views/templates/compose/use-template-compose-wizard.ts","../../src/views/templates/compose/TemplateComposeWizardView.tsx"],"sourcesContent":["'use client';\n\nimport type { ChangeEvent, ReactElement } from 'react';\nimport { useEffect, useState } from 'react';\nimport { FormField, Input, Select, Typography } from '@mezzanine-ui/react';\nimport { FormFieldLayout } from '@mezzanine-ui/core/form';\nimport type { SelectValue } from '@mezzanine-ui/react/Select';\nimport type {\n FormDefinitionSchema,\n FormUiSchema,\n} from '@rytass/bpm-core-shared/form';\nimport {\n ApprovalTemplateCategoryRecord,\n listApprovalTemplateCategoriesPage,\n} from '@rytass/bpm-core-client/template';\nimport { FormBuilderView } from '../../../forms/builder';\n\nconst UNCATEGORIZED_OPTION: SelectValue = {\n id: 'UNCATEGORIZED',\n name: '未分類',\n};\n\nconst CATEGORY_PAGE_SIZE = 100;\n\nexport interface ComposeFormStepProps {\n readonly name: string;\n readonly categoryId: string | null;\n readonly formSchema: FormDefinitionSchema;\n readonly formUiSchema: FormUiSchema;\n readonly onNameChange: (value: string) => void;\n readonly onCategoryIdChange: (value: string | null) => void;\n readonly onFormChange: (next: {\n readonly schema: FormDefinitionSchema;\n readonly uiSchema: FormUiSchema;\n }) => void;\n}\n\nexport function ComposeFormStep({\n categoryId,\n formSchema,\n formUiSchema,\n name,\n onCategoryIdChange,\n onFormChange,\n onNameChange,\n}: ComposeFormStepProps): ReactElement {\n const [categoryOptions, setCategoryOptions] = useState<\n readonly ApprovalTemplateCategoryRecord[]\n >([]);\n\n useEffect((): (() => void) => {\n let active = true;\n\n void (async (): Promise<void> => {\n try {\n const result = await listApprovalTemplateCategoriesPage({\n page: 1,\n pageSize: CATEGORY_PAGE_SIZE,\n searchText: '',\n status: 'ACTIVE',\n });\n\n if (active) {\n setCategoryOptions(result.categories);\n }\n } catch {\n if (active) {\n setCategoryOptions([]);\n }\n }\n })();\n\n return (): void => {\n active = false;\n };\n }, []);\n\n const selectOptions: SelectValue[] = [\n UNCATEGORIZED_OPTION,\n ...categoryOptions.map((category) => ({\n id: category.id,\n name: category.name,\n })),\n ];\n const selectedOption =\n selectOptions.find((option) => option.id === categoryId) ??\n UNCATEGORIZED_OPTION;\n\n return (\n <>\n <div style={BASICS_GRID_STYLE}>\n <FormField\n label=\"名稱\"\n layout={FormFieldLayout.VERTICAL}\n name=\"composeName\"\n >\n <Input\n fullWidth\n onChange={(event: ChangeEvent<HTMLInputElement>): void =>\n onNameChange(event.target.value)\n }\n placeholder=\"例如:請款簽核\"\n value={name}\n />\n </FormField>\n <FormField\n label=\"分類(選填)\"\n layout={FormFieldLayout.VERTICAL}\n name=\"composeCategory\"\n >\n <Select\n clearable={false}\n fullWidth\n onChange={(option): void =>\n onCategoryIdChange(\n option && option.id !== UNCATEGORIZED_OPTION.id\n ? option.id\n : null,\n )\n }\n options={selectOptions}\n placeholder=\"未分類\"\n value={selectedOption}\n />\n </FormField>\n </div>\n <Typography color=\"text-neutral\" variant=\"caption\">\n 先設計表單欄位,下一步的流程條件分流即可直接引用這些欄位。\n </Typography>\n <FormBuilderView\n onChange={onFormChange}\n value={{ schema: formSchema, uiSchema: formUiSchema }}\n />\n </>\n );\n}\n\nconst BASICS_GRID_STYLE = {\n display: 'grid',\n gap: 16,\n gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',\n} as const;\n","'use client';\n\nimport type { CSSProperties, ReactElement } from 'react';\nimport { Empty, Table, Tag, Typography } from '@mezzanine-ui/react';\nimport type { TableColumn } from '@mezzanine-ui/core/table';\nimport type {\n FormDefinitionSchema,\n FormUiSchema,\n} from '@rytass/bpm-core-shared/form';\nimport type {\n WorkflowDefinition,\n WorkflowNode,\n} from '@rytass/bpm-core-shared/workflow';\nimport { FormRenderer } from '../../../forms/renderer/FormRendererView';\n\ntype FlowNodeRow = Readonly<\n Record<string, unknown> & {\n detail: string;\n key: string;\n label: string;\n typeLabel: string;\n }\n>;\n\ntype BranchRow = Readonly<\n Record<string, unknown> & {\n condition: string;\n key: string;\n source: string;\n target: string;\n }\n>;\n\nexport interface ComposeReviewStepProps {\n readonly name: string;\n readonly formSchema: FormDefinitionSchema;\n readonly formUiSchema: FormUiSchema;\n readonly workflowDefinition: WorkflowDefinition | null;\n readonly initiatorPolicyCel: string | null;\n readonly publishError: string | null;\n}\n\nexport function ComposeReviewStep({\n formSchema,\n formUiSchema,\n initiatorPolicyCel,\n name,\n publishError,\n workflowDefinition,\n}: ComposeReviewStepProps): ReactElement {\n const nodes = workflowDefinition?.nodes ?? [];\n const edges = workflowDefinition?.edges ?? [];\n const fieldCount = formSchema.fields.length;\n const nodeLabelById = new Map(\n nodes.map((node) => [node.id, node.data.label] as const),\n );\n const nodeRows: FlowNodeRow[] = nodes.map((node) => ({\n detail: readNodeDetail(node) ?? '—',\n key: node.id,\n label: node.data.label,\n typeLabel: readNodeTypeLabel(node),\n }));\n const branchRows: BranchRow[] = edges\n .filter((edge) => Boolean(edge.data.condition))\n .map((edge) => ({\n condition: edge.data.condition ?? '',\n key: edge.id,\n source: nodeLabelById.get(edge.source) ?? edge.source,\n target: nodeLabelById.get(edge.target) ?? edge.target,\n }));\n\n return (\n <div style={STACK_STYLE}>\n <Typography component=\"h2\" style={TITLE_STYLE} variant=\"h2\">\n {name || '(未命名)'}\n </Typography>\n\n <div style={STACK_STYLE}>\n <Typography variant=\"h3\">表單預覽</Typography>\n {fieldCount > 0 ? (\n <FormRenderer\n dataSourceContext={{ kind: 'preview' }}\n readonly\n schema={formSchema}\n uiSchema={formUiSchema}\n />\n ) : (\n <Empty title=\"尚未設計表單欄位\" />\n )}\n </div>\n\n <div style={STACK_STYLE}>\n <Typography variant=\"h3\">流程概覽</Typography>\n {nodes.length > 0 ? (\n <Table columns={NODE_COLUMNS} dataSource={nodeRows} fullWidth />\n ) : (\n <Empty title=\"尚未設計流程節點\" />\n )}\n {branchRows.length > 0 ? (\n <>\n <Typography color=\"text-neutral\" variant=\"caption\">\n 條件分流\n </Typography>\n <Table columns={BRANCH_COLUMNS} dataSource={branchRows} fullWidth />\n </>\n ) : null}\n {initiatorPolicyCel ? (\n <Typography color=\"text-neutral\" variant=\"caption\">\n 發起權限:{initiatorPolicyCel}\n </Typography>\n ) : null}\n </div>\n\n {publishError ? (\n <Typography color=\"text-error\" variant=\"body\">\n {publishError}\n </Typography>\n ) : null}\n </div>\n );\n}\n\nconst NODE_COLUMNS: TableColumn<FlowNodeRow>[] = [\n {\n key: 'type',\n render: (record: FlowNodeRow): ReactElement => (\n <Tag label={record.typeLabel} size=\"sub\" type=\"static\" />\n ),\n title: '類型',\n width: 130,\n },\n { dataIndex: 'label', key: 'label', title: '節點' },\n { dataIndex: 'detail', key: 'detail', title: '簽核方式', width: 160 },\n];\n\nconst BRANCH_COLUMNS: TableColumn<BranchRow>[] = [\n { dataIndex: 'source', key: 'source', title: '來源', width: 180 },\n { dataIndex: 'target', key: 'target', title: '目標', width: 180 },\n { dataIndex: 'condition', key: 'condition', title: '條件' },\n];\n\nfunction readNodeTypeLabel(node: WorkflowNode): string {\n switch (node.type) {\n case 'startEvent':\n return '開始';\n case 'endEvent':\n return node.data.endState === 'REJECTED' ? '結束(駁回)' : '結束(核准)';\n case 'userTask':\n return '簽核';\n case 'serviceTask':\n return '服務';\n case 'exclusiveGateway':\n return '條件閘道';\n case 'parallelGateway':\n return '平行閘道';\n default:\n return '節點';\n }\n}\n\nfunction readNodeDetail(node: WorkflowNode): string | null {\n if (node.type !== 'userTask') {\n return null;\n }\n\n switch (node.data.approverResolver.type) {\n case 'DIRECT':\n return '指定成員';\n case 'POSITION':\n return '指定職位';\n case 'ORG_UNIT_MEMBER':\n return '單位成員';\n case 'ORG_UNIT_POSITION':\n return '單位職位';\n case 'ORG_MANAGER':\n return '主管';\n case 'ORG_UNIT_MANAGER':\n return '單位主管';\n case 'DYNAMIC_FORM':\n return '表單動態指派';\n case 'EXPRESSION':\n return '運算式';\n default:\n return '簽核人';\n }\n}\n\nconst STACK_STYLE: CSSProperties = {\n display: 'grid',\n gap: 12,\n};\n\n// Match the breathing room between the stepper and the PageHeader, which is the\n// Section's top padding token.\nconst TITLE_STYLE: CSSProperties = {\n marginTop: 'var(--mzn-spacing-padding-vertical-spacious)',\n};\n","'use client';\n\nimport type { ReactElement } from 'react';\nimport { Typography } from '@mezzanine-ui/react';\nimport type { FormDefinitionSchema } from '@rytass/bpm-core-shared/form';\nimport type { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';\nimport { TemplateDesignerView } from '../../designer';\n\nexport interface ComposeWorkflowStepProps {\n readonly formSchema: FormDefinitionSchema;\n readonly workflowDefinition: WorkflowDefinition | null;\n readonly initiatorPolicyCel: string | null;\n readonly onWorkflowChange: (definition: WorkflowDefinition) => void;\n readonly onInitiatorPolicyChange: (cel: string | null) => void;\n /**\n * Show the AI assistant button inside the embedded designer's side panel.\n * Follows the same opt-in contract as the standalone designer page; default\n * hidden. Wired up the stack from the server page's `BPM_AI_ASSISTANT_ENABLED`.\n */\n readonly showAiAssistant?: boolean;\n /**\n * Whether the LLM backend is configured (host has an API key). When `false`\n * the AI button shows disabled as a placeholder. Default `false`.\n */\n readonly aiAssistantAvailable?: boolean;\n}\n\nexport function ComposeWorkflowStep({\n aiAssistantAvailable = false,\n formSchema,\n initiatorPolicyCel,\n onInitiatorPolicyChange,\n onWorkflowChange,\n showAiAssistant = false,\n workflowDefinition,\n}: ComposeWorkflowStepProps): ReactElement {\n return (\n <>\n <Typography color=\"text-neutral\" variant=\"caption\">\n 設計簽核節點與條件分流;條件可直接引用上一步設計的表單欄位。\n </Typography>\n <TemplateDesignerView\n aiAssistantAvailable={aiAssistantAvailable}\n embedded\n formSchemaOverride={formSchema}\n initialInitiatorPolicyCel={initiatorPolicyCel}\n initialWorkflowDefinition={workflowDefinition ?? undefined}\n onInitiatorPolicyChange={onInitiatorPolicyChange}\n onWorkflowChange={onWorkflowChange}\n showAiAssistant={showAiAssistant}\n />\n </>\n );\n}\n","'use client';\n\nimport { useCallback, useState } from 'react';\nimport type {\n FormDefinitionSchema,\n FormUiSchema,\n} from '@rytass/bpm-core-shared/form';\nimport type { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';\nimport { readFormSchemaLintMessage } from '@rytass/bpm-core-client/form';\nimport {\n ComposeApprovalTemplateWithFormResult,\n composeApprovalTemplateWithForm,\n} from '@rytass/bpm-core-client/template';\n\nexport type ComposeWizardStep = 0 | 1 | 2;\n\nexport type ComposePublishPhase = 'error' | 'idle' | 'submitting' | 'success';\n\nexport const EMPTY_COMPOSE_FORM_SCHEMA: FormDefinitionSchema = {\n fields: [],\n schemaVersion: 1,\n};\n\nexport const EMPTY_COMPOSE_FORM_UI_SCHEMA: FormUiSchema = {\n layout: [],\n schemaVersion: 1,\n};\n\nexport interface TemplateComposeWizard {\n readonly currentStep: ComposeWizardStep;\n /**\n * Single user-facing name. Persisted to both the template and the form\n * (`templateName` / `formName`) at the `composeApprovalTemplateWithForm`\n * boundary — the DB keeps two columns, the UI keeps one field.\n */\n readonly name: string;\n readonly categoryId: string | null;\n readonly formSchema: FormDefinitionSchema;\n readonly formUiSchema: FormUiSchema;\n readonly workflowDefinition: WorkflowDefinition | null;\n readonly initiatorPolicyCel: string | null;\n readonly publishPhase: ComposePublishPhase;\n readonly publishError: string | null;\n readonly canLeaveBasics: boolean;\n readonly goToStep: (step: ComposeWizardStep) => void;\n readonly goNext: () => void;\n readonly goBack: () => void;\n readonly setName: (value: string) => void;\n readonly setCategoryId: (value: string | null) => void;\n readonly setFormValue: (next: {\n readonly schema: FormDefinitionSchema;\n readonly uiSchema: FormUiSchema;\n }) => void;\n readonly setWorkflowDefinition: (definition: WorkflowDefinition) => void;\n readonly setInitiatorPolicyCel: (cel: string | null) => void;\n readonly publish: () => Promise<ComposeApprovalTemplateWithFormResult | null>;\n}\n\n/**\n * Owns the cross-step state for the unified \"form + flow\" template wizard.\n *\n * Step 0 (表單) edits `formSchema`/`formUiSchema`; that same in-memory schema\n * feeds Step 1 (流程) as the field source for condition branches, so the\n * embedded designer never needs a published form version. Step 2 (檢視發佈)\n * submits everything through the atomic `composeApprovalTemplateWithForm`\n * mutation.\n */\nexport function useTemplateComposeWizard(): TemplateComposeWizard {\n const [currentStep, setCurrentStep] = useState<ComposeWizardStep>(0);\n const [name, setName] = useState('');\n const [categoryId, setCategoryId] = useState<string | null>(null);\n const [formSchema, setFormSchema] = useState<FormDefinitionSchema>(\n EMPTY_COMPOSE_FORM_SCHEMA,\n );\n const [formUiSchema, setFormUiSchema] = useState<FormUiSchema>(\n EMPTY_COMPOSE_FORM_UI_SCHEMA,\n );\n const [workflowDefinition, setWorkflowDefinitionState] =\n useState<WorkflowDefinition | null>(null);\n const [initiatorPolicyCel, setInitiatorPolicyCelState] = useState<\n string | null\n >(null);\n const [publishPhase, setPublishPhase] = useState<ComposePublishPhase>('idle');\n const [publishError, setPublishError] = useState<string | null>(null);\n\n const canLeaveBasics = name.trim().length > 0 && formSchema.fields.length > 0;\n\n const goToStep = useCallback((step: ComposeWizardStep): void => {\n setCurrentStep(step);\n }, []);\n\n const goNext = useCallback((): void => {\n setCurrentStep((step) =>\n step < 2 ? ((step + 1) as ComposeWizardStep) : step,\n );\n }, []);\n\n const goBack = useCallback((): void => {\n setCurrentStep((step) =>\n step > 0 ? ((step - 1) as ComposeWizardStep) : step,\n );\n }, []);\n\n const setFormValue = useCallback(\n (next: {\n readonly schema: FormDefinitionSchema;\n readonly uiSchema: FormUiSchema;\n }): void => {\n setFormSchema(next.schema);\n setFormUiSchema(next.uiSchema);\n },\n [],\n );\n\n const setWorkflowDefinition = useCallback(\n (definition: WorkflowDefinition): void => {\n setWorkflowDefinitionState(definition);\n },\n [],\n );\n\n const setInitiatorPolicyCel = useCallback((cel: string | null): void => {\n setInitiatorPolicyCelState(cel);\n }, []);\n\n const publish =\n useCallback(async (): Promise<ComposeApprovalTemplateWithFormResult | null> => {\n setPublishPhase('submitting');\n setPublishError(null);\n\n try {\n const result = await composeApprovalTemplateWithForm({\n category: null,\n categoryId,\n formDefinitionId: null,\n formDescription: null,\n // One UI name fans out to both persisted columns.\n formName: name,\n initiatorPolicyCel,\n notificationConfig: null,\n publish: true,\n schema: formSchema,\n slaDefaults: null,\n templateDescription: null,\n templateId: null,\n templateName: name,\n uiSchema: formUiSchema,\n workflowDefinition: workflowDefinition ?? EMPTY_WORKFLOW_DEFINITION,\n });\n\n setPublishPhase('success');\n\n return result;\n } catch (requestError: unknown) {\n setPublishError(readErrorMessage(requestError));\n setPublishPhase('error');\n\n return null;\n }\n }, [\n categoryId,\n formSchema,\n formUiSchema,\n initiatorPolicyCel,\n name,\n workflowDefinition,\n ]);\n\n return {\n canLeaveBasics,\n categoryId,\n currentStep,\n formSchema,\n formUiSchema,\n goBack,\n goNext,\n goToStep,\n initiatorPolicyCel,\n name,\n publish,\n publishError,\n publishPhase,\n setCategoryId,\n setFormValue,\n setInitiatorPolicyCel,\n setName,\n setWorkflowDefinition,\n workflowDefinition,\n };\n}\n\nconst EMPTY_WORKFLOW_DEFINITION: WorkflowDefinition = {\n edges: [],\n meta: { schemaVersion: 1 },\n nodes: [\n {\n data: { label: '開始' },\n id: 'start',\n position: { x: 80, y: 160 },\n type: 'startEvent',\n },\n {\n data: { endState: 'APPROVED', label: '完成', triggerMode: 'AND' },\n id: 'end',\n position: { x: 560, y: 160 },\n type: 'endEvent',\n },\n ],\n};\n\nfunction readErrorMessage(error: unknown): string {\n // Publish failures can carry stable `FORM_DATA_SOURCE_*` codes; map them to\n // readable copy and leave every other message untouched.\n return error instanceof Error\n ? readFormSchemaLintMessage(error.message)\n : '發生未知錯誤';\n}\n","'use client';\n\nimport type { ReactElement } from 'react';\nimport {\n Button,\n PageHeader,\n Section,\n SectionGroup,\n Step,\n Stepper,\n Typography,\n} from '@mezzanine-ui/react';\nimport ContentHeader from '@mezzanine-ui/react/ContentHeader';\nimport { useRouterAdapter } from '../../../lib/router-adapter';\nimport { useBPMRoutes } from '../../../lib/routes-config';\nimport { ComposeFormStep } from './steps/ComposeFormStep';\nimport { ComposeReviewStep } from './steps/ComposeReviewStep';\nimport { ComposeWorkflowStep } from './steps/ComposeWorkflowStep';\nimport { useTemplateComposeWizard } from './use-template-compose-wizard';\n\nexport interface TemplateComposeWizardViewProps {\n /**\n * Show the workflow designer AI assistant inside Step 1 (流程設計). Opt-in,\n * default hidden — the server page maps `BPM_AI_ASSISTANT_ENABLED` to it.\n */\n readonly showAiAssistant?: boolean;\n /**\n * Whether the LLM backend is configured (host has an API key). When `false`\n * the AI button shows disabled as a placeholder. Default `false`.\n */\n readonly aiAssistantAvailable?: boolean;\n}\n\n/**\n * Unified \"form + flow\" template creation wizard. Walks the user through\n * Step 0 表單設計 → Step 1 流程設計 → Step 2 檢視並發佈, then commits both\n * sides atomically through `composeApprovalTemplateWithForm`. This is the\n * template entry point; the form builder is intentionally controlled here\n * instead of exposed as a standalone `/forms` page.\n */\nexport function TemplateComposeWizardView({\n aiAssistantAvailable = false,\n showAiAssistant = false,\n}: TemplateComposeWizardViewProps = {}): ReactElement {\n const router = useRouterAdapter();\n const routes = useBPMRoutes();\n const wizard = useTemplateComposeWizard();\n const submitting = wizard.publishPhase === 'submitting';\n\n async function handlePublish(): Promise<void> {\n const result = await wizard.publish();\n\n if (result) {\n router.push(routes.templateDesigner(result.templateId));\n }\n }\n\n return (\n <>\n <PageHeader>\n <ContentHeader\n description=\"一次完成表單與流程設計,發佈後即可直接發起。\"\n title=\"建立模板(表單 + 流程)\"\n >\n <Button\n disabled={submitting}\n onClick={(): void => router.push(routes.templates())}\n variant=\"base-secondary\"\n >\n 返回模板列表\n </Button>\n </ContentHeader>\n </PageHeader>\n\n <SectionGroup>\n <Section>\n <Stepper currentStep={wizard.currentStep}>\n <Step description=\"設計欄位與版面\" title=\"表單設計\" />\n <Step description=\"設計簽核節點與條件\" title=\"流程設計\" />\n <Step description=\"確認後發佈\" title=\"檢視並發佈\" />\n </Stepper>\n\n {wizard.currentStep === 0 ? (\n <ComposeFormStep\n categoryId={wizard.categoryId}\n formSchema={wizard.formSchema}\n formUiSchema={wizard.formUiSchema}\n name={wizard.name}\n onCategoryIdChange={wizard.setCategoryId}\n onFormChange={wizard.setFormValue}\n onNameChange={wizard.setName}\n />\n ) : null}\n\n {wizard.currentStep === 1 ? (\n <ComposeWorkflowStep\n aiAssistantAvailable={aiAssistantAvailable}\n formSchema={wizard.formSchema}\n initiatorPolicyCel={wizard.initiatorPolicyCel}\n onInitiatorPolicyChange={wizard.setInitiatorPolicyCel}\n onWorkflowChange={wizard.setWorkflowDefinition}\n showAiAssistant={showAiAssistant}\n workflowDefinition={wizard.workflowDefinition}\n />\n ) : null}\n\n {wizard.currentStep === 2 ? (\n <ComposeReviewStep\n formSchema={wizard.formSchema}\n formUiSchema={wizard.formUiSchema}\n initiatorPolicyCel={wizard.initiatorPolicyCel}\n name={wizard.name}\n publishError={wizard.publishError}\n workflowDefinition={wizard.workflowDefinition}\n />\n ) : null}\n\n <div style={FOOTER_STYLE}>\n {wizard.currentStep === 0 && !wizard.canLeaveBasics ? (\n <Typography color=\"text-neutral\" variant=\"caption\">\n 請填寫模板名稱、表單名稱,並至少新增一個表單欄位。\n </Typography>\n ) : (\n <span />\n )}\n <div style={FOOTER_ACTIONS_STYLE}>\n <Button\n disabled={wizard.currentStep === 0 || submitting}\n onClick={wizard.goBack}\n variant=\"base-secondary\"\n >\n 上一步\n </Button>\n {wizard.currentStep < 2 ? (\n <Button\n disabled={wizard.currentStep === 0 && !wizard.canLeaveBasics}\n onClick={wizard.goNext}\n variant=\"base-primary\"\n >\n 下一步\n </Button>\n ) : (\n <Button\n disabled={submitting}\n loading={submitting}\n onClick={(): void => {\n void handlePublish();\n }}\n variant=\"base-primary\"\n >\n 發佈\n </Button>\n )}\n </div>\n </div>\n </Section>\n </SectionGroup>\n </>\n );\n}\n\nconst FOOTER_STYLE = {\n alignItems: 'center',\n display: 'flex',\n // Match the breathing room used elsewhere (the Section's top padding token).\n marginTop: 'var(--mzn-spacing-padding-vertical-spacious)',\n justifyContent: 'space-between',\n gap: 16,\n} as const;\n\nconst FOOTER_ACTIONS_STYLE = {\n display: 'flex',\n gap: 8,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAM,IAAoC;CACxC,IAAI;CACJ,MAAM;AACR,GAEM,IAAqB;AAe3B,SAAgB,EAAgB,EAC9B,eACA,eACA,iBACA,SACA,uBACA,iBACA,mBACqC;CACrC,IAAM,CAAC,GAAiB,KAAsB,EAE5C,CAAC,CAAC;CAEJ,QAA8B;EAC5B,IAAI,IAAS;EAqBb,QAnBM,YAA2B;GAC/B,IAAI;IACF,IAAM,IAAS,MAAM,EAAmC;KACtD,MAAM;KACN,UAAU;KACV,YAAY;KACZ,QAAQ;IACV,CAAC;IAED,AAAI,KACF,EAAmB,EAAO,UAAU;GAExC,QAAQ;IACN,AAAI,KACF,EAAmB,CAAC,CAAC;GAEzB;EACF,GAAG,SAEgB;GACjB,IAAS;EACX;CACF,GAAG,CAAC,CAAC;CAEL,IAAM,IAA+B,CACnC,GACA,GAAG,EAAgB,KAAK,OAAc;EACpC,IAAI,EAAS;EACb,MAAM,EAAS;CACjB,EAAE,CACJ,GACM,IACJ,EAAc,MAAM,MAAW,EAAO,OAAO,CAAU,KACvD;CAEF,OACE,kBAAA,GAAA,EAAA,UAAA;EACE,kBAAC,OAAD;GAAK,OAAO;aAAZ,CACE,kBAAC,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AAQ;eACT;IAEO,CAAA,IAER,kBAAC,GAAD;KACE,UAAU;KACV,SAAS;KACT,eAAqB;MACnB,EAAmB;KACrB;KACA,SAAQ;eACT;IAEO,CAAA,CAEP;KACF;;CACE,EAAA,CAAA,EACG,CAAA,CACd,EAAA,CAAA;AAEN;AAEA,IAAM,IAAe;CACnB,YAAY;CACZ,SAAS;CAET,WAAW;CACX,gBAAgB;CAChB,KAAK;AACP,GAEM,IAAuB;CAC3B,SAAS;CACT,KAAK;AACP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";require('../delegations.css');const e=require("./chunk-CMqjfN_6.cjs"),t=require("./auth-provider-4BeCw7cI.cjs"),n=require("./format-date-time-XxBzF0F5.cjs"),r=require("./bpm-form-field-Bc6k4ZEO.cjs");let i=require("react"),a=require("@mezzanine-ui/react"),o=require("react/jsx-runtime"),s=require("@rytass/bpm-core-client/workflow"),c=require("@mezzanine-ui/react/ContentHeader");c=e.t(c,1);let l=require("@mezzanine-ui/core/form"),u=require("@mezzanine-ui/icons"),d=require("@rytass/bpm-core-client/template");var f={delegationModalFields:`bpm_delegationModalFields_gUlCQ`,delegationFilterArea:`bpm_delegationFilterArea_QDZkw`,memberNameWithTooltip:`bpm_memberNameWithTooltip_RggTW`},p=l.FormFieldLayout.HORIZONTAL,m=[10,20,50],h=[{key:`ALL`,label:`全部`},{key:`ACTIVE`,label:`啟用中`},{key:`REVOKED`,label:`已撤銷`},{key:`EXPIRED`,label:`已過期`}],g=[{id:`ALL`,name:`全部簽核`},{id:`TEMPLATE_LIST`,name:`指定模板`}],_=[{id:`ALL_SCOPES`,name:`全部範圍`,scopeType:null},{id:`ALL`,name:`全部簽核`,scopeType:`ALL`},{id:`TEMPLATE_LIST`,name:`指定模板`,scopeType:`TEMPLATE_LIST`}];function v(){let{member:e}=t.n(),p=e?.memberId??null,[v,x]=(0,i.useState)(null),[C,w]=(0,i.useState)(``),[E,D]=(0,i.useState)(null),[O,A]=(0,i.useState)(!0),[j,M]=(0,i.useState)(!1),[N,P]=(0,i.useState)([]),[F,de]=(0,i.useState)(null),[I,fe]=(0,i.useState)(null),[pe,L]=(0,i.useState)(!1),[R,z]=(0,i.useState)(null),[B,me]=(0,i.useState)(`100`),[V,H]=(0,i.useState)(1),[U,he]=(0,i.useState)(10),[W,ge]=(0,i.useState)(`ALL`),[_e,ve]=(0,i.useState)(0),[ye,be]=(0,i.useState)([]),[xe,Se]=(0,i.useState)(!1),[G,Ce]=(0,i.useState)([]),[K,we]=(0,i.useState)(_[0]),[Te,Ee]=(0,i.useState)(g[0]),[q,De]=(0,i.useState)(``),[Oe,ke]=(0,i.useState)(!1),[Ae,J]=(0,i.useState)([]),Y=(0,i.useCallback)(async()=>{A(!0),D(null);try{let[e,t]=await Promise.all([(0,s.listDelegationRulesPage)({agentMemberId:I?.id??null,includeInactive:!0,page:V,pageSize:U,principalMemberId:F?.id??null,scopeType:K.scopeType,status:W===`ALL`?null:W}),(0,s.searchMembers)(``)]);be(e.rules),ve(e.totalCount),P(t.map(b))}catch(e){D(k(e))}finally{A(!1)}},[I,F,V,U,W,K]);(0,i.useEffect)(()=>{Y()},[Y]);let X=(0,i.useMemo)(()=>new Map(N.map(e=>[e.id,e])),[N]),je=(0,i.useMemo)(()=>ye.map(e=>({...e,agentEmail:X.get(e.agentMemberId)?.email??null,agentName:X.get(e.agentMemberId)?.displayName??e.agentMemberId,key:e.id,principalEmail:X.get(e.principalMemberId)?.email??null,principalName:X.get(e.principalMemberId)?.displayName??e.principalMemberId,scopeLabel:oe(e)})),[X,ye]),Z=g.find(e=>e.id===Te.id)??g[0],Me=(0,i.useMemo)(()=>[{key:`principal`,render:e=>(0,o.jsx)(S,{email:e.principalEmail,name:e.principalName}),title:`原簽核人`,width:220},{key:`agent`,render:e=>(0,o.jsx)(S,{email:e.agentEmail,name:e.agentName}),title:`代理人`,width:220},{dataIndex:`scopeLabel`,key:`scope`,title:`代理範圍`,width:220},{key:`status`,render:e=>(0,o.jsx)(se,{status:e.status}),title:`狀態`,width:120},{dataIndex:`priority`,key:`priority`,title:`優先序`,width:100},{key:`startAt`,render:e=>(0,o.jsx)(a.Typography,{component:`span`,variant:`body`,children:n.t(e.startAt)}),title:`開始時間`,width:220},{key:`endAt`,render:e=>(0,o.jsx)(a.Typography,{component:`span`,variant:`body`,children:e.endAt?n.t(e.endAt):`-`}),title:`結束時間`,width:220}],[]),Ne=(0,i.useCallback)(async e=>{if(p){D(null);try{await(0,s.revokeDelegationRule)({id:e,revokedByMemberId:p}),await Y()}catch(e){D(k(e))}}},[p,Y]),Pe=(0,i.useMemo)(()=>({render:e=>e.status===`ACTIVE`?[{name:`撤銷`,onClick:()=>void Ne(e.id)}]:[],variant:`destructive-secondary`,width:88}),[Ne]);async function Q(e){M(!0);try{P((await(0,s.searchMembers)(e)).map(b))}catch(e){D(k(e))}finally{M(!1)}}async function $(e,t=G){ke(!0);try{J(re(t,ne((await(0,d.listApprovalTemplates)()).map(ee),e)))}catch(e){D(k(e))}finally{ke(!1)}}function Fe(){x(null),w(``),z(null),me(`100`),Ce([]),Ee(g[0]),De(``),J([]),$(``,[]),L(!0)}function Ie(){xe||L(!1)}async function Le(){if(p){if(!R||!v){D(`請選擇原簽核人與代理人`);return}if(Z.id===`TEMPLATE_LIST`&&G.length<1){D(`請選擇至少一個簽核模板`);return}if(ue(q,C)){D(`結束時間必須晚於起始時間`);return}Se(!0),D(null);try{await(0,s.createDelegationRule)({agentMemberId:v.id,createdByMemberId:p,endAt:C||null,principalMemberId:R.id,priority:Number(B)||100,requiresConfirmation:!1,scopeConditionCel:null,scopeTemplateIds:Z.id===`TEMPLATE_LIST`?G.map(e=>e.id):[],scopeType:Z.id,startAt:q||null}),L(!1),V===1?await Y():H(1)}catch(e){D(k(e))}finally{Se(!1)}}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.PageHeader,{children:(0,o.jsx)(c.default,{description:`設定簽核代理規則,讓符合範圍的待簽任務自動改派給代理人。`,title:`代理設定`,children:(0,o.jsx)(a.Button,{icon:u.PlusIcon,iconType:`leading`,onClick:Fe,variant:`base-primary`,children:`建立代理`})})}),(0,o.jsx)(a.SectionGroup,{children:(0,o.jsxs)(a.Section,{filterArea:(0,o.jsx)(a.FilterArea,{className:f.delegationFilterArea,children:(0,o.jsxs)(a.FilterLine,{children:[(0,o.jsx)(a.Filter,{span:2,children:(0,o.jsx)(y,{hideLabel:!0,label:`原簽核人`,loading:j,name:`principalFilterMemberId`,onChange:e=>{de(e),H(1)},onSearch:Q,options:N,required:!1,layout:l.FormFieldLayout.VERTICAL,size:`sub`,value:F})}),(0,o.jsx)(a.Filter,{span:2,children:(0,o.jsx)(y,{hideLabel:!0,label:`代理人`,loading:j,name:`agentFilterMemberId`,onChange:e=>{fe(e),H(1)},onSearch:Q,options:N,required:!1,layout:l.FormFieldLayout.VERTICAL,size:`sub`,value:I})}),(0,o.jsx)(a.Filter,{span:2,children:(0,o.jsx)(a.FormField,{fullWidth:!0,layout:l.FormFieldLayout.VERTICAL,name:`scopeFilterType`,children:(0,o.jsx)(a.Select,{clearable:!1,fullWidth:!0,onChange:e=>{we(ae(e)),H(1)},options:[..._],placeholder:`代理範圍`,size:`sub`,value:K})})})]})}),tab:(0,o.jsx)(a.Tab,{activeKey:W,onChange:e=>{ge(ce(e)),H(1)},children:h.map(e=>(0,o.jsx)(a.TabItem,{children:e.label},e.key))}),children:[E?(0,o.jsx)(a.Typography,{color:`text-error`,variant:`body`,children:E}):null,(0,o.jsx)(a.Table,{actions:Pe,columns:Me,dataSource:je,fullWidth:!0,loading:O,pagination:{current:V,onChange:e=>{H(e)},onChangePageSize:e=>{H(1),he(e)},pageSize:U,pageSizeLabel:`每頁筆數`,pageSizeOptions:m,renderResultSummary:(e,t,n)=>`顯示 ${e}-${t} 筆,共 ${n} 筆`,showPageSizeOptions:!0,total:_e}})]})}),(0,o.jsx)(a.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!R||!v},confirmText:`建立代理`,loading:xe,modalType:`standard`,onCancel:Ie,onClose:Ie,onConfirm:()=>void Le(),open:pe,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`代理生效後,後續建立的待簽任務會依範圍自動指派。`,title:`建立代理`,children:(0,o.jsxs)(`div`,{className:f.delegationModalFields,children:[(0,o.jsx)(y,{label:`原簽核人`,loading:j,name:`principalMemberId`,onChange:z,onSearch:Q,options:N,value:R}),(0,o.jsx)(y,{label:`代理人`,loading:j,name:`agentMemberId`,onChange:x,onSearch:Q,options:N,value:v}),(0,o.jsx)(r.t,{label:`代理範圍`,name:`scopeType`,required:!0,children:(0,o.jsx)(a.Select,{clearable:!1,fullWidth:!0,onChange:e=>Ee(ie(e)),options:[...g],value:Z})}),Z.id===`TEMPLATE_LIST`?(0,o.jsx)(r.t,{label:`簽核模板`,name:`scopeTemplateIds`,required:!0,children:(0,o.jsx)(a.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的模板`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`scopeTemplateIds`,spellCheck:!1},loading:Oe,loadingText:`搜尋模板中...`,mode:`multiple`,onChange:e=>{let t=te(e);Ce(t),J(e=>re(t,e))},onSearch:$,onVisibilityChange:e=>{e&&$(``)},options:[...Ae],overflowStrategy:`wrap`,placeholder:`搜尋並選取簽核模板`,searchDebounceTime:300,value:[...G]})}):null,(0,o.jsx)(r.t,{label:`優先序`,name:`priority`,children:(0,o.jsx)(a.Input,{fullWidth:!0,onChange:e=>me(e.target.value),value:B,variant:`base`})}),(0,o.jsx)(r.t,{label:`起始時間`,name:`startAt`,children:(0,o.jsx)(a.DateTimePicker,{formatDate:`YYYY-MM-DD`,formatTime:`HH:mm`,fullWidth:!0,hideSecond:!0,onChange:e=>De(T(e)),placeholderLeft:`留空立即生效`,placeholderRight:`選擇時間`,value:le(q)})}),(0,o.jsx)(r.t,{label:`結束時間`,name:`endAt`,children:(0,o.jsx)(a.DateTimePicker,{formatDate:`YYYY-MM-DD`,formatTime:`HH:mm`,fullWidth:!0,hideSecond:!0,onChange:e=>w(T(e)),placeholderLeft:`可留空`,placeholderRight:`選擇時間`,value:le(C)})})]})})]})}function y({hideLabel:e=!1,label:t,layout:n=p,loading:i,name:s,onChange:c,onSearch:l,options:u,required:d=!0,size:f,value:m}){let h=(0,o.jsx)(a.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:s,spellCheck:!1},loading:i,loadingText:`搜尋成員中...`,mode:`single`,onChange:e=>c(x(e)),onSearch:l,onSearchTextChange:e=>c(C(e,u)),onVisibilityChange:e=>{e&&l(``)},options:[...u],placeholder:e?t:`搜尋姓名或信箱`,searchDebounceTime:300,size:f,value:m});return e?(0,o.jsx)(a.FormField,{fullWidth:!0,layout:n,name:s,children:h}):(0,o.jsx)(r.t,{label:t,layout:n,name:s,required:d,children:h})}function b(e){return{displayName:e.name,email:e.email,id:e.memberId,name:`${e.name} · ${e.email}`}}function x(e){if(!A(e))return null;let t=e.id,n=e.name,r=e.email,i=e.displayName;return typeof t==`string`&&typeof n==`string`?{displayName:typeof i==`string`?i:n,email:typeof r==`string`?r:null,id:t,name:n}:null}function S({email:e,name:t}){return e?(0,o.jsx)(a.Tooltip,{title:e,children:({onMouseEnter:e,onMouseLeave:n,ref:r})=>(0,o.jsx)(`span`,{className:f.memberNameWithTooltip,onMouseEnter:e,onMouseLeave:n,ref:r,children:t})}):(0,o.jsx)(`span`,{children:t})}function C(e,t){let n=e.trim().toLocaleLowerCase();if(!n)return null;let r=t.filter(e=>[e.id,e.name,e.email??``].some(e=>e.toLocaleLowerCase().includes(n)));return r.length===1?r[0]??null:null}function ee(e){return{id:e.id,name:e.name}}function te(e){return e.flatMap(e=>{if(!A(e))return[];let t=e.id,n=e.name;return typeof t==`string`&&typeof n==`string`?[{id:t,name:n}]:[]})}function ne(e,t){let n=t.trim().toLocaleLowerCase();return n?e.filter(e=>[e.id,e.name].some(e=>e.toLocaleLowerCase().includes(n))):e}function re(e,t){return[...e,...t].reduce((e,t)=>e.some(e=>e.id===t.id)?e:[...e,t],[])}function ie(e){return!A(e)||!w(e.id)?g[0]:g.find(t=>t.id===e.id)??g[0]}function ae(e){if(!A(e))return _[0];let t=e.id;return _.find(e=>e.id===t)??_[0]}function w(e){return e===`ALL`||e===`TEMPLATE_LIST`}function oe(e){return e.scopeType===`ALL`?`全部簽核`:e.scopeType===`TEMPLATE_LIST`?`指定模板:${e.scopeTemplateIds.length}`:e.scopeConditionCel?`條件:${e.scopeConditionCel}`:`條件式`}function se({status:e}){return e===`ACTIVE`?(0,o.jsx)(a.Badge,{size:`sub`,text:`啟用中`,variant:`dot-success`}):e===`REVOKED`?(0,o.jsx)(a.Badge,{size:`sub`,text:`已撤銷`,variant:`dot-inactive`}):e===`EXPIRED`?(0,o.jsx)(a.Badge,{size:`sub`,text:`已過期`,variant:`dot-warning`}):(0,o.jsx)(a.Badge,{size:`sub`,text:e,variant:`dot-info`})}function ce(e){return e===`ACTIVE`||e===`REVOKED`||e===`EXPIRED`?e:`ALL`}function le(e){let t=e?E(e):null;return t?`${D(t)}T${O(t.getHours())}:${O(t.getMinutes())}`:void 0}function T(e){let t=e?E(e):null;return t?t.toISOString():``}function ue(e,t){if(!e||!t)return!1;let n=E(e),r=E(t);return!!n&&!!r&&r.getTime()<=n.getTime()}function E(e){if(e.endsWith(`Z`)||/[+-]\d{2}:\d{2}$/.test(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}let[t=``,n=`00:00`]=e.split(`T`),[r=0,i=1,a=1]=t.split(`-`).map(Number),[o=0,s=0]=n.split(`:`).map(Number),c=new Date(r,i-1,a,o,s);return Number.isNaN(c.getTime())?null:c}function D(e){return`${e.getFullYear()}-${O(e.getMonth()+1)}-${O(e.getDate())}`}function O(e){return String(e).padStart(2,`0`)}function k(e){return e instanceof Error?e.message:`發生未知錯誤`}function A(e){return typeof e==`object`&&!!e}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
|
|
2
|
-
//# sourceMappingURL=delegations-
|
|
1
|
+
"use client";require('../delegations.css');const e=require("./chunk-CMqjfN_6.cjs"),t=require("./auth-provider-4BeCw7cI.cjs"),n=require("./format-date-time-XxBzF0F5.cjs"),r=require("./bpm-form-field-Bc6k4ZEO.cjs");let i=require("react"),a=require("@mezzanine-ui/react"),o=require("react/jsx-runtime"),s=require("@rytass/bpm-core-client/workflow"),c=require("@mezzanine-ui/core/form"),l=require("@mezzanine-ui/react/ContentHeader");l=e.t(l,1);let u=require("@mezzanine-ui/icons"),d=require("@rytass/bpm-core-client/template");var f={delegationModalFields:`bpm_delegationModalFields_gUlCQ`,delegationFilterArea:`bpm_delegationFilterArea_QDZkw`,memberNameWithTooltip:`bpm_memberNameWithTooltip_RggTW`},p=c.FormFieldLayout.HORIZONTAL,m=[10,20,50],h=[{key:`ALL`,label:`全部`},{key:`ACTIVE`,label:`啟用中`},{key:`REVOKED`,label:`已撤銷`},{key:`EXPIRED`,label:`已過期`}],g=[{id:`ALL`,name:`全部簽核`},{id:`TEMPLATE_LIST`,name:`指定模板`}],_=[{id:`ALL_SCOPES`,name:`全部範圍`,scopeType:null},{id:`ALL`,name:`全部簽核`,scopeType:`ALL`},{id:`TEMPLATE_LIST`,name:`指定模板`,scopeType:`TEMPLATE_LIST`}];function v(){let{member:e}=t.n(),p=e?.memberId??null,[v,x]=(0,i.useState)(null),[C,w]=(0,i.useState)(``),[E,D]=(0,i.useState)(null),[O,A]=(0,i.useState)(!0),[j,M]=(0,i.useState)(!1),[N,P]=(0,i.useState)([]),[F,de]=(0,i.useState)(null),[I,fe]=(0,i.useState)(null),[pe,L]=(0,i.useState)(!1),[R,z]=(0,i.useState)(null),[B,me]=(0,i.useState)(`100`),[V,H]=(0,i.useState)(1),[U,he]=(0,i.useState)(10),[W,ge]=(0,i.useState)(`ALL`),[_e,ve]=(0,i.useState)(0),[ye,be]=(0,i.useState)([]),[xe,Se]=(0,i.useState)(!1),[G,Ce]=(0,i.useState)([]),[K,we]=(0,i.useState)(_[0]),[Te,Ee]=(0,i.useState)(g[0]),[q,De]=(0,i.useState)(``),[Oe,ke]=(0,i.useState)(!1),[Ae,J]=(0,i.useState)([]),Y=(0,i.useCallback)(async()=>{A(!0),D(null);try{let[e,t]=await Promise.all([(0,s.listDelegationRulesPage)({agentMemberId:I?.id??null,includeInactive:!0,page:V,pageSize:U,principalMemberId:F?.id??null,scopeType:K.scopeType,status:W===`ALL`?null:W}),(0,s.searchMembers)(``)]);be(e.rules),ve(e.totalCount),P(t.map(b))}catch(e){D(k(e))}finally{A(!1)}},[I,F,V,U,W,K]);(0,i.useEffect)(()=>{Y()},[Y]);let X=(0,i.useMemo)(()=>new Map(N.map(e=>[e.id,e])),[N]),je=(0,i.useMemo)(()=>ye.map(e=>({...e,agentEmail:X.get(e.agentMemberId)?.email??null,agentName:X.get(e.agentMemberId)?.displayName??e.agentMemberId,key:e.id,principalEmail:X.get(e.principalMemberId)?.email??null,principalName:X.get(e.principalMemberId)?.displayName??e.principalMemberId,scopeLabel:oe(e)})),[X,ye]),Z=g.find(e=>e.id===Te.id)??g[0],Me=(0,i.useMemo)(()=>[{key:`principal`,render:e=>(0,o.jsx)(S,{email:e.principalEmail,name:e.principalName}),title:`原簽核人`,width:220},{key:`agent`,render:e=>(0,o.jsx)(S,{email:e.agentEmail,name:e.agentName}),title:`代理人`,width:220},{dataIndex:`scopeLabel`,key:`scope`,title:`代理範圍`,width:220},{key:`status`,render:e=>(0,o.jsx)(se,{status:e.status}),title:`狀態`,width:120},{dataIndex:`priority`,key:`priority`,title:`優先序`,width:100},{key:`startAt`,render:e=>(0,o.jsx)(a.Typography,{component:`span`,variant:`body`,children:n.t(e.startAt)}),title:`開始時間`,width:220},{key:`endAt`,render:e=>(0,o.jsx)(a.Typography,{component:`span`,variant:`body`,children:e.endAt?n.t(e.endAt):`-`}),title:`結束時間`,width:220}],[]),Ne=(0,i.useCallback)(async e=>{if(p){D(null);try{await(0,s.revokeDelegationRule)({id:e,revokedByMemberId:p}),await Y()}catch(e){D(k(e))}}},[p,Y]),Pe=(0,i.useMemo)(()=>({render:e=>e.status===`ACTIVE`?[{name:`撤銷`,onClick:()=>void Ne(e.id)}]:[],variant:`destructive-secondary`,width:88}),[Ne]);async function Q(e){M(!0);try{P((await(0,s.searchMembers)(e)).map(b))}catch(e){D(k(e))}finally{M(!1)}}async function $(e,t=G){ke(!0);try{J(re(t,ne((await(0,d.listApprovalTemplates)()).map(ee),e)))}catch(e){D(k(e))}finally{ke(!1)}}function Fe(){x(null),w(``),z(null),me(`100`),Ce([]),Ee(g[0]),De(``),J([]),$(``,[]),L(!0)}function Ie(){xe||L(!1)}async function Le(){if(p){if(!R||!v){D(`請選擇原簽核人與代理人`);return}if(Z.id===`TEMPLATE_LIST`&&G.length<1){D(`請選擇至少一個簽核模板`);return}if(ue(q,C)){D(`結束時間必須晚於起始時間`);return}Se(!0),D(null);try{await(0,s.createDelegationRule)({agentMemberId:v.id,createdByMemberId:p,endAt:C||null,principalMemberId:R.id,priority:Number(B)||100,requiresConfirmation:!1,scopeConditionCel:null,scopeTemplateIds:Z.id===`TEMPLATE_LIST`?G.map(e=>e.id):[],scopeType:Z.id,startAt:q||null}),L(!1),V===1?await Y():H(1)}catch(e){D(k(e))}finally{Se(!1)}}}return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.PageHeader,{children:(0,o.jsx)(l.default,{description:`設定簽核代理規則,讓符合範圍的待簽任務自動改派給代理人。`,title:`代理設定`,children:(0,o.jsx)(a.Button,{icon:u.PlusIcon,iconType:`leading`,onClick:Fe,variant:`base-primary`,children:`建立代理`})})}),(0,o.jsx)(a.SectionGroup,{children:(0,o.jsxs)(a.Section,{filterArea:(0,o.jsx)(a.FilterArea,{className:f.delegationFilterArea,children:(0,o.jsxs)(a.FilterLine,{children:[(0,o.jsx)(a.Filter,{span:2,children:(0,o.jsx)(y,{hideLabel:!0,label:`原簽核人`,loading:j,name:`principalFilterMemberId`,onChange:e=>{de(e),H(1)},onSearch:Q,options:N,required:!1,layout:c.FormFieldLayout.VERTICAL,size:`sub`,value:F})}),(0,o.jsx)(a.Filter,{span:2,children:(0,o.jsx)(y,{hideLabel:!0,label:`代理人`,loading:j,name:`agentFilterMemberId`,onChange:e=>{fe(e),H(1)},onSearch:Q,options:N,required:!1,layout:c.FormFieldLayout.VERTICAL,size:`sub`,value:I})}),(0,o.jsx)(a.Filter,{span:2,children:(0,o.jsx)(a.FormField,{fullWidth:!0,layout:c.FormFieldLayout.VERTICAL,name:`scopeFilterType`,children:(0,o.jsx)(a.Select,{clearable:!1,fullWidth:!0,onChange:e=>{we(ae(e)),H(1)},options:[..._],placeholder:`代理範圍`,size:`sub`,value:K})})})]})}),tab:(0,o.jsx)(a.Tab,{activeKey:W,onChange:e=>{ge(ce(e)),H(1)},children:h.map(e=>(0,o.jsx)(a.TabItem,{children:e.label},e.key))}),children:[E?(0,o.jsx)(a.Typography,{color:`text-error`,variant:`body`,children:E}):null,(0,o.jsx)(a.Table,{actions:Pe,columns:Me,dataSource:je,fullWidth:!0,loading:O,pagination:{current:V,onChange:e=>{H(e)},onChangePageSize:e=>{H(1),he(e)},pageSize:U,pageSizeLabel:`每頁筆數`,pageSizeOptions:m,renderResultSummary:(e,t,n)=>`顯示 ${e}-${t} 筆,共 ${n} 筆`,showPageSizeOptions:!0,total:_e}})]})}),(0,o.jsx)(a.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!R||!v},confirmText:`建立代理`,loading:xe,modalType:`standard`,onCancel:Ie,onClose:Ie,onConfirm:()=>void Le(),open:pe,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`代理生效後,後續建立的待簽任務會依範圍自動指派。`,title:`建立代理`,children:(0,o.jsxs)(`div`,{className:f.delegationModalFields,children:[(0,o.jsx)(y,{label:`原簽核人`,loading:j,name:`principalMemberId`,onChange:z,onSearch:Q,options:N,value:R}),(0,o.jsx)(y,{label:`代理人`,loading:j,name:`agentMemberId`,onChange:x,onSearch:Q,options:N,value:v}),(0,o.jsx)(r.t,{label:`代理範圍`,name:`scopeType`,required:!0,children:(0,o.jsx)(a.Select,{clearable:!1,fullWidth:!0,onChange:e=>Ee(ie(e)),options:[...g],value:Z})}),Z.id===`TEMPLATE_LIST`?(0,o.jsx)(r.t,{label:`簽核模板`,name:`scopeTemplateIds`,required:!0,children:(0,o.jsx)(a.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的模板`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`scopeTemplateIds`,spellCheck:!1},loading:Oe,loadingText:`搜尋模板中...`,mode:`multiple`,onChange:e=>{let t=te(e);Ce(t),J(e=>re(t,e))},onSearch:$,onVisibilityChange:e=>{e&&$(``)},options:[...Ae],overflowStrategy:`wrap`,placeholder:`搜尋並選取簽核模板`,searchDebounceTime:300,value:[...G]})}):null,(0,o.jsx)(r.t,{label:`優先序`,name:`priority`,children:(0,o.jsx)(a.Input,{fullWidth:!0,onChange:e=>me(e.target.value),value:B,variant:`base`})}),(0,o.jsx)(r.t,{label:`起始時間`,name:`startAt`,children:(0,o.jsx)(a.DateTimePicker,{formatDate:`YYYY-MM-DD`,formatTime:`HH:mm`,fullWidth:!0,hideSecond:!0,onChange:e=>De(T(e)),placeholderLeft:`留空立即生效`,placeholderRight:`選擇時間`,value:le(q)})}),(0,o.jsx)(r.t,{label:`結束時間`,name:`endAt`,children:(0,o.jsx)(a.DateTimePicker,{formatDate:`YYYY-MM-DD`,formatTime:`HH:mm`,fullWidth:!0,hideSecond:!0,onChange:e=>w(T(e)),placeholderLeft:`可留空`,placeholderRight:`選擇時間`,value:le(C)})})]})})]})}function y({hideLabel:e=!1,label:t,layout:n=p,loading:i,name:s,onChange:c,onSearch:l,options:u,required:d=!0,size:f,value:m}){let h=(0,o.jsx)(a.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:s,spellCheck:!1},loading:i,loadingText:`搜尋成員中...`,mode:`single`,onChange:e=>c(x(e)),onSearch:l,onSearchTextChange:e=>c(C(e,u)),onVisibilityChange:e=>{e&&l(``)},options:[...u],placeholder:e?t:`搜尋姓名或信箱`,searchDebounceTime:300,size:f,value:m});return e?(0,o.jsx)(a.FormField,{fullWidth:!0,layout:n,name:s,children:h}):(0,o.jsx)(r.t,{label:t,layout:n,name:s,required:d,children:h})}function b(e){return{displayName:e.name,email:e.email,id:e.memberId,name:`${e.name} · ${e.email}`}}function x(e){if(!A(e))return null;let t=e.id,n=e.name,r=e.email,i=e.displayName;return typeof t==`string`&&typeof n==`string`?{displayName:typeof i==`string`?i:n,email:typeof r==`string`?r:null,id:t,name:n}:null}function S({email:e,name:t}){return e?(0,o.jsx)(a.Tooltip,{title:e,children:({onMouseEnter:e,onMouseLeave:n,ref:r})=>(0,o.jsx)(`span`,{className:f.memberNameWithTooltip,onMouseEnter:e,onMouseLeave:n,ref:r,children:t})}):(0,o.jsx)(`span`,{children:t})}function C(e,t){let n=e.trim().toLocaleLowerCase();if(!n)return null;let r=t.filter(e=>[e.id,e.name,e.email??``].some(e=>e.toLocaleLowerCase().includes(n)));return r.length===1?r[0]??null:null}function ee(e){return{id:e.id,name:e.name}}function te(e){return e.flatMap(e=>{if(!A(e))return[];let t=e.id,n=e.name;return typeof t==`string`&&typeof n==`string`?[{id:t,name:n}]:[]})}function ne(e,t){let n=t.trim().toLocaleLowerCase();return n?e.filter(e=>[e.id,e.name].some(e=>e.toLocaleLowerCase().includes(n))):e}function re(e,t){return[...e,...t].reduce((e,t)=>e.some(e=>e.id===t.id)?e:[...e,t],[])}function ie(e){return!A(e)||!w(e.id)?g[0]:g.find(t=>t.id===e.id)??g[0]}function ae(e){if(!A(e))return _[0];let t=e.id;return _.find(e=>e.id===t)??_[0]}function w(e){return e===`ALL`||e===`TEMPLATE_LIST`}function oe(e){return e.scopeType===`ALL`?`全部簽核`:e.scopeType===`TEMPLATE_LIST`?`指定模板:${e.scopeTemplateIds.length}`:e.scopeConditionCel?`條件:${e.scopeConditionCel}`:`條件式`}function se({status:e}){return e===`ACTIVE`?(0,o.jsx)(a.Badge,{size:`sub`,text:`啟用中`,variant:`dot-success`}):e===`REVOKED`?(0,o.jsx)(a.Badge,{size:`sub`,text:`已撤銷`,variant:`dot-inactive`}):e===`EXPIRED`?(0,o.jsx)(a.Badge,{size:`sub`,text:`已過期`,variant:`dot-warning`}):(0,o.jsx)(a.Badge,{size:`sub`,text:e,variant:`dot-info`})}function ce(e){return e===`ACTIVE`||e===`REVOKED`||e===`EXPIRED`?e:`ALL`}function le(e){let t=e?E(e):null;return t?`${D(t)}T${O(t.getHours())}:${O(t.getMinutes())}`:void 0}function T(e){let t=e?E(e):null;return t?t.toISOString():``}function ue(e,t){if(!e||!t)return!1;let n=E(e),r=E(t);return!!n&&!!r&&r.getTime()<=n.getTime()}function E(e){if(e.endsWith(`Z`)||/[+-]\d{2}:\d{2}$/.test(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}let[t=``,n=`00:00`]=e.split(`T`),[r=0,i=1,a=1]=t.split(`-`).map(Number),[o=0,s=0]=n.split(`:`).map(Number),c=new Date(r,i-1,a,o,s);return Number.isNaN(c.getTime())?null:c}function D(e){return`${e.getFullYear()}-${O(e.getMonth()+1)}-${O(e.getDate())}`}function O(e){return String(e).padStart(2,`0`)}function k(e){return e instanceof Error?e.message:`發生未知錯誤`}function A(e){return typeof e==`object`&&!!e}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
|
|
2
|
+
//# sourceMappingURL=delegations-CGj-tZNO.cjs.map
|