@skyfox2000/webui 0.1.1 → 0.1.3

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.
Files changed (56) hide show
  1. package/lib/AceEditor.d.ts +0 -3
  2. package/lib/BasicLayout.d.ts +0 -3
  3. package/lib/Error403.d.ts +0 -3
  4. package/lib/Error404.d.ts +0 -3
  5. package/lib/ExcelForm.d.ts +0 -3
  6. package/lib/UploadForm.d.ts +0 -3
  7. package/lib/assets/modules/{index-FzWSvscZ.js → index-B8vL5FiT.js} +1 -1
  8. package/lib/assets/modules/menuTabs-DQt4U8CY.js +638 -0
  9. package/lib/assets/modules/uploadList-sP-EZUPi.js +182 -0
  10. package/lib/components/content/index.d.ts +0 -4
  11. package/lib/components/content/index.d.ts.map +1 -1
  12. package/lib/components/form/autoComplete/index.vue.d.ts +3 -3
  13. package/lib/components/form/cascader/index.vue.d.ts +3 -3
  14. package/lib/components/form/checkbox/index.vue.d.ts +1 -1
  15. package/lib/components/form/index.d.ts +0 -2
  16. package/lib/components/form/index.d.ts.map +1 -1
  17. package/lib/components/form/radio/index.vue.d.ts +3 -3
  18. package/lib/components/form/select/index.vue.d.ts +3 -3
  19. package/lib/components/form/transfer/index.vue.d.ts +2 -2
  20. package/lib/components/form/treeSelect/index.vue.d.ts +2 -2
  21. package/lib/components/index.d.ts +3 -6
  22. package/lib/components/index.d.ts.map +1 -1
  23. package/lib/components/layout/index.d.ts +0 -2
  24. package/lib/components/layout/index.d.ts.map +1 -1
  25. package/lib/es/AceEditor/index.js +9 -11
  26. package/lib/es/BasicLayout/index.js +94 -2
  27. package/lib/es/Error403/index.js +31 -2
  28. package/lib/es/Error404/index.js +31 -2
  29. package/lib/es/ExcelForm/index.js +315 -3
  30. package/lib/es/UploadForm/index.js +133 -3
  31. package/lib/webui.css +1 -1
  32. package/lib/webui.es.js +1565 -1573
  33. package/package.json +2 -2
  34. package/src/components/content/index.ts +4 -4
  35. package/src/components/form/index.ts +2 -2
  36. package/src/components/index.ts +1 -10
  37. package/src/components/layout/index.ts +2 -2
  38. package/lib/assets/modules/basicLayout-YP_-EySb.js +0 -726
  39. package/lib/assets/modules/error403-Bi0E2twj.js +0 -33
  40. package/lib/assets/modules/error404-BF7vasR_.js +0 -33
  41. package/lib/assets/modules/excelForm-WJVQmaDT.js +0 -317
  42. package/lib/assets/modules/uploadForm-CwXiG05t.js +0 -309
  43. package/lib/components/content/dialog/excelForm.vue.d.ts +0 -31
  44. package/lib/components/content/dialog/excelForm.vue.d.ts.map +0 -1
  45. package/lib/components/content/dialog/uploadForm.vue.d.ts +0 -25
  46. package/lib/components/content/dialog/uploadForm.vue.d.ts.map +0 -1
  47. package/lib/components/error/error403.vue.d.ts +0 -4
  48. package/lib/components/error/error403.vue.d.ts.map +0 -1
  49. package/lib/components/error/error404.vue.d.ts +0 -4
  50. package/lib/components/error/error404.vue.d.ts.map +0 -1
  51. package/lib/components/form/aceEditor/index.vue.d.ts +0 -13
  52. package/lib/components/form/aceEditor/index.vue.d.ts.map +0 -1
  53. package/lib/components/layout/page/basicLayout.vue.d.ts +0 -7
  54. package/lib/components/layout/page/basicLayout.vue.d.ts.map +0 -1
  55. /package/lib/assets/modules/{uploadForm-BahGnrAq.js → index-BahGnrAq.js} +0 -0
  56. /package/lib/assets/modules/{excelForm-Dzndz-SG.js → index-Dzndz-SG.js} +0 -0
