@skyfox2000/webui 1.2.0 → 1.2.2

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.
@@ -1,278 +0,0 @@
1
- import { ResStatus as w, httpPost as $ } from "@skyfox2000/fapi";
2
- import { d as Q, b as j, c as B, _ as T } from "./form-validate-CgX7aR7T.js";
3
- import { s as M } from "./index-DQMdt51R.js";
4
- import { b as A, r as G } from "./settingInfo-BZakNKIN.js";
5
- import { combineParams as z } from "@skyfox2000/microbase";
6
- import { defineComponent as V, ref as F, computed as O, watch as I, createElementBlock as m, openBlock as d, createElementVNode as l, createVNode as x, unref as c, mergeProps as q, withCtx as L, createTextVNode as P, toDisplayString as b, Fragment as H, renderList as J, normalizeClass as W, createCommentVNode as g } from "vue";
7
- import { Upload as X, Tag as Y, Progress as Z } from "ant-design-vue";
8
- import { U as n, p as C } from "./file-upload-CBUcsUnR.js";
9
- import y from "vue-m-message";
10
- import "async-validator";
11
- import "dayjs";
12
- import "./index-DmWrkTXX.js";
13
- const Fe = (t, s) => {
14
- const e = A();
15
- return t.filter((a) => {
16
- if (a.role && !e.hasRole(a.role) || a.permit && !e.hasPermit(G.currentRoute.value.path, a.permit))
17
- return !1;
18
- if (!s) {
19
- if (a.visible === !1)
20
- return !1;
21
- if (typeof a.visible == "function")
22
- return a.visible();
23
- }
24
- return !0;
25
- });
26
- }, Oe = (t) => (t.remotePage = !1, ee(t).then((s) => s.rows)), ee = (t) => {
27
- t.gridQuery || (t.gridQuery = {});
28
- const s = t.remotePage ? "find" : "list";
29
- return Q(t, {
30
- urlKey: s,
31
- url: t.gridUrl,
32
- params: t.gridQuery,
33
- loadingState: t.isGridLoading,
34
- processParams: (e) => {
35
- var u;
36
- return t.remotePage && (e.Query.$limit = [(t.pageNo.value - 1) * t.pageSize.value, t.pageSize.value]), z((u = t.gridUrl) == null ? void 0 : u.params, e, t.gridQuery);
37
- }
38
- }).then((e) => {
39
- if ((e == null ? void 0 : e.status) === w.SUCCESS) {
40
- let a = e.data;
41
- return a.rows ? (t.tableData.value = a.rows, t.total.value = a.total) : (t.tableData.value = e.data, t.total.value = e.data.length, a = {
42
- total: t.total.value,
43
- rows: e.data
44
- }, t.afterLoad && t.afterLoad(a)), a;
45
- }
46
- return t.tableData.value = [], t.total.value = 0, {
47
- total: 0,
48
- rows: []
49
- };
50
- });
51
- }, te = (t, s, e = {}) => j(t, {
52
- urlKey: "update",
53
- url: t.updateUrl,
54
- params: {
55
- Query: { [t.primaryKey]: s[t.primaryKey] },
56
- Data: s
57
- },
58
- loadingState: t.isGridSaving,
59
- ...e
60
- }).then((a) => ((a == null ? void 0 : a.status) === w.SUCCESS && setTimeout(() => {
61
- t.reload.value = !0, t.afterUpdate && t.afterUpdate(s);
62
- }, 50), a)), Pe = (t, s) => {
63
- const e = {};
64
- return e[t.primaryKey] = s[t.primaryKey], e[t.statusKey] = s[t.statusKey], te(t, e, {
65
- loadingText: !1,
66
- hideErrorToast: !0
67
- });
68
- }, ge = (t, s) => {
69
- let e = t.editor;
70
- t.rowData.value = s, e && (M(e, s), e.visible.value = !0);
71
- }, ze = (t, s) => B(t, s, {
72
- url: t.deleteUrl,
73
- primaryKey: t.primaryKey
74
- }).then((e) => ((e == null ? void 0 : e.status) === w.SUCCESS && setTimeout(() => {
75
- t.reload.value = !0, t.afterDelete && !Array.isArray(s) && t.afterDelete(s);
76
- }, 50), e)), ae = (t, s) => {
77
- const e = document.createElement("a"), a = URL.createObjectURL(t);
78
- e.href = a, e.download = s, e.style.display = "none", document.body.appendChild(e), e.click(), URL.revokeObjectURL(a), document.body.removeChild(e);
79
- }, oe = (t, s, e) => {
80
- try {
81
- const a = z(t.params, s);
82
- return $(t, a).then((u) => {
83
- if ((u == null ? void 0 : u.status) === w.SUCCESS && u.data) {
84
- const f = u.data, S = f.Content, _ = f.FileName, h = atob(S), v = [];
85
- for (let p = 0; p < h.length; p++)
86
- v.push(h.charCodeAt(p));
87
- const U = new Blob([new Uint8Array(v)], {
88
- type: f.Type
89
- });
90
- ae(U, _);
91
- } else
92
- y.error("下载文件失败!");
93
- });
94
- } catch (a) {
95
- console.error("下载失败:", a), y.error("文件下载失败,请稍后重试");
96
- }
97
- }, se = { class: "w-full border border-solid border-gray-100 mt-1 rounded-md py-5" }, ne = { class: "flex items-center justify-between w-full" }, re = { class: "w-35 mx-3" }, ie = { class: "flex-1 text-sm text-gray-500" }, le = { class: "mt-4 px-3" }, ue = { class: "flex items-center justify-between" }, ce = { class: "flex items-center" }, fe = { class: "flex items-center" }, pe = ["onClick"], me = ["onClick"], de = ["onClick"], Ke = /* @__PURE__ */ V({
98
- __name: "uploadList",
99
- props: {
100
- autoUpload: { type: Boolean, default: !1 },
101
- downloadUrl: {},
102
- fileList: { default: () => [] },
103
- placeholder: { default: "" },
104
- fileExt: {},
105
- maxFileSize: { default: 20 },
106
- maxCount: { default: 5 },
107
- parentPath: {}
108
- },
109
- emits: ["update:file-list"],
110
- setup(t, { emit: s }) {
111
- const e = t, a = F(e.fileList), u = F(), f = s, S = O(() => {
112
- var o;
113
- return (o = e.fileExt) != null && o.length ? e.fileExt.map((i) => `.${i}`).join(",") : "";
114
- }), _ = (o) => {
115
- var i;
116
- if (e.fileExt && e.fileExt.length > 0) {
117
- const r = ((i = o.name.split(".").pop()) == null ? void 0 : i.toLowerCase()) || "";
118
- if (!e.fileExt.includes(r))
119
- return y.error("文件类型不支持"), !1;
120
- }
121
- return o.size / 1024 / 1024 > e.maxFileSize ? (y.error(`文件大小超过 ${e.maxFileSize}MB 限制`), !1) : e.maxCount > 1 && a.value.length >= e.maxCount ? (y.error(`最多上传 ${e.maxCount} 个文件`), !1) : e.autoUpload;
122
- }, h = (o) => {
123
- o.forEach((i) => {
124
- i.fileName || (i.fileName = i.name), e.parentPath && (i.name = C.join("/", e.parentPath, i.fileName));
125
- });
126
- }, v = O(() => ({
127
- accept: S.value,
128
- multiple: !0,
129
- fileList: a.value,
130
- "onUpdate:fileList": h,
131
- beforeUpload: _,
132
- listType: "text",
133
- maxCount: e.maxCount,
134
- showUploadList: !1,
135
- onChange: (o) => {
136
- e.autoUpload || (a.value = o.fileList);
137
- }
138
- }));
139
- I(
140
- () => a.value,
141
- (o) => {
142
- f("update:file-list", o);
143
- },
144
- { deep: !0 }
145
- );
146
- const U = (o) => {
147
- const i = a.value[o].minioFile, r = {
148
- api: e.downloadUrl.api,
149
- authorize: e.downloadUrl.authorize,
150
- url: e.downloadUrl.url,
151
- // url: props.pageData.urls.download!.url,
152
- params: {
153
- Query: {
154
- FileKey: i.Key
155
- }
156
- }
157
- };
158
- oe(r);
159
- }, p = (o) => {
160
- o.status = o.status === n.Offline ? n.Online : n.Offline, o.minioFile.Status = o.status;
161
- }, K = (o) => {
162
- a.value.splice(o, 1);
163
- }, D = () => {
164
- const o = e.fileExt && e.fileExt.length ? `文件必须为 ${e.fileExt.join("/")}` : "", i = e.maxFileSize !== 0 ? `单文件最大 ${e.maxFileSize}MB` : "", r = e.maxCount !== 0 ? `最多 ${e.maxCount} 个文件` : "";
165
- return [i, o, r].filter(Boolean).join(",");
166
- }, N = (o) => {
167
- switch (o) {
168
- case n.Uploading:
169
- return "blue";
170
- case n.Success:
171
- return "green";
172
- case n.Error:
173
- return "red";
174
- case n.Online:
175
- return "green";
176
- case n.Offline:
177
- return "pink";
178
- default:
179
- return "cyan";
180
- }
181
- }, R = (o) => {
182
- switch (o) {
183
- case n.Uploading:
184
- return "上传中";
185
- case n.Success:
186
- return "已完成";
187
- case n.Error:
188
- return "上传失败";
189
- case n.Online:
190
- return "在线";
191
- case n.Offline:
192
- return "已下线";
193
- default:
194
- return "待上传";
195
- }
196
- };
197
- return (o, i) => (d(), m("div", se, [
198
- l("div", ne, [
199
- l("div", re, [
200
- x(c(X), q({
201
- ref_key: "fileUploader",
202
- ref: u
203
- }, v.value), {
204
- default: L(() => [
205
- x(c(T), null, {
206
- default: L(() => i[0] || (i[0] = [
207
- P("选择文件")
208
- ])),
209
- _: 1,
210
- __: [0]
211
- })
212
- ]),
213
- _: 1
214
- }, 16)
215
- ]),
216
- l("div", ie, b(D()), 1)
217
- ]),
218
- l("div", le, [
219
- (d(!0), m(H, null, J(a.value, (r, E) => (d(), m("div", {
220
- key: E,
221
- class: "mb-2 pb-1"
222
- }, [
223
- l("div", ue, [
224
- l("div", ce, [
225
- l("span", {
226
- class: W(["text-gray-700 mr-2", [r.status == c(n).Offline ? "line-through" : ""]])
227
- }, b(r.fileName ?? r.name), 3),
228
- l("span", null, [
229
- x(c(Y), {
230
- color: N(r.status)
231
- }, {
232
- default: L(() => [
233
- P(b(R(r.status)), 1)
234
- ]),
235
- _: 2
236
- }, 1032, ["color"])
237
- ])
238
- ]),
239
- l("div", fe, [
240
- r.status == c(n).Offline || r.status == c(n).Online ? (d(), m("span", {
241
- key: 0,
242
- class: "text-blue-500 hover:text-blue-700 mr-4 cursor-pointer",
243
- onClick: (k) => p(r)
244
- }, b(r.status == c(n).Offline ? "上线" : "下线"), 9, pe)) : g("", !0),
245
- r.status == c(n).Offline || r.status == c(n).Online ? (d(), m("span", {
246
- key: 1,
247
- class: "text-blue-500 hover:text-blue-700 mr-4 cursor-pointer",
248
- onClick: (k) => U(E)
249
- }, "下载", 8, me)) : g("", !0),
250
- l("span", {
251
- class: "text-red-500 hover:text-red-700 cursor-pointer",
252
- onClick: (k) => K(E)
253
- }, "删除", 8, de)
254
- ])
255
- ]),
256
- l("div", null, [
257
- x(c(Z), {
258
- percent: r.percent,
259
- "stroke-width": 2,
260
- "show-info": !1,
261
- style: { height: "2px" }
262
- }, null, 8, ["percent"])
263
- ])
264
- ]))), 128))
265
- ])
266
- ]));
267
- }
268
- });
269
- export {
270
- Ke as _,
271
- ze as a,
272
- Oe as b,
273
- Pe as c,
274
- te as d,
275
- Fe as f,
276
- ee as g,
277
- ge as o
278
- };