tree-upload-vue3 1.1.6 → 1.1.8
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/tree-upload-vue3.css +1 -1
- package/dist/tree-upload-vue3.es.js +282 -282
- package/dist/tree-upload-vue3.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.schema-tree
|
|
1
|
+
.schema-tree{height:100%;position:relative;display:flex;flex-direction:column}.tree-toolbar{padding:8px;border-bottom:1px solid var(--el-border-color-lighter);display:flex;gap:8px}.custom-tree-node{flex:1;display:flex;align-items:center;justify-content:space-between;font-size:14px;padding-right:8px}.custom-tree-node .actions{display:none}.custom-tree-node:hover .actions{display:inline-flex}.context-menu{position:fixed;z-index:1000;background:var(--el-bg-color-overlay);border:1px solid var(--el-border-color);box-shadow:var(--el-box-shadow-light);border-radius:4px;padding:5px 0;min-width:120px}.context-menu-item{padding:8px 16px;cursor:pointer;display:flex;align-items:center;gap:8px;font-size:13px;color:var(--el-text-color-regular)}.context-menu-item:hover{background-color:var(--el-fill-color-light);color:var(--el-color-primary)}.node-label{display:flex;align-items:center}.required-star{color:var(--el-color-danger);margin-right:4px;font-weight:700}.schema-upload[data-v-607d52fb]{width:100%}.schema-table{height:100%;display:flex;flex-direction:column}.table-toolbar{margin-bottom:12px}.pagination-wrapper{margin-top:12px;display:flex;justify-content:flex-end}.schema-template{margin-bottom:12px;background-color:var(--el-fill-color-light);padding:8px 12px;border-radius:4px;border:1px solid var(--el-border-color-light)}.template-container{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.label{font-size:13px;color:var(--el-text-color-secondary);white-space:nowrap}.tags-wrapper{display:flex;flex-wrap:wrap;gap:8px}.template-tag{cursor:pointer;border:none;background-color:var(--el-bg-color);transition:all .2s}.template-tag:hover{color:var(--el-color-primary);transform:translateY(-1px);box-shadow:var(--el-box-shadow-lighter)}.tag-content{display:flex;align-items:center;gap:4px}.tpl-name{line-height:1}.preview-content{height:100%;min-height:500px;display:flex;flex-direction:column}.custom-header{display:flex;justify-content:space-between;align-items:center;padding-right:0}.header-controls{display:flex;align-items:center;gap:8px}.tree-upload-container{display:flex;height:100%;border:1px solid var(--el-border-color);background:var(--el-bg-color)}.tree-pane{border-right:1px solid var(--el-border-color);height:100%;overflow-y:auto;padding:10px;box-sizing:border-box;flex-shrink:0}.resize-handle{width:5px;height:100%;cursor:col-resize;background-color:transparent;margin-left:-3px;z-index:10;position:relative;transition:background-color .2s}.resize-handle:hover,.resize-handle:active{background-color:var(--el-color-primary);opacity:.5}.tree-upload-content-pane{flex:1;display:flex;flex-direction:column;padding:16px;overflow:hidden}.top-section{margin-bottom:16px}.table-section{flex:1;overflow:hidden}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { defineComponent as G, ref as $, computed as z, onMounted as
|
|
1
|
+
import { defineComponent as G, ref as $, computed as z, onMounted as ye, onUnmounted as ge, resolveComponent as g, createElementBlock as _, openBlock as i, createCommentVNode as x, createVNode as k, Fragment as X, renderList as Y, createBlock as y, withCtx as f, createTextVNode as J, resolveDynamicComponent as H, toDisplayString as O, createElementVNode as T, withModifiers as _e, normalizeStyle as se, inject as re, createSlots as ke, watch as le, resolveDirective as xe, withDirectives as Ce, unref as ee, normalizeClass as Se, reactive as oe, provide as $e, nextTick as we } from "vue";
|
|
2
2
|
import { ElMessage as Q } from "element-plus";
|
|
3
|
-
import { Download as
|
|
3
|
+
import { Download as ze, Close as Ne } from "@element-plus/icons-vue";
|
|
4
4
|
import ie from "file-preview-vue3-ts";
|
|
5
|
-
function
|
|
6
|
-
return
|
|
5
|
+
function te(t, C, a) {
|
|
6
|
+
return C.permissions ? C.permissions.default?.[t] !== !1 : !0;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function ce(t, C) {
|
|
9
9
|
if (!t) return t;
|
|
10
|
-
let
|
|
11
|
-
const o =
|
|
12
|
-
return o.currentNode && (
|
|
10
|
+
let a = t;
|
|
11
|
+
const o = C.variables || {};
|
|
12
|
+
return o.currentNode && (a = a.replace(/\$currentNode\.id/g, String(o.currentNode.id)), a = a.replace(/\$currentNode\.label/g, String(o.currentNode.label || ""))), a;
|
|
13
13
|
}
|
|
14
|
-
function Ve(t,
|
|
15
|
-
const { id:
|
|
14
|
+
function Ve(t, C) {
|
|
15
|
+
const { id: a, pId: o, children: h } = C, d = /* @__PURE__ */ new Map(), r = [];
|
|
16
16
|
for (const m of t)
|
|
17
|
-
m[h] = m[h] || [], d.set(m[
|
|
17
|
+
m[h] = m[h] || [], d.set(m[a], m);
|
|
18
18
|
for (const m of t) {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const S = m[o];
|
|
20
|
+
S && d.has(S) ? d.get(S)[h].push(m) : r.push(m);
|
|
21
21
|
}
|
|
22
22
|
return r;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const Te = { class: "schema-tree" }, Ue = {
|
|
25
25
|
key: 0,
|
|
26
26
|
class: "tree-toolbar"
|
|
27
|
-
},
|
|
27
|
+
}, De = { class: "custom-tree-node" }, Fe = { class: "node-label" }, Me = {
|
|
28
28
|
key: 0,
|
|
29
29
|
class: "required-star"
|
|
30
|
-
},
|
|
30
|
+
}, Ie = {
|
|
31
31
|
key: 0,
|
|
32
32
|
class: "actions"
|
|
33
|
-
},
|
|
33
|
+
}, Ae = ["onClick"], Le = /* @__PURE__ */ G({
|
|
34
34
|
__name: "SchemaTree",
|
|
35
35
|
props: {
|
|
36
36
|
schema: {}
|
|
37
37
|
},
|
|
38
38
|
emits: ["node-click", "action"],
|
|
39
|
-
setup(t, { emit:
|
|
40
|
-
const
|
|
39
|
+
setup(t, { emit: C }) {
|
|
40
|
+
const a = t, o = C, h = $(), d = $(!1), r = $({ x: 0, y: 0 }), m = $(null), S = z(() => {
|
|
41
41
|
let c = [];
|
|
42
|
-
if (
|
|
43
|
-
c = JSON.parse(JSON.stringify(
|
|
42
|
+
if (a.schema.dataSource.type === "static")
|
|
43
|
+
c = JSON.parse(JSON.stringify(a.schema.dataSource.data));
|
|
44
44
|
else
|
|
45
45
|
return [];
|
|
46
|
-
return
|
|
47
|
-
id:
|
|
48
|
-
pId:
|
|
49
|
-
children:
|
|
46
|
+
return a.schema.parentIdKey ? Ve(c, {
|
|
47
|
+
id: a.schema.nodeKey || "id",
|
|
48
|
+
pId: a.schema.parentIdKey,
|
|
49
|
+
children: a.schema.childrenKey || "children"
|
|
50
50
|
}) : c;
|
|
51
51
|
}), A = z(() => ({
|
|
52
|
-
label:
|
|
53
|
-
children:
|
|
54
|
-
})),
|
|
55
|
-
const
|
|
56
|
-
return c?.[
|
|
57
|
-
}, L = (c) => typeof c == "string" ? c.trim().toLowerCase() === "true" : c === !0,
|
|
52
|
+
label: a.schema.labelKey || "label",
|
|
53
|
+
children: a.schema.childrenKey || "children"
|
|
54
|
+
})), B = (c, D) => {
|
|
55
|
+
const I = a.schema.labelKey || "label";
|
|
56
|
+
return c?.[I] || D || c?.label || "";
|
|
57
|
+
}, L = (c) => typeof c == "string" ? c.trim().toLowerCase() === "true" : c === !0, M = z(() => a.schema.actions?.filter((c) => c.position === "toolbar") || []), N = z(() => a.schema.actions?.filter((c) => c.position === "node") || []), q = z(() => a.schema.actions?.filter((c) => c.position === "contextMenu") || []), E = (c) => {
|
|
58
58
|
d.value = !1, o("node-click", c);
|
|
59
59
|
}, e = (c, D) => {
|
|
60
60
|
q.value.length !== 0 && (c.preventDefault(), d.value = !0, r.value = { x: c.clientX, y: c.clientY }, m.value = D);
|
|
61
|
-
},
|
|
61
|
+
}, l = (c, D) => {
|
|
62
62
|
d.value = !1, !(c.confirm && !confirm(c.confirm.message || "确定吗?")) && o("action", c.key, D);
|
|
63
63
|
}, p = () => {
|
|
64
64
|
d.value = !1;
|
|
65
65
|
};
|
|
66
|
-
return
|
|
66
|
+
return ye(() => {
|
|
67
67
|
document.addEventListener("click", p);
|
|
68
|
-
}),
|
|
68
|
+
}), ge(() => {
|
|
69
69
|
document.removeEventListener("click", p);
|
|
70
70
|
}), (c, D) => {
|
|
71
|
-
const
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
(
|
|
71
|
+
const I = g("el-icon"), K = g("el-button"), W = g("el-tooltip"), v = g("el-tree");
|
|
72
|
+
return i(), _("div", Te, [
|
|
73
|
+
M.value.length ? (i(), _("div", Ue, [
|
|
74
|
+
(i(!0), _(X, null, Y(M.value, (b) => (i(), y(K, {
|
|
75
75
|
key: b.key,
|
|
76
76
|
type: "primary",
|
|
77
77
|
link: "",
|
|
78
|
-
onClick: (
|
|
78
|
+
onClick: (P) => l(b, null)
|
|
79
79
|
}, {
|
|
80
80
|
default: f(() => [
|
|
81
|
-
b.icon ? (
|
|
81
|
+
b.icon ? (i(), y(I, { key: 0 }, {
|
|
82
82
|
default: f(() => [
|
|
83
|
-
(
|
|
83
|
+
(i(), y(H(b.icon)))
|
|
84
84
|
]),
|
|
85
85
|
_: 2
|
|
86
86
|
}, 1024)) : x("", !0),
|
|
@@ -92,7 +92,7 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
92
92
|
k(v, {
|
|
93
93
|
ref_key: "treeRef",
|
|
94
94
|
ref: h,
|
|
95
|
-
data:
|
|
95
|
+
data: S.value,
|
|
96
96
|
"node-key": t.schema.nodeKey || "id",
|
|
97
97
|
props: A.value,
|
|
98
98
|
"default-expand-all": t.schema.ui?.defaultExpandAll,
|
|
@@ -101,14 +101,14 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
101
101
|
onNodeClick: E,
|
|
102
102
|
onNodeContextmenu: e
|
|
103
103
|
}, {
|
|
104
|
-
default: f(({ node: b, data:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
L(
|
|
108
|
-
J(" " + O(
|
|
104
|
+
default: f(({ node: b, data: P }) => [
|
|
105
|
+
T("span", De, [
|
|
106
|
+
T("span", Fe, [
|
|
107
|
+
L(P.required) || P.minCount && P.minCount > 0 ? (i(), _("span", Me, "*")) : x("", !0),
|
|
108
|
+
J(" " + O(B(P, b.label)), 1)
|
|
109
109
|
]),
|
|
110
|
-
N.value.length ? (
|
|
111
|
-
(
|
|
110
|
+
N.value.length ? (i(), _("span", Ie, [
|
|
111
|
+
(i(!0), _(X, null, Y(N.value, (j) => (i(), y(W, {
|
|
112
112
|
key: j.key,
|
|
113
113
|
content: j.label,
|
|
114
114
|
placement: "top",
|
|
@@ -118,12 +118,12 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
118
118
|
k(K, {
|
|
119
119
|
link: "",
|
|
120
120
|
type: "primary",
|
|
121
|
-
onClick:
|
|
121
|
+
onClick: _e((ae) => l(j, P), ["stop"])
|
|
122
122
|
}, {
|
|
123
123
|
default: f(() => [
|
|
124
|
-
j.icon ? (
|
|
124
|
+
j.icon ? (i(), y(I, { key: 0 }, {
|
|
125
125
|
default: f(() => [
|
|
126
|
-
(
|
|
126
|
+
(i(), y(H(j.icon)))
|
|
127
127
|
]),
|
|
128
128
|
_: 2
|
|
129
129
|
}, 1024)) : x("", !0)
|
|
@@ -138,37 +138,32 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
138
138
|
]),
|
|
139
139
|
_: 1
|
|
140
140
|
}, 8, ["data", "node-key", "props", "default-expand-all", "highlight-current"]),
|
|
141
|
-
d.value ? (
|
|
141
|
+
d.value ? (i(), _("div", {
|
|
142
142
|
key: 1,
|
|
143
143
|
class: "context-menu",
|
|
144
|
-
style:
|
|
144
|
+
style: se({ left: r.value.x + "px", top: r.value.y + "px" })
|
|
145
145
|
}, [
|
|
146
|
-
(
|
|
146
|
+
(i(!0), _(X, null, Y(q.value, (b) => (i(), _("div", {
|
|
147
147
|
key: b.key,
|
|
148
148
|
class: "context-menu-item",
|
|
149
|
-
onClick: (
|
|
149
|
+
onClick: (P) => l(b, m.value)
|
|
150
150
|
}, [
|
|
151
|
-
b.icon ? (
|
|
151
|
+
b.icon ? (i(), y(I, { key: 0 }, {
|
|
152
152
|
default: f(() => [
|
|
153
|
-
(
|
|
153
|
+
(i(), y(H(b.icon)))
|
|
154
154
|
]),
|
|
155
155
|
_: 2
|
|
156
156
|
}, 1024)) : x("", !0),
|
|
157
157
|
J(" " + O(b.label), 1)
|
|
158
|
-
], 8,
|
|
158
|
+
], 8, Ae))), 128))
|
|
159
159
|
], 4)) : x("", !0)
|
|
160
160
|
]);
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
}),
|
|
164
|
-
const l = t.__vccOpts || t;
|
|
165
|
-
for (const [o, h] of S)
|
|
166
|
-
l[o] = h;
|
|
167
|
-
return l;
|
|
168
|
-
}, Pe = /* @__PURE__ */ Z(Ee, [["__scopeId", "data-v-10d6955a"]]), Re = {
|
|
163
|
+
}), Ee = {
|
|
169
164
|
key: 0,
|
|
170
165
|
class: "schema-upload"
|
|
171
|
-
},
|
|
166
|
+
}, Re = { class: "el-upload__text" }, Be = { class: "el-upload__tip" }, Pe = /* @__PURE__ */ G({
|
|
172
167
|
__name: "SchemaUpload",
|
|
173
168
|
props: {
|
|
174
169
|
schema: {},
|
|
@@ -176,67 +171,67 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
176
171
|
fileCount: {}
|
|
177
172
|
},
|
|
178
173
|
emits: ["upload-success", "upload-error", "upload-before"],
|
|
179
|
-
setup(t, { emit:
|
|
180
|
-
const
|
|
174
|
+
setup(t, { emit: C }) {
|
|
175
|
+
const a = t, o = C, h = re("schemaContext", {}), d = (e) => {
|
|
181
176
|
if (e == null || e === "") return;
|
|
182
|
-
const
|
|
183
|
-
if (!(!Number.isFinite(
|
|
184
|
-
return
|
|
177
|
+
const l = Number(e);
|
|
178
|
+
if (!(!Number.isFinite(l) || l <= 0))
|
|
179
|
+
return l;
|
|
185
180
|
}, r = z(() => {
|
|
186
|
-
const e = h.variables?.currentNode,
|
|
187
|
-
let p = d(
|
|
188
|
-
const c = d(e?.maxCount), D = d(
|
|
181
|
+
const e = h.variables?.currentNode, l = e?.meta?.upload || {};
|
|
182
|
+
let p = d(a.schema.limit);
|
|
183
|
+
const c = d(e?.maxCount), D = d(l.limit);
|
|
189
184
|
c !== void 0 ? p = c : D !== void 0 && (p = D);
|
|
190
|
-
let
|
|
191
|
-
e?.maxSize !== void 0 && (
|
|
192
|
-
let K =
|
|
193
|
-
e?.accept !== void 0 ? K = e.accept :
|
|
194
|
-
let W =
|
|
185
|
+
let I = l.maxSize;
|
|
186
|
+
e?.maxSize !== void 0 && (I = e.maxSize);
|
|
187
|
+
let K = a.schema.accept;
|
|
188
|
+
e?.accept !== void 0 ? K = e.accept : l.accept !== void 0 && (K = l.accept);
|
|
189
|
+
let W = l.minLimit;
|
|
195
190
|
e?.minCount !== void 0 && (W = e.minCount);
|
|
196
|
-
const v = e?.required || !1, b =
|
|
191
|
+
const v = e?.required || !1, b = a.schema.ui || {}, P = l.ui || {}, j = { ...b, ...P };
|
|
197
192
|
return {
|
|
198
|
-
...
|
|
199
|
-
...
|
|
193
|
+
...a.schema,
|
|
194
|
+
...l,
|
|
200
195
|
// 使用节点级配置覆盖
|
|
201
196
|
ui: j,
|
|
202
197
|
// 显式处理可能在 meta 中的字段
|
|
203
198
|
limit: p,
|
|
204
|
-
maxSize:
|
|
199
|
+
maxSize: I,
|
|
205
200
|
// 自定义字段: 字节
|
|
206
201
|
minLimit: W,
|
|
207
202
|
// 自定义字段
|
|
208
203
|
accept: K,
|
|
209
204
|
required: v,
|
|
210
|
-
multiple:
|
|
211
|
-
drag:
|
|
212
|
-
autoUpload:
|
|
205
|
+
multiple: l.multiple ?? a.schema.multiple,
|
|
206
|
+
drag: l.drag ?? a.schema.drag,
|
|
207
|
+
autoUpload: l.autoUpload ?? a.schema.autoUpload
|
|
213
208
|
};
|
|
214
209
|
}), m = z(() => {
|
|
215
210
|
if (r.value.limit === void 0) return 1 / 0;
|
|
216
|
-
const e =
|
|
211
|
+
const e = a.fileCount || 0;
|
|
217
212
|
return Math.max(0, r.value.limit - e);
|
|
218
|
-
}),
|
|
219
|
-
const e =
|
|
213
|
+
}), S = z(() => !!(a.disabled || r.value.limit !== void 0 && m.value <= 0)), A = z(() => a.schema.headers || {}), B = z(() => {
|
|
214
|
+
const e = a.schema.data || {}, l = {};
|
|
220
215
|
for (const p in e) {
|
|
221
216
|
const c = e[p];
|
|
222
|
-
typeof c == "string" ?
|
|
217
|
+
typeof c == "string" ? l[p] = ce(c, h) : l[p] = c;
|
|
223
218
|
}
|
|
224
|
-
return
|
|
219
|
+
return l;
|
|
225
220
|
}), L = z(() => {
|
|
226
221
|
let e = r.value.ui?.tipText || "";
|
|
227
|
-
const
|
|
222
|
+
const l = [];
|
|
228
223
|
if (r.value.maxSize) {
|
|
229
224
|
const p = (r.value.maxSize / 1024 / 1024).toFixed(1);
|
|
230
|
-
|
|
225
|
+
l.push(`大小限制 ${p}MB`);
|
|
231
226
|
}
|
|
232
227
|
if (r.value.limit) {
|
|
233
|
-
const p =
|
|
234
|
-
|
|
228
|
+
const p = a.fileCount || 0;
|
|
229
|
+
l.push(`数量限制 ${r.value.limit}个 (已上传 ${p})`);
|
|
235
230
|
}
|
|
236
|
-
return r.value.minLimit ?
|
|
237
|
-
}),
|
|
238
|
-
const
|
|
239
|
-
return
|
|
231
|
+
return r.value.minLimit ? l.push(`最少 ${r.value.minLimit}个`) : r.value.required && l.push("必填"), r.value.accept && l.push(`格式 ${r.value.accept}`), l.length ? `${e} (${l.join(", ")})` : e;
|
|
232
|
+
}), M = (e) => {
|
|
233
|
+
const l = r.value.maxSize;
|
|
234
|
+
return l && e.size > l ? (Q.error(`文件大小不能超过 ${(l / 1024 / 1024).toFixed(1)}MB!`), !1) : (o("upload-before", { file: e, context: h }), !0);
|
|
240
235
|
}, N = () => {
|
|
241
236
|
Q.warning(`当前限制选择 ${r.value.limit} 个文件,还能上传 ${m.value} 个`);
|
|
242
237
|
}, q = (e) => {
|
|
@@ -244,36 +239,36 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
244
239
|
}, E = (e) => {
|
|
245
240
|
o("upload-error", e);
|
|
246
241
|
};
|
|
247
|
-
return (e,
|
|
248
|
-
const p = g("upload-filled"), c = g("el-icon"), D = g("el-button"),
|
|
249
|
-
return t.schema.enabled ? (
|
|
250
|
-
k(
|
|
242
|
+
return (e, l) => {
|
|
243
|
+
const p = g("upload-filled"), c = g("el-icon"), D = g("el-button"), I = g("el-upload");
|
|
244
|
+
return t.schema.enabled ? (i(), _("div", Ee, [
|
|
245
|
+
k(I, {
|
|
251
246
|
class: "upload-demo",
|
|
252
247
|
action: t.schema.action,
|
|
253
248
|
method: t.schema.method || "post",
|
|
254
249
|
headers: A.value,
|
|
255
|
-
data:
|
|
250
|
+
data: B.value,
|
|
256
251
|
multiple: r.value.multiple,
|
|
257
252
|
drag: r.value.drag,
|
|
258
253
|
accept: r.value.accept,
|
|
259
254
|
limit: m.value,
|
|
260
255
|
"auto-upload": r.value.autoUpload !== !1,
|
|
261
|
-
disabled:
|
|
256
|
+
disabled: S.value,
|
|
262
257
|
"show-file-list": t.schema.ui?.showFileList,
|
|
263
|
-
"before-upload":
|
|
258
|
+
"before-upload": M,
|
|
264
259
|
"on-exceed": N,
|
|
265
260
|
onSuccess: q,
|
|
266
261
|
onError: E
|
|
267
|
-
},
|
|
262
|
+
}, ke({
|
|
268
263
|
default: f(() => [
|
|
269
|
-
r.value.drag ? (
|
|
264
|
+
r.value.drag ? (i(), _(X, { key: 0 }, [
|
|
270
265
|
k(c, { class: "el-icon--upload" }, {
|
|
271
266
|
default: f(() => [
|
|
272
267
|
k(p)
|
|
273
268
|
]),
|
|
274
269
|
_: 1
|
|
275
270
|
}),
|
|
276
|
-
|
|
271
|
+
T("div", Re, O(t.schema.ui?.buttonText || "将文件拖到此处,或点击上传"), 1)
|
|
277
272
|
], 64)) : x("", !0)
|
|
278
273
|
]),
|
|
279
274
|
_: 2
|
|
@@ -293,7 +288,7 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
293
288
|
t.schema.ui?.showTip ? {
|
|
294
289
|
name: "tip",
|
|
295
290
|
fn: f(() => [
|
|
296
|
-
|
|
291
|
+
T("div", Be, O(L.value), 1)
|
|
297
292
|
]),
|
|
298
293
|
key: "1"
|
|
299
294
|
} : void 0
|
|
@@ -301,41 +296,46 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
301
296
|
])) : x("", !0);
|
|
302
297
|
};
|
|
303
298
|
}
|
|
304
|
-
}),
|
|
299
|
+
}), qe = (t, C) => {
|
|
300
|
+
const a = t.__vccOpts || t;
|
|
301
|
+
for (const [o, h] of C)
|
|
302
|
+
a[o] = h;
|
|
303
|
+
return a;
|
|
304
|
+
}, Ke = /* @__PURE__ */ qe(Pe, [["__scopeId", "data-v-607d52fb"]]), je = { class: "schema-table" }, Oe = {
|
|
305
305
|
key: 0,
|
|
306
306
|
class: "table-toolbar"
|
|
307
|
-
},
|
|
307
|
+
}, We = {
|
|
308
308
|
key: 1,
|
|
309
309
|
class: "pagination-wrapper"
|
|
310
|
-
},
|
|
310
|
+
}, Je = /* @__PURE__ */ G({
|
|
311
311
|
__name: "SchemaTable",
|
|
312
312
|
props: {
|
|
313
313
|
schema: {},
|
|
314
314
|
files: {}
|
|
315
315
|
},
|
|
316
316
|
emits: ["action", "refresh", "delete-before", "delete-after"],
|
|
317
|
-
setup(t, { emit:
|
|
318
|
-
const
|
|
317
|
+
setup(t, { emit: C }) {
|
|
318
|
+
const a = t, o = C, h = re("schemaContext", {}), d = $(!1), r = $(1), m = $(a.schema.ui?.pagination?.pageSize || 20), S = $(0), A = $([]), B = z(() => {
|
|
319
319
|
let e = [];
|
|
320
|
-
return
|
|
321
|
-
}), L = (e,
|
|
322
|
-
if (!
|
|
323
|
-
if (
|
|
320
|
+
return a.files ? e = a.files : a.schema.dataSource.type === "static" ? e = a.schema.dataSource.data : e = A.value, (a.schema.dataSource.type === "static" || a.files) && (S.value = e.length), e;
|
|
321
|
+
}), L = (e, l) => {
|
|
322
|
+
if (!l) return e;
|
|
323
|
+
if (l === "fileSize") {
|
|
324
324
|
const p = Number(e);
|
|
325
325
|
return isNaN(p) ? e : p < 1024 ? p + " B" : p < 1024 * 1024 ? (p / 1024).toFixed(2) + " KB" : (p / 1024 / 1024).toFixed(2) + " MB";
|
|
326
326
|
}
|
|
327
327
|
return e;
|
|
328
|
-
},
|
|
329
|
-
e.confirm && !confirm(e.confirm.message || "确定吗?") || (e.key === "delete" && o("delete-before",
|
|
328
|
+
}, M = (e, l) => {
|
|
329
|
+
e.confirm && !confirm(e.confirm.message || "确定吗?") || (e.key === "delete" && o("delete-before", l), o("action", e.key, l), e.key === "delete" && o("delete-after", l));
|
|
330
330
|
}, N = async () => {
|
|
331
|
-
if (
|
|
331
|
+
if (a.schema.dataSource.type === "api") {
|
|
332
332
|
d.value = !0;
|
|
333
333
|
try {
|
|
334
|
-
const e =
|
|
335
|
-
|
|
336
|
-
for (const p in
|
|
337
|
-
typeof
|
|
338
|
-
console.log("Fetching Table Data:", e.url,
|
|
334
|
+
const e = a.schema.dataSource, l = { ...e.params };
|
|
335
|
+
a.schema.ui?.pagination?.enabled && (l.page = r.value, l.pageSize = m.value);
|
|
336
|
+
for (const p in l)
|
|
337
|
+
typeof l[p] == "string" && (l[p] = ce(l[p], h));
|
|
338
|
+
console.log("Fetching Table Data:", e.url, l), e.url;
|
|
339
339
|
} catch (e) {
|
|
340
340
|
console.error(e);
|
|
341
341
|
} finally {
|
|
@@ -348,20 +348,20 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
348
348
|
r.value = e, N();
|
|
349
349
|
};
|
|
350
350
|
return le(() => h.variables?.currentNode, (e) => {
|
|
351
|
-
e &&
|
|
352
|
-
}, { deep: !0 }), (e,
|
|
353
|
-
const p = g("el-icon"), c = g("el-button"), D = g("el-table-column"),
|
|
354
|
-
return
|
|
355
|
-
t.schema.toolbarActions?.length ? (
|
|
356
|
-
(
|
|
351
|
+
e && a.schema.dataSource.type === "api" && N();
|
|
352
|
+
}, { deep: !0 }), (e, l) => {
|
|
353
|
+
const p = g("el-icon"), c = g("el-button"), D = g("el-table-column"), I = g("el-table"), K = g("el-pagination"), W = xe("loading");
|
|
354
|
+
return i(), _("div", je, [
|
|
355
|
+
t.schema.toolbarActions?.length ? (i(), _("div", Oe, [
|
|
356
|
+
(i(!0), _(X, null, Y(t.schema.toolbarActions, (v) => (i(), y(c, {
|
|
357
357
|
key: v.key,
|
|
358
358
|
type: v.type || "default",
|
|
359
|
-
onClick: (b) =>
|
|
359
|
+
onClick: (b) => M(v, null)
|
|
360
360
|
}, {
|
|
361
361
|
default: f(() => [
|
|
362
|
-
v.icon ? (
|
|
362
|
+
v.icon ? (i(), y(p, { key: 0 }, {
|
|
363
363
|
default: f(() => [
|
|
364
|
-
(
|
|
364
|
+
(i(), y(H(v.icon)))
|
|
365
365
|
]),
|
|
366
366
|
_: 2
|
|
367
367
|
}, 1024)) : x("", !0),
|
|
@@ -370,15 +370,15 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
370
370
|
_: 2
|
|
371
371
|
}, 1032, ["type", "onClick"]))), 128))
|
|
372
372
|
])) : x("", !0),
|
|
373
|
-
Ce((
|
|
374
|
-
data:
|
|
373
|
+
Ce((i(), y(I, {
|
|
374
|
+
data: B.value,
|
|
375
375
|
stripe: t.schema.ui?.stripe,
|
|
376
376
|
border: t.schema.ui?.border,
|
|
377
377
|
size: t.schema.ui?.size,
|
|
378
378
|
style: { width: "100%", height: "100%", flex: "1" }
|
|
379
379
|
}, {
|
|
380
380
|
default: f(() => [
|
|
381
|
-
(
|
|
381
|
+
(i(!0), _(X, null, Y(t.schema.columns, (v) => (i(), y(D, {
|
|
382
382
|
key: v.prop,
|
|
383
383
|
prop: v.prop,
|
|
384
384
|
label: v.label,
|
|
@@ -392,18 +392,18 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
392
392
|
]),
|
|
393
393
|
_: 2
|
|
394
394
|
}, 1032, ["prop", "label", "width", "align", "fixed", "sortable"]))), 128)),
|
|
395
|
-
t.schema.actions?.length ? (
|
|
395
|
+
t.schema.actions?.length ? (i(), y(D, {
|
|
396
396
|
key: 0,
|
|
397
397
|
label: "操作",
|
|
398
398
|
fixed: "right",
|
|
399
399
|
width: "200"
|
|
400
400
|
}, {
|
|
401
401
|
default: f((v) => [
|
|
402
|
-
(
|
|
402
|
+
(i(!0), _(X, null, Y(t.schema.actions, (b) => (i(), y(c, {
|
|
403
403
|
key: b.key,
|
|
404
404
|
type: b.type || "primary",
|
|
405
405
|
link: "",
|
|
406
|
-
onClick: (
|
|
406
|
+
onClick: (P) => M(b, v.row)
|
|
407
407
|
}, {
|
|
408
408
|
default: f(() => [
|
|
409
409
|
J(O(b.label), 1)
|
|
@@ -418,15 +418,15 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
418
418
|
}, 8, ["data", "stripe", "border", "size"])), [
|
|
419
419
|
[W, d.value]
|
|
420
420
|
]),
|
|
421
|
-
t.schema.ui?.pagination?.enabled &&
|
|
421
|
+
t.schema.ui?.pagination?.enabled && S.value > 0 ? (i(), _("div", We, [
|
|
422
422
|
k(K, {
|
|
423
423
|
"current-page": r.value,
|
|
424
|
-
"onUpdate:currentPage":
|
|
424
|
+
"onUpdate:currentPage": l[0] || (l[0] = (v) => r.value = v),
|
|
425
425
|
"page-size": m.value,
|
|
426
|
-
"onUpdate:pageSize":
|
|
426
|
+
"onUpdate:pageSize": l[1] || (l[1] = (v) => m.value = v),
|
|
427
427
|
"page-sizes": [10, 20, 50, 100],
|
|
428
428
|
layout: t.schema.ui?.pagination?.layout || "total, sizes, prev, pager, next, jumper",
|
|
429
|
-
total:
|
|
429
|
+
total: S.value,
|
|
430
430
|
onSizeChange: q,
|
|
431
431
|
onCurrentChange: E
|
|
432
432
|
}, null, 8, ["current-page", "page-size", "layout", "total"])
|
|
@@ -434,37 +434,37 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
434
434
|
]);
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
|
-
}),
|
|
437
|
+
}), Xe = { class: "schema-template" }, Ye = { class: "template-container" }, Ge = { class: "tags-wrapper" }, He = { class: "tag-content" }, Qe = { class: "tpl-name" }, Ze = /* @__PURE__ */ G({
|
|
438
438
|
__name: "SchemaTemplate",
|
|
439
439
|
props: {
|
|
440
440
|
templates: {}
|
|
441
441
|
},
|
|
442
442
|
setup(t) {
|
|
443
|
-
const
|
|
444
|
-
window.open(
|
|
443
|
+
const C = (a) => {
|
|
444
|
+
window.open(a.url, "_blank");
|
|
445
445
|
};
|
|
446
|
-
return (
|
|
446
|
+
return (a, o) => {
|
|
447
447
|
const h = g("el-icon"), d = g("el-tag");
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
o[0] || (o[0] =
|
|
451
|
-
|
|
452
|
-
(
|
|
448
|
+
return i(), _("div", Xe, [
|
|
449
|
+
T("div", Ye, [
|
|
450
|
+
o[0] || (o[0] = T("span", { class: "label" }, "可用模板:", -1)),
|
|
451
|
+
T("div", Ge, [
|
|
452
|
+
(i(!0), _(X, null, Y(t.templates, (r, m) => (i(), y(d, {
|
|
453
453
|
key: m,
|
|
454
454
|
class: "template-tag",
|
|
455
455
|
type: "primary",
|
|
456
456
|
effect: "light",
|
|
457
|
-
onClick: (
|
|
457
|
+
onClick: (S) => C(r)
|
|
458
458
|
}, {
|
|
459
459
|
default: f(() => [
|
|
460
|
-
|
|
460
|
+
T("span", He, [
|
|
461
461
|
k(h, null, {
|
|
462
462
|
default: f(() => [
|
|
463
|
-
k(
|
|
463
|
+
k(ee(ze))
|
|
464
464
|
]),
|
|
465
465
|
_: 1
|
|
466
466
|
}),
|
|
467
|
-
|
|
467
|
+
T("span", Qe, O(r.name), 1)
|
|
468
468
|
])
|
|
469
469
|
]),
|
|
470
470
|
_: 2
|
|
@@ -474,10 +474,10 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
474
474
|
]);
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
-
}),
|
|
477
|
+
}), et = {
|
|
478
478
|
key: 0,
|
|
479
479
|
class: "schema-preview-container"
|
|
480
|
-
},
|
|
480
|
+
}, tt = { class: "custom-header" }, lt = ["id"], at = { class: "header-controls" }, nt = { class: "preview-content" }, ot = { class: "preview-content" }, it = /* @__PURE__ */ G({
|
|
481
481
|
__name: "SchemaPreview",
|
|
482
482
|
props: {
|
|
483
483
|
schema: {},
|
|
@@ -485,9 +485,9 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
485
485
|
file: {}
|
|
486
486
|
},
|
|
487
487
|
emits: ["update:modelValue"],
|
|
488
|
-
setup(t, { emit:
|
|
489
|
-
const
|
|
490
|
-
get: () =>
|
|
488
|
+
setup(t, { emit: C }) {
|
|
489
|
+
const a = t, o = C, h = $(!1), d = z({
|
|
490
|
+
get: () => a.modelValue,
|
|
491
491
|
set: (m) => {
|
|
492
492
|
o("update:modelValue", m), m || setTimeout(() => {
|
|
493
493
|
h.value = !1;
|
|
@@ -496,15 +496,15 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
496
496
|
}), r = () => {
|
|
497
497
|
h.value = !h.value;
|
|
498
498
|
};
|
|
499
|
-
return le(() =>
|
|
499
|
+
return le(() => a.schema.fullscreen, (m) => {
|
|
500
500
|
m !== void 0 && (h.value = m);
|
|
501
|
-
}, { immediate: !0 }), (m,
|
|
502
|
-
const A = g("el-icon"),
|
|
503
|
-
return d.value ? (
|
|
504
|
-
t.schema.mode === "dialog" ? (
|
|
501
|
+
}, { immediate: !0 }), (m, S) => {
|
|
502
|
+
const A = g("el-icon"), B = g("el-button"), L = g("el-dialog"), M = g("el-drawer");
|
|
503
|
+
return d.value ? (i(), _("div", et, [
|
|
504
|
+
t.schema.mode === "dialog" ? (i(), y(L, {
|
|
505
505
|
key: 0,
|
|
506
506
|
modelValue: d.value,
|
|
507
|
-
"onUpdate:modelValue":
|
|
507
|
+
"onUpdate:modelValue": S[0] || (S[0] = (N) => d.value = N),
|
|
508
508
|
width: t.schema.width,
|
|
509
509
|
fullscreen: h.value || t.schema.fullscreen,
|
|
510
510
|
draggable: "",
|
|
@@ -514,34 +514,34 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
514
514
|
"show-close": !1
|
|
515
515
|
}, {
|
|
516
516
|
header: f(({ close: N, titleId: q, titleClass: E }) => [
|
|
517
|
-
|
|
518
|
-
|
|
517
|
+
T("div", tt, [
|
|
518
|
+
T("span", {
|
|
519
519
|
id: q,
|
|
520
|
-
class:
|
|
521
|
-
}, O(t.schema.dialogTitle || "预览"), 11,
|
|
522
|
-
|
|
523
|
-
k(
|
|
520
|
+
class: Se(E)
|
|
521
|
+
}, O(t.schema.dialogTitle || "预览"), 11, lt),
|
|
522
|
+
T("div", at, [
|
|
523
|
+
k(B, {
|
|
524
524
|
link: "",
|
|
525
525
|
onClick: r
|
|
526
526
|
}, {
|
|
527
527
|
default: f(() => [
|
|
528
528
|
k(A, null, {
|
|
529
529
|
default: f(() => [
|
|
530
|
-
(
|
|
530
|
+
(i(), y(H(h.value ? "CopyDocument" : "FullScreen")))
|
|
531
531
|
]),
|
|
532
532
|
_: 1
|
|
533
533
|
})
|
|
534
534
|
]),
|
|
535
535
|
_: 1
|
|
536
536
|
}),
|
|
537
|
-
k(
|
|
537
|
+
k(B, {
|
|
538
538
|
link: "",
|
|
539
539
|
onClick: N
|
|
540
540
|
}, {
|
|
541
541
|
default: f(() => [
|
|
542
542
|
k(A, null, {
|
|
543
543
|
default: f(() => [
|
|
544
|
-
k(
|
|
544
|
+
k(ee(Ne))
|
|
545
545
|
]),
|
|
546
546
|
_: 1
|
|
547
547
|
})
|
|
@@ -552,8 +552,8 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
552
552
|
])
|
|
553
553
|
]),
|
|
554
554
|
default: f(() => [
|
|
555
|
-
|
|
556
|
-
t.file ? (
|
|
555
|
+
T("div", nt, [
|
|
556
|
+
t.file ? (i(), y(ee(ie), {
|
|
557
557
|
key: 0,
|
|
558
558
|
url: t.file.url,
|
|
559
559
|
type: t.file.type,
|
|
@@ -562,18 +562,18 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
562
562
|
])
|
|
563
563
|
]),
|
|
564
564
|
_: 1
|
|
565
|
-
}, 8, ["modelValue", "width", "fullscreen"])) : (
|
|
565
|
+
}, 8, ["modelValue", "width", "fullscreen"])) : (i(), y(M, {
|
|
566
566
|
key: 1,
|
|
567
567
|
modelValue: d.value,
|
|
568
|
-
"onUpdate:modelValue":
|
|
568
|
+
"onUpdate:modelValue": S[1] || (S[1] = (N) => d.value = N),
|
|
569
569
|
title: t.schema.dialogTitle || "预览",
|
|
570
570
|
size: t.schema.width,
|
|
571
571
|
"destroy-on-close": "",
|
|
572
572
|
"append-to-body": ""
|
|
573
573
|
}, {
|
|
574
574
|
default: f(() => [
|
|
575
|
-
|
|
576
|
-
t.file ? (
|
|
575
|
+
T("div", ot, [
|
|
576
|
+
t.file ? (i(), y(ee(ie), {
|
|
577
577
|
key: 0,
|
|
578
578
|
url: t.file.url,
|
|
579
579
|
type: t.file.type,
|
|
@@ -586,10 +586,10 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
586
586
|
])) : x("", !0);
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
|
-
}),
|
|
589
|
+
}), st = { class: "tree-upload-container" }, rt = { class: "tree-upload-content-pane" }, ct = {
|
|
590
590
|
key: 0,
|
|
591
591
|
class: "top-section"
|
|
592
|
-
},
|
|
592
|
+
}, ut = { class: "table-section" }, dt = { class: "dialog-footer" }, mt = /* @__PURE__ */ G({
|
|
593
593
|
__name: "TreeUpload",
|
|
594
594
|
props: {
|
|
595
595
|
schema: {},
|
|
@@ -602,37 +602,37 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
602
602
|
"delete-before",
|
|
603
603
|
"delete-after"
|
|
604
604
|
],
|
|
605
|
-
setup(t, { expose:
|
|
606
|
-
const o = t, h =
|
|
605
|
+
setup(t, { expose: C, emit: a }) {
|
|
606
|
+
const o = t, h = a, d = $(null), r = $([]), m = $(!1), S = $(null), A = $(!1), B = $("addRoot"), L = oe({ label: "" }), M = z(() => o.schema.tree.labelKey || "label"), N = $(), q = $(null), E = oe({
|
|
607
607
|
variables: {
|
|
608
608
|
...o.schema.context?.variables,
|
|
609
609
|
currentNode: void 0,
|
|
610
610
|
currentFile: void 0
|
|
611
611
|
}
|
|
612
612
|
});
|
|
613
|
-
|
|
614
|
-
const e = $(280),
|
|
613
|
+
$e("schemaContext", E);
|
|
614
|
+
const e = $(280), l = $(!1), p = z(() => o.schema.tree.ui?.resizable !== !1), c = z(() => `${e.value}px`);
|
|
615
615
|
le(() => o.schema.tree.ui?.width, (n) => {
|
|
616
616
|
if (typeof n == "number")
|
|
617
617
|
e.value = n;
|
|
618
618
|
else if (typeof n == "string") {
|
|
619
|
-
const
|
|
620
|
-
isNaN(
|
|
619
|
+
const s = parseInt(n, 10);
|
|
620
|
+
isNaN(s) || (e.value = s);
|
|
621
621
|
}
|
|
622
622
|
}, { immediate: !0 });
|
|
623
623
|
const D = (n) => {
|
|
624
|
-
p.value && (
|
|
625
|
-
},
|
|
626
|
-
if (!
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
629
|
-
const w =
|
|
624
|
+
p.value && (l.value = !0, document.addEventListener("mousemove", I), document.addEventListener("mouseup", K), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none");
|
|
625
|
+
}, I = (n) => {
|
|
626
|
+
if (!l.value) return;
|
|
627
|
+
const s = document.querySelector(".tree-upload-container");
|
|
628
|
+
if (s) {
|
|
629
|
+
const w = s.getBoundingClientRect(), u = n.clientX - w.left;
|
|
630
630
|
u >= 150 && u <= 800 && (e.value = u);
|
|
631
631
|
}
|
|
632
632
|
}, K = () => {
|
|
633
|
-
|
|
634
|
-
}, W = z(() => d.value?.meta?.templates || []), v = z(() => d.value ?
|
|
635
|
-
switch (
|
|
633
|
+
l.value = !1, document.removeEventListener("mousemove", I), document.removeEventListener("mouseup", K), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
634
|
+
}, W = z(() => d.value?.meta?.templates || []), v = z(() => d.value ? te("upload", o.schema) : !1), b = z(() => {
|
|
635
|
+
switch (B.value) {
|
|
636
636
|
case "addRoot":
|
|
637
637
|
return "添加根节点";
|
|
638
638
|
case "addChild":
|
|
@@ -644,13 +644,13 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
644
644
|
default:
|
|
645
645
|
return "节点操作";
|
|
646
646
|
}
|
|
647
|
-
}),
|
|
647
|
+
}), P = (n) => typeof n == "string" ? n.trim().toLowerCase() === "true" : n === !0, j = (n) => {
|
|
648
648
|
if (console.log("Node Selected:", n), d.value = n, E.variables && (E.variables.currentNode = n), o.schema.table.dataSource.type === "static") {
|
|
649
|
-
const
|
|
650
|
-
r.value =
|
|
649
|
+
const s = o.schema.table.dataSource.data;
|
|
650
|
+
r.value = s.filter((w) => w.meta?.nodeId === String(n.id));
|
|
651
651
|
}
|
|
652
|
-
},
|
|
653
|
-
if (console.log("树动作:", n,
|
|
652
|
+
}, ae = (n, s) => {
|
|
653
|
+
if (console.log("树动作:", n, s), !te(n, o.schema)) {
|
|
654
654
|
Q.error("权限不足");
|
|
655
655
|
return;
|
|
656
656
|
}
|
|
@@ -659,51 +659,51 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
659
659
|
return;
|
|
660
660
|
}
|
|
661
661
|
if (n === "delete") {
|
|
662
|
-
if (!
|
|
663
|
-
const w = o.schema.tree.dataSource.data, u = (
|
|
664
|
-
const U =
|
|
662
|
+
if (!s || !confirm(`确定删除节点 "${s.label}" 吗?`)) return;
|
|
663
|
+
const w = o.schema.tree.dataSource.data, u = (V) => {
|
|
664
|
+
const U = V.findIndex((R) => R.id === s.id);
|
|
665
665
|
if (U > -1)
|
|
666
|
-
return
|
|
667
|
-
for (const
|
|
668
|
-
if (
|
|
666
|
+
return V.splice(U, 1), !0;
|
|
667
|
+
for (const R of V)
|
|
668
|
+
if (R.children && u(R.children)) return !0;
|
|
669
669
|
return !1;
|
|
670
670
|
};
|
|
671
|
-
u(w) && d.value?.id ===
|
|
671
|
+
u(w) && d.value?.id === s.id && (d.value = null);
|
|
672
672
|
return;
|
|
673
673
|
}
|
|
674
|
-
(n === "addRoot" || n === "addChild" || n === "addSibling" || n === "edit") && (
|
|
674
|
+
(n === "addRoot" || n === "addChild" || n === "addSibling" || n === "edit") && (B.value = n, q.value = s, L.label = n === "edit" && s ? s[M.value] || s.label : "", A.value = !0, we(() => {
|
|
675
675
|
N.value?.clearValidate();
|
|
676
676
|
}));
|
|
677
|
-
},
|
|
677
|
+
}, ue = () => {
|
|
678
678
|
N.value?.validate((n) => {
|
|
679
679
|
if (!n || o.schema.tree.dataSource.type !== "static")
|
|
680
680
|
return;
|
|
681
|
-
const
|
|
682
|
-
const
|
|
683
|
-
return
|
|
681
|
+
const s = o.schema.tree.dataSource.data, w = L.label, u = B.value, V = q.value, U = (R) => {
|
|
682
|
+
const F = { id: String(Date.now()), children: [] };
|
|
683
|
+
return F[M.value] = R, M.value !== "label" && (F.label = R), F;
|
|
684
684
|
};
|
|
685
685
|
if (u === "addRoot")
|
|
686
|
-
|
|
686
|
+
s.push(U(w));
|
|
687
687
|
else if (u === "addChild")
|
|
688
|
-
|
|
688
|
+
V && (V.children || (V.children = []), V.children.push(U(w)));
|
|
689
689
|
else if (u === "addSibling") {
|
|
690
|
-
if (
|
|
691
|
-
const
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
return
|
|
695
|
-
for (const
|
|
696
|
-
if (
|
|
690
|
+
if (V) {
|
|
691
|
+
const R = (F) => {
|
|
692
|
+
const ne = F.findIndex((Z) => Z.id === V.id);
|
|
693
|
+
if (ne > -1)
|
|
694
|
+
return F.splice(ne + 1, 0, U(w)), !0;
|
|
695
|
+
for (const Z of F)
|
|
696
|
+
if (Z.children && R(Z.children)) return !0;
|
|
697
697
|
return !1;
|
|
698
698
|
};
|
|
699
|
-
|
|
699
|
+
R(s);
|
|
700
700
|
}
|
|
701
|
-
} else u === "edit" &&
|
|
701
|
+
} else u === "edit" && V && (V[M.value] = w, M.value !== "label" && (V.label = w));
|
|
702
702
|
A.value = !1;
|
|
703
703
|
});
|
|
704
|
-
},
|
|
704
|
+
}, de = (n) => {
|
|
705
705
|
if (console.log("上传成功:", n), h("upload-success", n), o.schema.table.dataSource.type === "static" && d.value) {
|
|
706
|
-
const
|
|
706
|
+
const s = {
|
|
707
707
|
id: Date.now(),
|
|
708
708
|
name: "已上传文件.png",
|
|
709
709
|
size: 1024,
|
|
@@ -711,106 +711,106 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
711
711
|
type: "png",
|
|
712
712
|
meta: { nodeId: String(d.value.id) }
|
|
713
713
|
};
|
|
714
|
-
o.schema.table.dataSource.data.push(
|
|
714
|
+
o.schema.table.dataSource.data.push(s), j(d.value);
|
|
715
715
|
}
|
|
716
|
-
},
|
|
717
|
-
if (console.log("Table Action:", n,
|
|
716
|
+
}, me = (n, s) => {
|
|
717
|
+
if (console.log("Table Action:", n, s), E.variables && (E.variables.currentFile = s), !te(n, o.schema)) {
|
|
718
718
|
Q.error("权限不足");
|
|
719
719
|
return;
|
|
720
720
|
}
|
|
721
721
|
if (n === "preview")
|
|
722
|
-
|
|
722
|
+
S.value = s, m.value = !0;
|
|
723
723
|
else if (n === "delete" && o.schema.table.dataSource.type === "static") {
|
|
724
|
-
const w = o.schema.table.dataSource.data.findIndex((u) => u.id ===
|
|
724
|
+
const w = o.schema.table.dataSource.data.findIndex((u) => u.id === s.id);
|
|
725
725
|
w > -1 && (o.schema.table.dataSource.data.splice(w, 1), d.value && j(d.value));
|
|
726
726
|
}
|
|
727
|
-
},
|
|
728
|
-
const n = [],
|
|
729
|
-
const
|
|
730
|
-
if (
|
|
727
|
+
}, fe = async () => {
|
|
728
|
+
const n = [], s = [], w = (u) => {
|
|
729
|
+
const V = P(u.required);
|
|
730
|
+
if (V || u.minCount && u.minCount > 0 || u.maxCount && u.maxCount > 0) {
|
|
731
731
|
let U = 0;
|
|
732
|
-
o.schema.table.dataSource.type === "static" ? U = o.schema.table.dataSource.data.filter((
|
|
732
|
+
o.schema.table.dataSource.type === "static" ? U = o.schema.table.dataSource.data.filter((F) => String(F.meta?.nodeId) === String(u.id)).length : U = u.meta?.fileCount || 0, V && U === 0 ? (n.push(`节点 "${u.label}" 必须上传文件`), s.push(u)) : u.minCount && U < u.minCount ? (n.push(`节点 "${u.label}" 至少需要 ${u.minCount} 个文件 (当前: ${U})`), s.push(u)) : u.maxCount && U > u.maxCount && (n.push(`节点 "${u.label}" 最多允许 ${u.maxCount} 个文件 (当前: ${U})`), s.push(u));
|
|
733
733
|
}
|
|
734
734
|
u.children && u.children.forEach(w);
|
|
735
735
|
};
|
|
736
|
-
return o.schema.tree.dataSource.type === "static" ? o.schema.tree.dataSource.data.forEach(w) : console.warn("API 模式下的树验证需要确保数据已加载或通过 meta 携带统计信息"), n.length > 0 ? Promise.reject({ valid: !1, errors: n, failedNodes:
|
|
737
|
-
},
|
|
738
|
-
return
|
|
739
|
-
validate:
|
|
740
|
-
}), (n,
|
|
741
|
-
const w = g("el-input"), u = g("el-form-item"),
|
|
742
|
-
return
|
|
743
|
-
|
|
736
|
+
return o.schema.tree.dataSource.type === "static" ? o.schema.tree.dataSource.data.forEach(w) : console.warn("API 模式下的树验证需要确保数据已加载或通过 meta 携带统计信息"), n.length > 0 ? Promise.reject({ valid: !1, errors: n, failedNodes: s }) : Promise.resolve({ valid: !0 });
|
|
737
|
+
}, pe = (n) => h("upload-before", n), he = (n) => h("upload-error", n), ve = (n) => h("delete-before", n), be = (n) => h("delete-after", n);
|
|
738
|
+
return C({
|
|
739
|
+
validate: fe
|
|
740
|
+
}), (n, s) => {
|
|
741
|
+
const w = g("el-input"), u = g("el-form-item"), V = g("el-form"), U = g("el-button"), R = g("el-dialog");
|
|
742
|
+
return i(), _("div", st, [
|
|
743
|
+
T("div", {
|
|
744
744
|
class: "tree-pane",
|
|
745
|
-
style:
|
|
745
|
+
style: se({ width: c.value })
|
|
746
746
|
}, [
|
|
747
|
-
k(
|
|
747
|
+
k(Le, {
|
|
748
748
|
schema: t.schema.tree,
|
|
749
749
|
onNodeClick: j,
|
|
750
|
-
onAction:
|
|
750
|
+
onAction: ae
|
|
751
751
|
}, null, 8, ["schema"])
|
|
752
752
|
], 4),
|
|
753
|
-
p.value ? (
|
|
753
|
+
p.value ? (i(), _("div", {
|
|
754
754
|
key: 0,
|
|
755
755
|
class: "resize-handle",
|
|
756
756
|
onMousedown: D
|
|
757
757
|
}, null, 32)) : x("", !0),
|
|
758
|
-
|
|
759
|
-
t.mode === "edit" ? (
|
|
760
|
-
W.value && W.value.length > 0 ? (
|
|
758
|
+
T("div", rt, [
|
|
759
|
+
t.mode === "edit" ? (i(), _("div", ct, [
|
|
760
|
+
W.value && W.value.length > 0 ? (i(), y(Ze, {
|
|
761
761
|
key: 0,
|
|
762
762
|
templates: W.value
|
|
763
763
|
}, null, 8, ["templates"])) : x("", !0),
|
|
764
|
-
t.schema.upload ? (
|
|
764
|
+
t.schema.upload ? (i(), y(Ke, {
|
|
765
765
|
key: 1,
|
|
766
766
|
schema: t.schema.upload,
|
|
767
767
|
disabled: !v.value,
|
|
768
768
|
"file-count": r.value.length,
|
|
769
|
-
onUploadBefore:
|
|
770
|
-
onUploadSuccess:
|
|
771
|
-
onUploadError:
|
|
769
|
+
onUploadBefore: pe,
|
|
770
|
+
onUploadSuccess: de,
|
|
771
|
+
onUploadError: he
|
|
772
772
|
}, null, 8, ["schema", "disabled", "file-count"])) : x("", !0)
|
|
773
773
|
])) : x("", !0),
|
|
774
|
-
|
|
775
|
-
k(
|
|
774
|
+
T("div", ut, [
|
|
775
|
+
k(Je, {
|
|
776
776
|
schema: t.schema.table,
|
|
777
777
|
files: r.value,
|
|
778
|
-
onAction:
|
|
779
|
-
onDeleteBefore:
|
|
780
|
-
onDeleteAfter:
|
|
778
|
+
onAction: me,
|
|
779
|
+
onDeleteBefore: ve,
|
|
780
|
+
onDeleteAfter: be
|
|
781
781
|
}, null, 8, ["schema", "files"])
|
|
782
782
|
])
|
|
783
783
|
]),
|
|
784
|
-
t.schema.preview ? (
|
|
784
|
+
t.schema.preview ? (i(), y(it, {
|
|
785
785
|
key: 1,
|
|
786
786
|
modelValue: m.value,
|
|
787
|
-
"onUpdate:modelValue":
|
|
787
|
+
"onUpdate:modelValue": s[0] || (s[0] = (F) => m.value = F),
|
|
788
788
|
schema: t.schema.preview,
|
|
789
|
-
file:
|
|
789
|
+
file: S.value
|
|
790
790
|
}, null, 8, ["modelValue", "schema", "file"])) : x("", !0),
|
|
791
|
-
k(
|
|
791
|
+
k(R, {
|
|
792
792
|
modelValue: A.value,
|
|
793
|
-
"onUpdate:modelValue":
|
|
793
|
+
"onUpdate:modelValue": s[3] || (s[3] = (F) => A.value = F),
|
|
794
794
|
title: b.value,
|
|
795
795
|
width: "400px",
|
|
796
796
|
"append-to-body": "",
|
|
797
797
|
"destroy-on-close": ""
|
|
798
798
|
}, {
|
|
799
799
|
footer: f(() => [
|
|
800
|
-
|
|
800
|
+
T("span", dt, [
|
|
801
801
|
k(U, {
|
|
802
|
-
onClick:
|
|
802
|
+
onClick: s[2] || (s[2] = (F) => A.value = !1)
|
|
803
803
|
}, {
|
|
804
|
-
default: f(() => [...
|
|
804
|
+
default: f(() => [...s[4] || (s[4] = [
|
|
805
805
|
J("取消", -1)
|
|
806
806
|
])]),
|
|
807
807
|
_: 1
|
|
808
808
|
}),
|
|
809
809
|
k(U, {
|
|
810
810
|
type: "primary",
|
|
811
|
-
onClick:
|
|
811
|
+
onClick: ue
|
|
812
812
|
}, {
|
|
813
|
-
default: f(() => [...
|
|
813
|
+
default: f(() => [...s[5] || (s[5] = [
|
|
814
814
|
J("确定", -1)
|
|
815
815
|
])]),
|
|
816
816
|
_: 1
|
|
@@ -818,7 +818,7 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
818
818
|
])
|
|
819
819
|
]),
|
|
820
820
|
default: f(() => [
|
|
821
|
-
k(
|
|
821
|
+
k(V, {
|
|
822
822
|
model: L,
|
|
823
823
|
ref_key: "nodeFormRef",
|
|
824
824
|
ref: N,
|
|
@@ -833,7 +833,7 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
833
833
|
default: f(() => [
|
|
834
834
|
k(w, {
|
|
835
835
|
modelValue: L.label,
|
|
836
|
-
"onUpdate:modelValue":
|
|
836
|
+
"onUpdate:modelValue": s[1] || (s[1] = (F) => L.label = F),
|
|
837
837
|
placeholder: "请输入节点名称"
|
|
838
838
|
}, null, 8, ["modelValue"])
|
|
839
839
|
]),
|
|
@@ -848,12 +848,12 @@ const Ue = { class: "schema-tree" }, De = {
|
|
|
848
848
|
]);
|
|
849
849
|
};
|
|
850
850
|
}
|
|
851
|
-
}),
|
|
851
|
+
}), bt = {
|
|
852
852
|
install(t) {
|
|
853
|
-
t.component("TreeUpload",
|
|
853
|
+
t.component("TreeUpload", mt);
|
|
854
854
|
}
|
|
855
855
|
};
|
|
856
856
|
export {
|
|
857
|
-
|
|
858
|
-
|
|
857
|
+
mt as TreeUpload,
|
|
858
|
+
bt as default
|
|
859
859
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(U,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus"),require("@element-plus/icons-vue"),require("file-preview-vue3-ts")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","@element-plus/icons-vue","file-preview-vue3-ts"],e):(U=typeof globalThis<"u"?globalThis:U||self,e(U.TreeUploadVue3={},U.Vue,U.ElementPlus,U.ElementPlusIconsVue,U.FilePreviewVue3Ts))})(this,(function(U,e,A,K,j){"use strict";function P(o,y,l){return y.permissions?y.permissions.default?.[o]!==!1:!0}function O(o,y){if(!o)return o;let l=o;const c=y.variables||{};return c.currentNode&&(l=l.replace(/\$currentNode\.id/g,String(c.currentNode.id)),l=l.replace(/\$currentNode\.label/g,String(c.currentNode.label||""))),l}function Y(o,y){const{id:l,pId:c,children:u}=y,m=new Map,i=[];for(const p of o)p[u]=p[u]||[],m.set(p[l],p);for(const p of o){const C=p[c];C&&m.has(C)?m.get(C)[u].push(p):i.push(p)}return i}const G={class:"schema-tree"},H={key:0,class:"tree-toolbar"},Q={class:"custom-tree-node"},Z={class:"node-label"},v={key:0,class:"required-star"},ee={key:0,class:"actions"},te=["onClick"],oe=e.defineComponent({__name:"SchemaTree",props:{schema:{}},emits:["node-click","action"],setup(o,{emit:y}){const l=o,c=y,u=e.ref(),m=e.ref(!1),i=e.ref({x:0,y:0}),p=e.ref(null),C=e.computed(()=>{let s=[];if(l.schema.dataSource.type==="static")s=JSON.parse(JSON.stringify(l.schema.dataSource.data));else return[];return l.schema.parentIdKey?Y(s,{id:l.schema.nodeKey||"id",pId:l.schema.parentIdKey,children:l.schema.childrenKey||"children"}):s}),S=e.computed(()=>({label:l.schema.labelKey||"label",children:l.schema.childrenKey||"children"})),z=(s,B)=>{const w=l.schema.labelKey||"label";return s?.[w]||B||s?.label||""},E=s=>typeof s=="string"?s.trim().toLowerCase()==="true":s===!0,V=e.computed(()=>l.schema.actions?.filter(s=>s.position==="toolbar")||[]),b=e.computed(()=>l.schema.actions?.filter(s=>s.position==="node")||[]),F=e.computed(()=>l.schema.actions?.filter(s=>s.position==="contextMenu")||[]),$=s=>{m.value=!1,c("node-click",s)},t=(s,B)=>{F.value.length!==0&&(s.preventDefault(),m.value=!0,i.value={x:s.clientX,y:s.clientY},p.value=B)},n=(s,B)=>{m.value=!1,!(s.confirm&&!confirm(s.confirm.message||"确定吗?"))&&c("action",s.key,B)},f=()=>{m.value=!1};return e.onMounted(()=>{document.addEventListener("click",f)}),e.onUnmounted(()=>{document.removeEventListener("click",f)}),(s,B)=>{const w=e.resolveComponent("el-icon"),M=e.resolveComponent("el-button"),L=e.resolveComponent("el-tooltip"),h=e.resolveComponent("el-tree");return e.openBlock(),e.createElementBlock("div",G,[V.value.length?(e.openBlock(),e.createElementBlock("div",H,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,k=>(e.openBlock(),e.createBlock(M,{key:k.key,type:"primary",link:"",onClick:D=>n(k,null)},{default:e.withCtx(()=>[k.icon?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.icon)))]),_:2},1024)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(k.label),1)]),_:2},1032,["onClick"]))),128))])):e.createCommentVNode("",!0),e.createVNode(h,{ref_key:"treeRef",ref:u,data:C.value,"node-key":o.schema.nodeKey||"id",props:S.value,"default-expand-all":o.schema.ui?.defaultExpandAll,"highlight-current":o.schema.ui?.highlightCurrent,"expand-on-click-node":!1,onNodeClick:$,onNodeContextmenu:t},{default:e.withCtx(({node:k,data:D})=>[e.createElementVNode("span",Q,[e.createElementVNode("span",Z,[E(D.required)||D.minCount&&D.minCount>0?(e.openBlock(),e.createElementBlock("span",v,"*")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(z(D,k.label)),1)]),b.value.length?(e.openBlock(),e.createElementBlock("span",ee,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,I=>(e.openBlock(),e.createBlock(L,{key:I.key,content:I.label,placement:"top","show-after":200},{default:e.withCtx(()=>[e.createVNode(M,{link:"",type:"primary",onClick:e.withModifiers(J=>n(I,D),["stop"])},{default:e.withCtx(()=>[I.icon?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(I.icon)))]),_:2},1024)):e.createCommentVNode("",!0)]),_:2},1032,["onClick"])]),_:2},1032,["content"]))),128))])):e.createCommentVNode("",!0)])]),_:1},8,["data","node-key","props","default-expand-all","highlight-current"]),m.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"context-menu",style:e.normalizeStyle({left:i.value.x+"px",top:i.value.y+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,k=>(e.openBlock(),e.createElementBlock("div",{key:k.key,class:"context-menu-item",onClick:D=>n(k,p.value)},[k.icon?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.icon)))]),_:2},1024)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(k.label),1)],8,te))),128))],4)):e.createCommentVNode("",!0)])}}}),R=(o,y)=>{const l=o.__vccOpts||o;for(const[c,u]of y)l[c]=u;return l},ne=R(oe,[["__scopeId","data-v-10d6955a"]]),le={key:0,class:"schema-upload"},ae={class:"el-upload__text"},ce={class:"el-upload__tip"},re=R(e.defineComponent({__name:"SchemaUpload",props:{schema:{},disabled:{type:Boolean},fileCount:{}},emits:["upload-success","upload-error","upload-before"],setup(o,{emit:y}){const l=o,c=y,u=e.inject("schemaContext",{}),m=t=>{if(t==null||t==="")return;const n=Number(t);if(!(!Number.isFinite(n)||n<=0))return n},i=e.computed(()=>{const t=u.variables?.currentNode,n=t?.meta?.upload||{};let f=m(l.schema.limit);const s=m(t?.maxCount),B=m(n.limit);s!==void 0?f=s:B!==void 0&&(f=B);let w=n.maxSize;t?.maxSize!==void 0&&(w=t.maxSize);let M=l.schema.accept;t?.accept!==void 0?M=t.accept:n.accept!==void 0&&(M=n.accept);let L=n.minLimit;t?.minCount!==void 0&&(L=t.minCount);const h=t?.required||!1,k=l.schema.ui||{},D=n.ui||{},I={...k,...D};return{...l.schema,...n,ui:I,limit:f,maxSize:w,minLimit:L,accept:M,required:h,multiple:n.multiple??l.schema.multiple,drag:n.drag??l.schema.drag,autoUpload:n.autoUpload??l.schema.autoUpload}}),p=e.computed(()=>{if(i.value.limit===void 0)return 1/0;const t=l.fileCount||0;return Math.max(0,i.value.limit-t)}),C=e.computed(()=>!!(l.disabled||i.value.limit!==void 0&&p.value<=0)),S=e.computed(()=>l.schema.headers||{}),z=e.computed(()=>{const t=l.schema.data||{},n={};for(const f in t){const s=t[f];typeof s=="string"?n[f]=O(s,u):n[f]=s}return n}),E=e.computed(()=>{let t=i.value.ui?.tipText||"";const n=[];if(i.value.maxSize){const f=(i.value.maxSize/1024/1024).toFixed(1);n.push(`大小限制 ${f}MB`)}if(i.value.limit){const f=l.fileCount||0;n.push(`数量限制 ${i.value.limit}个 (已上传 ${f})`)}return i.value.minLimit?n.push(`最少 ${i.value.minLimit}个`):i.value.required&&n.push("必填"),i.value.accept&&n.push(`格式 ${i.value.accept}`),n.length?`${t} (${n.join(", ")})`:t}),V=t=>{const n=i.value.maxSize;return n&&t.size>n?(A.ElMessage.error(`文件大小不能超过 ${(n/1024/1024).toFixed(1)}MB!`),!1):(c("upload-before",{file:t,context:u}),!0)},b=()=>{A.ElMessage.warning(`当前限制选择 ${i.value.limit} 个文件,还能上传 ${p.value} 个`)},F=t=>{c("upload-success",t)},$=t=>{c("upload-error",t)};return(t,n)=>{const f=e.resolveComponent("upload-filled"),s=e.resolveComponent("el-icon"),B=e.resolveComponent("el-button"),w=e.resolveComponent("el-upload");return o.schema.enabled?(e.openBlock(),e.createElementBlock("div",le,[e.createVNode(w,{class:"upload-demo",action:o.schema.action,method:o.schema.method||"post",headers:S.value,data:z.value,multiple:i.value.multiple,drag:i.value.drag,accept:i.value.accept,limit:p.value,"auto-upload":i.value.autoUpload!==!1,disabled:C.value,"show-file-list":o.schema.ui?.showFileList,"before-upload":V,"on-exceed":b,onSuccess:F,onError:$},e.createSlots({default:e.withCtx(()=>[i.value.drag?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(s,{class:"el-icon--upload"},{default:e.withCtx(()=>[e.createVNode(f)]),_:1}),e.createElementVNode("div",ae,e.toDisplayString(o.schema.ui?.buttonText||"将文件拖到此处,或点击上传"),1)],64)):e.createCommentVNode("",!0)]),_:2},[i.value.drag?void 0:{name:"trigger",fn:e.withCtx(()=>[e.createVNode(B,{type:"primary"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.schema.ui?.buttonText||"点击上传"),1)]),_:1})]),key:"0"},o.schema.ui?.showTip?{name:"tip",fn:e.withCtx(()=>[e.createElementVNode("div",ce,e.toDisplayString(E.value),1)]),key:"1"}:void 0]),1032,["action","method","headers","data","multiple","drag","accept","limit","auto-upload","disabled","show-file-list"])])):e.createCommentVNode("",!0)}}}),[["__scopeId","data-v-607d52fb"]]),ie={class:"schema-table"},se={key:0,class:"table-toolbar"},de={key:1,class:"pagination-wrapper"},me=R(e.defineComponent({__name:"SchemaTable",props:{schema:{},files:{}},emits:["action","refresh","delete-before","delete-after"],setup(o,{emit:y}){const l=o,c=y,u=e.inject("schemaContext",{}),m=e.ref(!1),i=e.ref(1),p=e.ref(l.schema.ui?.pagination?.pageSize||20),C=e.ref(0),S=e.ref([]),z=e.computed(()=>{let t=[];return l.files?t=l.files:l.schema.dataSource.type==="static"?t=l.schema.dataSource.data:t=S.value,(l.schema.dataSource.type==="static"||l.files)&&(C.value=t.length),t}),E=(t,n)=>{if(!n)return t;if(n==="fileSize"){const f=Number(t);return isNaN(f)?t:f<1024?f+" B":f<1024*1024?(f/1024).toFixed(2)+" KB":(f/1024/1024).toFixed(2)+" MB"}return t},V=(t,n)=>{t.confirm&&!confirm(t.confirm.message||"确定吗?")||(t.key==="delete"&&c("delete-before",n),c("action",t.key,n),t.key==="delete"&&c("delete-after",n))},b=async()=>{if(l.schema.dataSource.type==="api"){m.value=!0;try{const t=l.schema.dataSource,n={...t.params};l.schema.ui?.pagination?.enabled&&(n.page=i.value,n.pageSize=p.value);for(const f in n)typeof n[f]=="string"&&(n[f]=O(n[f],u));console.log("Fetching Table Data:",t.url,n),t.url}catch(t){console.error(t)}finally{m.value=!1}}},F=t=>{p.value=t,b()},$=t=>{i.value=t,b()};return e.watch(()=>u.variables?.currentNode,t=>{t&&l.schema.dataSource.type==="api"&&b()},{deep:!0}),(t,n)=>{const f=e.resolveComponent("el-icon"),s=e.resolveComponent("el-button"),B=e.resolveComponent("el-table-column"),w=e.resolveComponent("el-table"),M=e.resolveComponent("el-pagination"),L=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",ie,[o.schema.toolbarActions?.length?(e.openBlock(),e.createElementBlock("div",se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.schema.toolbarActions,h=>(e.openBlock(),e.createBlock(s,{key:h.key,type:h.type||"default",onClick:k=>V(h,null)},{default:e.withCtx(()=>[h.icon?(e.openBlock(),e.createBlock(f,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h.icon)))]),_:2},1024)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(h.label),1)]),_:2},1032,["type","onClick"]))),128))])):e.createCommentVNode("",!0),e.withDirectives((e.openBlock(),e.createBlock(w,{data:z.value,stripe:o.schema.ui?.stripe,border:o.schema.ui?.border,size:o.schema.ui?.size,style:{width:"100%",height:"100%",flex:"1"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.schema.columns,h=>(e.openBlock(),e.createBlock(B,{key:h.prop,prop:h.prop,label:h.label,width:h.width,align:h.align,fixed:h.fixed,sortable:h.sortable},{default:e.withCtx(k=>[e.createTextVNode(e.toDisplayString(E(k.row[h.prop],h.formatter)),1)]),_:2},1032,["prop","label","width","align","fixed","sortable"]))),128)),o.schema.actions?.length?(e.openBlock(),e.createBlock(B,{key:0,label:"操作",fixed:"right",width:"200"},{default:e.withCtx(h=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.schema.actions,k=>(e.openBlock(),e.createBlock(s,{key:k.key,type:k.type||"primary",link:"",onClick:D=>V(k,h.row)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(k.label),1)]),_:2},1032,["type","onClick"]))),128))]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["data","stripe","border","size"])),[[L,m.value]]),o.schema.ui?.pagination?.enabled&&C.value>0?(e.openBlock(),e.createElementBlock("div",de,[e.createVNode(M,{"current-page":i.value,"onUpdate:currentPage":n[0]||(n[0]=h=>i.value=h),"page-size":p.value,"onUpdate:pageSize":n[1]||(n[1]=h=>p.value=h),"page-sizes":[10,20,50,100],layout:o.schema.ui?.pagination?.layout||"total, sizes, prev, pager, next, jumper",total:C.value,onSizeChange:F,onCurrentChange:$},null,8,["current-page","page-size","layout","total"])])):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-e3496cb9"]]),pe={class:"schema-template"},fe={class:"template-container"},ue={class:"tags-wrapper"},he={class:"tag-content"},ke={class:"tpl-name"},ye=R(e.defineComponent({__name:"SchemaTemplate",props:{templates:{}},setup(o){const y=l=>{window.open(l.url,"_blank")};return(l,c)=>{const u=e.resolveComponent("el-icon"),m=e.resolveComponent("el-tag");return e.openBlock(),e.createElementBlock("div",pe,[e.createElementVNode("div",fe,[c[0]||(c[0]=e.createElementVNode("span",{class:"label"},"可用模板:",-1)),e.createElementVNode("div",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.templates,(i,p)=>(e.openBlock(),e.createBlock(m,{key:p,class:"template-tag",type:"primary",effect:"light",onClick:C=>y(i)},{default:e.withCtx(()=>[e.createElementVNode("span",he,[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(e.unref(K.Download))]),_:1}),e.createElementVNode("span",ke,e.toDisplayString(i.name),1)])]),_:2},1032,["onClick"]))),128))])])])}}}),[["__scopeId","data-v-ea09f00e"]]),Ce={key:0,class:"schema-preview-container"},ge={class:"custom-header"},be=["id"],_e={class:"header-controls"},xe={class:"preview-content"},Be={class:"preview-content"},Ne=R(e.defineComponent({__name:"SchemaPreview",props:{schema:{},modelValue:{type:Boolean},file:{}},emits:["update:modelValue"],setup(o,{emit:y}){const l=o,c=y,u=e.ref(!1),m=e.computed({get:()=>l.modelValue,set:p=>{c("update:modelValue",p),p||setTimeout(()=>{u.value=!1},300)}}),i=()=>{u.value=!u.value};return e.watch(()=>l.schema.fullscreen,p=>{p!==void 0&&(u.value=p)},{immediate:!0}),(p,C)=>{const S=e.resolveComponent("el-icon"),z=e.resolveComponent("el-button"),E=e.resolveComponent("el-dialog"),V=e.resolveComponent("el-drawer");return m.value?(e.openBlock(),e.createElementBlock("div",Ce,[o.schema.mode==="dialog"?(e.openBlock(),e.createBlock(E,{key:0,modelValue:m.value,"onUpdate:modelValue":C[0]||(C[0]=b=>m.value=b),width:o.schema.width,fullscreen:u.value||o.schema.fullscreen,draggable:"","destroy-on-close":"","append-to-body":"",class:"preview-dialog","show-close":!1},{header:e.withCtx(({close:b,titleId:F,titleClass:$})=>[e.createElementVNode("div",ge,[e.createElementVNode("span",{id:F,class:e.normalizeClass($)},e.toDisplayString(o.schema.dialogTitle||"预览"),11,be),e.createElementVNode("div",_e,[e.createVNode(z,{link:"",onClick:i},{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value?"CopyDocument":"FullScreen")))]),_:1})]),_:1}),e.createVNode(z,{link:"",onClick:b},{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[e.createVNode(e.unref(K.Close))]),_:1})]),_:1},8,["onClick"])])])]),default:e.withCtx(()=>[e.createElementVNode("div",xe,[o.file?(e.openBlock(),e.createBlock(e.unref(j),{key:0,url:o.file.url,type:o.file.type,name:o.file.name},null,8,["url","type","name"])):e.createCommentVNode("",!0)])]),_:1},8,["modelValue","width","fullscreen"])):(e.openBlock(),e.createBlock(V,{key:1,modelValue:m.value,"onUpdate:modelValue":C[1]||(C[1]=b=>m.value=b),title:o.schema.dialogTitle||"预览",size:o.schema.width,"destroy-on-close":"","append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",Be,[o.file?(e.openBlock(),e.createBlock(e.unref(j),{key:0,url:o.file.url,type:o.file.type,name:o.file.name},null,8,["url","type","name"])):e.createCommentVNode("",!0)])]),_:1},8,["modelValue","title","size"]))])):e.createCommentVNode("",!0)}}}),[["__scopeId","data-v-6a6a8acf"]]),Ve={class:"tree-upload-container"},we={class:"content-pane"},Se={key:0,class:"top-section"},Ee={class:"table-section"},$e={class:"dialog-footer"},W=e.defineComponent({__name:"TreeUpload",props:{schema:{},mode:{default:"edit"}},emits:["upload-before","upload-success","upload-error","delete-before","delete-after"],setup(o,{expose:y,emit:l}){const c=o,u=l,m=e.ref(null),i=e.ref([]),p=e.ref(!1),C=e.ref(null),S=e.ref(!1),z=e.ref("addRoot"),E=e.reactive({label:""}),V=e.computed(()=>c.schema.tree.labelKey||"label"),b=e.ref(),F=e.ref(null),$=e.reactive({variables:{...c.schema.context?.variables,currentNode:void 0,currentFile:void 0}});e.provide("schemaContext",$);const t=e.ref(280),n=e.ref(!1),f=e.computed(()=>c.schema.tree.ui?.resizable!==!1),s=e.computed(()=>`${t.value}px`);e.watch(()=>c.schema.tree.ui?.width,a=>{if(typeof a=="number")t.value=a;else if(typeof a=="string"){const r=parseInt(a,10);isNaN(r)||(t.value=r)}},{immediate:!0});const B=a=>{f.value&&(n.value=!0,document.addEventListener("mousemove",w),document.addEventListener("mouseup",M),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},w=a=>{if(!n.value)return;const r=document.querySelector(".tree-upload-container");if(r){const g=r.getBoundingClientRect(),d=a.clientX-g.left;d>=150&&d<=800&&(t.value=d)}},M=()=>{n.value=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""},L=e.computed(()=>m.value?.meta?.templates||[]),h=e.computed(()=>m.value?P("upload",c.schema):!1),k=e.computed(()=>{switch(z.value){case"addRoot":return"添加根节点";case"addChild":return"添加子节点";case"addSibling":return"添加本级节点";case"edit":return"编辑节点";default:return"节点操作"}}),D=a=>typeof a=="string"?a.trim().toLowerCase()==="true":a===!0,I=a=>{if(console.log("Node Selected:",a),m.value=a,$.variables&&($.variables.currentNode=a),c.schema.table.dataSource.type==="static"){const r=c.schema.table.dataSource.data;i.value=r.filter(g=>g.meta?.nodeId===String(a.id))}},J=(a,r)=>{if(console.log("树动作:",a,r),!P(a,c.schema)){A.ElMessage.error("权限不足");return}if(c.schema.tree.dataSource.type!=="static"){A.ElMessage.warning(`触发动作 ${a} (需要 API 实现)`);return}if(a==="delete"){if(!r||!confirm(`确定删除节点 "${r.label}" 吗?`))return;const g=c.schema.tree.dataSource.data,d=_=>{const x=_.findIndex(T=>T.id===r.id);if(x>-1)return _.splice(x,1),!0;for(const T of _)if(T.children&&d(T.children))return!0;return!1};d(g)&&m.value?.id===r.id&&(m.value=null);return}(a==="addRoot"||a==="addChild"||a==="addSibling"||a==="edit")&&(z.value=a,F.value=r,E.label=a==="edit"&&r?r[V.value]||r.label:"",S.value=!0,e.nextTick(()=>{b.value?.clearValidate()}))},ze=()=>{b.value?.validate(a=>{if(!a||c.schema.tree.dataSource.type!=="static")return;const r=c.schema.tree.dataSource.data,g=E.label,d=z.value,_=F.value,x=T=>{const N={id:String(Date.now()),children:[]};return N[V.value]=T,V.value!=="label"&&(N.label=T),N};if(d==="addRoot")r.push(x(g));else if(d==="addChild")_&&(_.children||(_.children=[]),_.children.push(x(g)));else if(d==="addSibling"){if(_){const T=N=>{const X=N.findIndex(q=>q.id===_.id);if(X>-1)return N.splice(X+1,0,x(g)),!0;for(const q of N)if(q.children&&T(q.children))return!0;return!1};T(r)}}else d==="edit"&&_&&(_[V.value]=g,V.value!=="label"&&(_.label=g));S.value=!1})},De=a=>{if(console.log("上传成功:",a),u("upload-success",a),c.schema.table.dataSource.type==="static"&&m.value){const r={id:Date.now(),name:"已上传文件.png",size:1024,url:"#",type:"png",meta:{nodeId:String(m.value.id)}};c.schema.table.dataSource.data.push(r),I(m.value)}},Ue=(a,r)=>{if(console.log("Table Action:",a,r),$.variables&&($.variables.currentFile=r),!P(a,c.schema)){A.ElMessage.error("权限不足");return}if(a==="preview")C.value=r,p.value=!0;else if(a==="delete"&&c.schema.table.dataSource.type==="static"){const g=c.schema.table.dataSource.data.findIndex(d=>d.id===r.id);g>-1&&(c.schema.table.dataSource.data.splice(g,1),m.value&&I(m.value))}},Fe=async()=>{const a=[],r=[],g=d=>{const _=D(d.required);if(_||d.minCount&&d.minCount>0||d.maxCount&&d.maxCount>0){let x=0;c.schema.table.dataSource.type==="static"?x=c.schema.table.dataSource.data.filter(N=>String(N.meta?.nodeId)===String(d.id)).length:x=d.meta?.fileCount||0,_&&x===0?(a.push(`节点 "${d.label}" 必须上传文件`),r.push(d)):d.minCount&&x<d.minCount?(a.push(`节点 "${d.label}" 至少需要 ${d.minCount} 个文件 (当前: ${x})`),r.push(d)):d.maxCount&&x>d.maxCount&&(a.push(`节点 "${d.label}" 最多允许 ${d.maxCount} 个文件 (当前: ${x})`),r.push(d))}d.children&&d.children.forEach(g)};return c.schema.tree.dataSource.type==="static"?c.schema.tree.dataSource.data.forEach(g):console.warn("API 模式下的树验证需要确保数据已加载或通过 meta 携带统计信息"),a.length>0?Promise.reject({valid:!1,errors:a,failedNodes:r}):Promise.resolve({valid:!0})},Me=a=>u("upload-before",a),Ie=a=>u("upload-error",a),Le=a=>u("delete-before",a),Ae=a=>u("delete-after",a);return y({validate:Fe}),(a,r)=>{const g=e.resolveComponent("el-input"),d=e.resolveComponent("el-form-item"),_=e.resolveComponent("el-form"),x=e.resolveComponent("el-button"),T=e.resolveComponent("el-dialog");return e.openBlock(),e.createElementBlock("div",Ve,[e.createElementVNode("div",{class:"tree-pane",style:e.normalizeStyle({width:s.value})},[e.createVNode(ne,{schema:o.schema.tree,onNodeClick:I,onAction:J},null,8,["schema"])],4),f.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"resize-handle",onMousedown:B},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",we,[o.mode==="edit"?(e.openBlock(),e.createElementBlock("div",Se,[L.value&&L.value.length>0?(e.openBlock(),e.createBlock(ye,{key:0,templates:L.value},null,8,["templates"])):e.createCommentVNode("",!0),o.schema.upload?(e.openBlock(),e.createBlock(re,{key:1,schema:o.schema.upload,disabled:!h.value,"file-count":i.value.length,onUploadBefore:Me,onUploadSuccess:De,onUploadError:Ie},null,8,["schema","disabled","file-count"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",Ee,[e.createVNode(me,{schema:o.schema.table,files:i.value,onAction:Ue,onDeleteBefore:Le,onDeleteAfter:Ae},null,8,["schema","files"])])]),o.schema.preview?(e.openBlock(),e.createBlock(Ne,{key:1,modelValue:p.value,"onUpdate:modelValue":r[0]||(r[0]=N=>p.value=N),schema:o.schema.preview,file:C.value},null,8,["modelValue","schema","file"])):e.createCommentVNode("",!0),e.createVNode(T,{modelValue:S.value,"onUpdate:modelValue":r[3]||(r[3]=N=>S.value=N),title:k.value,width:"400px","append-to-body":"","destroy-on-close":""},{footer:e.withCtx(()=>[e.createElementVNode("span",$e,[e.createVNode(x,{onClick:r[2]||(r[2]=N=>S.value=!1)},{default:e.withCtx(()=>[...r[4]||(r[4]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(x,{type:"primary",onClick:ze},{default:e.withCtx(()=>[...r[5]||(r[5]=[e.createTextVNode("确定",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createVNode(_,{model:E,ref_key:"nodeFormRef",ref:b,"label-width":"80px"},{default:e.withCtx(()=>[e.createVNode(d,{label:"节点名称",prop:"label",rules:[{required:!0,message:"请输入节点名称",trigger:"blur"}]},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:E.label,"onUpdate:modelValue":r[1]||(r[1]=N=>E.label=N),placeholder:"请输入节点名称"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}}),Te={install(o){o.component("TreeUpload",W)}};U.TreeUpload=W,U.default=Te,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1
|
+
(function(U,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus"),require("@element-plus/icons-vue"),require("file-preview-vue3-ts")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","@element-plus/icons-vue","file-preview-vue3-ts"],e):(U=typeof globalThis<"u"?globalThis:U||self,e(U.TreeUploadVue3={},U.Vue,U.ElementPlus,U.ElementPlusIconsVue,U.FilePreviewVue3Ts))})(this,(function(U,e,A,P,K){"use strict";function q(o,y,l){return y.permissions?y.permissions.default?.[o]!==!1:!0}function j(o,y){if(!o)return o;let l=o;const c=y.variables||{};return c.currentNode&&(l=l.replace(/\$currentNode\.id/g,String(c.currentNode.id)),l=l.replace(/\$currentNode\.label/g,String(c.currentNode.label||""))),l}function X(o,y){const{id:l,pId:c,children:f}=y,m=new Map,i=[];for(const p of o)p[f]=p[f]||[],m.set(p[l],p);for(const p of o){const C=p[c];C&&m.has(C)?m.get(C)[f].push(p):i.push(p)}return i}const Y={class:"schema-tree"},G={key:0,class:"tree-toolbar"},H={class:"custom-tree-node"},Q={class:"node-label"},Z={key:0,class:"required-star"},v={key:0,class:"actions"},ee=["onClick"],te=e.defineComponent({__name:"SchemaTree",props:{schema:{}},emits:["node-click","action"],setup(o,{emit:y}){const l=o,c=y,f=e.ref(),m=e.ref(!1),i=e.ref({x:0,y:0}),p=e.ref(null),C=e.computed(()=>{let s=[];if(l.schema.dataSource.type==="static")s=JSON.parse(JSON.stringify(l.schema.dataSource.data));else return[];return l.schema.parentIdKey?X(s,{id:l.schema.nodeKey||"id",pId:l.schema.parentIdKey,children:l.schema.childrenKey||"children"}):s}),S=e.computed(()=>({label:l.schema.labelKey||"label",children:l.schema.childrenKey||"children"})),z=(s,B)=>{const w=l.schema.labelKey||"label";return s?.[w]||B||s?.label||""},E=s=>typeof s=="string"?s.trim().toLowerCase()==="true":s===!0,V=e.computed(()=>l.schema.actions?.filter(s=>s.position==="toolbar")||[]),b=e.computed(()=>l.schema.actions?.filter(s=>s.position==="node")||[]),F=e.computed(()=>l.schema.actions?.filter(s=>s.position==="contextMenu")||[]),$=s=>{m.value=!1,c("node-click",s)},t=(s,B)=>{F.value.length!==0&&(s.preventDefault(),m.value=!0,i.value={x:s.clientX,y:s.clientY},p.value=B)},n=(s,B)=>{m.value=!1,!(s.confirm&&!confirm(s.confirm.message||"确定吗?"))&&c("action",s.key,B)},u=()=>{m.value=!1};return e.onMounted(()=>{document.addEventListener("click",u)}),e.onUnmounted(()=>{document.removeEventListener("click",u)}),(s,B)=>{const w=e.resolveComponent("el-icon"),M=e.resolveComponent("el-button"),I=e.resolveComponent("el-tooltip"),h=e.resolveComponent("el-tree");return e.openBlock(),e.createElementBlock("div",Y,[V.value.length?(e.openBlock(),e.createElementBlock("div",G,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,k=>(e.openBlock(),e.createBlock(M,{key:k.key,type:"primary",link:"",onClick:D=>n(k,null)},{default:e.withCtx(()=>[k.icon?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.icon)))]),_:2},1024)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(k.label),1)]),_:2},1032,["onClick"]))),128))])):e.createCommentVNode("",!0),e.createVNode(h,{ref_key:"treeRef",ref:f,data:C.value,"node-key":o.schema.nodeKey||"id",props:S.value,"default-expand-all":o.schema.ui?.defaultExpandAll,"highlight-current":o.schema.ui?.highlightCurrent,"expand-on-click-node":!1,onNodeClick:$,onNodeContextmenu:t},{default:e.withCtx(({node:k,data:D})=>[e.createElementVNode("span",H,[e.createElementVNode("span",Q,[E(D.required)||D.minCount&&D.minCount>0?(e.openBlock(),e.createElementBlock("span",Z,"*")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(z(D,k.label)),1)]),b.value.length?(e.openBlock(),e.createElementBlock("span",v,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,L=>(e.openBlock(),e.createBlock(I,{key:L.key,content:L.label,placement:"top","show-after":200},{default:e.withCtx(()=>[e.createVNode(M,{link:"",type:"primary",onClick:e.withModifiers(W=>n(L,D),["stop"])},{default:e.withCtx(()=>[L.icon?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(L.icon)))]),_:2},1024)):e.createCommentVNode("",!0)]),_:2},1032,["onClick"])]),_:2},1032,["content"]))),128))])):e.createCommentVNode("",!0)])]),_:1},8,["data","node-key","props","default-expand-all","highlight-current"]),m.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"context-menu",style:e.normalizeStyle({left:i.value.x+"px",top:i.value.y+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,k=>(e.openBlock(),e.createElementBlock("div",{key:k.key,class:"context-menu-item",onClick:D=>n(k,p.value)},[k.icon?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.icon)))]),_:2},1024)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(k.label),1)],8,ee))),128))],4)):e.createCommentVNode("",!0)])}}}),oe={key:0,class:"schema-upload"},ne={class:"el-upload__text"},le={class:"el-upload__tip"},ae=((o,y)=>{const l=o.__vccOpts||o;for(const[c,f]of y)l[c]=f;return l})(e.defineComponent({__name:"SchemaUpload",props:{schema:{},disabled:{type:Boolean},fileCount:{}},emits:["upload-success","upload-error","upload-before"],setup(o,{emit:y}){const l=o,c=y,f=e.inject("schemaContext",{}),m=t=>{if(t==null||t==="")return;const n=Number(t);if(!(!Number.isFinite(n)||n<=0))return n},i=e.computed(()=>{const t=f.variables?.currentNode,n=t?.meta?.upload||{};let u=m(l.schema.limit);const s=m(t?.maxCount),B=m(n.limit);s!==void 0?u=s:B!==void 0&&(u=B);let w=n.maxSize;t?.maxSize!==void 0&&(w=t.maxSize);let M=l.schema.accept;t?.accept!==void 0?M=t.accept:n.accept!==void 0&&(M=n.accept);let I=n.minLimit;t?.minCount!==void 0&&(I=t.minCount);const h=t?.required||!1,k=l.schema.ui||{},D=n.ui||{},L={...k,...D};return{...l.schema,...n,ui:L,limit:u,maxSize:w,minLimit:I,accept:M,required:h,multiple:n.multiple??l.schema.multiple,drag:n.drag??l.schema.drag,autoUpload:n.autoUpload??l.schema.autoUpload}}),p=e.computed(()=>{if(i.value.limit===void 0)return 1/0;const t=l.fileCount||0;return Math.max(0,i.value.limit-t)}),C=e.computed(()=>!!(l.disabled||i.value.limit!==void 0&&p.value<=0)),S=e.computed(()=>l.schema.headers||{}),z=e.computed(()=>{const t=l.schema.data||{},n={};for(const u in t){const s=t[u];typeof s=="string"?n[u]=j(s,f):n[u]=s}return n}),E=e.computed(()=>{let t=i.value.ui?.tipText||"";const n=[];if(i.value.maxSize){const u=(i.value.maxSize/1024/1024).toFixed(1);n.push(`大小限制 ${u}MB`)}if(i.value.limit){const u=l.fileCount||0;n.push(`数量限制 ${i.value.limit}个 (已上传 ${u})`)}return i.value.minLimit?n.push(`最少 ${i.value.minLimit}个`):i.value.required&&n.push("必填"),i.value.accept&&n.push(`格式 ${i.value.accept}`),n.length?`${t} (${n.join(", ")})`:t}),V=t=>{const n=i.value.maxSize;return n&&t.size>n?(A.ElMessage.error(`文件大小不能超过 ${(n/1024/1024).toFixed(1)}MB!`),!1):(c("upload-before",{file:t,context:f}),!0)},b=()=>{A.ElMessage.warning(`当前限制选择 ${i.value.limit} 个文件,还能上传 ${p.value} 个`)},F=t=>{c("upload-success",t)},$=t=>{c("upload-error",t)};return(t,n)=>{const u=e.resolveComponent("upload-filled"),s=e.resolveComponent("el-icon"),B=e.resolveComponent("el-button"),w=e.resolveComponent("el-upload");return o.schema.enabled?(e.openBlock(),e.createElementBlock("div",oe,[e.createVNode(w,{class:"upload-demo",action:o.schema.action,method:o.schema.method||"post",headers:S.value,data:z.value,multiple:i.value.multiple,drag:i.value.drag,accept:i.value.accept,limit:p.value,"auto-upload":i.value.autoUpload!==!1,disabled:C.value,"show-file-list":o.schema.ui?.showFileList,"before-upload":V,"on-exceed":b,onSuccess:F,onError:$},e.createSlots({default:e.withCtx(()=>[i.value.drag?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(s,{class:"el-icon--upload"},{default:e.withCtx(()=>[e.createVNode(u)]),_:1}),e.createElementVNode("div",ne,e.toDisplayString(o.schema.ui?.buttonText||"将文件拖到此处,或点击上传"),1)],64)):e.createCommentVNode("",!0)]),_:2},[i.value.drag?void 0:{name:"trigger",fn:e.withCtx(()=>[e.createVNode(B,{type:"primary"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.schema.ui?.buttonText||"点击上传"),1)]),_:1})]),key:"0"},o.schema.ui?.showTip?{name:"tip",fn:e.withCtx(()=>[e.createElementVNode("div",le,e.toDisplayString(E.value),1)]),key:"1"}:void 0]),1032,["action","method","headers","data","multiple","drag","accept","limit","auto-upload","disabled","show-file-list"])])):e.createCommentVNode("",!0)}}}),[["__scopeId","data-v-607d52fb"]]),ce={class:"schema-table"},re={key:0,class:"table-toolbar"},ie={key:1,class:"pagination-wrapper"},se=e.defineComponent({__name:"SchemaTable",props:{schema:{},files:{}},emits:["action","refresh","delete-before","delete-after"],setup(o,{emit:y}){const l=o,c=y,f=e.inject("schemaContext",{}),m=e.ref(!1),i=e.ref(1),p=e.ref(l.schema.ui?.pagination?.pageSize||20),C=e.ref(0),S=e.ref([]),z=e.computed(()=>{let t=[];return l.files?t=l.files:l.schema.dataSource.type==="static"?t=l.schema.dataSource.data:t=S.value,(l.schema.dataSource.type==="static"||l.files)&&(C.value=t.length),t}),E=(t,n)=>{if(!n)return t;if(n==="fileSize"){const u=Number(t);return isNaN(u)?t:u<1024?u+" B":u<1024*1024?(u/1024).toFixed(2)+" KB":(u/1024/1024).toFixed(2)+" MB"}return t},V=(t,n)=>{t.confirm&&!confirm(t.confirm.message||"确定吗?")||(t.key==="delete"&&c("delete-before",n),c("action",t.key,n),t.key==="delete"&&c("delete-after",n))},b=async()=>{if(l.schema.dataSource.type==="api"){m.value=!0;try{const t=l.schema.dataSource,n={...t.params};l.schema.ui?.pagination?.enabled&&(n.page=i.value,n.pageSize=p.value);for(const u in n)typeof n[u]=="string"&&(n[u]=j(n[u],f));console.log("Fetching Table Data:",t.url,n),t.url}catch(t){console.error(t)}finally{m.value=!1}}},F=t=>{p.value=t,b()},$=t=>{i.value=t,b()};return e.watch(()=>f.variables?.currentNode,t=>{t&&l.schema.dataSource.type==="api"&&b()},{deep:!0}),(t,n)=>{const u=e.resolveComponent("el-icon"),s=e.resolveComponent("el-button"),B=e.resolveComponent("el-table-column"),w=e.resolveComponent("el-table"),M=e.resolveComponent("el-pagination"),I=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",ce,[o.schema.toolbarActions?.length?(e.openBlock(),e.createElementBlock("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.schema.toolbarActions,h=>(e.openBlock(),e.createBlock(s,{key:h.key,type:h.type||"default",onClick:k=>V(h,null)},{default:e.withCtx(()=>[h.icon?(e.openBlock(),e.createBlock(u,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(h.icon)))]),_:2},1024)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(h.label),1)]),_:2},1032,["type","onClick"]))),128))])):e.createCommentVNode("",!0),e.withDirectives((e.openBlock(),e.createBlock(w,{data:z.value,stripe:o.schema.ui?.stripe,border:o.schema.ui?.border,size:o.schema.ui?.size,style:{width:"100%",height:"100%",flex:"1"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.schema.columns,h=>(e.openBlock(),e.createBlock(B,{key:h.prop,prop:h.prop,label:h.label,width:h.width,align:h.align,fixed:h.fixed,sortable:h.sortable},{default:e.withCtx(k=>[e.createTextVNode(e.toDisplayString(E(k.row[h.prop],h.formatter)),1)]),_:2},1032,["prop","label","width","align","fixed","sortable"]))),128)),o.schema.actions?.length?(e.openBlock(),e.createBlock(B,{key:0,label:"操作",fixed:"right",width:"200"},{default:e.withCtx(h=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.schema.actions,k=>(e.openBlock(),e.createBlock(s,{key:k.key,type:k.type||"primary",link:"",onClick:D=>V(k,h.row)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(k.label),1)]),_:2},1032,["type","onClick"]))),128))]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["data","stripe","border","size"])),[[I,m.value]]),o.schema.ui?.pagination?.enabled&&C.value>0?(e.openBlock(),e.createElementBlock("div",ie,[e.createVNode(M,{"current-page":i.value,"onUpdate:currentPage":n[0]||(n[0]=h=>i.value=h),"page-size":p.value,"onUpdate:pageSize":n[1]||(n[1]=h=>p.value=h),"page-sizes":[10,20,50,100],layout:o.schema.ui?.pagination?.layout||"total, sizes, prev, pager, next, jumper",total:C.value,onSizeChange:F,onCurrentChange:$},null,8,["current-page","page-size","layout","total"])])):e.createCommentVNode("",!0)])}}}),de={class:"schema-template"},me={class:"template-container"},pe={class:"tags-wrapper"},ue={class:"tag-content"},fe={class:"tpl-name"},he=e.defineComponent({__name:"SchemaTemplate",props:{templates:{}},setup(o){const y=l=>{window.open(l.url,"_blank")};return(l,c)=>{const f=e.resolveComponent("el-icon"),m=e.resolveComponent("el-tag");return e.openBlock(),e.createElementBlock("div",de,[e.createElementVNode("div",me,[c[0]||(c[0]=e.createElementVNode("span",{class:"label"},"可用模板:",-1)),e.createElementVNode("div",pe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.templates,(i,p)=>(e.openBlock(),e.createBlock(m,{key:p,class:"template-tag",type:"primary",effect:"light",onClick:C=>y(i)},{default:e.withCtx(()=>[e.createElementVNode("span",ue,[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(e.unref(P.Download))]),_:1}),e.createElementVNode("span",fe,e.toDisplayString(i.name),1)])]),_:2},1032,["onClick"]))),128))])])])}}}),ke={key:0,class:"schema-preview-container"},ye={class:"custom-header"},Ce=["id"],ge={class:"header-controls"},be={class:"preview-content"},xe={class:"preview-content"},_e=e.defineComponent({__name:"SchemaPreview",props:{schema:{},modelValue:{type:Boolean},file:{}},emits:["update:modelValue"],setup(o,{emit:y}){const l=o,c=y,f=e.ref(!1),m=e.computed({get:()=>l.modelValue,set:p=>{c("update:modelValue",p),p||setTimeout(()=>{f.value=!1},300)}}),i=()=>{f.value=!f.value};return e.watch(()=>l.schema.fullscreen,p=>{p!==void 0&&(f.value=p)},{immediate:!0}),(p,C)=>{const S=e.resolveComponent("el-icon"),z=e.resolveComponent("el-button"),E=e.resolveComponent("el-dialog"),V=e.resolveComponent("el-drawer");return m.value?(e.openBlock(),e.createElementBlock("div",ke,[o.schema.mode==="dialog"?(e.openBlock(),e.createBlock(E,{key:0,modelValue:m.value,"onUpdate:modelValue":C[0]||(C[0]=b=>m.value=b),width:o.schema.width,fullscreen:f.value||o.schema.fullscreen,draggable:"","destroy-on-close":"","append-to-body":"",class:"preview-dialog","show-close":!1},{header:e.withCtx(({close:b,titleId:F,titleClass:$})=>[e.createElementVNode("div",ye,[e.createElementVNode("span",{id:F,class:e.normalizeClass($)},e.toDisplayString(o.schema.dialogTitle||"预览"),11,Ce),e.createElementVNode("div",ge,[e.createVNode(z,{link:"",onClick:i},{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.value?"CopyDocument":"FullScreen")))]),_:1})]),_:1}),e.createVNode(z,{link:"",onClick:b},{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[e.createVNode(e.unref(P.Close))]),_:1})]),_:1},8,["onClick"])])])]),default:e.withCtx(()=>[e.createElementVNode("div",be,[o.file?(e.openBlock(),e.createBlock(e.unref(K),{key:0,url:o.file.url,type:o.file.type,name:o.file.name},null,8,["url","type","name"])):e.createCommentVNode("",!0)])]),_:1},8,["modelValue","width","fullscreen"])):(e.openBlock(),e.createBlock(V,{key:1,modelValue:m.value,"onUpdate:modelValue":C[1]||(C[1]=b=>m.value=b),title:o.schema.dialogTitle||"预览",size:o.schema.width,"destroy-on-close":"","append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",xe,[o.file?(e.openBlock(),e.createBlock(e.unref(K),{key:0,url:o.file.url,type:o.file.type,name:o.file.name},null,8,["url","type","name"])):e.createCommentVNode("",!0)])]),_:1},8,["modelValue","title","size"]))])):e.createCommentVNode("",!0)}}}),Be={class:"tree-upload-container"},Ne={class:"tree-upload-content-pane"},Ve={key:0,class:"top-section"},we={class:"table-section"},Se={class:"dialog-footer"},O=e.defineComponent({__name:"TreeUpload",props:{schema:{},mode:{default:"edit"}},emits:["upload-before","upload-success","upload-error","delete-before","delete-after"],setup(o,{expose:y,emit:l}){const c=o,f=l,m=e.ref(null),i=e.ref([]),p=e.ref(!1),C=e.ref(null),S=e.ref(!1),z=e.ref("addRoot"),E=e.reactive({label:""}),V=e.computed(()=>c.schema.tree.labelKey||"label"),b=e.ref(),F=e.ref(null),$=e.reactive({variables:{...c.schema.context?.variables,currentNode:void 0,currentFile:void 0}});e.provide("schemaContext",$);const t=e.ref(280),n=e.ref(!1),u=e.computed(()=>c.schema.tree.ui?.resizable!==!1),s=e.computed(()=>`${t.value}px`);e.watch(()=>c.schema.tree.ui?.width,a=>{if(typeof a=="number")t.value=a;else if(typeof a=="string"){const r=parseInt(a,10);isNaN(r)||(t.value=r)}},{immediate:!0});const B=a=>{u.value&&(n.value=!0,document.addEventListener("mousemove",w),document.addEventListener("mouseup",M),document.body.style.cursor="col-resize",document.body.style.userSelect="none")},w=a=>{if(!n.value)return;const r=document.querySelector(".tree-upload-container");if(r){const g=r.getBoundingClientRect(),d=a.clientX-g.left;d>=150&&d<=800&&(t.value=d)}},M=()=>{n.value=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",M),document.body.style.cursor="",document.body.style.userSelect=""},I=e.computed(()=>m.value?.meta?.templates||[]),h=e.computed(()=>m.value?q("upload",c.schema):!1),k=e.computed(()=>{switch(z.value){case"addRoot":return"添加根节点";case"addChild":return"添加子节点";case"addSibling":return"添加本级节点";case"edit":return"编辑节点";default:return"节点操作"}}),D=a=>typeof a=="string"?a.trim().toLowerCase()==="true":a===!0,L=a=>{if(console.log("Node Selected:",a),m.value=a,$.variables&&($.variables.currentNode=a),c.schema.table.dataSource.type==="static"){const r=c.schema.table.dataSource.data;i.value=r.filter(g=>g.meta?.nodeId===String(a.id))}},W=(a,r)=>{if(console.log("树动作:",a,r),!q(a,c.schema)){A.ElMessage.error("权限不足");return}if(c.schema.tree.dataSource.type!=="static"){A.ElMessage.warning(`触发动作 ${a} (需要 API 实现)`);return}if(a==="delete"){if(!r||!confirm(`确定删除节点 "${r.label}" 吗?`))return;const g=c.schema.tree.dataSource.data,d=x=>{const _=x.findIndex(T=>T.id===r.id);if(_>-1)return x.splice(_,1),!0;for(const T of x)if(T.children&&d(T.children))return!0;return!1};d(g)&&m.value?.id===r.id&&(m.value=null);return}(a==="addRoot"||a==="addChild"||a==="addSibling"||a==="edit")&&(z.value=a,F.value=r,E.label=a==="edit"&&r?r[V.value]||r.label:"",S.value=!0,e.nextTick(()=>{b.value?.clearValidate()}))},$e=()=>{b.value?.validate(a=>{if(!a||c.schema.tree.dataSource.type!=="static")return;const r=c.schema.tree.dataSource.data,g=E.label,d=z.value,x=F.value,_=T=>{const N={id:String(Date.now()),children:[]};return N[V.value]=T,V.value!=="label"&&(N.label=T),N};if(d==="addRoot")r.push(_(g));else if(d==="addChild")x&&(x.children||(x.children=[]),x.children.push(_(g)));else if(d==="addSibling"){if(x){const T=N=>{const J=N.findIndex(R=>R.id===x.id);if(J>-1)return N.splice(J+1,0,_(g)),!0;for(const R of N)if(R.children&&T(R.children))return!0;return!1};T(r)}}else d==="edit"&&x&&(x[V.value]=g,V.value!=="label"&&(x.label=g));S.value=!1})},Te=a=>{if(console.log("上传成功:",a),f("upload-success",a),c.schema.table.dataSource.type==="static"&&m.value){const r={id:Date.now(),name:"已上传文件.png",size:1024,url:"#",type:"png",meta:{nodeId:String(m.value.id)}};c.schema.table.dataSource.data.push(r),L(m.value)}},ze=(a,r)=>{if(console.log("Table Action:",a,r),$.variables&&($.variables.currentFile=r),!q(a,c.schema)){A.ElMessage.error("权限不足");return}if(a==="preview")C.value=r,p.value=!0;else if(a==="delete"&&c.schema.table.dataSource.type==="static"){const g=c.schema.table.dataSource.data.findIndex(d=>d.id===r.id);g>-1&&(c.schema.table.dataSource.data.splice(g,1),m.value&&L(m.value))}},De=async()=>{const a=[],r=[],g=d=>{const x=D(d.required);if(x||d.minCount&&d.minCount>0||d.maxCount&&d.maxCount>0){let _=0;c.schema.table.dataSource.type==="static"?_=c.schema.table.dataSource.data.filter(N=>String(N.meta?.nodeId)===String(d.id)).length:_=d.meta?.fileCount||0,x&&_===0?(a.push(`节点 "${d.label}" 必须上传文件`),r.push(d)):d.minCount&&_<d.minCount?(a.push(`节点 "${d.label}" 至少需要 ${d.minCount} 个文件 (当前: ${_})`),r.push(d)):d.maxCount&&_>d.maxCount&&(a.push(`节点 "${d.label}" 最多允许 ${d.maxCount} 个文件 (当前: ${_})`),r.push(d))}d.children&&d.children.forEach(g)};return c.schema.tree.dataSource.type==="static"?c.schema.tree.dataSource.data.forEach(g):console.warn("API 模式下的树验证需要确保数据已加载或通过 meta 携带统计信息"),a.length>0?Promise.reject({valid:!1,errors:a,failedNodes:r}):Promise.resolve({valid:!0})},Ue=a=>f("upload-before",a),Fe=a=>f("upload-error",a),Me=a=>f("delete-before",a),Le=a=>f("delete-after",a);return y({validate:De}),(a,r)=>{const g=e.resolveComponent("el-input"),d=e.resolveComponent("el-form-item"),x=e.resolveComponent("el-form"),_=e.resolveComponent("el-button"),T=e.resolveComponent("el-dialog");return e.openBlock(),e.createElementBlock("div",Be,[e.createElementVNode("div",{class:"tree-pane",style:e.normalizeStyle({width:s.value})},[e.createVNode(te,{schema:o.schema.tree,onNodeClick:L,onAction:W},null,8,["schema"])],4),u.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"resize-handle",onMousedown:B},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",Ne,[o.mode==="edit"?(e.openBlock(),e.createElementBlock("div",Ve,[I.value&&I.value.length>0?(e.openBlock(),e.createBlock(he,{key:0,templates:I.value},null,8,["templates"])):e.createCommentVNode("",!0),o.schema.upload?(e.openBlock(),e.createBlock(ae,{key:1,schema:o.schema.upload,disabled:!h.value,"file-count":i.value.length,onUploadBefore:Ue,onUploadSuccess:Te,onUploadError:Fe},null,8,["schema","disabled","file-count"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",we,[e.createVNode(se,{schema:o.schema.table,files:i.value,onAction:ze,onDeleteBefore:Me,onDeleteAfter:Le},null,8,["schema","files"])])]),o.schema.preview?(e.openBlock(),e.createBlock(_e,{key:1,modelValue:p.value,"onUpdate:modelValue":r[0]||(r[0]=N=>p.value=N),schema:o.schema.preview,file:C.value},null,8,["modelValue","schema","file"])):e.createCommentVNode("",!0),e.createVNode(T,{modelValue:S.value,"onUpdate:modelValue":r[3]||(r[3]=N=>S.value=N),title:k.value,width:"400px","append-to-body":"","destroy-on-close":""},{footer:e.withCtx(()=>[e.createElementVNode("span",Se,[e.createVNode(_,{onClick:r[2]||(r[2]=N=>S.value=!1)},{default:e.withCtx(()=>[...r[4]||(r[4]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(_,{type:"primary",onClick:$e},{default:e.withCtx(()=>[...r[5]||(r[5]=[e.createTextVNode("确定",-1)])]),_:1})])]),default:e.withCtx(()=>[e.createVNode(x,{model:E,ref_key:"nodeFormRef",ref:b,"label-width":"80px"},{default:e.withCtx(()=>[e.createVNode(d,{label:"节点名称",prop:"label",rules:[{required:!0,message:"请输入节点名称",trigger:"blur"}]},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:E.label,"onUpdate:modelValue":r[1]||(r[1]=N=>E.label=N),placeholder:"请输入节点名称"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}}),Ee={install(o){o.component("TreeUpload",O)}};U.TreeUpload=O,U.default=Ee,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|