jgy-public-component 0.0.4 → 0.0.7

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/index.js CHANGED
@@ -1,15 +1,16 @@
1
- import { defineComponent as $, openBlock as t, createElementBlock as u, normalizeClass as A, createCommentVNode as g, renderSlot as O, ref as w, watch as Z, resolveComponent as _, createVNode as d, unref as c, withCtx as f, createElementVNode as j, withModifiers as C, createBlock as p, Fragment as q, toDisplayString as F, mergeProps as G } from "vue";
2
- import { ElMessage as y } from "element-plus";
3
- import { Delete as S, Plus as E, Loading as U, ZoomIn as H } from "@element-plus/icons-vue";
4
- import K from "vuedraggable";
5
- import { Icon as Q } from "@iconify/vue";
6
- const W = ["disabled"], X = {
1
+ import { defineComponent as O, openBlock as s, createElementBlock as $, normalizeClass as X, createCommentVNode as C, renderSlot as N, ref as B, watch as oe, resolveComponent as h, createVNode as d, unref as x, withCtx as i, createElementVNode as _, withModifiers as Z, createBlock as m, Fragment as q, toDisplayString as S, mergeProps as re, computed as ie, onMounted as me, onBeforeUnmount as fe, normalizeStyle as ue, createTextVNode as A, useModel as pe, renderList as ee, mergeModels as ae } from "vue";
2
+ import { ElMessage as j } from "element-plus";
3
+ import { Delete as G, Plus as Q, Loading as ne, ZoomIn as ve, Search as ge, Refresh as he, ArrowDown as ye, Expand as be, Fold as _e } from "@element-plus/icons-vue";
4
+ import ke from "vuedraggable";
5
+ import { Icon as we } from "@iconify/vue";
6
+ import * as z from "xlsx";
7
+ const xe = ["disabled"], Ce = {
7
8
  key: 0,
8
9
  class: "j-button__loading-icon"
9
- }, Y = {
10
+ }, je = {
10
11
  key: 1,
11
12
  class: "j-button__text"
12
- }, ee = /* @__PURE__ */ $({
13
+ }, $e = /* @__PURE__ */ O({
13
14
  __name: "JButton",
14
15
  props: {
15
16
  type: { default: "default" },
@@ -21,12 +22,12 @@ const W = ["disabled"], X = {
21
22
  },
22
23
  emits: ["click"],
23
24
  setup(e, { emit: n }) {
24
- const l = e, r = n;
25
- function s(v) {
26
- !l.disabled && !l.loading && r("click", v);
25
+ const l = e, u = n;
26
+ function t(o) {
27
+ !l.disabled && !l.loading && u("click", o);
27
28
  }
28
- return (v, V) => (t(), u("button", {
29
- class: A(["j-button", [
29
+ return (o, r) => (s(), $("button", {
30
+ class: X(["j-button", [
30
31
  `j-button--${e.type}`,
31
32
  `j-button--${e.size}`,
32
33
  {
@@ -37,29 +38,29 @@ const W = ["disabled"], X = {
37
38
  }
38
39
  ]]),
39
40
  disabled: e.disabled || e.loading,
40
- onClick: s
41
+ onClick: t
41
42
  }, [
42
- e.loading ? (t(), u("span", X)) : g("", !0),
43
- v.$slots.default ? (t(), u("span", Y, [
44
- O(v.$slots, "default", {}, void 0, !0)
45
- ])) : g("", !0)
46
- ], 10, W));
43
+ e.loading ? (s(), $("span", Ce)) : C("", !0),
44
+ o.$slots.default ? (s(), $("span", je, [
45
+ N(o.$slots, "default", {}, void 0, !0)
46
+ ])) : C("", !0)
47
+ ], 10, xe));
47
48
  }
48
- }), D = (e, n) => {
49
+ }), P = (e, n) => {
49
50
  const l = e.__vccOpts || e;
50
- for (const [r, s] of n)
51
- l[r] = s;
51
+ for (const [u, t] of n)
52
+ l[u] = t;
52
53
  return l;
53
- }, te = /* @__PURE__ */ D(ee, [["__scopeId", "data-v-22864824"]]), le = { class: "j-upload-img-container" }, ae = {
54
+ }, Ie = /* @__PURE__ */ P($e, [["__scopeId", "data-v-22864824"]]), Be = { class: "j-upload-img-container" }, Se = {
54
55
  key: 0,
55
56
  class: "images-wrapper"
56
- }, ie = { class: "image-item" }, oe = ["onClick"], ne = {
57
+ }, Ve = { class: "image-item" }, Ee = ["onClick"], Ae = {
57
58
  key: 0,
58
59
  class: "image-item single-image-item"
59
- }, se = { class: "image-actions" }, de = {
60
+ }, Je = { class: "image-actions" }, Me = {
60
61
  key: 2,
61
62
  class: "upload-tip"
62
- }, ce = { key: 0 }, ue = /* @__PURE__ */ $({
63
+ }, Te = { key: 0 }, De = /* @__PURE__ */ O({
63
64
  name: "JUploadImg",
64
65
  __name: "JUploadImg",
65
66
  props: {
@@ -75,207 +76,850 @@ const W = ["disabled"], X = {
75
76
  },
76
77
  emits: ["update:modelValue", "success", "error"],
77
78
  setup(e, { emit: n }) {
78
- const l = e, r = n, s = w(""), v = w(!1), V = l.showTip, M = () => {
79
- v.value = !0;
80
- }, R = () => {
81
- s.value = "", r("update:modelValue", ""), y.success("删除成功");
82
- }, m = w([]), h = w(!1), P = (a) => {
83
- m.value = a.map((i, o) => ({
84
- uid: Date.now() + o,
85
- url: i
79
+ const l = e, u = n, t = B(""), o = B(!1), r = l.showTip, f = () => {
80
+ o.value = !0;
81
+ }, y = () => {
82
+ t.value = "", u("update:modelValue", ""), j.success("删除成功");
83
+ }, w = B([]), v = B(!1), J = (p) => {
84
+ w.value = p.map((c, a) => ({
85
+ uid: Date.now() + a,
86
+ url: c
86
87
  }));
87
88
  };
88
- Z(() => l.modelValue, (a) => {
89
- l.multiple ? Array.isArray(a) && a.length > 0 ? P(a) : m.value = [] : typeof a == "string" ? s.value = a : s.value = "";
89
+ oe(() => l.modelValue, (p) => {
90
+ l.multiple ? Array.isArray(p) && p.length > 0 ? J(p) : w.value = [] : typeof p == "string" ? t.value = p : t.value = "";
90
91
  }, { immediate: !0 });
91
- const T = () => {
92
- B();
93
- }, L = (a) => {
94
- m.value.splice(a, 1), B(), y.success("删除成功");
95
- }, I = async (a) => {
96
- const i = a.raw;
97
- if (!i) {
98
- y.error("文件不存在,请重试");
92
+ const M = () => {
93
+ T();
94
+ }, k = (p) => {
95
+ w.value.splice(p, 1), T(), j.success("删除成功");
96
+ }, g = async (p) => {
97
+ const c = p.raw;
98
+ if (!c) {
99
+ j.error("文件不存在,请重试");
99
100
  return;
100
101
  }
101
- if (i.size > l.maxSize * 1024 * 1024) {
102
- y.error(`图片大小不能超过 ${l.maxSize}MB`);
102
+ if (c.size > l.maxSize * 1024 * 1024) {
103
+ j.error(`图片大小不能超过 ${l.maxSize}MB`);
103
104
  return;
104
105
  }
105
106
  if (!l.uploadFn) {
106
- y.error("未配置上传函数 (uploadFn)");
107
+ j.error("未配置上传函数 (uploadFn)");
107
108
  return;
108
109
  }
109
110
  try {
110
- h.value = !0;
111
- const o = await l.uploadFn(i);
112
- l.multiple ? (m.value.push({ uid: Date.now(), url: o }), B()) : (s.value = o, r("update:modelValue", o)), r("success", o), y.success("上传成功");
113
- } catch (o) {
114
- console.error("上传出错:", o), y.error("上传失败,请重试"), r("error", o);
111
+ v.value = !0;
112
+ const a = await l.uploadFn(c);
113
+ l.multiple ? (w.value.push({ uid: Date.now(), url: a }), T()) : (t.value = a, u("update:modelValue", a)), u("success", a), j.success("上传成功");
114
+ } catch (a) {
115
+ console.error("上传出错:", a), j.error("上传失败,请重试"), u("error", a);
115
116
  } finally {
116
- h.value = !1;
117
+ v.value = !1;
117
118
  }
118
- }, B = () => {
119
- const a = m.value.map((i) => i.url);
120
- r("update:modelValue", a);
119
+ }, T = () => {
120
+ const p = w.value.map((c) => c.url);
121
+ u("update:modelValue", p);
121
122
  };
122
- return (a, i) => {
123
- const o = _("el-image"), b = _("el-icon"), x = _("el-upload"), N = _("el-image-viewer");
124
- return t(), u("div", le, [
125
- e.multiple ? (t(), u("div", ae, [
126
- d(c(K), {
127
- modelValue: m.value,
128
- "onUpdate:modelValue": i[0] || (i[0] = (k) => m.value = k),
123
+ return (p, c) => {
124
+ const a = h("el-image"), b = h("el-icon"), I = h("el-upload"), D = h("el-image-viewer");
125
+ return s(), $("div", Be, [
126
+ e.multiple ? (s(), $("div", Se, [
127
+ d(x(ke), {
128
+ modelValue: w.value,
129
+ "onUpdate:modelValue": c[0] || (c[0] = (F) => w.value = F),
129
130
  class: "images-list",
130
131
  "item-key": "uid",
131
132
  animation: 200,
132
133
  disabled: e.disabled,
133
- onEnd: T
134
+ onEnd: M
134
135
  }, {
135
- item: f(({ element: k, index: J }) => [
136
- j("div", ie, [
137
- d(o, {
138
- src: k.url,
139
- "preview-src-list": m.value.map((z) => z.url),
140
- "initial-index": J,
136
+ item: i(({ element: F, index: R }) => [
137
+ _("div", Ve, [
138
+ d(a, {
139
+ src: F.url,
140
+ "preview-src-list": w.value.map((E) => E.url),
141
+ "initial-index": R,
141
142
  fit: "cover",
142
143
  class: "image-preview",
143
144
  "preview-teleported": !0,
144
145
  "hide-on-click-modal": !0
145
146
  }, null, 8, ["src", "preview-src-list", "initial-index"]),
146
- e.disabled ? g("", !0) : (t(), u("div", {
147
+ e.disabled ? C("", !0) : (s(), $("div", {
147
148
  key: 0,
148
149
  class: "delete-btn",
149
- onClick: C((z) => L(J), ["stop"])
150
+ onClick: Z((E) => k(R), ["stop"])
150
151
  }, [
151
152
  d(b, { class: "icon-delete" }, {
152
- default: f(() => [
153
- d(c(S))
153
+ default: i(() => [
154
+ d(x(G))
154
155
  ]),
155
156
  _: 1
156
157
  })
157
- ], 8, oe))
158
+ ], 8, Ee))
158
159
  ])
159
160
  ]),
160
161
  _: 1
161
162
  }, 8, ["modelValue", "disabled"]),
162
- !e.disabled && (!e.limit || m.value.length < e.limit) ? (t(), p(x, {
163
+ !e.disabled && (!e.limit || w.value.length < e.limit) ? (s(), m(I, {
163
164
  key: 0,
164
165
  class: "image-uploader",
165
166
  "auto-upload": !1,
166
167
  "show-file-list": !1,
167
- "on-change": I,
168
- disabled: h.value,
168
+ "on-change": g,
169
+ disabled: v.value,
169
170
  "list-type": "picture-card",
170
171
  accept: e.accept
171
172
  }, {
172
- default: f(() => [
173
- h.value ? (t(), p(b, {
173
+ default: i(() => [
174
+ v.value ? (s(), m(b, {
174
175
  key: 1,
175
176
  class: "uploader-icon is-loading"
176
177
  }, {
177
- default: f(() => [
178
- d(c(U))
178
+ default: i(() => [
179
+ d(x(ne))
179
180
  ]),
180
181
  _: 1
181
- })) : (t(), p(b, {
182
+ })) : (s(), m(b, {
182
183
  key: 0,
183
184
  class: "uploader-icon"
184
185
  }, {
185
- default: f(() => [
186
- d(c(E))
186
+ default: i(() => [
187
+ d(x(Q))
187
188
  ]),
188
189
  _: 1
189
190
  }))
190
191
  ]),
191
192
  _: 1
192
- }, 8, ["disabled", "accept"])) : g("", !0)
193
- ])) : (t(), u(q, { key: 1 }, [
194
- s.value ? (t(), u("div", ne, [
195
- d(o, {
196
- src: s.value,
193
+ }, 8, ["disabled", "accept"])) : C("", !0)
194
+ ])) : (s(), $(q, { key: 1 }, [
195
+ t.value ? (s(), $("div", Ae, [
196
+ d(a, {
197
+ src: t.value,
197
198
  fit: "cover",
198
199
  class: "image-preview"
199
200
  }, null, 8, ["src"]),
200
- j("div", se, [
201
+ _("div", Je, [
201
202
  d(b, {
202
203
  class: "action-icon",
203
- onClick: C(M, ["stop"])
204
+ onClick: Z(f, ["stop"])
204
205
  }, {
205
- default: f(() => [
206
- d(c(H))
206
+ default: i(() => [
207
+ d(x(ve))
207
208
  ]),
208
209
  _: 1
209
210
  }),
210
- e.disabled ? g("", !0) : (t(), p(b, {
211
+ e.disabled ? C("", !0) : (s(), m(b, {
211
212
  key: 0,
212
213
  class: "action-icon",
213
- onClick: C(R, ["stop"])
214
+ onClick: Z(y, ["stop"])
214
215
  }, {
215
- default: f(() => [
216
- d(c(S))
216
+ default: i(() => [
217
+ d(x(G))
217
218
  ]),
218
219
  _: 1
219
220
  }))
220
221
  ])
221
- ])) : (t(), p(x, {
222
+ ])) : (s(), m(I, {
222
223
  key: 1,
223
224
  class: "image-uploader",
224
225
  "auto-upload": !1,
225
226
  "show-file-list": !1,
226
- "on-change": I,
227
- disabled: e.disabled || h.value,
227
+ "on-change": g,
228
+ disabled: e.disabled || v.value,
228
229
  accept: e.accept,
229
230
  "list-type": "picture-card"
230
231
  }, {
231
- default: f(() => [
232
+ default: i(() => [
232
233
  d(b, { class: "uploader-icon" }, {
233
- default: f(() => [
234
- h.value ? (t(), p(c(U), {
234
+ default: i(() => [
235
+ v.value ? (s(), m(x(ne), {
235
236
  key: 1,
236
237
  class: "is-loading"
237
- })) : (t(), p(c(E), { key: 0 }))
238
+ })) : (s(), m(x(Q), { key: 0 }))
238
239
  ]),
239
240
  _: 1
240
241
  })
241
242
  ]),
242
243
  _: 1
243
244
  }, 8, ["disabled", "accept"])),
244
- v.value ? (t(), p(N, {
245
+ o.value ? (s(), m(D, {
245
246
  key: 2,
246
- "url-list": [s.value],
247
+ "url-list": [t.value],
247
248
  teleported: !0,
248
- onClose: i[1] || (i[1] = (k) => v.value = !1)
249
- }, null, 8, ["url-list"])) : g("", !0)
249
+ onClose: c[1] || (c[1] = (F) => o.value = !1)
250
+ }, null, 8, ["url-list"])) : C("", !0)
250
251
  ], 64)),
251
- c(V) ? (t(), u("div", de, [
252
- j("span", null, F(e.tip), 1),
253
- e.multiple && e.limit ? (t(), u("span", ce, " (最多 " + F(e.limit) + " 张)", 1)) : g("", !0)
254
- ])) : g("", !0)
252
+ x(r) ? (s(), $("div", Me, [
253
+ _("span", null, S(e.tip), 1),
254
+ e.multiple && e.limit ? (s(), $("span", Te, " (最多 " + S(e.limit) + " 张)", 1)) : C("", !0)
255
+ ])) : C("", !0)
255
256
  ]);
256
257
  };
257
258
  }
258
- }), re = /* @__PURE__ */ D(ue, [["__scopeId", "data-v-052bacda"]]), me = /* @__PURE__ */ $({
259
+ }), Fe = /* @__PURE__ */ P(De, [["__scopeId", "data-v-052bacda"]]), Y = /* @__PURE__ */ O({
259
260
  name: "JIconRender",
260
261
  __name: "JIconRender",
261
262
  props: {
262
263
  icon: {}
263
264
  },
264
265
  setup(e) {
265
- return (n, l) => e.icon ? (t(), p(c(Q), G({
266
+ return (n, l) => e.icon ? (s(), m(x(we), re({
266
267
  key: 0,
267
268
  icon: e.icon
268
- }, n.$attrs), null, 16, ["icon"])) : g("", !0);
269
+ }, n.$attrs), null, 16, ["icon"])) : C("", !0);
269
270
  }
270
- }), fe = [te, re, me], pe = (e) => {
271
- fe.forEach((n) => {
271
+ }), Oe = { class: "action-left" }, Re = /* @__PURE__ */ O({
272
+ name: "JSearchHeader",
273
+ __name: "JSearchHeader",
274
+ props: {
275
+ selectedCount: { default: 0 },
276
+ addText: { default: "新增" },
277
+ defaultVisible: { default: 5 },
278
+ showAdd: { type: Boolean, default: !0 },
279
+ showBatchDelete: { type: Boolean, default: !0 },
280
+ showSearch: { type: Boolean, default: !0 },
281
+ showReset: { type: Boolean, default: !0 }
282
+ },
283
+ emits: ["search", "reset", "add", "batchDelete"],
284
+ setup(e, { emit: n }) {
285
+ const l = e, u = n, t = B(), o = B(!1), r = B(!1), f = B(0), y = B(0), w = ie(() => f.value > l.defaultVisible), v = () => {
286
+ if (!t.value) return;
287
+ const k = Array.from(t.value.children);
288
+ f.value = k.length;
289
+ const g = k[l.defaultVisible - 1];
290
+ if (g && t.value) {
291
+ const T = t.value.getBoundingClientRect(), p = g.getBoundingClientRect();
292
+ y.value = p.bottom - T.top;
293
+ }
294
+ }, J = () => {
295
+ const k = t.value;
296
+ if (k)
297
+ if (o.value)
298
+ v(), o.value = !1, k.style.maxHeight = k.scrollHeight + "px", k.offsetHeight, k.style.maxHeight = y.value + "px";
299
+ else {
300
+ o.value = !0, k.style.maxHeight = k.scrollHeight + "px";
301
+ const g = () => {
302
+ k.style.maxHeight = "none", k.removeEventListener("transitionend", g);
303
+ };
304
+ k.addEventListener("transitionend", g);
305
+ }
306
+ };
307
+ let M = null;
308
+ return me(() => {
309
+ v(), w.value && t.value && (t.value.style.maxHeight = y.value + "px"), requestAnimationFrame(() => {
310
+ requestAnimationFrame(() => {
311
+ r.value = !0;
312
+ });
313
+ }), t.value && (M = new MutationObserver(() => {
314
+ v(), w.value && !o.value && t.value && (t.value.style.maxHeight = y.value + "px");
315
+ }), M.observe(t.value, { childList: !0 }));
316
+ }), fe(() => {
317
+ M == null || M.disconnect();
318
+ }), (k, g) => {
319
+ const T = h("el-form"), p = h("el-button"), c = h("el-icon"), a = h("el-card");
320
+ return s(), m(a, {
321
+ shadow: "never",
322
+ class: "j-search-header-card"
323
+ }, {
324
+ default: i(() => [
325
+ d(T, {
326
+ inline: "",
327
+ class: "search-form"
328
+ }, {
329
+ default: i(() => [
330
+ _("div", {
331
+ ref_key: "formItemsRef",
332
+ ref: t,
333
+ class: X(["form-items-wrapper", { "is-animated": r.value }])
334
+ }, [
335
+ N(k.$slots, "default", {}, void 0, !0)
336
+ ], 2)
337
+ ]),
338
+ _: 3
339
+ }),
340
+ _("div", {
341
+ class: "action-bar",
342
+ style: ue({ marginTop: o.value ? "0px" : "10px" })
343
+ }, [
344
+ _("div", Oe, [
345
+ e.showAdd ? (s(), m(p, {
346
+ key: 0,
347
+ type: "primary",
348
+ icon: x(Q),
349
+ onClick: g[0] || (g[0] = (b) => u("add"))
350
+ }, {
351
+ default: i(() => [
352
+ A(S(e.addText), 1)
353
+ ]),
354
+ _: 1
355
+ }, 8, ["icon"])) : C("", !0),
356
+ e.showBatchDelete ? (s(), m(p, {
357
+ key: 1,
358
+ type: "danger",
359
+ icon: x(G),
360
+ disabled: e.selectedCount === 0,
361
+ onClick: g[1] || (g[1] = (b) => u("batchDelete"))
362
+ }, {
363
+ default: i(() => [
364
+ A(" 批量删除" + S(e.selectedCount ? `(${e.selectedCount})` : ""), 1)
365
+ ]),
366
+ _: 1
367
+ }, 8, ["icon", "disabled"])) : C("", !0),
368
+ e.showSearch ? (s(), m(p, {
369
+ key: 2,
370
+ type: "primary",
371
+ icon: x(ge),
372
+ onClick: g[2] || (g[2] = (b) => u("search"))
373
+ }, {
374
+ default: i(() => [...g[4] || (g[4] = [
375
+ A("搜索", -1)
376
+ ])]),
377
+ _: 1
378
+ }, 8, ["icon"])) : C("", !0),
379
+ e.showReset ? (s(), m(p, {
380
+ key: 3,
381
+ icon: x(he),
382
+ onClick: g[3] || (g[3] = (b) => u("reset"))
383
+ }, {
384
+ default: i(() => [...g[5] || (g[5] = [
385
+ A("重置", -1)
386
+ ])]),
387
+ _: 1
388
+ }, 8, ["icon"])) : C("", !0),
389
+ N(k.$slots, "actions", {}, void 0, !0)
390
+ ]),
391
+ w.value ? (s(), m(p, {
392
+ key: 0,
393
+ link: "",
394
+ type: "primary",
395
+ onClick: J
396
+ }, {
397
+ default: i(() => [
398
+ A(S(o.value ? "收起" : "展开") + " ", 1),
399
+ d(c, {
400
+ class: X(["toggle-icon", { "is-expanded": o.value }])
401
+ }, {
402
+ default: i(() => [
403
+ d(x(ye))
404
+ ]),
405
+ _: 1
406
+ }, 8, ["class"])
407
+ ]),
408
+ _: 1
409
+ })) : C("", !0)
410
+ ], 4)
411
+ ]),
412
+ _: 3
413
+ });
414
+ };
415
+ }
416
+ }), ze = /* @__PURE__ */ P(Re, [["__scopeId", "data-v-4488c604"]]), He = { class: "j-import-upload-row" }, Le = { class: "j-import-stat-num" }, Ue = { class: "j-import-stat-num" }, Ne = { class: "j-import-stat-num" }, Pe = {
417
+ key: 0,
418
+ class: "j-import-status-fail"
419
+ }, We = { key: 1 }, Ke = /* @__PURE__ */ O({
420
+ name: "JImportExcel",
421
+ __name: "JImportExcel",
422
+ props: /* @__PURE__ */ ae({
423
+ getFieldListApi: {},
424
+ importApi: {},
425
+ excludeFields: { default: () => ["id", "ctime", "mtime"] },
426
+ title: { default: "Excel 批量导入" }
427
+ }, {
428
+ modelValue: { type: Boolean, default: !1 },
429
+ modelModifiers: {}
430
+ }),
431
+ emits: /* @__PURE__ */ ae(["success"], ["update:modelValue"]),
432
+ setup(e, { emit: n }) {
433
+ const l = e, u = n, t = pe(e, "modelValue"), o = B(!1), r = B({}), f = B([]), y = B({ total: 0, success: 0, fail: 0 }), w = {
434
+ 0: "待创建",
435
+ 1: "创建成功",
436
+ 2: "创建中",
437
+ [-1]: "创建失败"
438
+ }, v = ie(() => Object.entries(r.value).filter(([c]) => !l.excludeFields.includes(c)).map(([c, a]) => ({ id: c, label: a, prop: c }))), J = async () => {
439
+ try {
440
+ const c = await l.getFieldListApi();
441
+ r.value = c.data.tableFieldsInfo ?? {};
442
+ } catch {
443
+ j.error("获取字段列表失败");
444
+ }
445
+ }, M = (c) => {
446
+ const a = c.raw;
447
+ if (!a) return;
448
+ if (![
449
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
450
+ "application/vnd.ms-excel"
451
+ ].includes(a.type) && !a.name.match(/\.xlsx?$/i)) {
452
+ j.warning("请上传 .xlsx 或 .xls 格式文件");
453
+ return;
454
+ }
455
+ const I = new FileReader();
456
+ I.onload = (D) => {
457
+ try {
458
+ const F = z.read(D.target.result, { type: "binary" }), R = F.SheetNames[0], E = F.Sheets[R], H = z.utils.sheet_to_json(E);
459
+ if (!H.length) {
460
+ j.warning("文件内容为空");
461
+ return;
462
+ }
463
+ const L = v.value.map((U) => U.prop), W = H.map((U) => {
464
+ const V = Object.values(U), K = { _status: 0, _error: "" };
465
+ return L.forEach((le, de) => {
466
+ K[le] = V[de];
467
+ }), K;
468
+ });
469
+ f.value = W, y.value = { total: W.length, success: 0, fail: 0 };
470
+ } catch {
471
+ j.error("解析文件失败,请检查文件格式");
472
+ }
473
+ }, I.readAsBinaryString(a);
474
+ }, k = (c) => {
475
+ f.value.splice(c, 1), y.value.total = f.value.length;
476
+ }, g = async () => {
477
+ const c = f.value.filter((a) => a._status === 0).map(({ _status: a, _error: b, ...I }) => I);
478
+ if (!c.length) {
479
+ j.warning("没有可导入的数据");
480
+ return;
481
+ }
482
+ o.value = !0;
483
+ try {
484
+ const a = await l.importApi(c);
485
+ a.code === 1 ? (f.value.forEach((b) => {
486
+ b._status === 0 && (b._status = 1);
487
+ }), y.value.success = f.value.filter((b) => b._status === 1).length, j.success("导入成功"), u("success")) : j.error(a.msg || "导入失败");
488
+ } catch {
489
+ j.error("导入失败,请重试");
490
+ } finally {
491
+ o.value = !1;
492
+ }
493
+ }, T = () => {
494
+ try {
495
+ const c = z.utils.book_new(), a = v.value.map((D) => D.label), b = {};
496
+ a.forEach((D) => b[D] = "");
497
+ const I = z.utils.json_to_sheet([b]);
498
+ z.utils.book_append_sheet(c, I, "模板"), z.writeFile(c, "导入模板.xlsx");
499
+ } catch {
500
+ j.error("模板下载失败");
501
+ }
502
+ }, p = () => {
503
+ o.value || (t.value = !1, f.value = [], y.value = { total: 0, success: 0, fail: 0 });
504
+ };
505
+ return (c, a) => {
506
+ const b = h("el-divider"), I = h("el-button"), D = h("el-upload"), F = h("el-link"), R = h("el-card"), E = h("el-col"), H = h("el-row"), L = h("el-table-column"), W = h("el-table"), U = h("el-dialog");
507
+ return s(), m(U, {
508
+ modelValue: t.value,
509
+ "onUpdate:modelValue": a[0] || (a[0] = (V) => t.value = V),
510
+ title: l.title,
511
+ width: "900px",
512
+ "close-on-click-modal": !1,
513
+ onOpen: J,
514
+ onClose: p
515
+ }, {
516
+ footer: i(() => [
517
+ d(I, { onClick: p }, {
518
+ default: i(() => [...a[9] || (a[9] = [
519
+ A("关闭", -1)
520
+ ])]),
521
+ _: 1
522
+ })
523
+ ]),
524
+ default: i(() => [
525
+ d(R, {
526
+ shadow: "never",
527
+ class: "j-import-upload-card"
528
+ }, {
529
+ default: i(() => [
530
+ a[3] || (a[3] = _("div", { class: "j-import-upload-card-title" }, "导入 EXCEL", -1)),
531
+ d(b, { style: { margin: "10px 0" } }),
532
+ _("div", He, [
533
+ d(D, {
534
+ accept: ".xlsx,.xls",
535
+ "auto-upload": !1,
536
+ "show-file-list": !1,
537
+ "on-change": M
538
+ }, {
539
+ default: i(() => [
540
+ d(I, { size: "small" }, {
541
+ default: i(() => [...a[1] || (a[1] = [
542
+ A("点击上传", -1)
543
+ ])]),
544
+ _: 1
545
+ })
546
+ ]),
547
+ _: 1
548
+ }),
549
+ v.value.length ? (s(), m(F, {
550
+ key: 0,
551
+ type: "primary",
552
+ class: "j-import-no-wrap",
553
+ onClick: T
554
+ }, {
555
+ default: i(() => [...a[2] || (a[2] = [
556
+ A(" 下载导入模板.xlsx ", -1)
557
+ ])]),
558
+ _: 1
559
+ })) : C("", !0)
560
+ ])
561
+ ]),
562
+ _: 1
563
+ }),
564
+ d(H, {
565
+ class: "j-import-stats-row",
566
+ gutter: 20,
567
+ align: "middle"
568
+ }, {
569
+ default: i(() => [
570
+ d(E, { span: 18 }, {
571
+ default: i(() => [
572
+ d(H, { class: "j-import-stats-cols" }, {
573
+ default: i(() => [
574
+ d(E, {
575
+ span: 4,
576
+ class: "j-import-stat-item"
577
+ }, {
578
+ default: i(() => [
579
+ _("div", Le, S(y.value.total), 1),
580
+ a[4] || (a[4] = _("div", { class: "j-import-stat-label" }, "导入数量", -1))
581
+ ]),
582
+ _: 1
583
+ }),
584
+ d(E, {
585
+ span: 4,
586
+ class: "j-import-stat-item"
587
+ }, {
588
+ default: i(() => [
589
+ _("div", Ue, S(y.value.fail), 1),
590
+ a[5] || (a[5] = _("div", { class: "j-import-stat-label" }, "失败数量", -1))
591
+ ]),
592
+ _: 1
593
+ }),
594
+ d(E, {
595
+ span: 4,
596
+ class: "j-import-stat-item"
597
+ }, {
598
+ default: i(() => [
599
+ _("div", Ne, S(y.value.success), 1),
600
+ a[6] || (a[6] = _("div", { class: "j-import-stat-label" }, "成功数量", -1))
601
+ ]),
602
+ _: 1
603
+ })
604
+ ]),
605
+ _: 1
606
+ })
607
+ ]),
608
+ _: 1
609
+ }),
610
+ d(E, {
611
+ span: 6,
612
+ class: "j-import-confirm-col"
613
+ }, {
614
+ default: i(() => [
615
+ d(I, {
616
+ type: "primary",
617
+ size: "small",
618
+ loading: o.value,
619
+ disabled: !f.value.length,
620
+ onClick: g
621
+ }, {
622
+ default: i(() => [...a[7] || (a[7] = [
623
+ A(" 确认导入 ", -1)
624
+ ])]),
625
+ _: 1
626
+ }, 8, ["loading", "disabled"])
627
+ ]),
628
+ _: 1
629
+ })
630
+ ]),
631
+ _: 1
632
+ }),
633
+ d(W, {
634
+ data: f.value,
635
+ border: "",
636
+ size: "small",
637
+ "max-height": "360",
638
+ class: "j-import-data-table"
639
+ }, {
640
+ default: i(() => [
641
+ (s(!0), $(q, null, ee(v.value, (V) => (s(), m(L, {
642
+ key: V.prop,
643
+ prop: V.prop,
644
+ label: V.label,
645
+ "min-width": 120,
646
+ "show-overflow-tooltip": ""
647
+ }, null, 8, ["prop", "label"]))), 128)),
648
+ d(L, {
649
+ label: "状态",
650
+ width: "110",
651
+ align: "center",
652
+ fixed: "right"
653
+ }, {
654
+ default: i(({ row: V }) => [
655
+ V._status === -1 ? (s(), $("span", Pe, S(V._error || "创建失败"), 1)) : (s(), $("span", We, S(w[V._status]), 1))
656
+ ]),
657
+ _: 1
658
+ }),
659
+ d(L, {
660
+ label: "操作",
661
+ width: "80",
662
+ align: "center",
663
+ fixed: "right"
664
+ }, {
665
+ default: i(({ $index: V, row: K }) => [
666
+ K._status === 0 ? (s(), m(I, {
667
+ key: 0,
668
+ size: "small",
669
+ onClick: (le) => k(V)
670
+ }, {
671
+ default: i(() => [...a[8] || (a[8] = [
672
+ A(" 删除 ", -1)
673
+ ])]),
674
+ _: 1
675
+ }, 8, ["onClick"])) : C("", !0)
676
+ ]),
677
+ _: 1
678
+ })
679
+ ]),
680
+ _: 1
681
+ }, 8, ["data"])
682
+ ]),
683
+ _: 1
684
+ }, 8, ["modelValue", "title"]);
685
+ };
686
+ }
687
+ }), Xe = /* @__PURE__ */ P(Ke, [["__scopeId", "data-v-2ece86f5"]]), ce = /* @__PURE__ */ O({
688
+ name: "JSideMenuItem",
689
+ __name: "JSideMenuItem",
690
+ props: {
691
+ menuItem: {},
692
+ isCollapse: { type: Boolean },
693
+ depth: { default: 0 }
694
+ },
695
+ emits: ["menu-click"],
696
+ setup(e, { emit: n }) {
697
+ const l = e, u = n, t = () => {
698
+ u("menu-click", l.menuItem);
699
+ };
700
+ return (o, r) => {
701
+ const f = h("JSideMenuItem", !0), y = h("el-sub-menu"), w = h("el-menu-item");
702
+ return e.menuItem.children && e.menuItem.children.length > 0 ? (s(), m(y, {
703
+ key: 0,
704
+ index: e.menuItem.path
705
+ }, {
706
+ title: i(() => [
707
+ e.menuItem.icon && e.depth === 0 ? (s(), m(x(Y), {
708
+ key: 0,
709
+ icon: e.menuItem.icon
710
+ }, null, 8, ["icon"])) : C("", !0),
711
+ _("span", null, S(e.menuItem.title || e.menuItem.name), 1)
712
+ ]),
713
+ default: i(() => [
714
+ (s(!0), $(q, null, ee(e.menuItem.children, (v) => (s(), m(f, {
715
+ key: v.path,
716
+ "menu-item": v,
717
+ "is-collapse": e.isCollapse,
718
+ depth: e.depth + 1,
719
+ onMenuClick: r[0] || (r[0] = (J) => u("menu-click", J))
720
+ }, null, 8, ["menu-item", "is-collapse", "depth"]))), 128))
721
+ ]),
722
+ _: 1
723
+ }, 8, ["index"])) : (s(), m(w, {
724
+ key: 1,
725
+ index: e.menuItem.path,
726
+ onClick: t
727
+ }, {
728
+ title: i(() => [
729
+ _("span", null, S(e.menuItem.title || e.menuItem.name), 1)
730
+ ]),
731
+ default: i(() => [
732
+ e.menuItem.icon && e.depth === 0 ? (s(), m(x(Y), {
733
+ key: 0,
734
+ icon: e.menuItem.icon
735
+ }, null, 8, ["icon"])) : C("", !0)
736
+ ]),
737
+ _: 1
738
+ }, 8, ["index"]));
739
+ };
740
+ }
741
+ }), qe = { class: "j-sidebar__logo" }, Ze = { class: "j-sidebar__title" }, Ge = { class: "j-sidebar__menu-wrapper" }, Qe = { class: "j-sidebar__footer" }, Ye = { class: "j-sidebar__collapse-text" }, et = /* @__PURE__ */ O({
742
+ name: "JSidebar",
743
+ __name: "JSidebar",
744
+ props: {
745
+ menus: {},
746
+ activeMenu: { default: "" },
747
+ title: { default: "" },
748
+ collapsedTitle: { default: "" },
749
+ collapsed: { type: Boolean, default: !1 },
750
+ collapsedWidth: { default: 64 },
751
+ expandedWidth: { default: 200 },
752
+ expandText: { default: "展开" },
753
+ collapseText: { default: "折叠" },
754
+ router: { type: Boolean, default: !0 }
755
+ },
756
+ emits: ["update:collapsed", "menu-click"],
757
+ setup(e, { emit: n }) {
758
+ const l = e, u = n, t = B(l.collapsed);
759
+ oe(() => l.collapsed, (r) => {
760
+ t.value = r;
761
+ });
762
+ const o = () => {
763
+ t.value = !t.value, u("update:collapsed", t.value);
764
+ };
765
+ return (r, f) => {
766
+ const y = h("el-menu"), w = h("el-icon");
767
+ return s(), $("div", {
768
+ class: X(["j-sidebar", t.value ? "j-sidebar--collapsed" : "j-sidebar--expanded"]),
769
+ style: ue({ width: t.value ? `${e.collapsedWidth}px` : `${e.expandedWidth}px` })
770
+ }, [
771
+ _("div", qe, [
772
+ N(r.$slots, "logo", { collapsed: t.value }, () => {
773
+ var v;
774
+ return [
775
+ _("h2", Ze, S(t.value ? e.collapsedTitle || ((v = e.title) == null ? void 0 : v.charAt(0)) || "" : e.title), 1)
776
+ ];
777
+ }, !0)
778
+ ]),
779
+ _("div", Ge, [
780
+ d(y, {
781
+ "default-active": e.activeMenu,
782
+ class: "j-sidebar__menu",
783
+ router: e.router,
784
+ collapse: t.value,
785
+ "collapse-transition": !1
786
+ }, {
787
+ default: i(() => [
788
+ (s(!0), $(q, null, ee(e.menus, (v) => (s(), m(ce, {
789
+ key: v.path,
790
+ "menu-item": v,
791
+ "is-collapse": t.value,
792
+ onMenuClick: f[0] || (f[0] = (J) => u("menu-click", J))
793
+ }, null, 8, ["menu-item", "is-collapse"]))), 128))
794
+ ]),
795
+ _: 1
796
+ }, 8, ["default-active", "router", "collapse"])
797
+ ]),
798
+ _("div", Qe, [
799
+ N(r.$slots, "footer", {
800
+ collapsed: t.value,
801
+ toggle: o
802
+ }, () => [
803
+ _("button", {
804
+ class: "j-sidebar__collapse-btn",
805
+ onClick: o
806
+ }, [
807
+ d(w, { size: 18 }, {
808
+ default: i(() => [
809
+ t.value ? (s(), m(x(be), { key: 0 })) : (s(), m(x(_e), { key: 1 }))
810
+ ]),
811
+ _: 1
812
+ }),
813
+ _("span", Ye, S(t.value ? e.expandText : e.collapseText), 1)
814
+ ])
815
+ ], !0)
816
+ ])
817
+ ], 6);
818
+ };
819
+ }
820
+ }), tt = /* @__PURE__ */ P(et, [["__scopeId", "data-v-69e5b32f"]]);
821
+ function te(e, n) {
822
+ return Array.isArray(e) ? e.map((l) => te(l, n)) : e !== null && typeof e == "object" && !(e instanceof Date) ? n(e) : e;
823
+ }
824
+ function lt(e, n = []) {
825
+ return Object.fromEntries(
826
+ Object.entries(e).map(([l, u]) => {
827
+ const t = te(u, (r) => lt(r, n));
828
+ return n.includes(l) ? [l, t] : [l.replace(/([A-Z])/g, "_$1").toLowerCase(), t];
829
+ })
830
+ );
831
+ }
832
+ function at(e, n = []) {
833
+ return Object.fromEntries(
834
+ Object.entries(e).map(([l, u]) => {
835
+ const t = te(u, (r) => at(r, n));
836
+ return n.includes(l) ? [l, t] : [l.replace(/_([a-z])/g, (r, f) => f.toUpperCase()), t];
837
+ })
838
+ );
839
+ }
840
+ function ft(e, n) {
841
+ const l = {};
842
+ for (const u of n)
843
+ u in e && (l[u] = e[u]);
844
+ return l;
845
+ }
846
+ function pt(e, n) {
847
+ const l = { ...e };
848
+ for (const u of n)
849
+ delete l[u];
850
+ return l;
851
+ }
852
+ function se(e) {
853
+ if (e === null || typeof e != "object") return e;
854
+ if (e instanceof Date) return new Date(e.getTime());
855
+ if (e instanceof RegExp) return new RegExp(e.source, e.flags);
856
+ if (Array.isArray(e)) return e.map((l) => se(l));
857
+ const n = {};
858
+ for (const l of Object.keys(e))
859
+ n[l] = se(e[l]);
860
+ return n;
861
+ }
862
+ function nt(e, n = !1) {
863
+ const l = {};
864
+ for (const [u, t] of Object.entries(e))
865
+ if (!(t == null || t === ""))
866
+ if (n && typeof t == "object" && !Array.isArray(t) && !(t instanceof Date)) {
867
+ const o = nt(t, !0);
868
+ Object.keys(o).length > 0 && (l[u] = o);
869
+ } else
870
+ l[u] = t;
871
+ return l;
872
+ }
873
+ function st(e, n = "", l = ".") {
874
+ const u = {};
875
+ for (const [t, o] of Object.entries(e)) {
876
+ const r = n ? `${n}${l}${t}` : t;
877
+ o !== null && typeof o == "object" && !Array.isArray(o) && !(o instanceof Date) ? Object.assign(u, st(o, r, l)) : u[r] = o;
878
+ }
879
+ return u;
880
+ }
881
+ function vt(e, n = ".") {
882
+ const l = {};
883
+ for (const [u, t] of Object.entries(e)) {
884
+ const o = u.split(n);
885
+ let r = l;
886
+ for (let f = 0; f < o.length - 1; f++) {
887
+ const y = o[f];
888
+ y in r || (r[y] = {}), r = r[y];
889
+ }
890
+ r[o[o.length - 1]] = t;
891
+ }
892
+ return l;
893
+ }
894
+ function gt(e) {
895
+ return Object.entries(e).map(([n, l]) => ({
896
+ id: n,
897
+ label: l,
898
+ prop: n
899
+ }));
900
+ }
901
+ const ot = [Ie, Fe, Y, ze, Xe, tt, ce], it = (e) => {
902
+ ot.forEach((n) => {
272
903
  e.component(n.name ?? n.__name ?? "", n);
273
904
  });
274
- }, ke = { install: pe };
905
+ }, ht = { install: it };
275
906
  export {
276
- te as JButton,
277
- me as JIconRender,
278
- re as JUploadImg,
279
- ke as default
907
+ Ie as JButton,
908
+ Y as JIconRender,
909
+ Xe as JImportExcel,
910
+ ze as JSearchHeader,
911
+ ce as JSideMenuItem,
912
+ tt as JSidebar,
913
+ Fe as JUploadImg,
914
+ se as deepClone,
915
+ ht as default,
916
+ nt as filterEmpty,
917
+ st as flatten,
918
+ pt as omit,
919
+ ft as pick,
920
+ at as toCamelCase,
921
+ lt as toSnakeCase,
922
+ gt as toTableColumns,
923
+ vt as unflatten
280
924
  };
281
925
  //# sourceMappingURL=index.js.map