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