@skyfox2000/webui 1.3.2 → 1.3.4

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 (38) hide show
  1. package/lib/assets/modules/{file-upload-BVB9c-eZ.js → file-upload-BBlFaIXB.js} +1 -1
  2. package/lib/assets/modules/index-4kDAt8nS.js +333 -0
  3. package/lib/assets/modules/{index-CaaMz5sz.js → index-BG1SqSVl.js} +1 -1
  4. package/lib/assets/modules/{index-k_AnrbPY.js → index-m5rogIyM.js} +2 -2
  5. package/lib/assets/modules/{menuTabs-_Ph7P8ES.js → menuTabs-tPIz4a89.js} +2 -2
  6. package/lib/assets/modules/{toolIcon-QMXCkImG.js → toolIcon-DwWoD9TN.js} +1 -1
  7. package/lib/assets/modules/{uploadList-D-FOtndj.js → uploadList-D_Z-Y2tw.js} +482 -508
  8. package/lib/assets/modules/uploadList-Da7mQUNK.js +382 -0
  9. package/lib/components/form/autoComplete/index.vue.d.ts +10 -48
  10. package/lib/components/form/upload/uploadList.vue.d.ts +1 -0
  11. package/lib/es/AceEditor/index.js +3 -3
  12. package/lib/es/BasicLayout/index.js +3 -3
  13. package/lib/es/Error403/index.js +1 -1
  14. package/lib/es/Error404/index.js +1 -1
  15. package/lib/es/ExcelForm/index.js +332 -202
  16. package/lib/es/UploadForm/index.js +4 -4
  17. package/lib/index.d.ts +4 -3
  18. package/lib/utils/download.d.ts +2 -0
  19. package/lib/utils/excel-view.d.ts +25 -0
  20. package/lib/utils/form-csv.d.ts +18 -0
  21. package/lib/utils/form-excel.d.ts +2 -13
  22. package/lib/webui.css +1 -1
  23. package/lib/webui.es.js +773 -742
  24. package/package.json +2 -2
  25. package/src/components/common/loading/index.vue +1 -1
  26. package/src/components/content/dialog/excelForm.vue +384 -106
  27. package/src/components/content/table/index.vue +22 -10
  28. package/src/components/form/autoComplete/index.vue +29 -60
  29. package/src/components/form/upload/uploadList.vue +50 -11
  30. package/src/index.ts +26 -3
  31. package/src/utils/download.ts +31 -0
  32. package/src/utils/excel-view.ts +340 -0
  33. package/src/utils/form-csv.ts +55 -0
  34. package/src/utils/form-excel.ts +59 -192
  35. package/src/utils/options.ts +0 -1
  36. package/vite.config.ts +0 -1
  37. package/lib/assets/modules/form-excel-CsQBtfkA.js +0 -235
  38. package/lib/assets/modules/uploadList-CXa3siDj.js +0 -327
@@ -1,31 +1,34 @@
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 ae, createElementVNode as c, createVNode as m, createElementBlock as f, createCommentVNode as M, createTextVNode as O, toDisplayString as F, normalizeClass as le, Fragment as P, renderList as $ } from "vue";
2
- import { _ as A } from "../../assets/modules/index-CaaMz5sz.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 { a1 as se, a7 as ie } from "../../assets/modules/uploadList-D-FOtndj.js";
6
- import { A as ue, p as ne, U as ce } from "../../assets/modules/file-upload-BVB9c-eZ.js";
1
+ import { defineComponent as Ce, ref as o, computed as G, watch as I, onMounted as Ue, createBlock as Q, openBlock as f, unref as i, withCtx as T, renderSlot as _e, createElementBlock as y, createCommentVNode as L, createElementVNode as x, createVNode as F, createTextVNode as q, toDisplayString as b, normalizeClass as Te, Fragment as re, renderList as te } from "vue";
2
+ import { _ as W } from "../../assets/modules/index-BG1SqSVl.js";
3
+ import { Modal as Fe, Upload as se, Alert as oe, Space as Ee } from "ant-design-vue";
4
+ import { httpGet as Se, ResStatus as ie } from "@skyfox2000/fapi";
5
+ import { C as ke, a1 as De, a7 as Ve } from "../../assets/modules/uploadList-D_Z-Y2tw.js";
6
+ import { A as Le, p as Re, U as Be } from "../../assets/modules/file-upload-BBlFaIXB.js";
7
7
  import "@skyfox2000/microbase";
