@skyfox2000/webui 1.2.10 → 1.2.11

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 (119) hide show
  1. package/lib/AceEditor.d.ts +1 -0
  2. package/lib/BasicLayout.d.ts +1 -0
  3. package/lib/Error403.d.ts +1 -0
  4. package/lib/Error404.d.ts +1 -0
  5. package/lib/ExcelForm.d.ts +1 -0
  6. package/lib/UploadForm.d.ts +1 -0
  7. package/lib/assets/modules/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  8. package/lib/assets/modules/file-upload-CGyzCx7I.js +204 -0
  9. package/lib/assets/modules/form-excel-DWirWVPA.js +235 -0
  10. package/lib/assets/modules/index-C1zkNPmi.js +109 -0
  11. package/lib/assets/modules/index-Czk7DDWM.js +112 -0
  12. package/lib/assets/modules/menuTabs-BOax-dro.js +671 -0
  13. package/lib/assets/modules/toolIcon-vJF7OgP6.js +50 -0
  14. package/lib/assets/modules/uploadList-BW23uSvi.js +369 -0
  15. package/lib/assets/modules/uploadList-DaUjVXLU.js +2267 -0
  16. package/lib/components/common/button/index.vue.d.ts +41 -0
  17. package/lib/components/common/icon/appicon.vue.d.ts +11 -0
  18. package/lib/components/common/icon/fullscreen.vue.d.ts +3 -0
  19. package/lib/components/common/icon/helper.vue.d.ts +22 -0
  20. package/lib/components/common/icon/index.vue.d.ts +243 -0
  21. package/lib/components/common/icon/layoutIcon.vue.d.ts +43 -0
  22. package/lib/components/common/icon/projectIcon.vue.d.ts +59 -0
  23. package/lib/components/common/icon/toolIcon.vue.d.ts +43 -0
  24. package/lib/components/common/index.d.ts +20 -0
  25. package/lib/components/common/loading/index.vue.d.ts +3 -0
  26. package/lib/components/common/tooltip/index.vue.d.ts +21 -0
  27. package/lib/components/content/dialog/index.vue.d.ts +35 -0
  28. package/lib/components/content/drawer/index.vue.d.ts +28 -0
  29. package/lib/components/content/form/formItem.vue.d.ts +27 -0
  30. package/lib/components/content/form/index.vue.d.ts +25 -0
  31. package/lib/components/content/index.d.ts +22 -0
  32. package/lib/components/content/search/index.vue.d.ts +30 -0
  33. package/lib/components/content/search/searchItem.vue.d.ts +23 -0
  34. package/lib/components/content/table/index.vue.d.ts +36 -0
  35. package/lib/components/content/table/tableOperate.vue.d.ts +18 -0
  36. package/lib/components/content/toolbar/icontool.vue.d.ts +7 -0
  37. package/lib/components/content/toolbar/index.vue.d.ts +18 -0
  38. package/lib/components/content/tree/index.vue.d.ts +46 -0
  39. package/lib/components/form/aceEditor/aceConfig.d.ts +8 -0
  40. package/lib/components/form/autoComplete/index.vue.d.ts +176 -0
  41. package/lib/components/form/cascader/index.vue.d.ts +120 -0
  42. package/lib/components/form/checkbox/index.vue.d.ts +139 -0
  43. package/lib/components/form/datePicker/index.vue.d.ts +6 -0
  44. package/lib/components/form/index.d.ts +39 -0
  45. package/lib/components/form/input/index.vue.d.ts +26 -0
  46. package/lib/components/form/input/inputIcon.vue.d.ts +10 -0
  47. package/lib/components/form/input/inputNumber.vue.d.ts +3 -0
  48. package/lib/components/form/input/inputPassword.vue.d.ts +3 -0
  49. package/lib/components/form/propEditor/index.vue.d.ts +21 -0
  50. package/lib/components/form/radio/index.vue.d.ts +144 -0
  51. package/lib/components/form/radio/radioStatus.vue.d.ts +31 -0
  52. package/lib/components/form/rangePicker/index.vue.d.ts +16 -0
  53. package/lib/components/form/select/index.vue.d.ts +153 -0
  54. package/lib/components/form/switch/index.vue.d.ts +43 -0
  55. package/lib/components/form/textarea/index.vue.d.ts +3 -0
  56. package/lib/components/form/transfer/index.vue.d.ts +38 -0
  57. package/lib/components/form/transfer/transferTable.vue.d.ts +38 -0
  58. package/lib/components/form/treeSelect/index.vue.d.ts +38 -0
  59. package/lib/components/form/upload/uploadList.vue.d.ts +487 -0
  60. package/lib/components/index.d.ts +4 -0
  61. package/lib/components/layout/breadcrumb/index.vue.d.ts +3 -0
  62. package/lib/components/layout/content/index.vue.d.ts +22 -0
  63. package/lib/components/layout/datetime/index.vue.d.ts +3 -0
  64. package/lib/components/layout/header/headerExits.vue.d.ts +3 -0
  65. package/lib/components/layout/header/index.vue.d.ts +3 -0
  66. package/lib/components/layout/header/user.vue.d.ts +3 -0
  67. package/lib/components/layout/index.d.ts +14 -0
  68. package/lib/components/layout/menu/index.vue.d.ts +6 -0
  69. package/lib/components/layout/menu/menuTabs.vue.d.ts +3 -0
  70. package/lib/const/options.d.ts +32 -0
  71. package/lib/directives/enter-submit.d.ts +4 -0
  72. package/lib/directives/index.d.ts +2 -0
  73. package/lib/directives/permission.d.ts +5 -0
  74. package/lib/es/AceEditor/index.js +167 -0
  75. package/lib/es/BasicLayout/index.js +101 -0
  76. package/lib/es/Error403/index.js +39 -0
  77. package/lib/es/Error404/index.js +39 -0
  78. package/lib/es/ExcelForm/index.js +321 -0
  79. package/lib/es/UploadForm/index.js +110 -0
  80. package/lib/index.d.ts +45 -0
  81. package/lib/router/index.d.ts +15 -0
  82. package/lib/stores/appInfo.d.ts +31 -0
  83. package/lib/stores/hostInfo.d.ts +9 -0
  84. package/lib/stores/pageInfo.d.ts +18 -0
  85. package/lib/stores/pinia.d.ts +3 -0
  86. package/lib/stores/settingInfo.d.ts +8 -0
  87. package/lib/stores/userInfo.d.ts +25 -0
  88. package/lib/typings/data.d.ts +80 -0
  89. package/lib/typings/form.d.ts +187 -0
  90. package/lib/typings/menu.d.ts +7 -0
  91. package/lib/typings/option.d.ts +189 -0
  92. package/lib/typings/page.d.ts +70 -0
  93. package/lib/typings/table.d.ts +181 -0
  94. package/lib/typings/tools.d.ts +130 -0
  95. package/lib/typings/tree.d.ts +72 -0
  96. package/lib/typings/upload.d.ts +161 -0
  97. package/lib/typings/urls.d.ts +69 -0
  98. package/lib/utils/cache.d.ts +23 -0
  99. package/lib/utils/data.d.ts +6 -0
  100. package/lib/utils/download.d.ts +4 -0
  101. package/lib/utils/eventbus.d.ts +16 -0
  102. package/lib/utils/export-table.d.ts +12 -0
  103. package/lib/utils/file-upload.d.ts +17 -0
  104. package/lib/utils/form-excel.d.ts +33 -0
  105. package/lib/utils/form-validate.d.ts +29 -0
  106. package/lib/utils/form.d.ts +9 -0
  107. package/lib/utils/icon-loader.d.ts +125 -0
  108. package/lib/utils/isEmpty.d.ts +1 -0
  109. package/lib/utils/main-openapis.d.ts +8 -0
  110. package/lib/utils/menu.d.ts +6 -0
  111. package/lib/utils/options.d.ts +10 -0
  112. package/lib/utils/page.d.ts +25 -0
  113. package/lib/utils/table.d.ts +21 -0
  114. package/lib/utils/tools.d.ts +18 -0
  115. package/lib/utils/tree.d.ts +3 -0
  116. package/lib/vite-env.d.ts +8 -0
  117. package/lib/webui.css +1 -0
  118. package/lib/webui.es.js +2262 -0
  119. package/package.json +1 -1
