@skyfox2000/webui 1.0.14 → 1.2.0
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/lib/assets/modules/file-upload-CBUcsUnR.js +170 -0
- package/lib/assets/modules/form-validate-CgX7aR7T.js +297 -0
- package/lib/assets/modules/index-Civhd8xG.js +112 -0
- package/lib/assets/modules/index-DQMdt51R.js +726 -0
- package/lib/assets/modules/{index-BEWJ_qAH.js → index-DmWrkTXX.js} +1 -1
- package/lib/assets/modules/{menuTabs-BXdbFZor.js → menuTabs-BRYvFWA-.js} +131 -121
- package/lib/assets/modules/settingInfo-BZakNKIN.js +999 -0
- package/lib/assets/modules/uploadList-B7XoxGOh.js +278 -0
- package/lib/components/common/icon/index.vue.d.ts +1 -1
- package/lib/components/content/dialog/index.vue.d.ts +1 -1
- package/lib/components/content/drawer/index.vue.d.ts +1 -1
- package/lib/components/content/form/index.vue.d.ts +1 -1
- package/lib/components/content/search/index.vue.d.ts +1 -1
- package/lib/components/content/table/index.vue.d.ts +1 -1
- package/lib/components/content/table/tableOperate.vue.d.ts +1 -1
- package/lib/components/content/toolbar/icontool.vue.d.ts +1 -1
- package/lib/components/content/toolbar/index.vue.d.ts +1 -1
- package/lib/components/content/tree/index.vue.d.ts +1 -1
- package/lib/components/form/transfer/transferTable.vue.d.ts +1 -1
- package/lib/components/form/treeSelect/index.vue.d.ts +1 -1
- package/lib/components/form/upload/uploadList.vue.d.ts +1 -1
- package/lib/const/options.d.ts +32 -0
- package/lib/directives/enter-submit.d.ts +4 -0
- package/lib/directives/index.d.ts +2 -0
- package/lib/directives/permission.d.ts +5 -0
- package/lib/es/AceEditor/index.js +9 -8
- package/lib/es/BasicLayout/index.js +28 -24
- package/lib/es/Error403/index.js +15 -10
- package/lib/es/Error404/index.js +15 -10
- package/lib/es/ExcelForm/index.js +380 -175
- package/lib/es/UploadForm/index.js +23 -20
- package/lib/index.d.ts +42 -2
- package/lib/router/index.d.ts +16 -0
- package/lib/stores/appInfo.d.ts +34 -0
- package/lib/stores/hostInfo.d.ts +9 -0
- package/lib/stores/pageInfo.d.ts +18 -0
- package/lib/stores/pinia.d.ts +3 -0
- package/lib/stores/settingInfo.d.ts +8 -0
- package/lib/stores/userInfo.d.ts +21 -0
- package/lib/typings/data.d.ts +80 -0
- package/lib/typings/form.d.ts +171 -0
- package/lib/typings/menu.d.ts +7 -0
- package/lib/typings/option.d.ts +175 -0
- package/lib/typings/page.d.ts +69 -0
- package/lib/typings/table.d.ts +181 -0
- package/lib/typings/tools.d.ts +130 -0
- package/lib/typings/tree.d.ts +72 -0
- package/lib/typings/upload.d.ts +161 -0
- package/lib/typings/urls.d.ts +69 -0
- package/lib/utils/cache.d.ts +23 -0
- package/lib/utils/data.d.ts +6 -0
- package/lib/utils/download.d.ts +4 -0
- package/lib/utils/eventbus.d.ts +16 -0
- package/lib/utils/export-table.d.ts +12 -0
- package/lib/utils/file-upload.d.ts +15 -0
- package/lib/utils/form-excel.d.ts +30 -0
- package/lib/utils/form-validate.d.ts +29 -0
- package/lib/utils/form.d.ts +9 -0
- package/lib/utils/icon-loader.d.ts +125 -0
- package/lib/utils/isEmpty.d.ts +1 -0
- package/lib/utils/main-openapis.d.ts +9 -0
- package/lib/utils/menu.d.ts +6 -0
- package/lib/utils/options.d.ts +10 -0
- package/lib/utils/page.d.ts +25 -0
- package/lib/utils/table.d.ts +21 -0
- package/lib/utils/tools.d.ts +18 -0
- package/lib/utils/tree.d.ts +3 -0
- package/lib/vite-env.d.ts +8 -0
- package/lib/webui.css +1 -1
- package/lib/webui.es.js +890 -724
- package/package.json +7 -6
- package/src/components/common/icon/appicon.vue +1 -1
- package/src/components/common/icon/fullscreen.vue +2 -1
- package/src/components/common/icon/index.vue +1 -1
- package/src/components/common/icon/layoutIcon.vue +1 -1
- package/src/components/common/icon/projectIcon.vue +1 -1
- package/src/components/common/icon/toolIcon.vue +1 -1
- package/src/components/content/dialog/excelForm.vue +2 -2
- package/src/components/content/dialog/index.vue +1 -1
- package/src/components/content/dialog/uploadForm.vue +7 -6
- package/src/components/content/drawer/index.vue +43 -18
- package/src/components/content/form/formItem.vue +1 -1
- package/src/components/content/form/index.vue +1 -1
- package/src/components/content/search/index.vue +1 -1
- package/src/components/content/search/searchItem.vue +1 -1
- package/src/components/content/table/index.vue +3 -3
- package/src/components/content/table/tableOperate.vue +2 -2
- package/src/components/content/toolbar/icontool.vue +2 -2
- package/src/components/content/toolbar/index.vue +3 -2
- package/src/components/content/tree/index.vue +1 -1
- package/src/components/error/error403.vue +2 -2
- package/src/components/error/error404.vue +2 -2
- package/src/components/form/autoComplete/index.vue +1 -1
- package/src/components/form/cascader/index.vue +1 -2
- package/src/components/form/checkbox/index.vue +11 -5
- package/src/components/form/datePicker/index.vue +1 -1
- package/src/components/form/input/index.vue +1 -1
- package/src/components/form/input/inputNumber.vue +1 -1
- package/src/components/form/input/inputPassword.vue +1 -1
- package/src/components/form/radio/index.vue +1 -1
- package/src/components/form/radio/radioStatus.vue +1 -1
- package/src/components/form/rangePicker/index.vue +1 -1
- package/src/components/form/select/index.vue +1 -1
- package/src/components/form/switch/index.vue +7 -3
- package/src/components/form/textarea/index.vue +1 -1
- package/src/components/form/transfer/index.vue +1 -1
- package/src/components/form/transfer/transferTable.vue +42 -22
- package/src/components/form/treeSelect/index.vue +2 -3
- package/src/components/form/upload/uploadList.vue +1 -1
- package/src/components/layout/breadcrumb/index.vue +1 -1
- package/src/components/layout/header/headerExits.vue +1 -1
- package/src/components/layout/header/index.vue +1 -1
- package/src/components/layout/header/user.vue +2 -1
- package/src/components/layout/menu/index.vue +9 -3
- package/src/components/layout/menu/menuTabs.vue +10 -12
- package/src/components/layout/page/basicLayout.vue +1 -1
- package/src/const/options.ts +114 -0
- package/src/directives/enter-submit.ts +13 -0
- package/src/directives/index.ts +26 -0
- package/src/directives/permission.ts +144 -0
- package/src/index.ts +201 -0
- package/src/router/index.ts +196 -0
- package/src/stores/appInfo.ts +471 -0
- package/src/stores/hostInfo.ts +117 -0
- package/src/stores/pageInfo.ts +131 -0
- package/src/stores/pinia.ts +10 -0
- package/src/stores/settingInfo.ts +53 -0
- package/src/stores/userInfo.ts +392 -0
- package/src/typings/data.d.ts +81 -0
- package/src/typings/form.d.ts +172 -0
- package/src/typings/menu.d.ts +7 -0
- package/src/typings/option.d.ts +177 -0
- package/src/typings/page.d.ts +70 -0
- package/src/typings/table.d.ts +182 -0
- package/src/typings/tools.d.ts +131 -0
- package/src/typings/tree.d.ts +73 -0
- package/src/typings/upload.d.ts +162 -0
- package/src/typings/urls.d.ts +70 -0
- package/src/utils/cache.ts +175 -0
- package/src/utils/data.ts +189 -0
- package/src/utils/download.ts +80 -0
- package/src/utils/eventbus.ts +78 -0
- package/src/utils/export-table.ts +155 -0
- package/src/utils/file-upload.ts +304 -0
- package/src/utils/form-excel.ts +523 -0
- package/src/utils/form-validate.ts +368 -0
- package/src/utils/form.ts +188 -0
- package/src/utils/icon-loader.ts +412 -0
- package/src/utils/isEmpty.ts +18 -0
- package/src/utils/main-openapis.ts +72 -0
- package/src/utils/menu.ts +89 -0
- package/src/utils/options.ts +324 -0
- package/src/utils/page.ts +262 -0
- package/src/utils/table.ts +274 -0
- package/src/utils/tools.ts +362 -0
- package/src/utils/tree.ts +28 -0
- package/tsconfig.json +1 -8
- package/vite.config.ts +7 -4
- package/lib/assets/modules/index-BahGnrAq.js +0 -415
- package/lib/assets/modules/index-BoKIa2sr.js +0 -109
- package/lib/assets/modules/index-D47Ci-T3.js +0 -107
- package/lib/assets/modules/uploadList-Dzlg47V0.js +0 -182
|
@@ -1,27 +1,232 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { _ as
|
|
3
|
-
import { Modal as
|
|
4
|
-
import { ResStatus as
|
|
5
|
-
import
|
|
6
|
-
import "../../assets/modules/
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
1
|
+
import { defineComponent as te, ref as E, watch as P, onMounted as ae, createBlock as le, openBlock as N, unref as k, withCtx as T, renderSlot as re, createElementVNode as O, createVNode as L, createElementBlock as U, createCommentVNode as V, createTextVNode as H, toDisplayString as M, normalizeClass as oe, Fragment as q, renderList as G } from "vue";
|
|
2
|
+
import { i as se, v as ie, g as ne, _ as I, b as ce } from "../../assets/modules/form-validate-CgX7aR7T.js";
|
|
3
|
+
import { Modal as ue, Upload as Q, Alert as X, Space as fe } from "ant-design-vue";
|
|
4
|
+
import { httpPost as ve, ResStatus as Y } from "@skyfox2000/fapi";
|
|
5
|
+
import "../../assets/modules/settingInfo-BZakNKIN.js";
|
|
6
|
+
import { A as de, p as pe, U as me } from "../../assets/modules/file-upload-CBUcsUnR.js";
|
|
7
|
+
import "@skyfox2000/microbase";
|
|
8
|
+
import b from "vue-m-message";
|
|
9
|
+
import ge from "async-validator";
|
|
10
|
+
import "dayjs";
|
|
11
|
+
import "../../assets/modules/index-DmWrkTXX.js";
|
|
12
|
+
import he from "@vue-office/excel";
|
|
13
|
+
const K = async (C) => {
|
|
14
|
+
const o = await import("exceljs"), a = new o.Workbook();
|
|
15
|
+
await a.xlsx.load(C);
|
|
16
|
+
const f = a.worksheets[0];
|
|
17
|
+
if (!f)
|
|
18
|
+
return b.error("Excel文件不包含工作表"), null;
|
|
19
|
+
const s = [], y = [];
|
|
20
|
+
return f.getRow(1).eachCell((t) => {
|
|
21
|
+
let r = "";
|
|
22
|
+
if (t.value !== null && t.value !== void 0)
|
|
23
|
+
if (typeof t.value == "object")
|
|
24
|
+
if ("richText" in t.value && Array.isArray(t.value.richText))
|
|
25
|
+
r = t.value.richText.map((l) => l.text || "").join("");
|
|
26
|
+
else if ("text" in t.value && typeof t.value.text == "string")
|
|
27
|
+
r = t.value.text;
|
|
28
|
+
else if (t.value instanceof Date)
|
|
29
|
+
r = t.value.toLocaleDateString();
|
|
30
|
+
else
|
|
31
|
+
try {
|
|
32
|
+
r = JSON.stringify(t.value);
|
|
33
|
+
} catch {
|
|
34
|
+
r = String(t.value);
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
r = String(t.value);
|
|
38
|
+
s.push(r);
|
|
39
|
+
}), f.eachRow((t, r) => {
|
|
40
|
+
if (r > 1) {
|
|
41
|
+
const l = {};
|
|
42
|
+
s.forEach((c, i) => {
|
|
43
|
+
if (c) {
|
|
44
|
+
const n = t.getCell(i + 1).value;
|
|
45
|
+
n != null ? typeof n == "object" ? "richText" in n && Array.isArray(n.richText) ? l[c] = n.richText.map((g) => g.text || "").join("") : "text" in n && typeof n.text == "string" ? l[c] = n.text : (n instanceof Date, l[c] = n) : l[c] = n : l[c] = null;
|
|
46
|
+
}
|
|
47
|
+
}), y.push(l);
|
|
48
|
+
}
|
|
49
|
+
}), { workbook: a, worksheet: f, headers: s, excelData: y };
|
|
50
|
+
}, Z = async (C, o) => {
|
|
51
|
+
const a = await import("exceljs"), f = await K(C);
|
|
52
|
+
if (!f) return { hasError: !0 };
|
|
53
|
+
const { worksheet: s, headers: y } = f, { markCells: t, markHeaders: r } = o;
|
|
54
|
+
if (t.length === 0 && (!r || r.length === 0))
|
|
55
|
+
return { hasError: !1 };
|
|
56
|
+
const l = [...y];
|
|
57
|
+
r && r.length > 0 && r.forEach((v) => {
|
|
58
|
+
l.includes(v) || l.push(v);
|
|
59
|
+
});
|
|
60
|
+
const c = new a.Workbook(), i = c.addWorksheet("Sheet1"), p = 15, n = /* @__PURE__ */ new Map();
|
|
61
|
+
t.forEach(({ row: v, col: F, color: u }) => {
|
|
62
|
+
const w = `${v}-${F}`;
|
|
63
|
+
n.set(w, u || "FFFF0000");
|
|
64
|
+
});
|
|
65
|
+
for (let v = 0; v < l.length; v++) {
|
|
66
|
+
const F = i.getColumn(v + 1);
|
|
67
|
+
if (v < s.columnCount && v < y.length) {
|
|
68
|
+
const u = s.getColumn(v + 1);
|
|
69
|
+
u && u.width ? F.width = u.width : F.width = p;
|
|
70
|
+
} else
|
|
71
|
+
F.width = p;
|
|
72
|
+
}
|
|
73
|
+
const g = i.getRow(1);
|
|
74
|
+
l.forEach((v, F) => {
|
|
75
|
+
const u = g.getCell(F + 1);
|
|
76
|
+
u.value = v;
|
|
77
|
+
const w = F < y.length;
|
|
78
|
+
if (w && F < s.columnCount) {
|
|
79
|
+
const e = s.getRow(1).getCell(F + 1);
|
|
80
|
+
e.style && (u.style = JSON.parse(JSON.stringify(e.style))), e.font && (u.font = JSON.parse(JSON.stringify(e.font))), e.alignment && (u.alignment = JSON.parse(JSON.stringify(e.alignment))), e.border && (u.border = JSON.parse(JSON.stringify(e.border))), e.numFmt && (u.numFmt = e.numFmt), e.fill && (u.fill = JSON.parse(JSON.stringify(e.fill)));
|
|
81
|
+
}
|
|
82
|
+
r && r.includes(v) && !w && (u.fill = {
|
|
83
|
+
type: "pattern",
|
|
84
|
+
pattern: "solid",
|
|
85
|
+
fgColor: { argb: "FFFF0000" }
|
|
86
|
+
// 红色背景
|
|
87
|
+
}, u.font = {
|
|
88
|
+
name: "Arial",
|
|
89
|
+
size: 10,
|
|
90
|
+
bold: !0,
|
|
91
|
+
color: { argb: "FFFFFFFF" }
|
|
92
|
+
// 白色文字
|
|
93
|
+
});
|
|
94
|
+
}), g.commit(), s.eachRow((v, F) => {
|
|
95
|
+
if (F > 1) {
|
|
96
|
+
const u = i.getRow(F);
|
|
97
|
+
for (let w = 0; w < l.length; w++) {
|
|
98
|
+
const e = u.getCell(w + 1);
|
|
99
|
+
if (w < y.length && w < s.columnCount) {
|
|
100
|
+
const h = v.getCell(w + 1);
|
|
101
|
+
if (e.value = h.value, e.value !== null && e.value !== void 0 && typeof e.value == "object" && !("richText" in e.value) && !("formula" in e.value) && !("hyperlink" in e.value) && !(e.value instanceof Date))
|
|
102
|
+
try {
|
|
103
|
+
"text" in e.value && typeof e.value.text == "string" ? e.value = e.value.text : e.value = JSON.stringify(e.value);
|
|
104
|
+
} catch {
|
|
105
|
+
e.value = String(e.value);
|
|
106
|
+
}
|
|
107
|
+
h.style && (e.style = JSON.parse(JSON.stringify(h.style))), h.font && (e.font = JSON.parse(JSON.stringify(h.font))), h.alignment && (e.alignment = JSON.parse(JSON.stringify(h.alignment))), h.border && (e.border = JSON.parse(JSON.stringify(h.border))), h.numFmt && (e.numFmt = h.numFmt), h.fill && (e.fill = JSON.parse(JSON.stringify(h.fill)));
|
|
108
|
+
const A = `${F}-${w + 1}`;
|
|
109
|
+
n.has(A) && (e.fill = {
|
|
110
|
+
type: "pattern",
|
|
111
|
+
pattern: "solid",
|
|
112
|
+
fgColor: { argb: n.get(A) }
|
|
113
|
+
});
|
|
114
|
+
} else
|
|
115
|
+
e.value = null;
|
|
116
|
+
}
|
|
117
|
+
v.height && (u.height = v.height), v.outlineLevel && (u.outlineLevel = v.outlineLevel), u.commit();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const J = await c.xlsx.writeBuffer();
|
|
121
|
+
return { hasError: !0, errBlob: new Blob([J], {
|
|
122
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
123
|
+
}) };
|
|
124
|
+
}, xe = async (C, o) => {
|
|
125
|
+
if (!o || se(o))
|
|
126
|
+
return { hasError: !1 };
|
|
127
|
+
const a = await K(C);
|
|
128
|
+
if (!a) return { hasError: !0 };
|
|
129
|
+
const { headers: f, excelData: s } = a, y = [];
|
|
130
|
+
if (Object.keys(o).forEach((l) => {
|
|
131
|
+
f.includes(l) || y.push(l);
|
|
132
|
+
}), f.length === 0 || s.length === 0)
|
|
133
|
+
return b.error("Excel文件不包含足够的数据"), { hasError: !0 };
|
|
134
|
+
const t = new ge({});
|
|
135
|
+
t.messages(ie.messages()), t.define(o);
|
|
136
|
+
const r = await ye(f, s, t);
|
|
137
|
+
if (r.length > 0 || y.length > 0) {
|
|
138
|
+
const l = r.map((c) => ({
|
|
139
|
+
row: c.row + 2,
|
|
140
|
+
// 转为Excel行号(+2是因为表头占一行,且是1-based索引)
|
|
141
|
+
col: c.col + 1,
|
|
142
|
+
// 转为Excel列号(+1是因为是1-based索引)
|
|
143
|
+
color: "FFFF0000"
|
|
144
|
+
// 红色
|
|
145
|
+
}));
|
|
146
|
+
return Z(C, {
|
|
147
|
+
markCells: l,
|
|
148
|
+
markHeaders: y
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return { hasError: !1 };
|
|
152
|
+
}, ye = async (C, o, a) => {
|
|
153
|
+
const f = [];
|
|
154
|
+
for (let s = 0; s < o.length; s++) {
|
|
155
|
+
const y = o[s];
|
|
156
|
+
try {
|
|
157
|
+
await a.validate(y).catch(({ errors: t }) => {
|
|
158
|
+
const r = [];
|
|
159
|
+
t.forEach((l) => {
|
|
160
|
+
const c = C.indexOf(l.field);
|
|
161
|
+
c >= 0 && (r.some((p) => p.row === s && p.col === c) || r.push({
|
|
162
|
+
row: s,
|
|
163
|
+
col: c,
|
|
164
|
+
header: l.field,
|
|
165
|
+
message: l.message.replace("${label}", C[c])
|
|
166
|
+
}));
|
|
167
|
+
}), f.push(...r);
|
|
168
|
+
});
|
|
169
|
+
} catch (t) {
|
|
170
|
+
console.error("验证表格数据时发生错误:", t), b.error("验证表格数据时发生错误:" + t);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return f;
|
|
174
|
+
}, we = async (C, o, a) => {
|
|
175
|
+
if (!o || o.length === 0)
|
|
176
|
+
return { hasError: !1 };
|
|
177
|
+
const f = await K(C);
|
|
178
|
+
if (!f) return { hasError: !0 };
|
|
179
|
+
const { headers: s, excelData: y } = f, t = [];
|
|
180
|
+
if (o.forEach((i) => {
|
|
181
|
+
s.includes(i) || t.push(i);
|
|
182
|
+
}), t.length > 0)
|
|
183
|
+
return b.error(`表头缺少重复检测所需字段: ${t.join(", ")}`), { hasError: !0 };
|
|
184
|
+
const r = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), c = new Array();
|
|
185
|
+
if (y.forEach((i, p) => {
|
|
186
|
+
const n = o.map((g) => i[g]).join("|");
|
|
187
|
+
c.push(n), r.has(n) ? (l.add(p), l.add(r.get(n))) : r.set(n, p);
|
|
188
|
+
}), a) {
|
|
189
|
+
const i = await ve(a, {
|
|
190
|
+
Data: c
|
|
191
|
+
});
|
|
192
|
+
if (i != null && i.data && i.data.forEach((p) => {
|
|
193
|
+
l.add(p);
|
|
194
|
+
}), (i == null ? void 0 : i.status) === Y.ERROR)
|
|
195
|
+
throw new Error(i.msg);
|
|
196
|
+
}
|
|
197
|
+
if (l.size > 0) {
|
|
198
|
+
const i = [];
|
|
199
|
+
return l.forEach((p) => {
|
|
200
|
+
o.forEach((n) => {
|
|
201
|
+
const g = s.indexOf(n);
|
|
202
|
+
g >= 0 && i.push({
|
|
203
|
+
row: p + 2,
|
|
204
|
+
// Excel行号 = 数组索引 + 2(表头和1-based索引)
|
|
205
|
+
col: g + 1,
|
|
206
|
+
// Excel列号 = 数组索引 + 1(1-based索引)
|
|
207
|
+
color: "FFFF0000"
|
|
208
|
+
// 红色
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}), Z(C, { markCells: i, markHeaders: t });
|
|
212
|
+
}
|
|
213
|
+
return { hasError: !1 };
|
|
214
|
+
}, be = { class: "mb-4 flex items-center" }, Fe = {
|
|
10
215
|
key: 0,
|
|
11
216
|
class: "ml-3 text-gray-600"
|
|
12
|
-
},
|
|
217
|
+
}, Ee = { class: "flex gap-4" }, Ce = {
|
|
13
218
|
key: 0,
|
|
14
219
|
class: "w-[22%] flex-grow overflow-hidden flex flex-col"
|
|
15
|
-
},
|
|
220
|
+
}, Se = { class: "bg-gray-50 p-2 rounded border flex-grow flex flex-col" }, ke = {
|
|
16
221
|
key: 0,
|
|
17
222
|
class: "text-gray-500"
|
|
18
|
-
},
|
|
223
|
+
}, _e = {
|
|
19
224
|
key: 1,
|
|
20
225
|
class: "flex flex-col"
|
|
21
|
-
},
|
|
226
|
+
}, Oe = { class: "overflow-y-auto" }, De = { class: "text-[13px] text-gray-600" }, Ne = { class: "pl-5 mt-1 mb-0" }, Je = {
|
|
22
227
|
key: 0,
|
|
23
228
|
class: "mt-3"
|
|
24
|
-
}, Ue = { class: "text-[12px] text-gray-600 p-1" },
|
|
229
|
+
}, Ue = { class: "text-[12px] text-gray-600 p-1" }, Le = { class: "text-[13px] text-gray-600" }, Re = { class: "pl-5 mt-1 mb-0" }, Be = { class: "text-[12px] text-gray-600" }, qe = /* @__PURE__ */ te({
|
|
25
230
|
__name: "excelForm",
|
|
26
231
|
props: {
|
|
27
232
|
title: {},
|
|
@@ -33,189 +238,189 @@ const me = { class: "mb-4 flex items-center" }, xe = {
|
|
|
33
238
|
excelBatchField: {},
|
|
34
239
|
saveText: {}
|
|
35
240
|
},
|
|
36
|
-
setup(
|
|
37
|
-
const o =
|
|
38
|
-
|
|
39
|
-
() =>
|
|
241
|
+
setup(C) {
|
|
242
|
+
const o = C, a = o.excelCtrl, f = E(!1), s = E(""), y = E([]), t = E(""), r = E(!0), l = E("待验证数据规则"), c = E("warning"), i = E("待验证重复数据"), p = E("warning");
|
|
243
|
+
P(
|
|
244
|
+
() => a.visible.value,
|
|
40
245
|
() => {
|
|
41
|
-
|
|
246
|
+
f.value = a.visible.value;
|
|
42
247
|
}
|
|
43
|
-
),
|
|
44
|
-
() =>
|
|
248
|
+
), P(
|
|
249
|
+
() => f.value,
|
|
45
250
|
() => {
|
|
46
|
-
|
|
251
|
+
a.visible.value = f.value;
|
|
47
252
|
}
|
|
48
253
|
);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
|
|
254
|
+
const n = E(o.uploadParams), g = E(n.value.uploadUrl), J = E(n.value.duplicateRules), R = E(n.value.duplicateUrl), v = async () => {
|
|
255
|
+
const d = g.value;
|
|
256
|
+
if (!d) {
|
|
257
|
+
b.error("未配置文件上传地址!");
|
|
53
258
|
return;
|
|
54
259
|
}
|
|
55
|
-
if (
|
|
56
|
-
|
|
260
|
+
if (u.value) {
|
|
261
|
+
b.error("表格数据存在验证错误,请修正后再上传!");
|
|
57
262
|
return;
|
|
58
263
|
}
|
|
59
|
-
|
|
264
|
+
a.isFormLoading.value = !0;
|
|
60
265
|
try {
|
|
61
|
-
if (!
|
|
62
|
-
|
|
266
|
+
if (!e.value || !t.value) {
|
|
267
|
+
b.warning("请先选择Excel文件!"), a.isFormLoading.value = !1;
|
|
63
268
|
return;
|
|
64
269
|
}
|
|
65
|
-
const
|
|
270
|
+
const m = new de(d, 1), S = new File([e.value], t.value, {
|
|
66
271
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
67
|
-
}),
|
|
272
|
+
}), x = pe.join(n.value.basePath, t.value), D = {
|
|
68
273
|
uid: "1",
|
|
69
|
-
name:
|
|
70
|
-
originFileObj:
|
|
71
|
-
status:
|
|
274
|
+
name: t.value,
|
|
275
|
+
originFileObj: S,
|
|
276
|
+
status: me.Uploading,
|
|
72
277
|
percent: 0,
|
|
73
278
|
params: {
|
|
74
|
-
FileKey:
|
|
279
|
+
FileKey: x
|
|
75
280
|
}
|
|
76
|
-
},
|
|
281
|
+
}, B = new AbortController();
|
|
77
282
|
try {
|
|
78
|
-
await
|
|
79
|
-
|
|
80
|
-
}),
|
|
81
|
-
} catch (
|
|
82
|
-
throw console.error("文件上传错误:",
|
|
283
|
+
await m.uploadFile(D, B.signal, (_) => {
|
|
284
|
+
D.percent = _;
|
|
285
|
+
}), b.success("文件上传成功,开始业务处理!"), F(D);
|
|
286
|
+
} catch (_) {
|
|
287
|
+
throw console.error("文件上传错误:", _), b.error((_ == null ? void 0 : _.message) || "文件上传失败,请稍后再试!"), _;
|
|
83
288
|
}
|
|
84
|
-
} catch (
|
|
85
|
-
console.error("上传处理错误:",
|
|
289
|
+
} catch (m) {
|
|
290
|
+
console.error("上传处理错误:", m), b.error("上传处理失败:" + ((m == null ? void 0 : m.message) || "未知错误"));
|
|
86
291
|
} finally {
|
|
87
|
-
|
|
292
|
+
a.isFormLoading.value = !1;
|
|
88
293
|
}
|
|
89
|
-
},
|
|
90
|
-
if (
|
|
294
|
+
}, F = async (d) => {
|
|
295
|
+
if (a.formData.value) {
|
|
91
296
|
if (o.excelBatchField) {
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
94
|
-
const { excelData:
|
|
95
|
-
const
|
|
96
|
-
for (const
|
|
97
|
-
const
|
|
98
|
-
|
|
297
|
+
const x = await K(e.value);
|
|
298
|
+
if (!x) return null;
|
|
299
|
+
const { excelData: D } = x, B = D.map((_) => {
|
|
300
|
+
const j = {};
|
|
301
|
+
for (const $ in _) {
|
|
302
|
+
const z = o.excelFieldMap[$];
|
|
303
|
+
z && (j[z] = _[$]);
|
|
99
304
|
}
|
|
100
|
-
return
|
|
305
|
+
return j;
|
|
101
306
|
});
|
|
102
|
-
|
|
307
|
+
a.formData.value[o.excelBatchField] = B;
|
|
103
308
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const
|
|
309
|
+
const m = o.fileField ?? "FileInfo";
|
|
310
|
+
a.formData.value[m] = d, a.beforeSave && a.beforeSave();
|
|
311
|
+
const S = {
|
|
107
312
|
Data: {
|
|
108
|
-
...
|
|
313
|
+
...a.formData.value
|
|
109
314
|
},
|
|
110
315
|
Query: {
|
|
111
|
-
[o.excelCtrl.primaryKey]:
|
|
316
|
+
[o.excelCtrl.primaryKey]: a.formData.value[o.excelCtrl.primaryKey]
|
|
112
317
|
}
|
|
113
318
|
};
|
|
114
|
-
|
|
319
|
+
a.isFormLoading.value = !0;
|
|
115
320
|
try {
|
|
116
|
-
const
|
|
117
|
-
params:
|
|
321
|
+
const x = await ce(o.excelCtrl, {
|
|
322
|
+
params: S,
|
|
118
323
|
urlKey: "save",
|
|
119
324
|
url: o.excelCtrl.saveUrl
|
|
120
325
|
});
|
|
121
|
-
(
|
|
122
|
-
} catch (
|
|
123
|
-
console.error("保存错误:",
|
|
326
|
+
(x == null ? void 0 : x.status) === Y.SUCCESS ? (b.success("数据保存成功!"), a.afterSave && a.afterSave(), a.visible.value = !1) : b.error("保存失败:" + ((x == null ? void 0 : x.msg) || "未知错误"));
|
|
327
|
+
} catch (x) {
|
|
328
|
+
console.error("保存错误:", x), b.error("数据保存失败,请稍后再试!");
|
|
124
329
|
} finally {
|
|
125
|
-
|
|
330
|
+
a.isFormLoading.value = !1;
|
|
126
331
|
}
|
|
127
332
|
}
|
|
128
|
-
},
|
|
129
|
-
if (!(
|
|
130
|
-
return
|
|
333
|
+
}, u = E(!1), w = E(!1), e = E(null), W = async (d) => {
|
|
334
|
+
if (!(d.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || d.type === "application/vnd.ms-excel"))
|
|
335
|
+
return b.error("只能上传Excel文件!"), Q.LIST_IGNORE;
|
|
131
336
|
try {
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
const { hasError:
|
|
139
|
-
if (
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
337
|
+
t.value = d.name, u.value = !1, w.value = !1, r.value = !0, l.value = "待验证数据规则", c.value = "warning", i.value = "待验证重复数据", p.value = "warning";
|
|
338
|
+
const S = await d.arrayBuffer();
|
|
339
|
+
e.value = S;
|
|
340
|
+
const x = new FileReader();
|
|
341
|
+
x.readAsDataURL(d), x.onload = async (D) => {
|
|
342
|
+
if (D.target) {
|
|
343
|
+
const { hasError: B, errBlob: _ } = await xe(S, a.formRules.value);
|
|
344
|
+
if (B) {
|
|
345
|
+
if (_) {
|
|
346
|
+
u.value = !0, r.value = !1, l.value = "数据验证失败", c.value = "error";
|
|
347
|
+
const j = URL.createObjectURL(_);
|
|
348
|
+
s.value = j;
|
|
144
349
|
}
|
|
145
350
|
return;
|
|
146
351
|
} else
|
|
147
|
-
|
|
148
|
-
if (
|
|
352
|
+
l.value = "数据验证成功", c.value = "success";
|
|
353
|
+
if (J.value && J.value.length > 0 && R.value)
|
|
149
354
|
try {
|
|
150
|
-
|
|
151
|
-
const { hasError:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
355
|
+
R.value.api || (R.value.api = o.gridCtrl.page.api), R.value.authorize === void 0 && (R.value.authorize = o.gridCtrl.page.authorize);
|
|
356
|
+
const { hasError: j, errBlob: $ } = await we(
|
|
357
|
+
S,
|
|
358
|
+
J.value,
|
|
359
|
+
R.value
|
|
155
360
|
);
|
|
156
|
-
if (
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
361
|
+
if (j) {
|
|
362
|
+
if ($) {
|
|
363
|
+
w.value = !0, i.value = "检测到重复数据", p.value = "error";
|
|
364
|
+
const z = URL.createObjectURL($);
|
|
365
|
+
s.value = z;
|
|
161
366
|
}
|
|
162
367
|
return;
|
|
163
368
|
} else
|
|
164
|
-
|
|
369
|
+
w.value = !1, i.value = "数据验证通过", p.value = "success";
|
|
165
370
|
} catch {
|
|
166
|
-
|
|
371
|
+
i.value = "重复检测异常", p.value = "error";
|
|
167
372
|
}
|
|
168
|
-
|
|
373
|
+
s.value = D.target.result, r.value = !1;
|
|
169
374
|
} else
|
|
170
|
-
|
|
375
|
+
b.error("加载Excel文件失败,请检查文件格式!");
|
|
171
376
|
};
|
|
172
|
-
} catch (
|
|
173
|
-
console.error("Excel处理错误:",
|
|
377
|
+
} catch (S) {
|
|
378
|
+
console.error("Excel处理错误:", S), b.error("Excel文件处理失败,请检查文件格式!"), r.value = !1, l.value = "Excel处理错误", c.value = "error";
|
|
174
379
|
}
|
|
175
380
|
return !1;
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
|
|
381
|
+
}, h = ne(a.formRules.value);
|
|
382
|
+
ae(() => {
|
|
383
|
+
const d = o.gridCtrl.page;
|
|
384
|
+
if (g.value = g.value ?? d.urls.upload, !g.value) {
|
|
385
|
+
b.error("未配置文件上传地址!");
|
|
181
386
|
return;
|
|
182
387
|
}
|
|
183
|
-
|
|
184
|
-
for (const
|
|
185
|
-
o.gridCtrl.rowData.value && (
|
|
186
|
-
|
|
388
|
+
g.value.api || (g.value.api = d.api), g.value.authorize === void 0 && (g.value.authorize = d.authorize);
|
|
389
|
+
for (const m in a.formData.value)
|
|
390
|
+
o.gridCtrl.rowData.value && (a.formData.value[m] = o.gridCtrl.rowData.value[m]);
|
|
391
|
+
f.value = a.visible.value;
|
|
187
392
|
});
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
},
|
|
393
|
+
const A = () => {
|
|
394
|
+
a.visible.value = !1;
|
|
395
|
+
}, ee = () => {
|
|
191
396
|
console.error("渲染失败");
|
|
192
397
|
};
|
|
193
|
-
return (
|
|
194
|
-
title:
|
|
195
|
-
open:
|
|
196
|
-
"onUpdate:open":
|
|
197
|
-
wrapClassName: ["modal", "mx-auto",
|
|
398
|
+
return (d, m) => (N(), le(k(ue), {
|
|
399
|
+
title: d.title ?? "Excel文件上传",
|
|
400
|
+
open: f.value,
|
|
401
|
+
"onUpdate:open": m[0] || (m[0] = (S) => f.value = S),
|
|
402
|
+
wrapClassName: ["modal", "mx-auto", d.$attrs.width ? "w-[" + d.$attrs.width + "]" : ""].join(" "),
|
|
198
403
|
width: 940,
|
|
199
|
-
onClose:
|
|
404
|
+
onClose: A
|
|
200
405
|
}, {
|
|
201
|
-
footer:
|
|
202
|
-
|
|
203
|
-
default:
|
|
204
|
-
|
|
205
|
-
default:
|
|
206
|
-
|
|
406
|
+
footer: T(() => [
|
|
407
|
+
L(k(fe), null, {
|
|
408
|
+
default: T(() => [
|
|
409
|
+
L(k(I), { onClick: A }, {
|
|
410
|
+
default: T(() => m[2] || (m[2] = [
|
|
411
|
+
H("取消")
|
|
207
412
|
])),
|
|
208
413
|
_: 1,
|
|
209
414
|
__: [2]
|
|
210
415
|
}),
|
|
211
|
-
|
|
212
|
-
onClick:
|
|
416
|
+
L(k(I), {
|
|
417
|
+
onClick: v,
|
|
213
418
|
type: "primary",
|
|
214
|
-
loading:
|
|
215
|
-
disabled: !
|
|
419
|
+
loading: k(a).isFormSaving.value,
|
|
420
|
+
disabled: !s.value || u.value || w.value || r.value
|
|
216
421
|
}, {
|
|
217
|
-
default:
|
|
218
|
-
|
|
422
|
+
default: T(() => [
|
|
423
|
+
H(M(d.saveText ?? "上传文件"), 1)
|
|
219
424
|
]),
|
|
220
425
|
_: 1
|
|
221
426
|
}, 8, ["loading", "disabled"])
|
|
@@ -223,19 +428,19 @@ const me = { class: "mb-4 flex items-center" }, xe = {
|
|
|
223
428
|
_: 1
|
|
224
429
|
})
|
|
225
430
|
]),
|
|
226
|
-
default:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
"file-list":
|
|
431
|
+
default: T(() => [
|
|
432
|
+
re(d.$slots, "default"),
|
|
433
|
+
O("div", be, [
|
|
434
|
+
L(k(Q), {
|
|
435
|
+
"file-list": y.value,
|
|
231
436
|
"before-upload": W,
|
|
232
437
|
accept: ".xlsx,.xls",
|
|
233
438
|
showUploadList: !0
|
|
234
439
|
}, {
|
|
235
|
-
default:
|
|
236
|
-
|
|
237
|
-
default:
|
|
238
|
-
|
|
440
|
+
default: T(() => [
|
|
441
|
+
L(k(I), { type: "primary" }, {
|
|
442
|
+
default: T(() => m[1] || (m[1] = [
|
|
443
|
+
H("选择Excel文件")
|
|
239
444
|
])),
|
|
240
445
|
_: 1,
|
|
241
446
|
__: [1]
|
|
@@ -243,18 +448,18 @@ const me = { class: "mb-4 flex items-center" }, xe = {
|
|
|
243
448
|
]),
|
|
244
449
|
_: 1
|
|
245
450
|
}, 8, ["file-list"]),
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
])) :
|
|
451
|
+
s.value && t.value ? (N(), U("div", Fe, [
|
|
452
|
+
O("span", null, M(t.value), 1)
|
|
453
|
+
])) : V("", !0)
|
|
249
454
|
]),
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
class:
|
|
455
|
+
O("div", Ee, [
|
|
456
|
+
O("div", {
|
|
457
|
+
class: oe(["flex-shrink-0 excel-container", [k(h).length === 0 ? "w-[100%]" : "w-[80%]"]]),
|
|
253
458
|
style: { height: "430px" }
|
|
254
459
|
}, [
|
|
255
|
-
|
|
256
|
-
src:
|
|
257
|
-
onError:
|
|
460
|
+
L(k(he), {
|
|
461
|
+
src: s.value,
|
|
462
|
+
onError: ee,
|
|
258
463
|
style: { width: "100%", height: "100%" },
|
|
259
464
|
options: {
|
|
260
465
|
styles: !0,
|
|
@@ -266,46 +471,46 @@ const me = { class: "mb-4 flex items-center" }, xe = {
|
|
|
266
471
|
}
|
|
267
472
|
}, null, 8, ["src"])
|
|
268
473
|
], 2),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
message:
|
|
274
|
-
type:
|
|
474
|
+
k(h).length > 0 ? (N(), U("div", Ce, [
|
|
475
|
+
O("div", Se, [
|
|
476
|
+
k(h).length === 0 ? (N(), U("div", ke, "没有设置验证规则")) : (N(), U("div", _e, [
|
|
477
|
+
L(k(X), {
|
|
478
|
+
message: l.value,
|
|
479
|
+
type: c.value,
|
|
275
480
|
"show-icon": "",
|
|
276
481
|
class: "mb-2"
|
|
277
482
|
}, null, 8, ["message", "type"]),
|
|
278
|
-
|
|
279
|
-
(
|
|
280
|
-
key:
|
|
483
|
+
O("div", Oe, [
|
|
484
|
+
(N(!0), U(q, null, G(k(h), (S, x) => (N(), U("div", {
|
|
485
|
+
key: x,
|
|
281
486
|
class: "border-b pb-0"
|
|
282
487
|
}, [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
(
|
|
286
|
-
key:
|
|
488
|
+
O("div", De, M(S.field), 1),
|
|
489
|
+
O("ul", Ne, [
|
|
490
|
+
(N(!0), U(q, null, G(S.rules, (D, B) => (N(), U("li", {
|
|
491
|
+
key: B,
|
|
287
492
|
class: "text-[12px] text-gray-600"
|
|
288
|
-
},
|
|
493
|
+
}, M(D), 1))), 128))
|
|
289
494
|
])
|
|
290
495
|
]))), 128))
|
|
291
496
|
]),
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
message:
|
|
295
|
-
type:
|
|
497
|
+
J.value && J.value.length > 0 ? (N(), U("div", Je, [
|
|
498
|
+
L(k(X), {
|
|
499
|
+
message: i.value,
|
|
500
|
+
type: p.value,
|
|
296
501
|
"show-icon": "",
|
|
297
502
|
class: "mt-2 mb-2"
|
|
298
503
|
}, null, 8, ["message", "type"]),
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
504
|
+
O("div", Ue, [
|
|
505
|
+
O("div", Le, " 以下" + M(J.value.length > 1 ? "组合" : "字段") + "必须唯一 ", 1),
|
|
506
|
+
O("ul", Re, [
|
|
507
|
+
O("li", Be, M(J.value.join(", ")), 1)
|
|
303
508
|
])
|
|
304
509
|
])
|
|
305
|
-
])) :
|
|
510
|
+
])) : V("", !0)
|
|
306
511
|
]))
|
|
307
512
|
])
|
|
308
|
-
])) :
|
|
513
|
+
])) : V("", !0)
|
|
309
514
|
])
|
|
310
515
|
]),
|
|
311
516
|
_: 3
|
|
@@ -313,5 +518,5 @@ const me = { class: "mb-4 flex items-center" }, xe = {
|
|
|
313
518
|
}
|
|
314
519
|
});
|
|
315
520
|
export {
|
|
316
|
-
|
|
521
|
+
qe as default
|
|
317
522
|
};
|