@skyfox2000/webui 1.2.8 → 1.2.10

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 (148) hide show
  1. package/package.json +1 -1
  2. package/scripts/userInput.py +2 -0
  3. package/src/components/common/index.ts +3 -0
  4. package/src/components/common/loading/index.vue +11 -0
  5. package/src/components/content/dialog/index.vue +15 -8
  6. package/src/components/content/dialog/uploadForm.vue +38 -79
  7. package/src/components/content/drawer/index.vue +26 -6
  8. package/src/components/content/form/formItem.vue +21 -5
  9. package/src/components/content/form/index.vue +4 -2
  10. package/src/components/content/search/searchItem.vue +1 -1
  11. package/src/components/form/autoComplete/index.vue +12 -4
  12. package/src/components/form/cascader/index.vue +1 -1
  13. package/src/components/form/datePicker/index.vue +1 -1
  14. package/src/components/form/index.ts +1 -0
  15. package/src/components/form/input/inputIcon.vue +1 -1
  16. package/src/components/form/propEditor/index.vue +113 -33
  17. package/src/components/form/select/index.vue +27 -17
  18. package/src/components/form/upload/uploadList.vue +174 -34
  19. package/src/components/index.ts +13 -1
  20. package/src/directives/permission.ts +2 -2
  21. package/src/index.ts +3 -1
  22. package/src/stores/userInfo.ts +28 -2
  23. package/src/typings/form.d.ts +18 -2
  24. package/src/typings/option.d.ts +16 -2
  25. package/src/typings/page.d.ts +1 -0
  26. package/src/utils/download.ts +1 -1
  27. package/src/utils/eventbus.ts +1 -1
  28. package/src/utils/file-upload.ts +75 -14
  29. package/src/utils/form-excel.ts +50 -1
  30. package/src/utils/form-validate.ts +18 -1
  31. package/src/utils/form.ts +3 -1
  32. package/src/utils/options.ts +38 -12
  33. package/lib/AceEditor.d.ts +0 -1
  34. package/lib/BasicLayout.d.ts +0 -1
  35. package/lib/Error403.d.ts +0 -1
  36. package/lib/Error404.d.ts +0 -1
  37. package/lib/ExcelForm.d.ts +0 -1
  38. package/lib/UploadForm.d.ts +0 -1
  39. package/lib/assets/modules/file-upload-CZO-pMJd.js +0 -176
  40. package/lib/assets/modules/form-excel-N-2OYqKv.js +0 -211
  41. package/lib/assets/modules/index-BnHnS9ug.js +0 -111
  42. package/lib/assets/modules/index-CTVMLeDF.js +0 -109
  43. package/lib/assets/modules/index-D9kzQ23e.js +0 -2213
  44. package/lib/assets/modules/menuTabs-BtOiocOC.js +0 -676
  45. package/lib/assets/modules/toolIcon-B9Mw9Ktm.js +0 -50
  46. package/lib/assets/modules/uploadList-B4LxzsC6.js +0 -210
  47. package/lib/components/common/button/index.vue.d.ts +0 -41
  48. package/lib/components/common/icon/appicon.vue.d.ts +0 -11
  49. package/lib/components/common/icon/fullscreen.vue.d.ts +0 -3
  50. package/lib/components/common/icon/helper.vue.d.ts +0 -22
  51. package/lib/components/common/icon/index.vue.d.ts +0 -243
  52. package/lib/components/common/icon/layoutIcon.vue.d.ts +0 -43
  53. package/lib/components/common/icon/projectIcon.vue.d.ts +0 -59
  54. package/lib/components/common/icon/toolIcon.vue.d.ts +0 -43
  55. package/lib/components/common/index.d.ts +0 -18
  56. package/lib/components/common/tooltip/index.vue.d.ts +0 -21
  57. package/lib/components/content/dialog/index.vue.d.ts +0 -34
  58. package/lib/components/content/drawer/index.vue.d.ts +0 -26
  59. package/lib/components/content/form/formItem.vue.d.ts +0 -25
  60. package/lib/components/content/form/index.vue.d.ts +0 -25
  61. package/lib/components/content/index.d.ts +0 -22
  62. package/lib/components/content/search/index.vue.d.ts +0 -30
  63. package/lib/components/content/search/searchItem.vue.d.ts +0 -23
  64. package/lib/components/content/table/index.vue.d.ts +0 -36
  65. package/lib/components/content/table/tableOperate.vue.d.ts +0 -18
  66. package/lib/components/content/toolbar/icontool.vue.d.ts +0 -7
  67. package/lib/components/content/toolbar/index.vue.d.ts +0 -18
  68. package/lib/components/content/tree/index.vue.d.ts +0 -46
  69. package/lib/components/form/aceEditor/aceConfig.d.ts +0 -8
  70. package/lib/components/form/autoComplete/index.vue.d.ts +0 -139
  71. package/lib/components/form/cascader/index.vue.d.ts +0 -109
  72. package/lib/components/form/checkbox/index.vue.d.ts +0 -128
  73. package/lib/components/form/datePicker/index.vue.d.ts +0 -6
  74. package/lib/components/form/index.d.ts +0 -38
  75. package/lib/components/form/input/index.vue.d.ts +0 -26
  76. package/lib/components/form/input/inputIcon.vue.d.ts +0 -10
  77. package/lib/components/form/input/inputNumber.vue.d.ts +0 -3
  78. package/lib/components/form/input/inputPassword.vue.d.ts +0 -3
  79. package/lib/components/form/propEditor/index.vue.d.ts +0 -12
  80. package/lib/components/form/radio/index.vue.d.ts +0 -133
  81. package/lib/components/form/radio/radioStatus.vue.d.ts +0 -31
  82. package/lib/components/form/rangePicker/index.vue.d.ts +0 -16
  83. package/lib/components/form/select/index.vue.d.ts +0 -142
  84. package/lib/components/form/switch/index.vue.d.ts +0 -43
  85. package/lib/components/form/textarea/index.vue.d.ts +0 -3
  86. package/lib/components/form/transfer/index.vue.d.ts +0 -38
  87. package/lib/components/form/transfer/transferTable.vue.d.ts +0 -38
  88. package/lib/components/form/treeSelect/index.vue.d.ts +0 -38
  89. package/lib/components/form/upload/uploadList.vue.d.ts +0 -476
  90. package/lib/components/index.d.ts +0 -4
  91. package/lib/components/layout/breadcrumb/index.vue.d.ts +0 -3
  92. package/lib/components/layout/content/index.vue.d.ts +0 -22
  93. package/lib/components/layout/datetime/index.vue.d.ts +0 -3
  94. package/lib/components/layout/header/headerExits.vue.d.ts +0 -3
  95. package/lib/components/layout/header/index.vue.d.ts +0 -3
  96. package/lib/components/layout/header/user.vue.d.ts +0 -3
  97. package/lib/components/layout/index.d.ts +0 -14
  98. package/lib/components/layout/menu/index.vue.d.ts +0 -6
  99. package/lib/components/layout/menu/menuTabs.vue.d.ts +0 -3
  100. package/lib/const/options.d.ts +0 -32
  101. package/lib/directives/enter-submit.d.ts +0 -4
  102. package/lib/directives/index.d.ts +0 -2
  103. package/lib/directives/permission.d.ts +0 -5
  104. package/lib/es/AceEditor/index.js +0 -167
  105. package/lib/es/BasicLayout/index.js +0 -101
  106. package/lib/es/Error403/index.js +0 -39
  107. package/lib/es/Error404/index.js +0 -39
  108. package/lib/es/ExcelForm/index.js +0 -321
  109. package/lib/es/UploadForm/index.js +0 -137
  110. package/lib/index.d.ts +0 -45
  111. package/lib/router/index.d.ts +0 -15
  112. package/lib/stores/appInfo.d.ts +0 -31
  113. package/lib/stores/hostInfo.d.ts +0 -9
  114. package/lib/stores/pageInfo.d.ts +0 -18
  115. package/lib/stores/pinia.d.ts +0 -3
  116. package/lib/stores/settingInfo.d.ts +0 -8
  117. package/lib/stores/userInfo.d.ts +0 -24
  118. package/lib/typings/data.d.ts +0 -80
  119. package/lib/typings/form.d.ts +0 -171
  120. package/lib/typings/menu.d.ts +0 -7
  121. package/lib/typings/option.d.ts +0 -175
  122. package/lib/typings/page.d.ts +0 -69
  123. package/lib/typings/table.d.ts +0 -181
  124. package/lib/typings/tools.d.ts +0 -130
  125. package/lib/typings/tree.d.ts +0 -72
  126. package/lib/typings/upload.d.ts +0 -161
  127. package/lib/typings/urls.d.ts +0 -69
  128. package/lib/utils/cache.d.ts +0 -23
  129. package/lib/utils/data.d.ts +0 -6
  130. package/lib/utils/download.d.ts +0 -4
  131. package/lib/utils/eventbus.d.ts +0 -16
  132. package/lib/utils/export-table.d.ts +0 -12
  133. package/lib/utils/file-upload.d.ts +0 -15
  134. package/lib/utils/form-excel.d.ts +0 -30
  135. package/lib/utils/form-validate.d.ts +0 -29
  136. package/lib/utils/form.d.ts +0 -9
  137. package/lib/utils/icon-loader.d.ts +0 -125
  138. package/lib/utils/isEmpty.d.ts +0 -1
  139. package/lib/utils/main-openapis.d.ts +0 -8
  140. package/lib/utils/menu.d.ts +0 -6
  141. package/lib/utils/options.d.ts +0 -10
  142. package/lib/utils/page.d.ts +0 -25
  143. package/lib/utils/table.d.ts +0 -21
  144. package/lib/utils/tools.d.ts +0 -18
  145. package/lib/utils/tree.d.ts +0 -3
  146. package/lib/vite-env.d.ts +0 -8
  147. package/lib/webui.css +0 -1
  148. package/lib/webui.es.js +0 -2240