@@ -1,33 +0,0 @@
1
- import { defineComponent as n, createBlock as p, openBlock as i, unref as e, withCtx as r, createVNode as _, createTextVNode as a } from "vue";
2
- import { Result as c, Button as m } from "ant-design-vue";
3
- import { AppRouter as s } from "@skyfox2000/webbase";
4
- const x = /* @__PURE__ */ n({
5
- __name: "error403",
6
- setup(u) {
7
- const o = () => {
8
- s.back();
9
- };
10
- return (l, t) => (i(), p(e(c), {
11
- status: "403",
12
- title: "403",
13
- "sub-title": "您没有权限访问当前页面!"
14
- }, {
15
- extra: r(() => [
16
- _(e(m), {
17
- type: "primary",
18
- onClick: o
19
- }, {
20
- default: r(() => t[0] || (t[0] = [
21
- a("点击返回")
22
- ])),
23
- _: 1,
24
- __: [0]
25
- })
26
- ]),
27
- _: 1
28
- }));
29
- }
30
- });
31
- export {
32
- x as _
33
- };
@@ -1,33 +0,0 @@
1
- import { defineComponent as n, createBlock as p, openBlock as i, unref as e, withCtx as r, createVNode as _, createTextVNode as a } from "vue";
2
- import { Result as c, Button as m } from "ant-design-vue";
3
- import { AppRouter as s } from "@skyfox2000/webbase";
4
- const x = /* @__PURE__ */ n({
5
- __name: "error404",
6
- setup(u) {
7
- const o = () => {
8
- s.back();
9
- };
10
- return (l, t) => (i(), p(e(c), {
11
- status: "404",
12
- title: "404",
13
- "sub-title": "页面不存在或者没有权限访问页面!"
14
- }, {
15
- extra: r(() => [
16
- _(e(m), {
17
- type: "primary",
18
- onClick: o
19
- }, {
20
- default: r(() => t[0] || (t[0] = [
21
- a("点击返回")
22
- ])),
23
- _: 1,
24
- __: [0]
25
- })
26
- ]),
27
- _: 1
28
- }));
29
- }
30
- });
31
- export {
32
- x as _
33
- };
@@ -1,317 +0,0 @@
1
- import { defineComponent as Y, ref as r, watch as A, onMounted as Z, createBlock as ee, openBlock as d, unref as i, withCtx as _, renderSlot as le, createElementVNode as c, createVNode as m, createElementBlock as f, createCommentVNode as M, createTextVNode as O, toDisplayString as F, normalizeClass as ae, Fragment as P, renderList as $ } from "vue";
2
- import { _ as K } from "./excelForm-Dzndz-SG.js";
3
- import { Modal as te, Upload as I, Alert as G, Space as re } from "ant-design-vue";
4
- import { ResStatus as oe } from "@skyfox2000/fapi";
5
- import { getRuleTexts as se, AsyncUploader as ie, path as ue, UploadStatus as ne, processExcelFile as ce, doSave as ve, validateExcel as de, checkExcelDuplicates as fe } from "@skyfox2000/webbase";
6
- import "./index-ekkaExvB.js";
7
- import n from "vue-m-message";
8
- import pe from "@vue-office/excel";
9
- const me = { class: "mb-4 flex items-center" }, xe = {
10
- key: 0,
11
- class: "ml-3 text-gray-600"
12
- }, ge = { class: "flex gap-4" }, ye = {
13
- key: 0,
14
- class: "w-[22%] flex-grow overflow-hidden flex flex-col"
15
- }, he = { class: "bg-gray-50 p-2 rounded border flex-grow flex flex-col" }, _e = {
16
- key: 0,
17
- class: "text-gray-500"
18
- }, be = {
19
- key: 1,
20
- class: "flex flex-col"
21
- }, we = { class: "overflow-y-auto" }, Ce = { class: "text-[13px] text-gray-600" }, Fe = { class: "pl-5 mt-1 mb-0" }, Ee = {
22
- key: 0,
23
- class: "mt-3"
24
- }, Ue = { class: "text-[12px] text-gray-600 p-1" }, Se = { class: "text-[13px] text-gray-600" }, ke = { class: "pl-5 mt-1 mb-0" }, De = { class: "text-[12px] text-gray-600" }, Oe = /* @__PURE__ */ Y({
25
- __name: "excelForm",
26
- props: {
27
- title: {},
28
- gridCtrl: {},
29
- excelCtrl: {},
30
- uploadParams: {},
31
- excelFieldMap: {},
32
- fileField: {},
33
- excelBatchField: {},
34
- saveText: {}
35
- },
36
- setup(Q) {
37
- const o = Q, e = o.excelCtrl, b = r(!1), w = r(""), q = r([]), x = r(""), E = r(!0), U = r("待验证数据规则"), S = r("warning"), k = r("待验证重复数据"), D = r("warning");
38
- A(
39
- () => e.visible.value,
40
- () => {
41
- b.value = e.visible.value;
42
- }
43
- ), A(
44
- () => b.value,
45
- () => {
46
- e.visible.value = b.value;
47
- }
48
- );
49
- const R = r(o.uploadParams), p = r(R.value.uploadUrl), g = r(R.value.duplicateRules), C = r(R.value.duplicateUrl), H = async () => {
50
- const l = p.value;
51
- if (!l) {
52
- n.error("未配置文件上传地址!");
53
- return;
54
- }
55
- if (B.value) {
56
- n.error("表格数据存在验证错误,请修正后再上传!");
57
- return;
58
- }
59
- e.isFormLoading.value = !0;
60
- try {
61
- if (!z.value || !x.value) {
62
- n.warning("请先选择Excel文件!"), e.isFormLoading.value = !1;
63
- return;
64
- }
65
- const a = new ie(l, 1), s = new File([z.value], x.value, {
66
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
67
- }), t = ue.join(R.value.basePath, x.value), v = {
68
- uid: "1",
69
- name: x.value,
70
- originFileObj: s,
71
- status: ne.Uploading,
72
- percent: 0,
73
- params: {
74
- FileKey: t
75
- }
76
- }, y = new AbortController();
77
- try {
78
- await a.uploadFile(v, y.signal, (u) => {
79
- v.percent = u;
80
- }), n.success("文件上传成功,开始业务处理!"), J(v);
81
- } catch (u) {
82
- throw console.error("文件上传错误:", u), n.error((u == null ? void 0 : u.message) || "文件上传失败,请稍后再试!"), u;
83
- }
84
- } catch (a) {
85
- console.error("上传处理错误:", a), n.error("上传处理失败:" + ((a == null ? void 0 : a.message) || "未知错误"));
86
- } finally {
87
- e.isFormLoading.value = !1;
88
- }
89
- }, J = async (l) => {
90
- if (e.formData.value) {
91
- if (o.excelBatchField) {
92
- const t = await ce(z.value);
93
- if (!t) return null;
94
- const { excelData: v } = t, y = v.map((u) => {
95
- const h = {};
96
- for (const L in u) {
97
- const j = o.excelFieldMap[L];
98
- j && (h[j] = u[L]);
99
- }
100
- return h;
101
- });
102
- e.formData.value[o.excelBatchField] = y;
103
- }
104
- const a = o.fileField ?? "FileInfo";
105
- e.formData.value[a] = l, e.beforeSave && e.beforeSave();
106
- const s = {
107
- Data: {
108
- ...e.formData.value
109
- },
110
- Query: {
111
- [o.excelCtrl.primaryKey]: e.formData.value[o.excelCtrl.primaryKey]
112
- }
113
- };
114
- e.isFormLoading.value = !0;
115
- try {
116
- const t = await ve(o.excelCtrl, {
117
- params: s,
118
- urlKey: "save",
119
- url: o.excelCtrl.saveUrl
120
- });
121
- (t == null ? void 0 : t.status) === oe.SUCCESS ? (n.success("数据保存成功!"), e.afterSave && e.afterSave(), e.visible.value = !1) : n.error("保存失败:" + ((t == null ? void 0 : t.msg) || "未知错误"));
122
- } catch (t) {
123
- console.error("保存错误:", t), n.error("数据保存失败,请稍后再试!");
124
- } finally {
125
- e.isFormLoading.value = !1;
126
- }
127
- }
128
- }, B = r(!1), N = r(!1), z = r(null), W = async (l) => {
129
- if (!(l.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || l.type === "application/vnd.ms-excel"))
130
- return n.error("只能上传Excel文件!"), I.LIST_IGNORE;
131
- try {
132
- x.value = l.name, B.value = !1, N.value = !1, E.value = !0, U.value = "待验证数据规则", S.value = "warning", k.value = "待验证重复数据", D.value = "warning";
133
- const s = await l.arrayBuffer();
134
- z.value = s;
135
- const t = new FileReader();
136
- t.readAsDataURL(l), t.onload = async (v) => {
137
- if (v.target) {
138
- const { hasError: y, errBlob: u } = await de(s, e.formRules.value);
139
- if (y) {
140
- if (u) {
141
- B.value = !0, E.value = !1, U.value = "数据验证失败", S.value = "error";
142
- const h = URL.createObjectURL(u);
143
- w.value = h;
144
- }
145
- return;
146
- } else
147
- U.value = "数据验证成功", S.value = "success";
148
- if (g.value && g.value.length > 0 && C.value)
149
- try {
150
- C.value.api || (C.value.api = o.gridCtrl.page.api), C.value.authorize === void 0 && (C.value.authorize = o.gridCtrl.page.authorize);
151
- const { hasError: h, errBlob: L } = await fe(
152
- s,
153
- g.value,
154
- C.value
155
- );
156
- if (h) {
157
- if (L) {
158
- N.value = !0, k.value = "检测到重复数据", D.value = "error";
159
- const j = URL.createObjectURL(L);
160
- w.value = j;
161
- }
162
- return;
163
- } else
164
- N.value = !1, k.value = "数据验证通过", D.value = "success";
165
- } catch {
166
- k.value = "重复检测异常", D.value = "error";
167
- }
168
- w.value = v.target.result, E.value = !1;
169
- } else
170
- n.error("加载Excel文件失败,请检查文件格式!");
171
- };
172
- } catch (s) {
173
- console.error("Excel处理错误:", s), n.error("Excel文件处理失败,请检查文件格式!"), E.value = !1, U.value = "Excel处理错误", S.value = "error";
174
- }
175
- return !1;
176
- }, T = se(e.formRules.value);
177
- Z(() => {
178
- const l = o.gridCtrl.page;
179
- if (p.value = p.value ?? l.urls.upload, !p.value) {
180
- n.error("未配置文件上传地址!");
181
- return;
182
- }
183
- p.value.api || (p.value.api = l.api), p.value.authorize === void 0 && (p.value.authorize = l.authorize);
184
- for (const a in e.formData.value)
185
- o.gridCtrl.rowData.value && (e.formData.value[a] = o.gridCtrl.rowData.value[a]);
186
- b.value = e.visible.value;
187
- });
188
- const V = () => {
189
- e.visible.value = !1;
190
- }, X = () => {
191
- console.error("渲染失败");
192
- };
193
- return (l, a) => (d(), ee(i(te), {
194
- title: l.title ?? "Excel文件上传",
195
- open: b.value,
196
- "onUpdate:open": a[0] || (a[0] = (s) => b.value = s),
197
- wrapClassName: ["modal", "mx-auto", l.$attrs.width ? "w-[" + l.$attrs.width + "]" : ""].join(" "),
198
- width: 940,
199
- onClose: V
200
- }, {
201
- footer: _(() => [
202
- m(i(re), null, {
203
- default: _(() => [
204
- m(i(K), { onClick: V }, {
205
- default: _(() => a[2] || (a[2] = [
206
- O("取消")
207
- ])),
208
- _: 1,
209
- __: [2]
210
- }),
211
- m(i(K), {
212
- onClick: H,
213
- type: "primary",
214
- loading: i(e).isFormSaving.value,
215
- disabled: !w.value || B.value || N.value || E.value
216
- }, {
217
- default: _(() => [
218
- O(F(l.saveText ?? "上传文件"), 1)
219
- ]),
220
- _: 1
221
- }, 8, ["loading", "disabled"])
222
- ]),
223
- _: 1
224
- })
225
- ]),
226
- default: _(() => [
227
- le(l.$slots, "default"),
228
- c("div", me, [
229
- m(i(I), {
230
- "file-list": q.value,
231
- "before-upload": W,
232
- accept: ".xlsx,.xls",
233
- showUploadList: !0
234
- }, {
235
- default: _(() => [
236
- m(i(K), { type: "primary" }, {
237
- default: _(() => a[1] || (a[1] = [
238
- O("选择Excel文件")
239
- ])),
240
- _: 1,
241
- __: [1]
242
- })
243
- ]),
244
- _: 1
245
- }, 8, ["file-list"]),
246
- w.value && x.value ? (d(), f("div", xe, [
247
- c("span", null, F(x.value), 1)
248
- ])) : M("", !0)
249
- ]),
250
- c("div", ge, [
251
- c("div", {
252
- class: ae(["flex-shrink-0 excel-container", [i(T).length === 0 ? "w-[100%]" : "w-[80%]"]]),
253
- style: { height: "430px" }
254
- }, [
255
- m(i(pe), {
256
- src: w.value,
257
- onError: X,
258
- style: { width: "100%", height: "100%" },
259
- options: {
260
- styles: !0,
261
- formatCells: !0,
262
- skipStyles: !1,
263
- autoStyle: !0,
264
- keepOriginalFormat: !0,
265
- renderingStyle: "svg"
266
- }
267
- }, null, 8, ["src"])
268
- ], 2),
269
- i(T).length > 0 ? (d(), f("div", ye, [
270
- c("div", he, [
271
- i(T).length === 0 ? (d(), f("div", _e, "没有设置验证规则")) : (d(), f("div", be, [
272
- m(i(G), {
273
- message: U.value,
274
- type: S.value,
275
- "show-icon": "",
276
- class: "mb-2"
277
- }, null, 8, ["message", "type"]),
278
- c("div", we, [
279
- (d(!0), f(P, null, $(i(T), (s, t) => (d(), f("div", {
280
- key: t,
281
- class: "border-b pb-0"
282
- }, [
283
- c("div", Ce, F(s.field), 1),
284
- c("ul", Fe, [
285
- (d(!0), f(P, null, $(s.rules, (v, y) => (d(), f("li", {
286
- key: y,
287
- class: "text-[12px] text-gray-600"
288
- }, F(v), 1))), 128))
289
- ])
290
- ]))), 128))
291
- ]),
292
- g.value && g.value.length > 0 ? (d(), f("div", Ee, [
293
- m(i(G), {
294
- message: k.value,
295
- type: D.value,
296
- "show-icon": "",
297
- class: "mt-2 mb-2"
298
- }, null, 8, ["message", "type"]),
299
- c("div", Ue, [
300
- c("div", Se, " 以下" + F(g.value.length > 1 ? "组合" : "字段") + "必须唯一 ", 1),
301
- c("ul", ke, [
302
- c("li", De, F(g.value.join(", ")), 1)
303
- ])
304
- ])
305
- ])) : M("", !0)
306
- ]))
307
- ])
308
- ])) : M("", !0)
309
- ])
310
- ]),
311
- _: 3
312
- }, 8, ["title", "open", "wrapClassName"]));
313
- }
314
- });
315
- export {
316
- Oe as _
317
- };
@@ -1,309 +0,0 @@
1
- import { defineComponent as M, ref as C, computed as N, watch as D, createElementBlock as w, openBlock as h, createElementVNode as d, createVNode as v, unref as s, mergeProps as P, withCtx as m, createTextVNode as b, toDisplayString as y, Fragment as j, renderList as V, normalizeClass as R, createCommentVNode as B, onMounted as T, createBlock as K } from "vue";
2
- import { _ as L } from "./excelForm-Dzndz-SG.js";
3
- import { Upload as A, Tag as I, Progress as Q, Modal as q, Space as G } from "ant-design-vue";
4
- import { ResStatus as H } from "@skyfox2000/fapi";
5
- import { UploadStatus as r, path as J, donwloadFromMinio as W, AsyncUploader as X, gridRowUpdate as Y } from "@skyfox2000/webbase";
6
- import "./index-ekkaExvB.js";
7
- import "./uploadForm-BahGnrAq.js";
8
- import u from "vue-m-message";
9
- import "@vue-office/excel";
10
- import "vue-draggable-next";
11
- import "@skyfox2000/microbase";
12
- import "dayjs";
13
- const Z = { class: "w-full border border-solid border-gray-100 mt-1 rounded-md py-5" }, ee = { class: "flex items-center justify-between w-full" }, te = { class: "w-35 mx-3" }, oe = { class: "flex-1 text-sm text-gray-500" }, ae = { class: "mt-4 px-3" }, le = { class: "flex items-center justify-between" }, re = { class: "flex items-center" }, se = { class: "flex items-center" }, ne = ["onClick"], ie = ["onClick"], ue = ["onClick"], de = /* @__PURE__ */ M({
14
- __name: "uploadList",
15
- props: {
16
- autoUpload: { type: Boolean, default: !1 },
17
- downloadUrl: {},
18
- fileList: { default: () => [] },
19
- placeholder: { default: "" },
20
- fileExt: {},
21
- maxFileSize: { default: 20 },
22
- maxCount: { default: 5 },
23
- parentPath: {}
24
- },
25
- emits: ["update:file-list"],
26
- setup(F, { emit: E }) {
27
- const t = F, o = C(t.fileList), g = C(), S = E, k = N(() => {
28
- var e;
29
- return (e = t.fileExt) != null && e.length ? t.fileExt.map((a) => `.${a}`).join(",") : "";
30
- }), f = (e) => {
31
- var a;
32
- if (t.fileExt && t.fileExt.length > 0) {
33
- const l = ((a = e.name.split(".").pop()) == null ? void 0 : a.toLowerCase()) || "";
34
- if (!t.fileExt.includes(l))
35
- return u.error("文件类型不支持"), !1;
36
- }
37
- return e.size / 1024 / 1024 > t.maxFileSize ? (u.error(`文件大小超过 ${t.maxFileSize}MB 限制`), !1) : t.maxCount > 1 && o.value.length >= t.maxCount ? (u.error(`最多上传 ${t.maxCount} 个文件`), !1) : t.autoUpload;
38
- }, x = (e) => {
39
- e.forEach((a) => {
40
- a.fileName || (a.fileName = a.name), t.parentPath && (a.name = J.join("/", t.parentPath, a.fileName));
41
- });
42
- }, c = N(() => ({
43
- accept: k.value,
44
- multiple: !0,
45
- fileList: o.value,
46
- "onUpdate:fileList": x,
47
- beforeUpload: f,
48
- listType: "text",
49
- maxCount: t.maxCount,
50
- showUploadList: !1,
51
- onChange: (e) => {
52
- t.autoUpload || (o.value = e.fileList);
53
- }
54
- }));
55
- D(
56
- () => o.value,
57
- (e) => {
58
- S("update:file-list", e);
59
- },
60
- { deep: !0 }
61
- );
62
- const p = (e) => {
63
- const a = o.value[e].minioFile, l = {
64
- api: t.downloadUrl.api,
65
- authorize: t.downloadUrl.authorize,
66
- url: t.downloadUrl.url,
67
- // url: props.pageData.urls.download!.url,
68
- params: {
69
- Query: {
70
- FileKey: a.Key
71
- }
72
- }
73
- };
74
- W(l);
75
- }, O = (e) => {
76
- e.status = e.status === r.Offline ? r.Online : r.Offline, e.minioFile.Status = e.status;
77
- }, _ = (e) => {
78
- o.value.splice(e, 1);
79
- }, U = () => {
80
- const e = t.fileExt && t.fileExt.length ? `文件必须为 ${t.fileExt.join("/")}` : "", a = t.maxFileSize !== 0 ? `单文件最大 ${t.maxFileSize}MB` : "", l = t.maxCount !== 0 ? `最多 ${t.maxCount} 个文件` : "";
81
- return [a, e, l].filter(Boolean).join(",");
82
- }, n = (e) => {
83
- switch (e) {
84
- case r.Uploading:
85
- return "blue";
86
- case r.Success:
87
- return "green";
88
- case r.Error:
89
- return "red";
90
- case r.Online:
91
- return "green";
92
- case r.Offline:
93
- return "pink";
94
- default:
95
- return "cyan";
96
- }
97
- }, i = (e) => {
98
- switch (e) {
99
- case r.Uploading:
100
- return "上传中";
101
- case r.Success:
102
- return "已完成";
103
- case r.Error:
104
- return "上传失败";
105
- case r.Online:
106
- return "在线";
107
- case r.Offline:
108
- return "已下线";
109
- default:
110
- return "待上传";
111
- }
112
- };
113
- return (e, a) => (h(), w("div", Z, [
114
- d("div", ee, [
115
- d("div", te, [
116
- v(s(A), P({
117
- ref_key: "fileUploader",
118
- ref: g
119
- }, c.value), {
120
- default: m(() => [
121
- v(s(L), null, {
122
- default: m(() => a[0] || (a[0] = [
123
- b("选择文件")
124
- ])),
125
- _: 1,
126
- __: [0]
127
- })
128
- ]),
129
- _: 1
130
- }, 16)
131
- ]),
132
- d("div", oe, y(U()), 1)
133
- ]),
134
- d("div", ae, [
135
- (h(!0), w(j, null, V(o.value, (l, z) => (h(), w("div", {
136
- key: z,
137
- class: "mb-2 pb-1"
138
- }, [
139
- d("div", le, [
140
- d("div", re, [
141
- d("span", {
142
- class: R(["text-gray-700 mr-2", [l.status == s(r).Offline ? "line-through" : ""]])
143
- }, y(l.fileName ?? l.name), 3),
144
- d("span", null, [
145
- v(s(I), {
146
- color: n(l.status)
147
- }, {
148
- default: m(() => [
149
- b(y(i(l.status)), 1)
150
- ]),
151
- _: 2
152
- }, 1032, ["color"])
153
- ])
154
- ]),
155
- d("div", se, [
156
- l.status == s(r).Offline || l.status == s(r).Online ? (h(), w("span", {
157
- key: 0,
158
- class: "text-blue-500 hover:text-blue-700 mr-4 cursor-pointer",
159
- onClick: ($) => O(l)
160
- }, y(l.status == s(r).Offline ? "上线" : "下线"), 9, ne)) : B("", !0),
161
- l.status == s(r).Offline || l.status == s(r).Online ? (h(), w("span", {
162
- key: 1,
163
- class: "text-blue-500 hover:text-blue-700 mr-4 cursor-pointer",
164
- onClick: ($) => p(z)
165
- }, "下载", 8, ie)) : B("", !0),
166
- d("span", {
167
- class: "text-red-500 hover:text-red-700 cursor-pointer",
168
- onClick: ($) => _(z)
169
- }, "删除", 8, ue)
170
- ])
171
- ]),
172
- d("div", null, [
173
- v(s(Q), {
174
- percent: l.percent,
175
- "stroke-width": 2,
176
- "show-info": !1,
177
- style: { height: "2px" }
178
- }, null, 8, ["percent"])
179
- ])
180
- ]))), 128))
181
- ])
182
- ]));
183
- }
184
- }), ye = /* @__PURE__ */ M({
185
- __name: "uploadForm",
186
- props: {
187
- mode: {},
188
- fileExt: {},
189
- gridCtrl: {},
190
- maxCount: {},
191
- maxConcurrent: {},
192
- uploadForm: {},
193
- uploadUrl: {},
194
- downloadUrl: {},
195
- continueOnError: { type: Boolean }
196
- },
197
- emits: ["before:file-list", "before:upload", "after:upload"],
198
- setup(F, { emit: E }) {
199
- const t = F, o = t.uploadForm, g = C(!1), S = t.maxCount ?? 1, k = t.maxConcurrent ?? 3, f = C([]), x = E;
200
- D(
201
- () => o.visible.value,
202
- () => {
203
- g.value = o.visible.value;
204
- }
205
- );
206
- const c = C(t.uploadUrl), p = C(t.downloadUrl), O = async () => {
207
- const n = c.value;
208
- if (!n) {
209
- u.error("未配置文件上传地址!");
210
- return;
211
- }
212
- x("before:upload", f.value);
213
- const i = new X(n, k);
214
- o.isFormLoading.value = !0;
215
- try {
216
- if (f.value.length === 0) {
217
- u.warning("请选择上传的文件!");
218
- return;
219
- }
220
- await i.uploadFiles(
221
- f.value,
222
- (e) => {
223
- },
224
- (e) => {
225
- o.isFormLoading.value = !1;
226
- let a = 0;
227
- for (const l of e)
228
- l.status === r.Error && a++;
229
- a ? a < e.length ? t.continueOnError ? (u.error("上传结束,部分文件上传失败!"), u.warning("保存上传成功的文件!"), x("after:upload", e), _()) : u.error("上传结束,部分文件上传失败,取消保存!") : u.error("上传结束,所有文件上传失败!") : (u.success("全部文件上传成功!"), x("after:upload", e), _());
230
- }
231
- );
232
- } catch (e) {
233
- o.isFormLoading.value = !1, console.error("上传错误:", e), u.error("上传错误,请稍后再试!"), x("after:upload", f.value);
234
- }
235
- }, _ = async () => {
236
- switch (t.mode) {
237
- case "Row":
238
- o.formData.value && (await Y(t.gridCtrl, o.formData.value)).status === H.SUCCESS && (o.visible.value = !1);
239
- break;
240
- }
241
- };
242
- T(() => {
243
- const n = t.gridCtrl.page;
244
- if (c.value = c.value ?? n.urls.upload, p.value = p.value ?? n.urls.download, !c.value) {
245
- u.error("未配置文件上传地址!");
246
- return;
247
- }
248
- if (c.value.api || (c.value.api = n.api), c.value.authorize === void 0 && (c.value.authorize = n.authorize), !p.value) {
249
- u.error("未配置文件下载地址!");
250
- return;
251
- }
252
- p.value.api || (p.value.api = n.api), p.value.authorize === void 0 && (p.value.authorize = n.authorize);
253
- for (const e in o.formData.value)
254
- t.gridCtrl.rowData.value && (o.formData.value[e] = t.gridCtrl.rowData.value[e]);
255
- const i = [];
256
- x("before:file-list", o, i), f.value.push(...i), g.value = o.visible.value;
257
- });
258
- const U = () => {
259
- o.visible.value = !1;
260
- };
261
- return (n, i) => (h(), K(s(q), {
262
- title: "文件上传",
263
- open: g.value,
264
- "onUpdate:open": i[1] || (i[1] = (e) => g.value = e),
265
- wrapClassName: "modal mx-auto " + (n.$attrs.width ? "w-[" + n.$attrs.width + "]" : "w-[430px]"),
266
- onClose: U
267
- }, {
268
- footer: m(() => [
269
- v(s(G), null, {
270
- default: m(() => [
271
- v(s(L), { onClick: U }, {
272
- default: m(() => i[2] || (i[2] = [
273
- b("取消")
274
- ])),
275
- _: 1,
276
- __: [2]
277
- }),
278
- v(s(L), {
279
- onClick: O,
280
- type: "primary",
281
- loading: s(o).isFormSaving.value
282
- }, {
283
- default: m(() => i[3] || (i[3] = [
284
- b(" 上传文件并保存 ")
285
- ])),
286
- _: 1,
287
- __: [3]
288
- }, 8, ["loading"])
289
- ]),
290
- _: 1
291
- })
292
- ]),
293
- default: m(() => [
294
- v(s(de), {
295
- "file-list": f.value,
296
- "onUpdate:fileList": i[0] || (i[0] = (e) => f.value = e),
297
- "download-url": p.value,
298
- "max-count": s(S),
299
- "file-ext": n.fileExt
300
- }, null, 8, ["file-list", "download-url", "max-count", "file-ext"])
301
- ]),
302
- _: 1
303
- }, 8, ["open", "wrapClassName"]));
304
- }
305
- });
306
- export {
307
- ye as _,
308
- de as a
309
- };