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