@@ -1,167 +0,0 @@
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-B9Mw9Ktm.js";
4
- import "@skyfox2000/fapi";
5
- import "../../assets/modules/index-D9kzQ23e.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-BnHnS9ug.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
- };
@@ -1,101 +0,0 @@
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-B9Mw9Ktm.js";
4
- import { I as A, a as B, g as L, e as V, h as D } from "../../assets/modules/menuTabs-BtOiocOC.js";
5
- import { ab as j, a as K, ad as M } from "../../assets/modules/index-D9kzQ23e.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(), a = K(), x = M(), p = I("h-[calc(100vh-80px)]");
22
- return C(
23
- () => a.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(a).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(a).menuCollapse,
37
- "onUpdate:collapsed": m[0] || (m[0] = (s) => e(a).menuCollapse = s),
38
- collapsible: ""
39
- }, {
40
- default: l(() => [
41
- u("div", T, [
42
- r(z, {
43
- title: e(a).menuCollapse ? e(t).appInfo.Name : "",
44
- placement: "right"
45
- }, {
46
- default: l(() => {
47
- var s;
48
- return [
49
- (s = e(t).appInfo.Icon) != null && s.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(a).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(a).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: s, route: v }) => [
80
- (o(), n(N, {
81
- include: e(t).CachedComponents,
82
- exclude: e(t).ExcludeComponents
83
- }, [
84
- (o(), n($(e(t).cacheComponent(s, 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
- };
@@ -1,39 +0,0 @@
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/index-D9kzQ23e.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
- };
@@ -1,39 +0,0 @@
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/index-D9kzQ23e.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
- };
@@ -1,321 +0,0 @@
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-CTVMLeDF.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/index-D9kzQ23e.js";
6
- import { A as ue, p as ne, U as ce } from "../../assets/modules/file-upload-CZO-pMJd.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-N-2OYqKv.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
- };