8
8
  import n from "vue-m-message";
9
- import { p as ve, v as de, c as fe } from "../../assets/modules/form-excel-CsQBtfkA.js";
9
+ import { _ as Ne, c as Pe, p as ze, v as Ae, a as Me } from "../../assets/modules/index-4kDAt8nS.js";
10
10
  import "dayjs";
11
11
  import "vue-draggable-next";
12
- import pe from "@vue-office/excel";
13
- const me = { class: "mb-4 flex items-center" }, xe = {
12
+ import $e from "@vue-office/excel";
13
+ const je = {
14
14
  key: 0,
15
- class: "ml-3 text-gray-600"
16
- }, ge = { class: "flex gap-4" }, ye = {
15
+ class: "mb-4 flex items-center"
16
+ }, Oe = {
17
17
  key: 0,
18
+ class: "ml-3 text-gray-600"
19
+ }, Ke = { class: "flex gap-4" }, Ge = {
20
+ key: 1,
18
21
  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 = {
22
+ }, Ie = { class: "bg-gray-50 p-2 rounded border flex-grow flex flex-col" }, Qe = {
20
23
  key: 0,
21
24
  class: "text-gray-500"
22
- }, be = {
25
+ }, qe = {
23
26
  key: 1,
24
27
  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 = {
28
+ }, We = { class: "overflow-y-auto" }, He = { class: "text-[13px] text-gray-600" }, Je = { class: "pl-5 mt-1 mb-0" }, Xe = {
26
29
  key: 0,
27
30
  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" }, Pe = /* @__PURE__ */ Y({
31
+ }, Ye = { class: "text-[12px] text-gray-600 p-1" }, Ze = { class: "text-[13px] text-gray-600" }, el = { class: "pl-5 mt-1 mb-0" }, ll = { class: "text-[12px] text-gray-600" }, xl = /* @__PURE__ */ Ce({
29
32
  __name: "excelForm",
30
33
  props: {
31
34
  title: {},
@@ -35,230 +38,357 @@ const me = { class: "mb-4 flex items-center" }, xe = {
35
38
  excelFieldMap: {},
36
39
  fileField: {},
37
40
  excelBatchField: {},
38
- saveText: {}
41
+ saveText: {},
42
+ cancelText: {},
43
+ previewUrl: {},
44
+ fileType: {}
39
45
  },
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,
46
+ setup(ne) {
47
+ var Z, ee, le;
48
+ const r = ne, t = r.excelCtrl, h = o(!1), d = o(""), ce = o([]), c = o(""), C = o(!0), z = G(() => !!r.previewUrl), ue = G(() => {
49
+ switch (r.fileType || "both") {
50
+ case "excel":
51
+ return ".xlsx,.xls";
52
+ case "csv":
53
+ return ".csv";
54
+ case "both":
55
+ default:
56
+ return ".xlsx,.xls,.csv";
57
+ }
58
+ }), ve = G(() => {
59
+ switch (r.fileType || "both") {
60
+ case "excel":
61
+ return "请选择Excel文件";
62
+ case "csv":
63
+ return "请选择CSV文件";
64
+ case "both":
65
+ default:
66
+ return "请选择Excel或CSV文件";
67
+ }
68
+ }), E = o("待验证数据规则"), S = o("warning"), k = o("待验证重复数据"), D = o("warning");
69
+ I(
70
+ () => t.visible.value,
44
71
  () => {
45
- b.value = e.visible.value;
72
+ h.value = t.visible.value, h.value && (d.value = "", c.value = "", C.value = !0, E.value = "待验证数据规则", S.value = "warning", k.value = "待验证重复数据", D.value = "warning", R.value = !1, B.value = !1, r.previewUrl && j());
46
73
  }
47
- ), V(
48
- () => b.value,
74
+ ), I(
75
+ () => h.value,
49
76
  () => {
50
- e.visible.value = b.value;
77
+ t.visible.value = h.value;
51
78
  }
79
+ ), I(
80
+ () => r.previewUrl,
81
+ () => {
82
+ h.value && r.previewUrl && j();
83
+ },
84
+ { deep: !0 }
52
85
  );
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 a = p.value;
55
- if (!a) {
86
+ const A = o(r.uploadParams), g = o((Z = A.value) == null ? void 0 : Z.uploadUrl), U = o((ee = A.value) == null ? void 0 : ee.duplicateRules), V = o((le = A.value) == null ? void 0 : le.duplicateUrl), j = async () => {
87
+ if (!(!r.previewUrl || !t))
88
+ try {
89
+ let e = null;
90
+ if (t.isFormLoading.value = !0, r.previewUrl.method === "GET") {
91
+ const l = {
92
+ ...r.previewUrl,
93
+ method: "GET",
94
+ api: r.previewUrl.api || t.page.api,
95
+ authorize: r.previewUrl.authorize ?? t.page.authorize
96
+ };
97
+ e = await Se(l);
98
+ } else {
99
+ const l = r.previewUrl.params;
100
+ e = await ke(t, {
101
+ url: r.previewUrl,
102
+ urlKey: "preview",
103
+ params: l,
104
+ hideErrorToast: !0
105
+ });
106
+ }
107
+ if (r.previewUrl.raw)
108
+ await H(e);
109
+ else if ((e == null ? void 0 : e.status) === ie.SUCCESS && e.data) {
110
+ const l = e.data;
111
+ await H(l);
112
+ } else
113
+ throw new Error((e == null ? void 0 : e.msg) || "文件加载失败");
114
+ } catch (e) {
115
+ console.error("预览文件加载错误:", e), n.error("文件加载失败:" + ((e == null ? void 0 : e.message) || "未知错误"));
116
+ } finally {
117
+ t.isFormLoading.value = !1;
118
+ }
119
+ }, O = async (e, l = "preview.csv") => {
120
+ const a = await Pe(e, l);
121
+ if (a.success)
122
+ d.value = a.blobUrl, c.value = a.fileName;
123
+ else
124
+ throw new Error(a.error || "CSV格式处理失败");
125
+ }, K = (e, l, a = "预览文件.xlsx") => {
126
+ const s = l || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
127
+ d.value = `data:${s};base64,${e}`, c.value = a;
128
+ }, pe = (e) => e.includes(",") || e.includes(`
129
+ `), fe = (e, l) => e === "text/csv" || (l == null ? void 0 : l.toLowerCase().includes(".csv")), de = (e, l) => e === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || e === "application/vnd.ms-excel" || (l == null ? void 0 : l.toLowerCase().match(/\.(xlsx|xls)$/)), H = async (e) => {
130
+ var l;
131
+ if ((l = r.previewUrl) != null && l.raw) {
132
+ if (typeof e == "string")
133
+ pe(e) ? await O(e) : K(e);
134
+ else if (e instanceof ArrayBuffer || e instanceof Uint8Array) {
135
+ const a = new Blob([e], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
136
+ d.value = URL.createObjectURL(a), c.value = "预览文件.xlsx";
137
+ } else
138
+ throw new Error("不支持的原始文件格式");
139
+ return;
140
+ }
141
+ if (e.Content && e.Type)
142
+ fe(e.Type, e.FileName) ? await O(e.Content, e.FileName || "preview.csv") : de(e.Type, e.FileName) ? K(e.Content, e.Type, e.FileName || "预览文件.xlsx") : K(e.Content);
143
+ else if (e.url)
144
+ d.value = e.url, c.value = e.fileName || "预览文件.xlsx";
145
+ else if (typeof e == "string")
146
+ await O(e);
147
+ else
148
+ throw new Error("不支持的文件格式");
149
+ }, me = async () => {
150
+ var l;
151
+ const e = g.value;
152
+ if (!e) {
56
153
  n.error("未配置文件上传地址!");
57
154
  return;
58
155
  }
59
- if (B.value) {
156
+ if (R.value) {
60
157
  n.error("表格数据存在验证错误,请修正后再上传!");
61
158
  return;
62
159
  }
63
- e.isFormLoading.value = !0;
160
+ t.isFormSaving.value = !0;
64
161
  try {
65
- if (!z.value || !x.value) {
66
- n.warning("请先选择Excel文件!"), e.isFormLoading.value = !1;
162
+ if (!N.value || !c.value) {
163
+ n.warning("请先选择文件!"), t.isFormSaving.value = !1;
67
164
  return;
68
165
  }
69
- const l = new ue(a, 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 = {
166
+ const a = new Le(e, 1), s = J.value || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", m = new File([N.value], c.value, {
167
+ type: s
168
+ }), u = Re.join(((l = A.value) == null ? void 0 : l.basePath) ?? "", c.value), v = {
72
169
  uid: "1",
73
- name: x.value,
74
- originFileObj: s,
75
- status: ce.Uploading,
170
+ name: c.value,
171
+ originFileObj: m,
172
+ status: Be.Uploading,
76
173
  percent: 0,
77
174
  params: {
78
- FileKey: t
175
+ FileKey: u
79
176
  }
80
- }, y = new AbortController();
177
+ }, w = new AbortController();
81
178
  try {
82
- await l.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;
179
+ await a.uploadFile(v, w.signal, (p) => {
180
+ v.percent = p;
181
+ }), n.success("文件上传成功,开始业务处理!"), xe(v);
182
+ } catch (p) {
183
+ throw console.error("文件上传错误:", p), n.error((p == null ? void 0 : p.message) || "文件上传失败,请稍后再试!"), p;
87
184
  }
88
- } catch (l) {
89
- console.error("上传处理错误:", l), n.error("上传处理失败:" + ((l == null ? void 0 : l.message) || "未知错误"));
185
+ } catch (a) {
186
+ console.error("上传处理错误:", a), n.error("上传处理失败:" + ((a == null ? void 0 : a.message) || "未知错误"));
90
187
  } finally {
91
- e.isFormLoading.value = !1;
188
+ t.isFormSaving.value = !1;
92
189
  }
93
- }, J = async (a) => {
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]);
190
+ }, xe = async (e) => {
191
+ if (t.formData.value) {
192
+ if (r.excelBatchField) {
193
+ const s = await ze(N.value);
194
+ if (!s) return null;
195
+ const { excelData: m } = s, u = m.map((v) => {
196
+ var p;
197
+ const w = {};
198
+ for (const _ in v) {
199
+ const $ = (p = r.excelFieldMap) == null ? void 0 : p[_];
200
+ $ && (w[$] = v[_]);
103
201
  }
104
- return h;
202
+ return w;
105
203
  });
106
- e.formData.value[o.excelBatchField] = y;
204
+ t.formData.value[r.excelBatchField] = u;
107
205
  }
108
- const l = o.fileField ?? "FileInfo";
109
- e.formData.value[l] = a, e.beforeSave && e.beforeSave();
110
- const s = {
206
+ const l = r.fileField ?? "FileInfo";
207
+ t.formData.value[l] = e, t.beforeSave && t.beforeSave();
208
+ const a = {
111
209
  Data: {
112
- ...e.formData.value
210
+ ...t.formData.value
113
211
  },
114
212
  Query: {
115
- [o.excelCtrl.primaryKey]: e.formData.value[o.excelCtrl.primaryKey]
213
+ [r.excelCtrl.primaryKey]: t.formData.value[r.excelCtrl.primaryKey]
116
214
  }
117
215
  };
118
- e.isFormLoading.value = !0;
216
+ t.isFormSaving.value = !0;
119
217
  try {
120
- const t = await ie(o.excelCtrl, {
121
- params: s,
218
+ const s = await Ve(r.excelCtrl, {
219
+ params: a,
122
220
  urlKey: "save",
123
- url: o.excelCtrl.saveUrl
221
+ url: r.excelCtrl.saveUrl
124
222
  });
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("数据保存失败,请稍后再试!");
223
+ (s == null ? void 0 : s.status) === ie.SUCCESS ? (n.success("数据保存成功!"), t.afterSave && t.afterSave(), t.visible.value = !1) : n.error("保存失败:" + ((s == null ? void 0 : s.msg) || "未知错误"));
224
+ } catch (s) {
225
+ console.error("保存错误:", s), n.error("数据保存失败,请稍后再试!");
128
226
  } finally {
129
- e.isFormLoading.value = !1;
227
+ t.isFormSaving.value = !1;
130
228
  }
131
229
  }
132
- }, B = r(!1), N = r(!1), z = r(null), W = async (a) => {
133
- if (!(a.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || a.type === "application/vnd.ms-excel"))
134
- return n.error("只能上传Excel文件!"), I.LIST_IGNORE;
230
+ }, R = o(!1), B = o(!1), N = o(null), J = o(""), X = async (e) => {
231
+ const l = r.gridCtrl;
232
+ if (!l) return !1;
233
+ const { hasError: a, errBlob: s } = await Ae(e, t.formRules.value);
234
+ if (a) {
235
+ if (s) {
236
+ R.value = !0, C.value = !1, E.value = "数据验证失败", S.value = "error";
237
+ const m = URL.createObjectURL(s);
238
+ d.value = m;
239
+ }
240
+ return !1;
241
+ } else
242
+ E.value = "数据验证成功", S.value = "success";
243
+ if (U.value && U.value.length > 0 && V.value)
244
+ try {
245
+ V.value.api || (V.value.api = l.page.api), V.value.authorize === void 0 && (V.value.authorize = l.page.authorize);
246
+ const { hasError: m, errBlob: u } = await Me(e, U.value, V.value);
247
+ if (m) {
248
+ if (u) {
249
+ B.value = !0, k.value = "检测到重复数据", D.value = "error";
250
+ const v = URL.createObjectURL(u);
251
+ d.value = v;
252
+ }
253
+ return !1;
254
+ } else
255
+ B.value = !1, k.value = "数据验证通过", D.value = "success";
256
+ } catch {
257
+ return k.value = "重复检测异常", D.value = "error", !1;
258
+ }
259
+ return !0;
260
+ }, ye = async (e) => {
261
+ if (!r.gridCtrl) {
262
+ n.error("未配置表格控制器!");
263
+ return;
264
+ }
265
+ const a = e.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || e.type === "application/vnd.ms-excel", s = e.type === "text/csv" || e.name.toLowerCase().endsWith(".csv"), m = r.fileType || "both";
266
+ let u = !1, v = "";
267
+ switch (m) {
268
+ case "excel":
269
+ u = a, v = "只能上传Excel文件!";
270
+ break;
271
+ case "csv":
272
+ u = s, v = "只能上传CSV文件!";
273
+ break;
274
+ case "both":
275
+ default:
276
+ u = a || s, v = "只能上传Excel文件或CSV文件!";
277
+ break;
278
+ }
279
+ if (!u)
280
+ return n.error(v), se.LIST_IGNORE;
135
281
  try {
136
- x.value = a.name, B.value = !1, N.value = !1, E.value = !0, U.value = "待验证数据规则", S.value = "warning", k.value = "待验证重复数据", D.value = "warning";
137
- const s = await a.arrayBuffer();
138
- z.value = s;
139
- const t = new FileReader();
140
- t.readAsDataURL(a), 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
- }
282
+ if (c.value = e.name, J.value = s ? "text/csv" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", R.value = !1, B.value = !1, C.value = !0, E.value = "待验证数据规则", S.value = "warning", k.value = "待验证重复数据", D.value = "warning", s) {
283
+ const _ = await e.arrayBuffer(), we = new TextDecoder("utf-8").decode(_), { csvToExcelView: ge } = await import("../../assets/modules/index-4kDAt8nS.js").then((be) => be.h), P = await ge(we, e.name);
284
+ if (!P.success)
285
+ throw new Error(P.error || "CSV文件处理失败");
286
+ const ae = await (await fetch(P.blobUrl)).arrayBuffer();
287
+ return N.value = ae, await X(ae) && (d.value = P.blobUrl, c.value = P.fileName, C.value = !1), !1;
288
+ }
289
+ const w = await e.arrayBuffer();
290
+ N.value = w;
291
+ const p = new FileReader();
292
+ p.readAsDataURL(e), p.onload = async (_) => {
293
+ if (_.target) {
294
+ if (!await X(w))
149
295
  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;
296
+ d.value = _.target.result, C.value = !1;
173
297
  } else
174
- n.error("加载Excel文件失败,请检查文件格式!");
298
+ n.error("加载文件失败,请检查文件格式!");
175
299
  };
176
- } catch (s) {
177
- console.error("Excel处理错误:", s), n.error("Excel文件处理失败,请检查文件格式!"), E.value = !1, U.value = "Excel处理错误", S.value = "error";
300
+ } catch (w) {
301
+ console.error("文件处理错误:", w), n.error("文件处理失败,请检查文件格式!"), C.value = !1, E.value = "文件处理错误", S.value = "error";
178
302
  }
179
303
  return !1;
180
- }, T = se(e.formRules.value);
181
- Z(() => {
182
- const a = o.gridCtrl.page;
183
- if (p.value = p.value ?? a.urls.upload, !p.value) {
184
- n.error("未配置文件上传地址!");
185
- return;
304
+ }, M = De(t.formRules.value);
305
+ Ue(() => {
306
+ var l;
307
+ const e = (l = r.gridCtrl) == null ? void 0 : l.page;
308
+ if (e && !z.value) {
309
+ if (g.value = g.value ?? e.urls.upload, !g.value) {
310
+ n.error("未配置文件上传地址!");
311
+ return;
312
+ }
313
+ g.value.api || (g.value.api = e.api), g.value.authorize === void 0 && (g.value.authorize = e.authorize);
314
+ for (const a in t.formData.value)
315
+ r.gridCtrl.rowData.value && (t.formData.value[a] = r.gridCtrl.rowData.value[a]);
186
316
  }
187
- p.value.api || (p.value.api = a.api), p.value.authorize === void 0 && (p.value.authorize = a.authorize);
188
- for (const l in e.formData.value)
189
- o.gridCtrl.rowData.value && (e.formData.value[l] = o.gridCtrl.rowData.value[l]);
190
- b.value = e.visible.value;
317
+ h.value = t.visible.value, h.value && r.previewUrl && j();
191
318
  });
192
- const K = () => {
193
- e.visible.value = !1;
194
- }, X = () => {
319
+ const Y = () => {
320
+ t.visible.value = !1;
321
+ }, he = () => {
195
322
  console.error("渲染失败");
196
323
  };
197
- return (a, l) => (d(), ee(i(te), {
198
- title: a.title ?? "Excel文件上传",
199
- open: b.value,
200
- "onUpdate:open": l[0] || (l[0] = (s) => b.value = s),
201
- wrapClassName: ["modal", "mx-auto", a.$attrs.width ? "w-[" + a.$attrs.width + "]" : ""].join(" "),
324
+ return (e, l) => (f(), Q(i(Fe), {
325
+ title: e.title ?? "文件上传",
326
+ open: h.value,
327
+ "onUpdate:open": l[0] || (l[0] = (a) => h.value = a),
328
+ wrapClassName: ["modal", "mx-auto", e.$attrs.width ? "w-[" + e.$attrs.width + "]" : ""].join(" "),
202
329
  width: 940,
203
- onClose: K
330
+ onClose: Y
204
331
  }, {
205
- footer: _(() => [
206
- m(i(re), null, {
207
- default: _(() => [
208
- m(i(A), { onClick: K }, {
209
- default: _(() => l[2] || (l[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(a.saveText ?? "上传文件"), 1)
223
- ]),
224
- _: 1
225
- }, 8, ["loading", "disabled"])
226
- ]),
332
+ footer: T(() => [
333
+ F(i(Ee), null, {
334
+ default: T(() => {
335
+ var a;
336
+ return [
337
+ F(i(W), { onClick: Y }, {
338
+ default: T(() => [
339
+ q(b(e.cancelText ?? (z.value ? "关闭" : "取消")), 1)
340
+ ]),
341
+ _: 1
342
+ }),
343
+ z.value ? L("", !0) : (f(), Q(i(W), {
344
+ key: 0,
345
+ onClick: me,
346
+ type: "primary",
347
+ loading: ((a = i(t)) == null ? void 0 : a.isFormSaving.value) ?? !1,
348
+ disabled: !d.value || R.value || B.value || C.value
349
+ }, {
350
+ default: T(() => [
351
+ q(b(e.saveText ?? "上传文件"), 1)
352
+ ]),
353
+ _: 1
354
+ }, 8, ["loading", "disabled"]))
355
+ ];
356
+ }),
227
357
  _: 1
228
358
  })
229
359
  ]),
230
- default: _(() => [
231
- ae(a.$slots, "default"),
232
- c("div", me, [
233
- m(i(I), {
234
- "file-list": q.value,
235
- "before-upload": W,
236
- accept: ".xlsx,.xls",
360
+ default: T(() => [
361
+ _e(e.$slots, "default"),
362
+ z.value ? L("", !0) : (f(), y("div", je, [
363
+ F(i(se), {
364
+ "file-list": ce.value,
365
+ "before-upload": ye,
366
+ accept: ue.value,
237
367
  showUploadList: !0
238
368
  }, {
239
- default: _(() => [
240
- m(i(A), { type: "primary" }, {
241
- default: _(() => l[1] || (l[1] = [
242
- O("选择Excel文件")
243
- ])),
244
- _: 1,
245
- __: [1]
369
+ default: T(() => [
370
+ F(i(W), { type: "primary" }, {
371
+ default: T(() => [
372
+ q(b(ve.value), 1)
373
+ ]),
374
+ _: 1
246
375
  })
247
376
  ]),
248
377
  _: 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: le(["flex-shrink-0 excel-container", [i(T).length === 0 ? "w-[100%]" : "w-[80%]"]]),
378
+ }, 8, ["file-list", "accept"]),
379
+ d.value && c.value ? (f(), y("div", Oe, [
380
+ x("span", null, b(c.value), 1)
381
+ ])) : L("", !0)
382
+ ])),
383
+ x("div", Ke, [
384
+ i(t).isFormLoading ? (f(), Q(i(Ne), { key: 0 })) : L("", !0),
385
+ x("div", {
386
+ class: Te(["flex-shrink-0 relative border border-gray-200 rounded-md overflow-hidden", [i(M).length === 0 ? "w-[100%]" : "w-[80%]"]]),
257
387
  style: { height: "430px" }
258
388
  }, [
259
- m(i(pe), {
260
- src: w.value,
261
- onError: X,
389
+ F(i($e), {
390
+ src: d.value,
391
+ onError: he,
262
392
  style: { width: "100%", height: "100%" },
263
393
  options: {
264
394
  styles: !0,
@@ -270,46 +400,46 @@ const me = { class: "mb-4 flex items-center" }, xe = {
270
400
  }
271
401
  }, null, 8, ["src"])
272
402
  ], 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,
403
+ i(M).length > 0 ? (f(), y("div", Ge, [
404
+ x("div", Ie, [
405
+ i(M).length === 0 ? (f(), y("div", Qe, "没有设置验证规则")) : (f(), y("div", qe, [
406
+ F(i(oe), {
407
+ message: E.value,
278
408
  type: S.value,
279
409
  "show-icon": "",
280
410
  class: "mb-2"
281
411
  }, null, 8, ["message", "type"]),
282
- c("div", we, [
283
- (d(!0), f(P, null, $(i(T), (s, t) => (d(), f("div", {
284
- key: t,
412
+ x("div", We, [
413
+ (f(!0), y(re, null, te(i(M), (a, s) => (f(), y("div", {
414
+ key: s,
285
415
  class: "border-b pb-0"
286
416
  }, [
287
- c("div", Ce, F(s.field), 1),
288
- c("ul", Fe, [
289
- (d(!0), f(P, null, $(s.rules, (v, y) => (d(), f("li", {
290
- key: y,
417
+ x("div", He, b(a.field), 1),
418
+ x("ul", Je, [
419
+ (f(!0), y(re, null, te(a.rules, (m, u) => (f(), y("li", {
420
+ key: u,
291
421
  class: "text-[12px] text-gray-600"
292
- }, F(v), 1))), 128))
422
+ }, b(m), 1))), 128))
293
423
  ])
294
424
  ]))), 128))
295
425
  ]),
296
- g.value && g.value.length > 0 ? (d(), f("div", Ee, [
297
- m(i(G), {
426
+ U.value && U.value.length > 0 ? (f(), y("div", Xe, [
427
+ F(i(oe), {
298
428
  message: k.value,
299
429
  type: D.value,
300
430
  "show-icon": "",
301
431
  class: "mt-2 mb-2"
302
432
  }, 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)
433
+ x("div", Ye, [
434
+ x("div", Ze, " 以下" + b(U.value.length > 1 ? "组合" : "字段") + "必须唯一 ", 1),
435
+ x("ul", el, [
436
+ x("li", ll, b(U.value.join(", ")), 1)
307
437
  ])
308
438
  ])
309
- ])) : M("", !0)
439
+ ])) : L("", !0)
310
440
  ]))
311
441
  ])
312
- ])) : M("", !0)
442
+ ])) : L("", !0)
313
443
  ])
314
444
  ]),
315
445
  _: 3
@@ -317,5 +447,5 @@ const me = { class: "mb-4 flex items-center" }, xe = {
317
447
  }
318
448
  });
319
449
  export {
320
- Pe as default
450
+ xl as default
321
451
  };