@guodun/antdv 1.4.3 → 1.4.5
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/es/components/contract-signing-location/src/ContractSigningLocation.vue.mjs +85 -85
- package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +1 -1
- package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.vue.mjs +66 -13
- package/dist/es/components/contract-signing-location/src/constants.mjs +27 -17
- package/dist/es/components/contract-signing-location/src/location-rules.mjs +2 -2
- package/dist/es/components/contract-signing-location/src/template-source.mjs +52 -36
- package/dist/es/components/contract-signing-location/style/index.css +1 -1
- package/dist/es/components/dept-selector/src/dept.mjs +170 -142
- package/dist/es/components/index.mjs +2 -1
- package/dist/es/components/pro-contract-template-designer/index.mjs +2 -1
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.mjs +372 -185
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.vue.mjs +59 -42
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.mjs +4 -4
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.mjs +218 -85
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateVariableDataModal.mjs +5 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateVariableDataModal.vue.mjs +97 -0
- package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +50 -50
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +948 -887
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +550 -245
- package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +225 -150
- package/dist/es/components/pro-contract-template-designer/src/extensions/template-variable.mjs +53 -35
- package/dist/es/components/pro-contract-template-designer/src/types.mjs +15 -2
- package/dist/es/components/pro-contract-template-designer/src/utils/advanced-controls.mjs +91 -0
- package/dist/es/components/pro-contract-template-designer/src/utils/page-decorations.mjs +17 -17
- package/dist/es/components/pro-contract-template-designer/src/utils/signing-placement.mjs +14 -14
- package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +168 -137
- package/dist/es/components/pro-contract-template-designer/src/utils/template-tool-icons.mjs +23 -16
- package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/es/components/pro-selector/src/components/org-tree.mjs +130 -89
- package/dist/es/components/pro-selector/src/components/user.mjs +34 -26
- package/dist/es/components/pro-selector/src/pro-user.mjs +86 -72
- package/dist/es/components/pro-selector/src/types.mjs +4 -1
- package/dist/es/components/pro-selector/src/utils/orgTree.mjs +5 -2
- package/dist/es/components/pro-selector-group/src/compoents/dept-tree.vue.mjs +92 -65
- package/dist/es/components/pro-selector-group/src/compoents/dept.vue.mjs +3 -3
- package/dist/es/components/pro-selector-group/src/compoents/role.vue.mjs +98 -73
- package/dist/es/components/pro-selector-group/src/compoents/select-box.vue.mjs +12 -9
- package/dist/es/components/pro-selector-group/src/compoents/user.vue.mjs +101 -72
- package/dist/es/components/pro-selector-group/src/hooks/useApi.mjs +39 -22
- package/dist/es/components/pro-selector-group/src/index.vue.mjs +105 -83
- package/dist/es/components/pro-selector-group/src/utils/index.mjs +36 -0
- package/dist/es/components/role-selector/src/role.mjs +134 -120
- package/dist/es/index.mjs +50 -49
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocation.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/constants.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/location-rules.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/template-source.cjs +1 -1
- package/dist/lib/components/contract-signing-location/style/index.css +1 -1
- package/dist/lib/components/dept-selector/src/dept.cjs +1 -1
- package/dist/lib/components/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.cjs +2 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateVariableDataModal.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateVariableDataModal.vue.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
- package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
- package/dist/lib/components/pro-contract-template-designer/src/extensions/template-variable.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/types.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/advanced-controls.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/utils/page-decorations.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/signing-placement.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +3 -3
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-tool-icons.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/lib/components/pro-selector/src/components/org-tree.cjs +1 -1
- package/dist/lib/components/pro-selector/src/components/user.cjs +1 -1
- package/dist/lib/components/pro-selector/src/pro-user.cjs +1 -1
- package/dist/lib/components/pro-selector/src/types.cjs +1 -1
- package/dist/lib/components/pro-selector/src/utils/orgTree.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/compoents/dept-tree.vue.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/compoents/dept.vue.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/compoents/role.vue.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/compoents/select-box.vue.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/compoents/user.vue.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/hooks/useApi.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/index.vue.cjs +1 -1
- package/dist/lib/components/pro-selector-group/src/utils/index.cjs +1 -0
- package/dist/lib/components/role-selector/src/role.cjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/theme/contract-signing-location.css +1 -1
- package/dist/theme/dept-selector.css +1 -1
- package/dist/theme/icon.css +1 -1
- package/dist/theme/index.css +1 -1
- package/dist/theme/pro-selector-group.css +1 -1
- package/dist/theme/pro-selector.css +1 -1
- package/dist/theme/role-selector.css +1 -1
- package/dist/types/components/contract-signing-location/src/ContractSigningLocation.vue.d.ts +3 -3
- package/dist/types/components/contract-signing-location/src/ContractSigningTemplatePage.vue.d.ts +3 -1
- package/dist/types/components/contract-signing-location/src/constants.d.ts +18 -0
- package/dist/types/components/contract-signing-location/src/coordinates.d.ts +6 -0
- package/dist/types/components/contract-signing-location/src/template-source.d.ts +17 -0
- package/dist/types/components/pro-contract-template-designer/index.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.vue.d.ts +3 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.d.ts +7 -1
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateVariableDataModal.vue.d.ts +14 -0
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +13 -1
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.d.ts +11 -1
- package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +4 -0
- package/dist/types/components/pro-contract-template-designer/src/extensions/template-variable.d.ts +11 -1
- package/dist/types/components/pro-contract-template-designer/src/types.d.ts +131 -2
- package/dist/types/components/pro-contract-template-designer/src/utils/advanced-controls.d.ts +15 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/template-renderer.d.ts +10 -2
- package/dist/types/components/pro-selector/index.d.ts +9 -0
- package/dist/types/components/pro-selector/src/components/user.d.ts +9 -0
- package/dist/types/components/pro-selector/src/types.d.ts +2 -0
- package/dist/types/components/pro-selector/src/utils/orgTree.d.ts +4 -1
- package/dist/types/components/pro-selector-group/src/compoents/select-box.vue.d.ts +4 -4
- package/dist/types/components/pro-selector-group/src/hooks/useApi.d.ts +6 -1
- package/dist/types/components/pro-selector-group/src/utils/index.d.ts +8 -0
- package/package.json +5 -1
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { canParseHtmlDocument as e, canUseDomHtml as t, collectFromHtmlTags as n, escapeHtmlAttribute as r, escapeHtmlText as i, getHtmlAttribute as a, hasPositivePageSize as o, replaceTemplateVariableSpans as s } from "./html.mjs";
|
|
2
|
+
import { resolveTemplateVariablePresentation as c } from "./template-variable-render.mjs";
|
|
3
|
+
import { buildPageDecorationClassNames as l, buildPageDecorationsHtml as u, collectPageDecorationVariableKeys as d, normalizePageDecorations as f, validatePageDecorations as p } from "./page-decorations.mjs";
|
|
4
|
+
import { isContractTemplateFieldType as m } from "../types.mjs";
|
|
5
|
+
import { formatContractTemplateRenderValue as h, isContractTemplateSelectionValue as g } from "./advanced-controls.mjs";
|
|
6
|
+
import { CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS as _, CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN as v, DEFAULT_PAGE_SIZE as y, resolvePageSize as b, validateContractTemplateVariableKey as x } from "../composables/use-template-designer.mjs";
|
|
7
|
+
import { isSafeContractImageUrl as S } from "./image-url.mjs";
|
|
7
8
|
//#region src/components/pro-contract-template-designer/src/utils/template-renderer.ts
|
|
8
|
-
|
|
9
|
+
function C(e) {
|
|
10
|
+
let t = Array.isArray(e?.variables) ? e.variables : [], n = t.map((e) => w(e)), r = {};
|
|
11
|
+
return t.forEach((e) => {
|
|
12
|
+
let t = typeof e?.key == "string" ? e.key : "";
|
|
13
|
+
if (t) {
|
|
14
|
+
if (e.type === "checkbox") {
|
|
15
|
+
r[t] = !1;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (e.type === "number") {
|
|
19
|
+
let n = typeof e.defaultValue == "string" ? e.defaultValue.trim().length > 0 : e.defaultValue !== void 0, i = Number(e.defaultValue);
|
|
20
|
+
r[t] = n && Number.isFinite(i) ? i : "";
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
r[t] = e.defaultValue ?? "";
|
|
24
|
+
}
|
|
25
|
+
}), {
|
|
26
|
+
values: r,
|
|
27
|
+
variables: n
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function w(e) {
|
|
31
|
+
return JSON.parse(JSON.stringify(e));
|
|
32
|
+
}
|
|
33
|
+
var T = new Set([
|
|
9
34
|
"action",
|
|
10
35
|
"formaction",
|
|
11
36
|
"href",
|
|
12
37
|
"src",
|
|
13
38
|
"xlink:href"
|
|
14
|
-
]),
|
|
15
|
-
function
|
|
39
|
+
]), E = /<[^>]+data-template-variable=["']true["'][^>]*>/gi;
|
|
40
|
+
function D(e) {
|
|
16
41
|
let t = {};
|
|
17
42
|
return (Array.isArray(e?.variables) ? e.variables : []).forEach((e) => {
|
|
18
|
-
e?.key && (t[e.key] =
|
|
43
|
+
e?.key && (t[e.key] = B(e));
|
|
19
44
|
}), t;
|
|
20
45
|
}
|
|
21
|
-
function
|
|
46
|
+
function O(e, t) {
|
|
22
47
|
return {
|
|
23
|
-
...
|
|
48
|
+
...D(e),
|
|
24
49
|
...t ?? {}
|
|
25
50
|
};
|
|
26
51
|
}
|
|
27
|
-
function
|
|
28
|
-
let n =
|
|
52
|
+
function k(e, t) {
|
|
53
|
+
let n = j(e);
|
|
29
54
|
if (!e) return n;
|
|
30
55
|
let r = Array.isArray(e.variables) ? e.variables : [], i = new Set(r.map((e) => e?.key).filter(Boolean));
|
|
31
56
|
return Object.keys(t).forEach((e) => {
|
|
@@ -39,7 +64,7 @@ function T(e, t) {
|
|
|
39
64
|
}), r.forEach((e) => {
|
|
40
65
|
if (!e?.key) return;
|
|
41
66
|
let r = t[e.key];
|
|
42
|
-
if (e.required &&
|
|
67
|
+
if (e.required && P(r)) {
|
|
43
68
|
n.push({
|
|
44
69
|
type: "variable",
|
|
45
70
|
id: e.id,
|
|
@@ -49,7 +74,7 @@ function T(e, t) {
|
|
|
49
74
|
});
|
|
50
75
|
return;
|
|
51
76
|
}
|
|
52
|
-
|
|
77
|
+
P(r) || (e.type === "number" && (typeof r != "number" || !Number.isFinite(r)) && n.push({
|
|
53
78
|
type: "variable",
|
|
54
79
|
id: e.id,
|
|
55
80
|
variableKey: e.key,
|
|
@@ -61,111 +86,117 @@ function T(e, t) {
|
|
|
61
86
|
variableKey: e.key,
|
|
62
87
|
message: `${e.label || e.key} 不是合法复选值`,
|
|
63
88
|
code: "VARIABLE_TYPE_INVALID"
|
|
64
|
-
}), e.type === "date" && !
|
|
89
|
+
}), e.type === "date" && !X(r) && n.push({
|
|
65
90
|
type: "variable",
|
|
66
91
|
id: e.id,
|
|
67
92
|
variableKey: e.key,
|
|
68
93
|
message: `${e.label || e.key} 不是合法日期`,
|
|
69
94
|
code: "VARIABLE_TYPE_INVALID"
|
|
70
|
-
}), e.type === "image" && !
|
|
95
|
+
}), e.type === "image" && !S(String(r)) && n.push({
|
|
71
96
|
type: "security",
|
|
72
97
|
id: e.id,
|
|
73
98
|
variableKey: e.key,
|
|
74
99
|
message: `${e.label || e.key} 不是安全的图片地址`,
|
|
75
100
|
code: "IMAGE_URL_UNSAFE"
|
|
76
|
-
}))
|
|
101
|
+
}), (e.type === "select" || e.type === "radio" || e.type === "user-selector" || e.type === "dept-selector" || e.type === "role-selector" || e.type === "org-selector") && r !== void 0 && ((Array.isArray(r) ? r.every(g) : g(r)) || n.push({
|
|
102
|
+
type: "variable",
|
|
103
|
+
id: e.id,
|
|
104
|
+
variableKey: e.key,
|
|
105
|
+
message: `${e.label || e.key} 不是合法选择值`,
|
|
106
|
+
code: "VARIABLE_SELECTION_INVALID"
|
|
107
|
+
})));
|
|
77
108
|
}), n;
|
|
78
109
|
}
|
|
79
|
-
function
|
|
80
|
-
return n ?
|
|
110
|
+
function A(e, t, n) {
|
|
111
|
+
return n ? k(e, t) : j(e);
|
|
81
112
|
}
|
|
82
|
-
function
|
|
83
|
-
if (!
|
|
113
|
+
function j(e) {
|
|
114
|
+
if (!e) return [{
|
|
84
115
|
type: "page",
|
|
85
116
|
id: "template",
|
|
86
117
|
message: "缺少可渲染的合同模板",
|
|
87
118
|
code: "TEMPLATE_MISSING"
|
|
88
119
|
}];
|
|
89
|
-
let
|
|
90
|
-
(!Array.isArray(
|
|
120
|
+
let t = [], n = Array.isArray(e.pages) ? e.pages : [], r = Array.isArray(e.variables) ? e.variables : [];
|
|
121
|
+
(!Array.isArray(e.pages) || n.length === 0) && t.push({
|
|
91
122
|
type: "page",
|
|
92
123
|
id: "template-pages",
|
|
93
124
|
message: "模板至少需要一个合法页面",
|
|
94
125
|
code: "TEMPLATE_PAGES_INVALID"
|
|
95
|
-
}), Array.isArray(
|
|
126
|
+
}), Array.isArray(e.variables) || t.push({
|
|
96
127
|
type: "variable",
|
|
97
128
|
id: "template-variables",
|
|
98
129
|
message: "模板变量列表格式无效",
|
|
99
130
|
code: "TEMPLATE_VARIABLES_INVALID"
|
|
100
|
-
}),
|
|
131
|
+
}), o(e.pageSize) || t.push({
|
|
101
132
|
type: "page",
|
|
102
133
|
id: "template-page-size",
|
|
103
134
|
message: "模板默认页面尺寸无效,已回退为安全默认尺寸",
|
|
104
135
|
code: "TEMPLATE_PAGE_SIZE_INVALID"
|
|
105
136
|
});
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
if (!
|
|
109
|
-
|
|
137
|
+
let i = /* @__PURE__ */ new Map();
|
|
138
|
+
r.forEach((e, n) => {
|
|
139
|
+
if (!e || typeof e.key != "string" || !e.key.trim()) {
|
|
140
|
+
t.push({
|
|
110
141
|
type: "variable",
|
|
111
|
-
id:
|
|
112
|
-
message: `第 ${
|
|
142
|
+
id: e?.id || `variable-${n}`,
|
|
143
|
+
message: `第 ${n + 1} 个变量缺少有效 key`,
|
|
113
144
|
code: "VARIABLE_KEY_MISSING"
|
|
114
145
|
});
|
|
115
146
|
return;
|
|
116
147
|
}
|
|
117
|
-
let
|
|
118
|
-
|
|
148
|
+
let a = e.key.trim(), o = r.some((t) => t?.id !== e.id && typeof t?.key == "string" && t.key.trim() === a), s = x(e.key, r, e.id), c = !v.test(a) || _.has(a);
|
|
149
|
+
s && (c || !o || e.key !== a) && t.push({
|
|
119
150
|
type: "variable",
|
|
120
|
-
id:
|
|
121
|
-
variableKey:
|
|
122
|
-
message: `${
|
|
151
|
+
id: e.id || `variable-${n}`,
|
|
152
|
+
variableKey: e.key,
|
|
153
|
+
message: `${e.label || e.key}:${s}`,
|
|
123
154
|
code: "VARIABLE_KEY_INVALID"
|
|
124
|
-
}),
|
|
155
|
+
}), i.set(a, (i.get(a) ?? 0) + 1), m(e.type ?? "text") || t.push({
|
|
125
156
|
type: "variable",
|
|
126
|
-
id:
|
|
127
|
-
variableKey:
|
|
128
|
-
message: `${
|
|
157
|
+
id: e.id,
|
|
158
|
+
variableKey: e.key,
|
|
159
|
+
message: `${e.label || e.key} 不是正文填写变量`,
|
|
129
160
|
code: "VARIABLE_TYPE_UNSUPPORTED"
|
|
130
161
|
});
|
|
131
|
-
}),
|
|
132
|
-
e > 1 &&
|
|
162
|
+
}), i.forEach((e, n) => {
|
|
163
|
+
e > 1 && t.push({
|
|
133
164
|
type: "variable",
|
|
134
|
-
id:
|
|
135
|
-
variableKey:
|
|
136
|
-
message: `变量 key ${
|
|
165
|
+
id: n,
|
|
166
|
+
variableKey: n,
|
|
167
|
+
message: `变量 key ${n} 重复`,
|
|
137
168
|
code: "VARIABLE_KEY_DUPLICATED"
|
|
138
169
|
});
|
|
139
170
|
});
|
|
140
|
-
let
|
|
141
|
-
|
|
171
|
+
let a = /* @__PURE__ */ new Set();
|
|
172
|
+
n.forEach((e, n) => {
|
|
142
173
|
if (!e || typeof e.id != "string" || !e.id.trim() || typeof e.contentHtml != "string") {
|
|
143
|
-
|
|
174
|
+
t.push({
|
|
144
175
|
type: "page",
|
|
145
|
-
id: e?.id || `page-${
|
|
176
|
+
id: e?.id || `page-${n}`,
|
|
146
177
|
pageId: e?.id,
|
|
147
|
-
message: `第 ${
|
|
178
|
+
message: `第 ${n + 1} 页结构无效,已跳过渲染`,
|
|
148
179
|
code: "PAGE_INVALID"
|
|
149
180
|
});
|
|
150
181
|
return;
|
|
151
182
|
}
|
|
152
|
-
e.pageSize !== void 0 && !
|
|
183
|
+
e.pageSize !== void 0 && !o(e.pageSize) && t.push({
|
|
153
184
|
type: "page",
|
|
154
185
|
id: `${e.id}-page-size`,
|
|
155
186
|
pageId: e.id,
|
|
156
|
-
message: `${e.title || `第 ${
|
|
187
|
+
message: `${e.title || `第 ${n + 1} 页`}:页面尺寸无效,已回退为安全尺寸`,
|
|
157
188
|
code: "PAGE_SIZE_INVALID"
|
|
158
|
-
}),
|
|
159
|
-
|
|
189
|
+
}), G(e.contentHtml).forEach((e) => a.add(e)), K(e.contentHtml).forEach((r, i) => {
|
|
190
|
+
t.push({
|
|
160
191
|
type: "security",
|
|
161
192
|
id: `${e.id}-security-${i}`,
|
|
162
193
|
pageId: e.id,
|
|
163
|
-
message: `${e.title || `第 ${
|
|
194
|
+
message: `${e.title || `第 ${n + 1} 页`}:${r}`,
|
|
164
195
|
code: "HTML_UNSAFE"
|
|
165
196
|
});
|
|
166
197
|
});
|
|
167
|
-
}),
|
|
168
|
-
|
|
198
|
+
}), a.forEach((e) => {
|
|
199
|
+
i.has(e) || t.push({
|
|
169
200
|
type: "variable",
|
|
170
201
|
id: e,
|
|
171
202
|
variableKey: e,
|
|
@@ -173,70 +204,70 @@ function D(t) {
|
|
|
173
204
|
code: "VARIABLE_CONFIG_MISSING"
|
|
174
205
|
});
|
|
175
206
|
});
|
|
176
|
-
let
|
|
177
|
-
return
|
|
178
|
-
!
|
|
207
|
+
let s = d(e.pageDecorations);
|
|
208
|
+
return i.forEach((e, n) => {
|
|
209
|
+
!a.has(n) && !s.has(n) && t.push({
|
|
179
210
|
type: "variable",
|
|
180
|
-
id:
|
|
181
|
-
variableKey:
|
|
182
|
-
message: `变量 ${
|
|
211
|
+
id: n,
|
|
212
|
+
variableKey: n,
|
|
213
|
+
message: `变量 ${n} 缺少正文节点`,
|
|
183
214
|
code: "VARIABLE_NODE_MISSING"
|
|
184
215
|
});
|
|
185
|
-
}),
|
|
216
|
+
}), t.push(...p(e.pageDecorations, r)), t;
|
|
186
217
|
}
|
|
187
|
-
function
|
|
218
|
+
function M(e, t, n = {}) {
|
|
188
219
|
if (!e || !Array.isArray(e.pages)) return [];
|
|
189
|
-
let r = Array.isArray(e.variables) ? e.variables : [], i = new Map(r.filter((e) => e?.key).map((e) => [e.key, e])), a =
|
|
220
|
+
let r = Array.isArray(e.variables) ? e.variables : [], i = new Map(r.filter((e) => e?.key).map((e) => [e.key, e])), a = o(e.pageSize) ? e.pageSize : y;
|
|
190
221
|
return e.pages.flatMap((o) => {
|
|
191
222
|
if (!o || typeof o.id != "string" || !o.id.trim() || typeof o.contentHtml != "string") return [];
|
|
192
|
-
let s =
|
|
223
|
+
let s = b(o.pageSize, a);
|
|
193
224
|
return [{
|
|
194
225
|
id: o.id,
|
|
195
226
|
title: o.title || "未命名页面",
|
|
196
227
|
format: s.format ?? "Custom",
|
|
197
228
|
width: s.width,
|
|
198
229
|
height: s.height,
|
|
199
|
-
contentHtml:
|
|
200
|
-
...e.pageDecorations ? { pageDecorations:
|
|
230
|
+
contentHtml: F(o.contentHtml, i, t, n),
|
|
231
|
+
...e.pageDecorations ? { pageDecorations: f(e.pageDecorations) } : {},
|
|
201
232
|
decorationVariables: r,
|
|
202
233
|
decorationValues: t
|
|
203
234
|
}];
|
|
204
235
|
});
|
|
205
236
|
}
|
|
206
|
-
function
|
|
207
|
-
return
|
|
208
|
-
let
|
|
209
|
-
return `<section class="${
|
|
237
|
+
function N(e, t, n = {}) {
|
|
238
|
+
return M(e, t, n).map((e, t, n) => {
|
|
239
|
+
let i = u(e.pageDecorations, t + 1, n.length, e.decorationVariables, e.decorationValues);
|
|
240
|
+
return `<section class="${l(e.pageDecorations, t + 1)}" data-page-id="${r(e.id)}" data-page-format="${r(e.format)}" data-page-width="${e.width}" data-page-height="${e.height}" style="width:${e.width}px;min-height:${e.height}px">${i}<div class="gd-contract-template-page__content">${e.contentHtml}</div></section>`;
|
|
210
241
|
}).join("\n");
|
|
211
242
|
}
|
|
212
|
-
function
|
|
213
|
-
return e == null || e === "";
|
|
243
|
+
function P(e) {
|
|
244
|
+
return e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
214
245
|
}
|
|
215
|
-
function
|
|
246
|
+
function F(e, n, r, i) {
|
|
216
247
|
if (!e) return e;
|
|
217
|
-
let
|
|
218
|
-
if (
|
|
219
|
-
let e = new DOMParser().parseFromString(
|
|
248
|
+
let o = W(e);
|
|
249
|
+
if (t()) {
|
|
250
|
+
let e = new DOMParser().parseFromString(o, "text/html");
|
|
220
251
|
return e.querySelectorAll("[data-template-variable]").forEach((e) => {
|
|
221
|
-
|
|
252
|
+
I(e, n, r, i);
|
|
222
253
|
}), e.body.innerHTML;
|
|
223
254
|
}
|
|
224
|
-
return
|
|
225
|
-
let
|
|
226
|
-
return
|
|
255
|
+
return s(o, (e, t) => {
|
|
256
|
+
let o = a(t, "data-key");
|
|
257
|
+
return o ? L(n.get(o), o, r[o], i) : e;
|
|
227
258
|
});
|
|
228
259
|
}
|
|
229
|
-
function
|
|
260
|
+
function I(e, t, n, r) {
|
|
230
261
|
let i = e.dataset.key || "", a = t.get(i);
|
|
231
262
|
if (!i || !a) return;
|
|
232
|
-
let o = new DOMParser().parseFromString(
|
|
263
|
+
let o = new DOMParser().parseFromString(L(a, i, n[i], r), "text/html").body.firstElementChild;
|
|
233
264
|
o && e.replaceWith(o);
|
|
234
265
|
}
|
|
235
|
-
function
|
|
236
|
-
return r.mode === "display" ?
|
|
266
|
+
function L(e, t, n, r) {
|
|
267
|
+
return r.mode === "display" ? R(e, t, n, r) : z(e, t, n, r);
|
|
237
268
|
}
|
|
238
|
-
function
|
|
239
|
-
let o = e?.type ?? "text", s = n ??
|
|
269
|
+
function R(e, t, n, a) {
|
|
270
|
+
let o = e?.type ?? "text", s = n ?? B(e), l = o === "image" && !P(s) && !S(String(s)) ? "" : s, u = H(l), d = c({
|
|
240
271
|
type: o,
|
|
241
272
|
width: e?.width,
|
|
242
273
|
height: e?.height,
|
|
@@ -252,31 +283,31 @@ function P(e, t, n, r) {
|
|
|
252
283
|
lineHeight: e?.lineHeight,
|
|
253
284
|
style: e?.style
|
|
254
285
|
}), f = d.displayText || e?.placeholder || e?.label || t, p = [
|
|
255
|
-
`class="${
|
|
286
|
+
`class="${r([
|
|
256
287
|
"gd-contract-template-renderer__control",
|
|
257
288
|
"gd-contract-template-renderer__preview-control",
|
|
258
289
|
...d.classes,
|
|
259
|
-
|
|
260
|
-
|
|
290
|
+
a.activeKey === t ? "is-active" : "",
|
|
291
|
+
P(l) ? "is-empty" : ""
|
|
261
292
|
].filter(Boolean).join(" "))}"`,
|
|
262
|
-
`style="${
|
|
293
|
+
`style="${r(d.styleText)}"`,
|
|
263
294
|
"data-contract-render-wrapper=\"true\"",
|
|
264
295
|
"data-contract-render-preview=\"true\"",
|
|
265
|
-
`data-key="${
|
|
266
|
-
`data-variable-type="${
|
|
267
|
-
`aria-label="${
|
|
268
|
-
|
|
269
|
-
|
|
296
|
+
`data-key="${r(t)}"`,
|
|
297
|
+
`data-variable-type="${r(o)}"`,
|
|
298
|
+
`aria-label="${r(e?.label || t)}"`,
|
|
299
|
+
a.disabled ? "" : "role=\"button\"",
|
|
300
|
+
a.disabled ? "" : "tabindex=\"0\""
|
|
270
301
|
].filter(Boolean).join(" ");
|
|
271
|
-
return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${
|
|
302
|
+
return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${U(l) ? "✓" : ""}</span>${i(f)}</span>` : o === "image" && !P(l) ? `<span ${p}></span>` : `<span ${p}>${i(f)}</span>`;
|
|
272
303
|
}
|
|
273
|
-
function
|
|
274
|
-
let o = e?.type ?? "text", s = !!
|
|
304
|
+
function z(e, t, n, a) {
|
|
305
|
+
let o = e?.type ?? "text", s = !!a.readonly, l = V(n ?? B(e)), u = c({
|
|
275
306
|
type: o,
|
|
276
307
|
width: e?.width,
|
|
277
308
|
height: e?.height,
|
|
278
309
|
placeholder: e?.placeholder ?? "",
|
|
279
|
-
defaultValue: s ?
|
|
310
|
+
defaultValue: s ? l : "",
|
|
280
311
|
format: e?.format ?? "",
|
|
281
312
|
precision: e?.precision,
|
|
282
313
|
useGrouping: e?.useGrouping,
|
|
@@ -286,57 +317,57 @@ function F(e, t, n, r) {
|
|
|
286
317
|
rows: e?.rows,
|
|
287
318
|
lineHeight: e?.lineHeight,
|
|
288
319
|
style: e?.style
|
|
289
|
-
}), d =
|
|
320
|
+
}), d = a.disabled || s, f = [
|
|
290
321
|
"data-contract-render-control=\"true\"",
|
|
291
|
-
`data-key="${
|
|
292
|
-
`data-variable-type="${
|
|
293
|
-
`aria-label="${
|
|
322
|
+
`data-key="${r(t)}"`,
|
|
323
|
+
`data-variable-type="${r(o)}"`,
|
|
324
|
+
`aria-label="${r(e?.label || t)}"`,
|
|
294
325
|
d ? "disabled" : "",
|
|
295
326
|
s ? "readonly" : ""
|
|
296
|
-
].filter(Boolean).join(" "), p = `style="${
|
|
297
|
-
return o === "checkbox" ? `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${
|
|
327
|
+
].filter(Boolean).join(" "), p = `style="${r(u.styleText)}"`, m = r(["gd-contract-template-renderer__control", ...u.classes].join(" "));
|
|
328
|
+
return o === "checkbox" ? `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}"><input type="checkbox" ${f} ${U(l) ? "checked" : ""}>${i(e?.checkedText || e?.label || t)}</label>` : s ? `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(u.displayText || l)}</span>` : o === "number" ? `<input class="${m}" ${p} type="number" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">` : o === "date" ? `<input class="${m}" ${p} type="date" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">` : o === "select" || o === "radio" || o.endsWith("-selector") || o === "custom" ? `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(h(n))}</span>` : e?.multiline ? `<textarea class="${m}" ${p} ${f} placeholder="${r(e.placeholder || "")}">${i(l)}</textarea>` : `<input class="${m}" ${p} type="text" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
|
|
298
329
|
}
|
|
299
|
-
function
|
|
330
|
+
function B(e) {
|
|
300
331
|
if (!e) return "";
|
|
301
|
-
if (e.type === "checkbox") return
|
|
332
|
+
if (e.type === "checkbox") return U(e.defaultValue);
|
|
302
333
|
if (e.type === "number" && e.defaultValue !== void 0) {
|
|
303
334
|
let t = Number(e.defaultValue);
|
|
304
335
|
return Number.isFinite(t) ? t : e.defaultValue;
|
|
305
336
|
}
|
|
306
|
-
return e.defaultValue ?? "";
|
|
337
|
+
if (!(e.type === "select" || e.type === "radio" || e.type?.endsWith("-selector"))) return e.defaultValue ?? "";
|
|
307
338
|
}
|
|
308
|
-
function
|
|
309
|
-
return typeof e == "boolean" ? e ? "true" : "" : e == null ? "" :
|
|
339
|
+
function V(e) {
|
|
340
|
+
return typeof e == "boolean" ? e ? "true" : "" : e == null ? "" : h(e);
|
|
310
341
|
}
|
|
311
|
-
function
|
|
312
|
-
return typeof e == "boolean" ? e ? "true" : "false" : e == null ? "" :
|
|
342
|
+
function H(e) {
|
|
343
|
+
return typeof e == "boolean" ? e ? "true" : "false" : e == null ? "" : h(e);
|
|
313
344
|
}
|
|
314
|
-
function
|
|
345
|
+
function U(e) {
|
|
315
346
|
return e === !0 || e === "true" || e === "1" || e === "yes" || e === "是" || e === "已选";
|
|
316
347
|
}
|
|
317
|
-
function
|
|
318
|
-
if (
|
|
319
|
-
let
|
|
320
|
-
return
|
|
348
|
+
function W(t) {
|
|
349
|
+
if (e()) {
|
|
350
|
+
let e = new DOMParser().parseFromString(t, "text/html");
|
|
351
|
+
return e.querySelectorAll("script,style,meta,link,iframe,object,embed").forEach((e) => e.remove()), e.querySelectorAll("*").forEach((e) => {
|
|
321
352
|
Array.from(e.attributes).forEach((t) => {
|
|
322
353
|
let n = t.name.toLowerCase();
|
|
323
|
-
(n.startsWith("on") || n === "srcdoc" ||
|
|
354
|
+
(n.startsWith("on") || n === "srcdoc" || T.has(n) && q(t.value) || n === "style" && Y(t.value)) && e.removeAttribute(t.name);
|
|
324
355
|
});
|
|
325
|
-
}),
|
|
356
|
+
}), e.body.innerHTML;
|
|
326
357
|
}
|
|
327
|
-
return
|
|
358
|
+
return t.replace(/<\s*(script|style|iframe|object|embed)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*\/?\s*(?:script|style|meta|link|iframe|object|embed)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+srcdoc\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(action|formaction|href|src|xlink:href)\s*=\s*(?:(["'])(.*?)\2|([^\s>]+))/gi, (e, t, n, r, i) => {
|
|
328
359
|
let a = r ?? i ?? "";
|
|
329
|
-
return
|
|
330
|
-
}).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) =>
|
|
360
|
+
return q(a) ? "" : n ? ` ${t}=${n}${a}${n}` : ` ${t}=${a}`;
|
|
361
|
+
}).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Y(n) ? "" : ` style=${t}${n}${t}`);
|
|
331
362
|
}
|
|
332
|
-
function
|
|
333
|
-
return
|
|
363
|
+
function G(e) {
|
|
364
|
+
return n(e, E, (e) => a(e, "data-key"));
|
|
334
365
|
}
|
|
335
|
-
function
|
|
366
|
+
function K(e) {
|
|
336
367
|
let t = [];
|
|
337
|
-
return /<\s*(script|style|meta|link|iframe|object|embed)\b/i.test(e) && t.push("正文包含已移除的危险标签"), /\s(?:on[a-z]+|srcdoc)\s*=/i.test(e) && t.push("正文包含已移除的事件或嵌入属性"), (
|
|
368
|
+
return /<\s*(script|style|meta|link|iframe|object|embed)\b/i.test(e) && t.push("正文包含已移除的危险标签"), /\s(?:on[a-z]+|srcdoc)\s*=/i.test(e) && t.push("正文包含已移除的事件或嵌入属性"), (J(e) || /style\s*=\s*["'][^"']*(?:expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html))/i.test(e)) && t.push("正文包含已移除的危险 URL 或样式"), t;
|
|
338
369
|
}
|
|
339
|
-
function
|
|
370
|
+
function q(e) {
|
|
340
371
|
let t = e.replace(/&#(?:x([\da-f]+)|(\d+));?/gi, (e, t, n) => {
|
|
341
372
|
let r = Number.parseInt(t ?? n ?? "", t ? 16 : 10);
|
|
342
373
|
try {
|
|
@@ -351,22 +382,22 @@ function U(e) {
|
|
|
351
382
|
})[t.toLowerCase()] ?? "").trim().replace(/[\u0000-\u0020\u007F]+/g, "");
|
|
352
383
|
return /^(?:javascript|vbscript|data:text\/html)/i.test(t);
|
|
353
384
|
}
|
|
354
|
-
function
|
|
385
|
+
function J(e) {
|
|
355
386
|
let t = /\s+(?:action|formaction|href|src|xlink:href)\s*=\s*(?:(["'])(.*?)\1|([^\s>]+))/gi, n = t.exec(e);
|
|
356
387
|
for (; n;) {
|
|
357
|
-
if (
|
|
388
|
+
if (q(n[2] ?? n[3] ?? "")) return !0;
|
|
358
389
|
n = t.exec(e);
|
|
359
390
|
}
|
|
360
391
|
return !1;
|
|
361
392
|
}
|
|
362
|
-
function
|
|
393
|
+
function Y(e) {
|
|
363
394
|
return /expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html)/i.test(e);
|
|
364
395
|
}
|
|
365
|
-
function
|
|
396
|
+
function X(e) {
|
|
366
397
|
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e));
|
|
367
398
|
if (!t) return !1;
|
|
368
399
|
let n = /* @__PURE__ */ new Date(`${t[1]}-${t[2]}-${t[3]}T00:00:00Z`);
|
|
369
400
|
return !Number.isNaN(n.getTime()) && n.getUTCFullYear() === Number(t[1]) && n.getUTCMonth() + 1 === Number(t[2]) && n.getUTCDate() === Number(t[3]);
|
|
370
401
|
}
|
|
371
402
|
//#endregion
|
|
372
|
-
export {
|
|
403
|
+
export { D as buildInitialRenderValues, N as buildTemplateRenderHtml, M as buildTemplateRenderPages, C as buildTemplateVariableData, P as isEmptyRenderValue, O as normalizeRenderValues, A as resolveTemplateRenderSubmitErrors, W as sanitizeContractRendererHtml, j as validateTemplateRenderStructure, k as validateTemplateRenderValues };
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { isContractTemplateFieldType as e } from "../types.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { ApartmentOutlined as t, CalendarOutlined as n, CheckSquareOutlined as r, CodeOutlined as i, DownOutlined as a, EditOutlined as o, FontSizeOutlined as s, NumberOutlined as c, PictureOutlined as l, ProfileOutlined as u, SafetyCertificateOutlined as d, TeamOutlined as f, UserOutlined as p } from "@ant-design/icons-vue";
|
|
3
3
|
//#region src/components/pro-contract-template-designer/src/utils/template-tool-icons.ts
|
|
4
|
-
var
|
|
5
|
-
text:
|
|
6
|
-
date:
|
|
7
|
-
number:
|
|
8
|
-
image:
|
|
9
|
-
checkbox:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
var m = {
|
|
5
|
+
text: s,
|
|
6
|
+
date: n,
|
|
7
|
+
number: c,
|
|
8
|
+
image: l,
|
|
9
|
+
checkbox: r,
|
|
10
|
+
select: a,
|
|
11
|
+
radio: u,
|
|
12
|
+
"user-selector": p,
|
|
13
|
+
"dept-selector": t,
|
|
14
|
+
"role-selector": f,
|
|
15
|
+
"org-selector": t,
|
|
16
|
+
custom: i
|
|
17
|
+
}, h = {
|
|
18
|
+
seal: d,
|
|
19
|
+
signature: o,
|
|
20
|
+
date: n
|
|
14
21
|
};
|
|
15
|
-
function
|
|
16
|
-
return
|
|
22
|
+
function g(t) {
|
|
23
|
+
return m[e(t) ? t : "text"];
|
|
17
24
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
25
|
+
function _(e) {
|
|
26
|
+
return h[e];
|
|
20
27
|
}
|
|
21
28
|
//#endregion
|
|
22
|
-
export {
|
|
29
|
+
export { g as resolveFieldTypeIcon, _ as resolveSigningPlacementTypeIcon };
|