@skyfox2000/webui 1.3.3 → 1.3.5

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