@@ -0,0 +1,167 @@
1
+ import { defineComponent as F, defineAsyncComponent as M, ref as m, watch as V, onMounted as J, createElementBlock as x, openBlock as p, Fragment as K, createElementVNode as v, createVNode as _, toDisplayString as W, unref as i, createBlock as P, withKeys as f, normalizeClass as N, withModifiers as w, withCtx as z, createCommentVNode as L } from "vue";
2
+ import "ant-design-vue";
3
+ import { _ as q } from "../../assets/modules/toolIcon-vJF7OgP6.js";
4
+ import "@skyfox2000/fapi";
5
+ import "../../assets/modules/uploadList-DaUjVXLU.js";
6
+ import "@skyfox2000/microbase";
7
+ import "vue-m-message";
8
+ import "async-validator";
9
+ import "dayjs";
10
+ import { _ as D } from "../../assets/modules/index-Czk7DDWM.js";
11
+ import "vue-draggable-next";
12
+ const h = async (s) => window.ace ? window.ace : new Promise((l, t) => {
13
+ const o = document.createElement("script");
14
+ o.src = `${s}ace/ace.js`, o.async = !0, o.onload = () => {
15
+ window.ace.config.set("basePath", `${s}ace/`);
16
+ const n = document.createElement("script");
17
+ n.src = `${s}ace/ext-language_tools.js`, n.async = !0, n.onload = () => {
18
+ l(window.ace);
19
+ }, n.onerror = () => {
20
+ t(new Error("Failed to load language tools extension"));
21
+ }, document.head.appendChild(n);
22
+ }, o.onerror = () => {
23
+ t(new Error("Failed to load Ace editor"));
24
+ }, document.head.appendChild(o);
25
+ }), Q = async (s, l) => {
26
+ const t = await h(s), o = `${s}ace/mode-${l}.js`, n = `${s}ace/worker-${l}.js`;
27
+ if (!document.querySelector(`script[src="${o}"]`)) {
28
+ const r = document.createElement("script");
29
+ r.src = o, r.async = !0, document.head.appendChild(r), await new Promise((a) => {
30
+ r.onload = a, r.onerror = a;
31
+ });
32
+ }
33
+ t.config.setModuleUrl(`ace/mode/${l}`, o), t.config.setModuleUrl(`ace/mode/${l}_worker`, n);
34
+ }, R = async (s, l) => {
35
+ const t = await h(s), o = `${s}ace/theme-${l}.js`;
36
+ if (!document.querySelector(`script[src="${o}"]`)) {
37
+ const n = document.createElement("script");
38
+ n.src = o, n.async = !0, document.head.appendChild(n), await new Promise((r) => {
39
+ n.onload = r, n.onerror = r;
40
+ });
41
+ }
42
+ t.config.setModuleUrl(`ace/theme/${l}`, o);
43
+ }, T = { class: "w-full overflow-hidden rounded-md border-1 border-solid border-gray-300" }, G = { class: "w-full h-[30px] bg-[#ccc] relative flex items-center justify-between px-2" }, H = { class: "flex-1 overflow-hidden" }, I = {
44
+ key: 1,
45
+ class: "h-[500px] w-[99.3%] flex justify-center items-center border-1 border-solid border-gray-200"
46
+ }, $ = "github", ie = /* @__PURE__ */ F({
47
+ __name: "index",
48
+ props: {
49
+ value: {},
50
+ baseUrl: {},
51
+ lang: {}
52
+ },
53
+ emits: ["update:value"],
54
+ setup(s, { emit: l }) {
55
+ const t = s, o = t.baseUrl.endsWith("/") ? t.baseUrl : t.baseUrl + "/", n = M(() => h(o).then(() => import("vue3-ace-editor").then((c) => c.VAceEditor))), r = t.lang ?? "json", a = m(""), b = t.value ? "h-[240px]" : "h-[100px]", S = {
56
+ useWorker: !0,
57
+ showPrintMargin: !1,
58
+ highlightActiveLine: !0,
59
+ highlightSelectedWord: !0,
60
+ tabSize: 3,
61
+ fontSize: 10,
62
+ wrap: !0,
63
+ readOnly: !1
64
+ }, g = m({
65
+ ...S
66
+ }), k = l, C = () => {
67
+ r === "json" ? A() && k("update:value", JSON.parse(a.value)) : k("update:value", a.value);
68
+ }, A = () => {
69
+ if (a.value) {
70
+ let e = a.value;
71
+ const u = /(\w+)(?=\s*:)/g;
72
+ e = e.replace(u, '"$1"');
73
+ const U = /'([^']*)'/g;
74
+ e = e.replace(U, '"$1"');
75
+ try {
76
+ const E = JSON.parse(e), B = JSON.stringify(E, null, 3);
77
+ return a.value = B, !0;
78
+ } catch {
79
+ }
80
+ }
81
+ return !1;
82
+ }, j = () => {
83
+ t.value && typeof t.value == "object" ? a.value = JSON.stringify(t.value, null, 3) : a.value = t.value ?? "";
84
+ };
85
+ V(
86
+ () => t.value,
87
+ (c, e) => {
88
+ c !== e && j();
89
+ }
90
+ );
91
+ const d = m(!1), y = m(!1), O = () => {
92
+ d.value = !d.value;
93
+ };
94
+ return J(async () => {
95
+ try {
96
+ await h(o), await Promise.all([R(o, $), Q(o, r)]), y.value = !0, j(), g.value = {
97
+ ...S
98
+ // TODO 会提示拼写错误
99
+ // enableBasicAutocompletion: true,
100
+ // enableLiveAutocompletion: true,
101
+ // enableSnippets: true,
102
+ };
103
+ } catch (c) {
104
+ console.error("Failed to load Ace editor:", c);
105
+ }
106
+ }), (c, e) => (p(), x(K, null, [
107
+ v("div", T, [
108
+ v("div", G, [
109
+ v("div", null, W(i(r).toUpperCase()), 1),
110
+ _(i(q), {
111
+ icon: "icon-fullscreen",
112
+ clickable: "",
113
+ class: "w-4 h-4 text-[12px]",
114
+ onClick: O
115
+ })
116
+ ]),
117
+ v("div", H, [
118
+ y.value ? (p(), P(i(n), {
119
+ key: 0,
120
+ class: N([i(b)]),
121
+ value: a.value,
122
+ "onUpdate:value": e[0] || (e[0] = (u) => a.value = u),
123
+ lang: i(r),
124
+ theme: $,
125
+ options: g.value,
126
+ onBlur: C,
127
+ onKeyup: e[1] || (e[1] = f(w(() => {
128
+ }, ["stop"]), ["enter", "native"])),
129
+ onKeydown: e[2] || (e[2] = f(w(() => {
130
+ }, ["stop"]), ["enter", "native"]))
131
+ }, null, 8, ["class", "value", "lang", "options"])) : (p(), x("div", {
132
+ key: 1,
133
+ class: N([i(b), "flex justify-center items-center"])
134
+ }, "加载编辑器中...", 2))
135
+ ])
136
+ ]),
137
+ _(i(D), {
138
+ title: "代码编辑器",
139
+ open: d.value,
140
+ "onUpdate:open": e[6] || (e[6] = (u) => d.value = u),
141
+ width: 680,
142
+ footer: null
143
+ }, {
144
+ default: z(() => [
145
+ d.value && y.value ? (p(), P(i(n), {
146
+ key: 0,
147
+ class: "h-[500px] w-[99.3%] border-1 border-solid border-gray-200",
148
+ value: a.value,
149
+ "onUpdate:value": e[3] || (e[3] = (u) => a.value = u),
150
+ lang: i(r),
151
+ theme: $,
152
+ options: g.value,
153
+ onBlur: C,
154
+ onKeyup: e[4] || (e[4] = f(w(() => {
155
+ }, ["stop"]), ["enter", "native"])),
156
+ onKeydown: e[5] || (e[5] = f(w(() => {
157
+ }, ["stop"]), ["enter", "native"]))
158
+ }, null, 8, ["value", "lang", "options"])) : d.value ? (p(), x("div", I, " 加载编辑器中... ")) : L("", !0)
159
+ ]),
160
+ _: 1
161
+ }, 8, ["open"])
162
+ ], 64));
163
+ }
164
+ });
165
+ export {
166
+ ie as default
167
+ };
@@ -0,0 +1,101 @@
1
+ import { defineComponent as y, ref as I, watch as C, onMounted as b, resolveComponent as g, createBlock as n, openBlock as o, unref as e, withCtx as l, createCommentVNode as c, createVNode as r, createElementVNode as u, createElementBlock as k, toDisplayString as w, normalizeClass as S, KeepAlive as N, resolveDynamicComponent as $ } from "vue";
2
+ import { Layout as f, LayoutSider as E } from "ant-design-vue";
3
+ import { a as z } from "../../assets/modules/toolIcon-vJF7OgP6.js";
4
+ import { I as A, _ as B, f as L, d as V, g as D } from "../../assets/modules/menuTabs-BOax-dro.js";
5
+ import { ab as j, a as K, ad as M } from "../../assets/modules/uploadList-DaUjVXLU.js";
6
+ import "@skyfox2000/microbase";
7
+ import "@skyfox2000/fapi";
8
+ import P from "vue-m-message";
9
+ import "async-validator";
10
+ import "dayjs";
11
+ import "vue-draggable-next";
12
+ const T = { class: "h-[40px] max-h-[40px] bg-[rgba(240,240,240,0.2)] flex flex-nowrap items-center justify-center text-white font-bold text-lg overflow-hidden text-ellipsis" }, U = {
13
+ key: 0,
14
+ class: "ml-[10px]"
15
+ }, Z = /* @__PURE__ */ y({
16
+ __name: "basicLayout",
17
+ props: {
18
+ routes: {}
19
+ },
20
+ setup(d) {
21
+ const _ = d, t = j(), s = K(), x = M(), p = I("h-[calc(100vh-80px)]");
22
+ return C(
23
+ () => s.fullscreen,
24
+ (i) => {
25
+ p.value = i ? "h-[calc(100vh-40px)]" : "h-[calc(100vh-80px)]";
26
+ }
27
+ ), b(() => {
28
+ P.closeAll();
29
+ }), (i, m) => {
30
+ const h = g("router-view");
31
+ return o(), n(e(f), { class: "h-screen" }, {
32
+ default: l(() => [
33
+ e(s).fullscreen ? c("", !0) : (o(), n(e(E), {
34
+ key: 0,
35
+ class: "overflow-auto h-screen left-0 top-0 bottom-0",
36
+ collapsed: e(s).menuCollapse,
37
+ "onUpdate:collapsed": m[0] || (m[0] = (a) => e(s).menuCollapse = a),
38
+ collapsible: ""
39
+ }, {
40
+ default: l(() => [
41
+ u("div", T, [
42
+ r(z, {
43
+ title: e(s).menuCollapse ? e(t).appInfo.Name : "",
44
+ placement: "right"
45
+ }, {
46
+ default: l(() => {
47
+ var a;
48
+ return [
49
+ (a = e(t).appInfo.Icon) != null && a.startsWith("sym-") ? (o(), n(A, {
50
+ key: 0,
51
+ icon: e(t).appInfo.Icon,
52
+ fontsize: "30px",
53
+ size: "26px"
54
+ }, null, 8, ["icon"])) : (o(), n(B, {
55
+ key: 1,
56
+ icon: e(t).appInfo.Icon,
57
+ class: "mx-1"
58
+ }, null, 8, ["icon"]))
59
+ ];
60
+ }),
61
+ _: 1
62
+ }, 8, ["title"]),
63
+ e(s).menuCollapse ? c("", !0) : (o(), k("span", U, w(e(t).appInfo.Name), 1))
64
+ ]),
65
+ r(L, {
66
+ routes: _.routes
67
+ }, null, 8, ["routes"])
68
+ ]),
69
+ _: 1
70
+ }, 8, ["collapsed"])),
71
+ r(e(f), { class: "overflow-y-auto block" }, {
72
+ default: l(() => [
73
+ e(s).fullscreen ? c("", !0) : (o(), n(V, { key: 0 })),
74
+ e(x).TabEnabled ? (o(), n(D, { key: 1 })) : c("", !0),
75
+ u("div", {
76
+ class: S(["relative overflow-y-auto", p.value])
77
+ }, [
78
+ r(h, null, {
79
+ default: l(({ Component: a, route: v }) => [
80
+ (o(), n(N, {
81
+ include: e(t).CachedComponents,
82
+ exclude: e(t).ExcludeComponents
83
+ }, [
84
+ (o(), n($(e(t).cacheComponent(a, v))))
85
+ ], 1032, ["include", "exclude"]))
86
+ ]),
87
+ _: 1
88
+ })
89
+ ], 2)
90
+ ]),
91
+ _: 1
92
+ })
93
+ ]),
94
+ _: 1
95
+ });
96
+ };
97
+ }
98
+ });
99
+ export {
100
+ Z as default
101
+ };
@@ -0,0 +1,39 @@
1
+ import { defineComponent as i, createBlock as p, openBlock as m, unref as r, withCtx as e, createVNode as n, createTextVNode as a } from "vue";
2
+ import { r as s } from "../../assets/modules/uploadList-DaUjVXLU.js";
3
+ import "@skyfox2000/microbase";
4
+ import "@skyfox2000/fapi";
5
+ import "vue-m-message";
6
+ import "async-validator";
7
+ import "dayjs";
8
+ import { Result as u, Button as c } from "ant-design-vue";
9
+ import "vue-draggable-next";
10
+ const V = /* @__PURE__ */ i({
11
+ __name: "error403",
12
+ setup(_) {
13
+ const o = () => {
14
+ s.back();
15
+ };
16
+ return (l, t) => (m(), p(r(u), {
17
+ status: "403",
18
+ title: "403",
19
+ "sub-title": "您没有权限访问当前页面!"
20
+ }, {
21
+ extra: e(() => [
22
+ n(r(c), {
23
+ type: "primary",
24
+ onClick: o
25
+ }, {
26
+ default: e(() => t[0] || (t[0] = [
27
+ a("点击返回")
28
+ ])),
29
+ _: 1,
30
+ __: [0]
31
+ })
32
+ ]),
33
+ _: 1
34
+ }));
35
+ }
36
+ });
37
+ export {
38
+ V as default
39
+ };
@@ -0,0 +1,39 @@
1
+ import { defineComponent as i, createBlock as p, openBlock as m, unref as r, withCtx as e, createVNode as n, createTextVNode as a } from "vue";
2
+ import { r as s } from "../../assets/modules/uploadList-DaUjVXLU.js";
3
+ import "@skyfox2000/microbase";
4
+ import "@skyfox2000/fapi";
5
+ import "vue-m-message";
6
+ import "async-validator";
7
+ import "dayjs";
8
+ import { Result as u, Button as c } from "ant-design-vue";
9
+ import "vue-draggable-next";
10
+ const V = /* @__PURE__ */ i({
11
+ __name: "error404",
12
+ setup(_) {
13
+ const o = () => {
14
+ s.back();
15
+ };
16
+ return (l, t) => (m(), p(r(u), {
17
+ status: "404",
18
+ title: "404",
19
+ "sub-title": "页面不存在或者没有权限访问页面!"
20
+ }, {
21
+ extra: e(() => [
22
+ n(r(c), {
23
+ type: "primary",
24
+ onClick: o
25
+ }, {
26
+ default: e(() => t[0] || (t[0] = [
27
+ a("点击返回")
28
+ ])),
29
+ _: 1,
30
+ __: [0]
31
+ })
32
+ ]),
33
+ _: 1
34
+ }));
35
+ }
36
+ });
37
+ export {
38
+ V as default
39
+ };
@@ -0,0 +1,321 @@
1
+ import { defineComponent as Y, ref as r, watch as V, 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 $, renderList as P } from "vue";
2
+ import { _ as A } from "../../assets/modules/index-C1zkNPmi.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 { $ as se, a5 as ie } from "../../assets/modules/uploadList-DaUjVXLU.js";
6
+ import { A as ue, p as ne, U as ce } from "../../assets/modules/file-upload-CGyzCx7I.js";
7
+ import "@skyfox2000/microbase";
8
+ import n from "vue-m-message";
9
+ import { p as ve, v as de, c as fe } from "../../assets/modules/form-excel-DWirWVPA.js";
10
+ import "dayjs";
11
+ import "vue-draggable-next";
12
+ import pe from "@vue-office/excel";
13
+ const me = { class: "mb-4 flex items-center" }, xe = {
14
+ key: 0,
15
+ class: "ml-3 text-gray-600"
16
+ }, ge = { class: "flex gap-4" }, ye = {
17
+ key: 0,
18
+ class: "w-[22%] flex-grow overflow-hidden flex flex-col"
19
+ }, he = { class: "bg-gray-50 p-2 rounded border flex-grow flex flex-col" }, _e = {
20
+ key: 0,
21
+ class: "text-gray-500"
22
+ }, be = {
23
+ key: 1,
24
+ class: "flex flex-col"
25
+ }, we = { class: "overflow-y-auto" }, Ce = { class: "text-[13px] text-gray-600" }, Fe = { class: "pl-5 mt-1 mb-0" }, Ee = {
26
+ key: 0,
27
+ class: "mt-3"
28
+ }, 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" }, $e = /* @__PURE__ */ Y({
29
+ __name: "excelForm",
30
+ props: {
31
+ title: {},
32
+ gridCtrl: {},
33
+ excelCtrl: {},
34
+ uploadParams: {},
35
+ excelFieldMap: {},
36
+ fileField: {},
37
+ excelBatchField: {},
38
+ saveText: {}
39
+ },
40
+ setup(Q) {
41
+ 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");
42
+ V(
43
+ () => e.visible.value,
44
+ () => {
45
+ b.value = e.visible.value;
46
+ }
47
+ ), V(
48
+ () => b.value,
49
+ () => {
50
+ e.visible.value = b.value;
51
+ }
52
+ );
53
+ const R = r(o.uploadParams), p = r(R.value.uploadUrl), g = r(R.value.duplicateRules), C = r(R.value.duplicateUrl), H = async () => {
54
+ const l = p.value;
55
+ if (!l) {
56
+ n.error("未配置文件上传地址!");
57
+ return;
58
+ }
59
+ if (B.value) {
60
+ n.error("表格数据存在验证错误,请修正后再上传!");
61
+ return;
62
+ }
63
+ e.isFormLoading.value = !0;
64
+ try {
65
+ if (!z.value || !x.value) {
66
+ n.warning("请先选择Excel文件!"), e.isFormLoading.value = !1;
67
+ return;
68
+ }
69
+ const a = new ue(l, 1), s = new File([z.value], x.value, {
70
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
71
+ }), t = ne.join(R.value.basePath, x.value), v = {
72
+ uid: "1",
73
+ name: x.value,
74
+ originFileObj: s,
75
+ status: ce.Uploading,
76
+ percent: 0,
77
+ params: {
78
+ FileKey: t
79
+ }
80
+ }, y = new AbortController();
81
+ try {
82
+ await a.uploadFile(v, y.signal, (u) => {
83
+ v.percent = u;
84
+ }), n.success("文件上传成功,开始业务处理!"), J(v);
85
+ } catch (u) {
86
+ throw console.error("文件上传错误:", u), n.error((u == null ? void 0 : u.message) || "文件上传失败,请稍后再试!"), u;
87
+ }
88
+ } catch (a) {
89
+ console.error("上传处理错误:", a), n.error("上传处理失败:" + ((a == null ? void 0 : a.message) || "未知错误"));
90
+ } finally {
91
+ e.isFormLoading.value = !1;
92
+ }
93
+ }, J = async (l) => {
94
+ if (e.formData.value) {
95
+ if (o.excelBatchField) {
96
+ const t = await ve(z.value);
97
+ if (!t) return null;
98
+ const { excelData: v } = t, y = v.map((u) => {
99
+ const h = {};
100
+ for (const L in u) {
101
+ const j = o.excelFieldMap[L];
102
+ j && (h[j] = u[L]);
103
+ }
104
+ return h;
105
+ });
106
+ e.formData.value[o.excelBatchField] = y;
107
+ }
108
+ const a = o.fileField ?? "FileInfo";
109
+ e.formData.value[a] = l, e.beforeSave && e.beforeSave();
110
+ const s = {
111
+ Data: {
112
+ ...e.formData.value
113
+ },
114
+ Query: {
115
+ [o.excelCtrl.primaryKey]: e.formData.value[o.excelCtrl.primaryKey]
116
+ }
117
+ };
118
+ e.isFormLoading.value = !0;
119
+ try {
120
+ const t = await ie(o.excelCtrl, {
121
+ params: s,
122
+ urlKey: "save",
123
+ url: o.excelCtrl.saveUrl
124
+ });
125
+ (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) || "未知错误"));
126
+ } catch (t) {
127
+ console.error("保存错误:", t), n.error("数据保存失败,请稍后再试!");
128
+ } finally {
129
+ e.isFormLoading.value = !1;
130
+ }
131
+ }
132
+ }, B = r(!1), N = r(!1), z = r(null), W = async (l) => {
133
+ if (!(l.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || l.type === "application/vnd.ms-excel"))
134
+ return n.error("只能上传Excel文件!"), I.LIST_IGNORE;
135
+ try {
136
+ x.value = l.name, B.value = !1, N.value = !1, E.value = !0, U.value = "待验证数据规则", S.value = "warning", k.value = "待验证重复数据", D.value = "warning";
137
+ const s = await l.arrayBuffer();
138
+ z.value = s;
139
+ const t = new FileReader();
140
+ t.readAsDataURL(l), t.onload = async (v) => {
141
+ if (v.target) {
142
+ const { hasError: y, errBlob: u } = await de(s, e.formRules.value);
143
+ if (y) {
144
+ if (u) {
145
+ B.value = !0, E.value = !1, U.value = "数据验证失败", S.value = "error";
146
+ const h = URL.createObjectURL(u);
147
+ w.value = h;
148
+ }
149
+ return;
150
+ } else
151
+ U.value = "数据验证成功", S.value = "success";
152
+ if (g.value && g.value.length > 0 && C.value)
153
+ try {
154
+ C.value.api || (C.value.api = o.gridCtrl.page.api), C.value.authorize === void 0 && (C.value.authorize = o.gridCtrl.page.authorize);
155
+ const { hasError: h, errBlob: L } = await fe(
156
+ s,
157
+ g.value,
158
+ C.value
159
+ );
160
+ if (h) {
161
+ if (L) {
162
+ N.value = !0, k.value = "检测到重复数据", D.value = "error";
163
+ const j = URL.createObjectURL(L);
164
+ w.value = j;
165
+ }
166
+ return;
167
+ } else
168
+ N.value = !1, k.value = "数据验证通过", D.value = "success";
169
+ } catch {
170
+ k.value = "重复检测异常", D.value = "error";
171
+ }
172
+ w.value = v.target.result, E.value = !1;
173
+ } else
174
+ n.error("加载Excel文件失败,请检查文件格式!");
175
+ };
176
+ } catch (s) {
177
+ console.error("Excel处理错误:", s), n.error("Excel文件处理失败,请检查文件格式!"), E.value = !1, U.value = "Excel处理错误", S.value = "error";
178
+ }
179
+ return !1;
180
+ }, T = se(e.formRules.value);
181
+ Z(() => {
182
+ const l = o.gridCtrl.page;
183
+ if (p.value = p.value ?? l.urls.upload, !p.value) {
184
+ n.error("未配置文件上传地址!");
185
+ return;
186
+ }
187
+ p.value.api || (p.value.api = l.api), p.value.authorize === void 0 && (p.value.authorize = l.authorize);
188
+ for (const a in e.formData.value)
189
+ o.gridCtrl.rowData.value && (e.formData.value[a] = o.gridCtrl.rowData.value[a]);
190
+ b.value = e.visible.value;
191
+ });
192
+ const K = () => {
193
+ e.visible.value = !1;
194
+ }, X = () => {
195
+ console.error("渲染失败");
196
+ };
197
+ return (l, a) => (d(), ee(i(te), {
198
+ title: l.title ?? "Excel文件上传",
199
+ open: b.value,
200
+ "onUpdate:open": a[0] || (a[0] = (s) => b.value = s),
201
+ wrapClassName: ["modal", "mx-auto", l.$attrs.width ? "w-[" + l.$attrs.width + "]" : ""].join(" "),
202
+ width: 940,
203
+ onClose: K
204
+ }, {
205
+ footer: _(() => [
206
+ m(i(re), null, {
207
+ default: _(() => [
208
+ m(i(A), { onClick: K }, {
209
+ default: _(() => a[2] || (a[2] = [
210
+ O("取消")
211
+ ])),
212
+ _: 1,
213
+ __: [2]
214
+ }),
215
+ m(i(A), {
216
+ onClick: H,
217
+ type: "primary",
218
+ loading: i(e).isFormSaving.value,
219
+ disabled: !w.value || B.value || N.value || E.value
220
+ }, {
221
+ default: _(() => [
222
+ O(F(l.saveText ?? "上传文件"), 1)
223
+ ]),
224
+ _: 1
225
+ }, 8, ["loading", "disabled"])
226
+ ]),
227
+ _: 1
228
+ })
229
+ ]),
230
+ default: _(() => [
231
+ le(l.$slots, "default"),
232
+ c("div", me, [
233
+ m(i(I), {
234
+ "file-list": q.value,
235
+ "before-upload": W,
236
+ accept: ".xlsx,.xls",
237
+ showUploadList: !0
238
+ }, {
239
+ default: _(() => [
240
+ m(i(A), { type: "primary" }, {
241
+ default: _(() => a[1] || (a[1] = [
242
+ O("选择Excel文件")
243
+ ])),
244
+ _: 1,
245
+ __: [1]
246
+ })
247
+ ]),
248
+ _: 1
249
+ }, 8, ["file-list"]),
250
+ w.value && x.value ? (d(), f("div", xe, [
251
+ c("span", null, F(x.value), 1)
252
+ ])) : M("", !0)
253
+ ]),
254
+ c("div", ge, [
255
+ c("div", {
256
+ class: ae(["flex-shrink-0 excel-container", [i(T).length === 0 ? "w-[100%]" : "w-[80%]"]]),
257
+ style: { height: "430px" }
258
+ }, [
259
+ m(i(pe), {
260
+ src: w.value,
261
+ onError: X,
262
+ style: { width: "100%", height: "100%" },
263
+ options: {
264
+ styles: !0,
265
+ formatCells: !0,
266
+ skipStyles: !1,
267
+ autoStyle: !0,
268
+ keepOriginalFormat: !0,
269
+ renderingStyle: "svg"
270
+ }
271
+ }, null, 8, ["src"])
272
+ ], 2),
273
+ i(T).length > 0 ? (d(), f("div", ye, [
274
+ c("div", he, [
275
+ i(T).length === 0 ? (d(), f("div", _e, "没有设置验证规则")) : (d(), f("div", be, [
276
+ m(i(G), {
277
+ message: U.value,
278
+ type: S.value,
279
+ "show-icon": "",
280
+ class: "mb-2"
281
+ }, null, 8, ["message", "type"]),
282
+ c("div", we, [
283
+ (d(!0), f($, null, P(i(T), (s, t) => (d(), f("div", {
284
+ key: t,
285
+ class: "border-b pb-0"
286
+ }, [
287
+ c("div", Ce, F(s.field), 1),
288
+ c("ul", Fe, [
289
+ (d(!0), f($, null, P(s.rules, (v, y) => (d(), f("li", {
290
+ key: y,
291
+ class: "text-[12px] text-gray-600"
292
+ }, F(v), 1))), 128))
293
+ ])
294
+ ]))), 128))
295
+ ]),
296
+ g.value && g.value.length > 0 ? (d(), f("div", Ee, [
297
+ m(i(G), {
298
+ message: k.value,
299
+ type: D.value,
300
+ "show-icon": "",
301
+ class: "mt-2 mb-2"
302
+ }, null, 8, ["message", "type"]),
303
+ c("div", Ue, [
304
+ c("div", Se, " 以下" + F(g.value.length > 1 ? "组合" : "字段") + "必须唯一 ", 1),
305
+ c("ul", ke, [
306
+ c("li", De, F(g.value.join(", ")), 1)
307
+ ])
308
+ ])
309
+ ])) : M("", !0)
310
+ ]))
311
+ ])
312
+ ])) : M("", !0)
313
+ ])
314
+ ]),
315
+ _: 3
316
+ }, 8, ["title", "open", "wrapClassName"]));
317
+ }
318
+ });
319
+ export {
320
+ $e as default
321
+ };