mgacn-commonsdk 1.2.9 → 1.3.1

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.
@@ -0,0 +1,877 @@
1
+ import ue from "axios";
2
+ import { ref as j, computed as D, watch as le, onBeforeUnmount as ae, resolveComponent as U, resolveDirective as ce, openBlock as g, createElementBlock as w, normalizeStyle as fe, normalizeClass as me, createElementVNode as b, toDisplayString as de, createCommentVNode as x, createVNode as M, withCtx as L, createTextVNode as pe, withDirectives as ge, unref as $, createBlock as ye, nextTick as we } from "vue";
3
+ import be from "vue-pdf-embed";
4
+ import he from "video.js";
5
+ import Se from "@vue-office/docx";
6
+ import _e from "@vue-office/excel";
7
+ const H = "__MGACN_COMMONSDK_SYSTEM_ID__", B = "__MGACN_COMMONSDK_USER_ID__";
8
+ function ve(e) {
9
+ globalThis[H] = e == null ? "" : String(e);
10
+ }
11
+ function O() {
12
+ return globalThis[H] || "";
13
+ }
14
+ function Ne(e) {
15
+ globalThis[B] = e == null ? "" : String(e);
16
+ }
17
+ function Te() {
18
+ return globalThis[B] || "";
19
+ }
20
+ function Ee(e = {}) {
21
+ const {
22
+ baseURL: t = "",
23
+ timeout: r = 6e4,
24
+ tokenKey: n,
25
+ systemId: i,
26
+ userId: o,
27
+ loginUrl: c = "/login"
28
+ } = e;
29
+ i != null && i !== "" && ve(i), o != null && o !== "" && Ne(o);
30
+ const u = ue.create({ baseURL: t, timeout: r });
31
+ let d = !1;
32
+ function f() {
33
+ typeof localStorage < "u" && localStorage.clear(), !d && (d = !0, setTimeout(() => {
34
+ typeof window < "u" && window.location.replace(c);
35
+ }, 1500));
36
+ }
37
+ return u.interceptors.request.use(
38
+ (a) => {
39
+ if (a.headers["Content-Type"] = "application/json;charset=UTF-8", typeof localStorage < "u" && n) {
40
+ const p = localStorage.getItem(n);
41
+ p && (a.headers.Authorization = p);
42
+ }
43
+ const l = O();
44
+ return l && (a.headers.systemId = l), a;
45
+ },
46
+ (a) => Promise.reject(a)
47
+ ), u.interceptors.response.use(
48
+ (a) => {
49
+ if (a.status !== 200)
50
+ return Promise.reject(new Error(`请求发生错误,状态码 ${a.status}`));
51
+ const { data: l, config: p } = a;
52
+ if (p.responseType === "arraybuffer" || p.responseType === "blob")
53
+ return l;
54
+ if (l && l.code === 0) return l.data;
55
+ const _ = Number(l == null ? void 0 : l.code);
56
+ if (_ === 401 || _ === 403)
57
+ return f(), Promise.reject(new Error("登录失效,请重新登录"));
58
+ const N = G(l) || "请求失败", y = new Error(N);
59
+ return y.code = _, y.data = l == null ? void 0 : l.data, y.biz = l, Promise.reject(y);
60
+ },
61
+ (a) => {
62
+ var N, y;
63
+ const l = (N = a == null ? void 0 : a.response) == null ? void 0 : N.status;
64
+ if (l === 401 || l === 403)
65
+ return f(), Promise.reject(new Error("登录失效,请重新登录"));
66
+ const p = (y = a == null ? void 0 : a.response) == null ? void 0 : y.data, _ = G(p) || (a == null ? void 0 : a.message) || "请求失败";
67
+ return Promise.reject(new Error(String(_)));
68
+ }
69
+ ), u;
70
+ }
71
+ function G(e) {
72
+ if (e == null) return "";
73
+ if (typeof e == "string") {
74
+ const r = e.trim();
75
+ return r ? /^<!DOCTYPE html>/i.test(r) || /^<html[\s>]/i.test(r) ? "接口地址无效或未配置代理" : r.length > 200 ? `${r.slice(0, 200)}…` : r : "";
76
+ }
77
+ if (typeof e != "object") return String(e);
78
+ const t = [e.message, e.msg, e.data, e.error];
79
+ for (const r of t)
80
+ if (!(r == null || r === "") && (typeof r == "string" || typeof r == "number")) {
81
+ const n = String(r).trim();
82
+ return /^<!DOCTYPE html>/i.test(n) || /^<html[\s>]/i.test(n) ? "接口地址无效或未配置代理" : n.length > 200 ? `${n.slice(0, 200)}…` : n;
83
+ }
84
+ return "";
85
+ }
86
+ function ht(e = {}) {
87
+ const t = Ee(e);
88
+ return {
89
+ GET(r, n = {}) {
90
+ return t({ method: "get", url: r, ...n });
91
+ },
92
+ POST(r, n, i = {}) {
93
+ return t({ method: "post", url: r, data: n, ...i });
94
+ },
95
+ DELETE(r, n = {}) {
96
+ return t({ method: "delete", url: r, ...n });
97
+ }
98
+ };
99
+ }
100
+ const K = "__MGACN_COMMONSDK_REQUEST__";
101
+ function St(e) {
102
+ globalThis[K] = e;
103
+ }
104
+ function Ae() {
105
+ const e = globalThis[K];
106
+ if (!e)
107
+ throw new Error("[mgacn-commonsdk] 请先 app.use(MgacnCommonSdk, { tokenKey, baseURL })");
108
+ return e;
109
+ }
110
+ function V(e, t, r = "application/vnd.ms-excel") {
111
+ if (e == null || typeof window > "u") return;
112
+ const n = e instanceof Blob ? e : new Blob([e], { type: r }), i = window.URL.createObjectURL(n), o = document.createElement("a");
113
+ o.href = i, o.download = t || "download", o.style.display = "none", document.body.appendChild(o), o.click(), document.body.removeChild(o), window.URL.revokeObjectURL(i);
114
+ }
115
+ function E(e) {
116
+ return String(e).padStart(2, "0");
117
+ }
118
+ function De(e = /* @__PURE__ */ new Date()) {
119
+ return `${e.getFullYear()}${E(e.getMonth() + 1)}${E(e.getDate())}${E(e.getHours())}${E(e.getMinutes())}${E(e.getSeconds())}`;
120
+ }
121
+ async function Me(e) {
122
+ if (!(e instanceof Blob) || !e.type || !/json/i.test(e.type)) return;
123
+ const t = await e.text();
124
+ let r = "导出失败";
125
+ try {
126
+ const n = JSON.parse(t);
127
+ r = (n == null ? void 0 : n.message) || (n == null ? void 0 : n.msg) || r;
128
+ } catch {
129
+ }
130
+ throw new Error(r);
131
+ }
132
+ async function Pe(e = {}) {
133
+ const {
134
+ url: t,
135
+ data: r,
136
+ params: n,
137
+ method: i = "POST",
138
+ filename: o,
139
+ ext: c = "xlsx"
140
+ } = e;
141
+ if (!t) throw new Error("导出地址不能为空");
142
+ if (!o) throw new Error("导出文件名不能为空");
143
+ const u = Ae(), d = String(i).toUpperCase();
144
+ let f;
145
+ d === "GET" ? f = await u.GET(t, { params: n, responseType: "blob" }) : f = await u.POST(t, r, { responseType: "blob" }), await Me(f);
146
+ const l = /\.[a-z0-9]+$/i.test(o) ? o : `${o}_${De()}.${c}`;
147
+ return V(f, l), l;
148
+ }
149
+ let S = null, T = null;
150
+ function xe(e, t) {
151
+ if (!e || t == null || t === "") return !1;
152
+ if (typeof t == "object")
153
+ return t.id != null && t.id !== "" && String(e.id) === String(t.id) || t.platformName != null && t.platformName !== "" && String(e.platformName || "") === String(t.platformName).trim();
154
+ const r = String(t).trim();
155
+ return e.id != null && String(e.id) === r || String(e.platformName || "") === r;
156
+ }
157
+ function z(e) {
158
+ S = Array.isArray(e) ? e : [];
159
+ }
160
+ function $e() {
161
+ S = null, T = null;
162
+ }
163
+ function Oe(e) {
164
+ if (!Array.isArray(S) || !S.length) return "";
165
+ const t = S.find((r) => xe(r, e));
166
+ return (t == null ? void 0 : t.platformLogo) || "";
167
+ }
168
+ async function Ce() {
169
+ return S ?? (T || (T = (async () => {
170
+ try {
171
+ const e = await Ze().listPlatformInfoAll();
172
+ return z(e), S;
173
+ } finally {
174
+ T = null;
175
+ }
176
+ })(), T));
177
+ }
178
+ const Ie = ["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "ico"], ke = ["mp4", "webm", "ogg", "mov", "m4v"], Re = ["pdf"], Ye = ["docx"], Fe = ["xlsx", "xls", "csv"];
179
+ function h(e = "") {
180
+ const t = String(e || "").trim();
181
+ if (!t) return "";
182
+ const r = t.split("?")[0].split("#")[0], n = r.includes("/") ? r.slice(r.lastIndexOf("/") + 1) : r, i = n.lastIndexOf(".");
183
+ return i < 0 || i === n.length - 1 ? "" : n.slice(i + 1).toLowerCase();
184
+ }
185
+ function X(e = {}) {
186
+ const t = String(e.fileType || "").trim().toLowerCase();
187
+ if (t === "image" || t === "video" || t === "pdf" || t === "word" || t === "excel" || t === "unsupported")
188
+ return t;
189
+ const r = h(e.name) || h(e.src);
190
+ return Ie.includes(r) ? "image" : ke.includes(r) ? "video" : Re.includes(r) ? "pdf" : Ye.includes(r) ? "word" : Fe.includes(r) ? "excel" : "unsupported";
191
+ }
192
+ function q(e = "", t = "") {
193
+ const r = h(t) || h(e);
194
+ return {
195
+ mp4: "video/mp4",
196
+ m4v: "video/mp4",
197
+ webm: "video/webm",
198
+ ogg: "video/ogg",
199
+ mov: "video/mp4"
200
+ // 多数 .mov 为 H.264,按 mp4 更易被 Chrome 等播放
201
+ }[r] || "video/mp4";
202
+ }
203
+ function W(e = "", t = "") {
204
+ const r = String(e || "").trim();
205
+ return r ? (h(t) || h(e)) === "mov" ? [
206
+ { src: r, type: "video/mp4" },
207
+ { src: r, type: "video/quicktime" }
208
+ ] : [{ src: r, type: q(e, t) }] : [];
209
+ }
210
+ const Q = "/hide/mg-file-preview";
211
+ function J(e = {}) {
212
+ const t = String(e.src || "").trim();
213
+ if (!t) return "";
214
+ const r = new URLSearchParams();
215
+ r.set("src", t);
216
+ const n = String(e.name || "").trim(), i = String(e.fileType || "").trim(), o = String(e.title || "").trim();
217
+ n && r.set("name", n), i && r.set("fileType", i), o && r.set("title", o);
218
+ const c = `#${Q}?${r.toString()}`;
219
+ if (typeof window > "u") return c;
220
+ const { origin: u, pathname: d, search: f } = window.location;
221
+ return `${u}${d}${f}${c}`;
222
+ }
223
+ function je(e = {}, t = "_blank") {
224
+ const r = J(e);
225
+ return !r || typeof window > "u" ? null : window.open(r, t);
226
+ }
227
+ function Z(e) {
228
+ const t = String(e || "").trim().toUpperCase();
229
+ if (/^\d{15}$/.test(t)) {
230
+ const f = +`19${t.slice(6, 8)}`, a = Number(t.slice(8, 10)), l = Number(t.slice(10, 12)), p = new Date(f, a - 1, l);
231
+ return p.getFullYear() === f && p.getMonth() + 1 === a && p.getDate() === l;
232
+ }
233
+ if (!/^\d{17}[\dX]$/.test(t)) return !1;
234
+ const r = Number(t.slice(6, 10)), n = Number(t.slice(10, 12)), i = Number(t.slice(12, 14)), o = new Date(r, n - 1, i);
235
+ if (o.getFullYear() !== r || o.getMonth() + 1 !== n || o.getDate() !== i) return !1;
236
+ const c = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], u = "10X98765432";
237
+ let d = 0;
238
+ for (let f = 0; f < 17; f++) d += Number(t[f]) * c[f];
239
+ return u[d % 11] === t[17];
240
+ }
241
+ function ee(e) {
242
+ const t = String(e || "").trim().replace(/\s+/g, "");
243
+ return t ? /^1\d{10}$/.test(t) || /^\+[1-9]\d{6,14}$/.test(t) : !1;
244
+ }
245
+ function te(e) {
246
+ const t = String(e || "").trim();
247
+ return t ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t) : !1;
248
+ }
249
+ function R(e) {
250
+ return e == null || e === "";
251
+ }
252
+ function Ue(e, t, r) {
253
+ if (R(t)) {
254
+ r();
255
+ return;
256
+ }
257
+ if (!Z(t)) {
258
+ r(new Error("请输入正确的身份证号(15/18位)"));
259
+ return;
260
+ }
261
+ r();
262
+ }
263
+ function Le(e, t, r) {
264
+ if (R(t)) {
265
+ r();
266
+ return;
267
+ }
268
+ if (!ee(t)) {
269
+ r(new Error("请输入正确的国内或海外手机号"));
270
+ return;
271
+ }
272
+ r();
273
+ }
274
+ function Ge(e, t, r) {
275
+ if (R(t)) {
276
+ r();
277
+ return;
278
+ }
279
+ if (!te(t)) {
280
+ r(new Error("请输入正确的邮箱"));
281
+ return;
282
+ }
283
+ r();
284
+ }
285
+ function He(e) {
286
+ return !!(e == null || typeof e == "string" && e.trim() === "" || Array.isArray(e) && e.length === 0 || typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0);
287
+ }
288
+ function C(e) {
289
+ if (e === null || typeof e != "object") return e;
290
+ if (e instanceof Date) return new Date(e.getTime());
291
+ if (Array.isArray(e)) return e.map((r) => C(r));
292
+ const t = {};
293
+ return Object.keys(e).forEach((r) => {
294
+ t[r] = C(e[r]);
295
+ }), t;
296
+ }
297
+ function Be(e, t = 300) {
298
+ let r = null;
299
+ return function(...i) {
300
+ r && clearTimeout(r), r = setTimeout(() => {
301
+ e.apply(this, i);
302
+ }, t);
303
+ };
304
+ }
305
+ function Ke(e, t = 300) {
306
+ let r = 0;
307
+ return function(...i) {
308
+ const o = Date.now();
309
+ o - r >= t && (r = o, e.apply(this, i));
310
+ };
311
+ }
312
+ function re(e) {
313
+ if (e == null || e === "") return null;
314
+ if (e instanceof Date)
315
+ return Number.isNaN(e.getTime()) ? null : e;
316
+ if (typeof e == "number") {
317
+ const i = new Date(e);
318
+ return Number.isNaN(i.getTime()) ? null : i;
319
+ }
320
+ const t = String(e).trim();
321
+ if (!t) return null;
322
+ if (/^\d{10,13}$/.test(t)) {
323
+ const i = t.length === 10 ? Number(t) * 1e3 : Number(t), o = new Date(i);
324
+ return Number.isNaN(o.getTime()) ? null : o;
325
+ }
326
+ if (/[Zz]$|[+-]\d{2}:?\d{2}$/.test(t)) {
327
+ const i = new Date(t);
328
+ return Number.isNaN(i.getTime()) ? null : i;
329
+ }
330
+ const r = t.match(
331
+ /^(\d{4})[-/.年](\d{1,2})[-/.月](\d{1,2})日?(?:[\sT]+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?(?:\.(\d{1,3}))?)?/
332
+ );
333
+ if (r) {
334
+ const [, i, o, c, u = "0", d = "0", f = "0", a = "0"] = r, l = new Date(
335
+ Number(i),
336
+ Number(o) - 1,
337
+ Number(c),
338
+ Number(u),
339
+ Number(d),
340
+ Number(f),
341
+ Number(String(a).padEnd(3, "0"))
342
+ );
343
+ return Number.isNaN(l.getTime()) ? null : l;
344
+ }
345
+ const n = new Date(t);
346
+ return Number.isNaN(n.getTime()) ? null : n;
347
+ }
348
+ function I(e, t = "YYYY-MM-DD HH:mm:ss") {
349
+ const r = re(e);
350
+ if (!r) return "";
351
+ const n = r.getFullYear(), i = r.getMonth() + 1, o = r.getDate(), c = r.getHours(), u = r.getMinutes(), d = r.getSeconds(), f = {
352
+ YYYY: String(n),
353
+ MM: String(i).padStart(2, "0"),
354
+ DD: String(o).padStart(2, "0"),
355
+ HH: String(c).padStart(2, "0"),
356
+ mm: String(u).padStart(2, "0"),
357
+ ss: String(d).padStart(2, "0"),
358
+ M: String(i),
359
+ D: String(o),
360
+ H: String(c),
361
+ m: String(u),
362
+ s: String(d)
363
+ };
364
+ return t.replace(/YYYY|MM|DD|HH|mm|ss|M|D|H|m|s/g, (a) => f[a]);
365
+ }
366
+ function Ve() {
367
+ const e = /* @__PURE__ */ new Date();
368
+ e.setHours(23, 59, 59, 0);
369
+ const t = /* @__PURE__ */ new Date();
370
+ return t.setDate(t.getDate() - 30), t.setHours(0, 0, 0, 0), {
371
+ start: I(t, "YYYY-MM-DD HH:mm:ss"),
372
+ end: I(e, "YYYY-MM-DD HH:mm:ss")
373
+ };
374
+ }
375
+ function v(e) {
376
+ const t = {};
377
+ return Object.keys(e || {}).forEach((r) => {
378
+ const n = e[r];
379
+ n == null || n === "" || Array.isArray(n) && n.length === 0 || (t[r] = n);
380
+ }), t;
381
+ }
382
+ function ze(e) {
383
+ return e == null || e === "" ? "-" : e;
384
+ }
385
+ function Y(e, t = 2) {
386
+ if (!Number.isFinite(e)) return e;
387
+ const r = Math.max(0, Math.floor(Number(t) || 0));
388
+ return +(Math.round(+`${e}e${r}`) + `e-${r}`);
389
+ }
390
+ function k(e, t = 2) {
391
+ if (e == null || e === "") return "-";
392
+ const r = Number(e);
393
+ if (Number.isNaN(r)) return e;
394
+ const n = Y(r, t).toFixed(t), [i, o] = n.split("."), c = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
395
+ if (o == null) return c;
396
+ const u = o.replace(/0+$/, "");
397
+ return u ? `${c}.${u}` : c;
398
+ }
399
+ function Xe(e) {
400
+ if (e == null || e === "") return "-";
401
+ const t = Number(e);
402
+ return Number.isNaN(t) ? "-" : Math.abs(t) > 1e4 ? `${k(t / 1e4, 2)}w` : String(k(t, 0));
403
+ }
404
+ function qe(e, t = 4, r = "toDecimal") {
405
+ if (r === "toPercent" || r === "toPercentText") {
406
+ if (e == null || e === "") return r === "toPercentText" ? "-" : e;
407
+ const i = Number(e);
408
+ if (!Number.isFinite(i) || Number.isNaN(i)) return r === "toPercentText" ? "-" : e;
409
+ if (i === 0) return r === "toPercentText" ? "0%" : 0;
410
+ const o = Number(String(Number((i * 100).toFixed(2))).replace(/(?:\.0*|(\.\d+?)0+)$/, "$1"));
411
+ return r === "toPercentText" ? `${o}%` : o;
412
+ }
413
+ if (e === "" || e == null) return;
414
+ const n = Number(e);
415
+ if (Number.isFinite(n))
416
+ return Number((n / 100).toFixed(t));
417
+ }
418
+ function We(e) {
419
+ if (e === "" || e == null) return "";
420
+ const t = Number(e);
421
+ return Number.isFinite(t) ? t : "";
422
+ }
423
+ function Qe(e, t = 2, r = 9999999999999) {
424
+ if (e === 0 || e === "0") return 0;
425
+ if (e == null || e === "") return "";
426
+ let n = Number(e);
427
+ if (!Number.isFinite(n)) return "";
428
+ const i = Number(r), o = Number.isFinite(i) ? Math.abs(i) : 9999999999999;
429
+ return Math.abs(n) >= o && (n = n < 0 ? -o : o), Number.isInteger(n) ? n : Y(n, t);
430
+ }
431
+ function Je(e = "id") {
432
+ return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
433
+ }
434
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
435
+ __proto__: null,
436
+ FILE_PREVIEW_ROUTE_PATH: Q,
437
+ buildFilePreviewHref: J,
438
+ cleanNumber: Qe,
439
+ cleanParams: v,
440
+ clearPlatformCache: $e,
441
+ debounce: Be,
442
+ deepClone: C,
443
+ downloadBlob: V,
444
+ exportFile: Pe,
445
+ findPlatformLogo: Oe,
446
+ formatDate: I,
447
+ formatEmpty: ze,
448
+ formatFansCount: Xe,
449
+ formatNum: k,
450
+ getFileExtension: h,
451
+ getRecentMonthRange: Ve,
452
+ isEmail: te,
453
+ isEmpty: He,
454
+ isMainlandIdCard: Z,
455
+ isMobile: ee,
456
+ openFilePreview: je,
457
+ parseDate: re,
458
+ preloadPlatformList: Ce,
459
+ resolveFilePreviewType: X,
460
+ resolveVideoMimeType: q,
461
+ resolveVideoSources: W,
462
+ roundHalfUp: Y,
463
+ setPlatformCache: z,
464
+ throttle: Ke,
465
+ toNumberOrEmpty: We,
466
+ toRebateRatio: qe,
467
+ uniqueId: Je,
468
+ validateEmail: Ge,
469
+ validateIdCardNo: Ue,
470
+ validateMobile: Le
471
+ }, Symbol.toStringTag, { value: "Module" }));
472
+ function vt(e) {
473
+ if (!e)
474
+ throw new Error("[mgacn-commonsdk] createApi 需要传入 request 实例");
475
+ return {
476
+ // ---------- 注销登录 ----------
477
+ logout(t) {
478
+ return e.GET(`/yhAdmin/login/exit/${t}`);
479
+ },
480
+ // ---------- 用户 ----------
481
+ getUserInfo(t) {
482
+ return e.GET(`/yhAdmin/user/queryUser/${t}`);
483
+ },
484
+ /**
485
+ * 用户下拉选择列表
486
+ * POST /yhAdmin/user/listForSelect
487
+ * @param {object} [params]
488
+ * @param {0|1} [params.status] 0 正常/有效,1 禁用/锁定;不传查全部
489
+ * @param {0|1} [params.isDelete] 0 否,1 是;不传默认查未删除
490
+ * @param {string} [params.realName] 真实姓名,模糊
491
+ * @param {string} [params.username] 登录账号/工号,模糊
492
+ * @param {string} [params.mobile] 手机号,模糊
493
+ * @param {string} [params.openId] 第三方 openId,模糊
494
+ * @param {string} [params.createTimeStart]
495
+ * @param {string} [params.createTimeEnd]
496
+ * @param {string} [params.updateTimeStart]
497
+ * @param {string} [params.updateTimeEnd]
498
+ * @returns {Promise<Array>} 用户列表(兼容 result / list / 直接数组)
499
+ */
500
+ async listUserForSelect(t = {}) {
501
+ const r = await e.POST("/yhAdmin/user/listForSelect", v(t));
502
+ return Array.isArray(r) ? r : Array.isArray(r == null ? void 0 : r.result) ? r.result : Array.isArray(r == null ? void 0 : r.list) ? r.list : [];
503
+ },
504
+ /**
505
+ * 按角色名称查询用户列表(下拉)
506
+ * POST /yhAdmin/user/queryUserByRoleName
507
+ * systemId 由组件库自动填充,宿主勿传
508
+ * @param {object} params
509
+ * @param {string} params.roleName 角色名称
510
+ */
511
+ async queryByRoleName(t = {}) {
512
+ const { systemId: r, ...n } = t && typeof t == "object" ? t : {}, i = await e.POST(
513
+ "/yhAdmin/user/queryUserByRoleName",
514
+ v({
515
+ ...n,
516
+ systemId: O()
517
+ })
518
+ );
519
+ return Array.isArray(i) ? i : Array.isArray(i == null ? void 0 : i.result) ? i.result : Array.isArray(i == null ? void 0 : i.list) ? i.list : [];
520
+ },
521
+ /**
522
+ * 查询部门树
523
+ * POST /yhAdmin/dept/queryDeptTree
524
+ * @param {object} [params]
525
+ * @param {string} [params.deptName] 部门名称
526
+ * @param {string[]} [params.deptIds] 部门 IDS
527
+ * @param {boolean} [params.queryUser] 是否查询用户
528
+ * @returns {Promise<Array>} 部门树(兼容 result / list / 直接数组)
529
+ */
530
+ async queryDeptTree(t = {}) {
531
+ const r = await e.POST("/yhAdmin/dept/queryDeptTree", v(t));
532
+ return Array.isArray(r) ? r : [];
533
+ },
534
+ /**
535
+ * 飞书关联审批分页(待办 / 已办 / 抄送我 / 已发起)
536
+ * POST /yhShared/feishuApproval/pageRelated
537
+ * @param {object} params
538
+ * @param {'todo'|'done'|'cc'|'initiated'} params.tab
539
+ * @param {string} params.unionId 飞书 union_id
540
+ * @param {string} [params.approvalCode] 审批定义 Code,空表示全部
541
+ * @param {string} [params.status] PENDING / APPROVED / REJECTED / CANCELED,空表示全部
542
+ * @param {string} [params.keyword] 审批名称、实例 Code
543
+ * @param {number} [params.page] 页码,从 0 开始
544
+ * @param {number} [params.limit] 每页条数
545
+ * @returns {Promise<{result: Array, totalCount: number, pageCount: number}>}
546
+ */
547
+ pageRelated(t = {}) {
548
+ return e.POST("/yhShared/feishuApproval/pageRelated", v(t));
549
+ },
550
+ /**
551
+ * 关联审批的审批类型
552
+ * GET /yhShared/feishuApproval/definitions
553
+ * @returns {Promise<Array<{approvalCode: string, approvalName: string}>>}
554
+ */
555
+ async listApprovalDefinitions() {
556
+ const t = await e.GET("/yhShared/feishuApproval/definitions");
557
+ return Array.isArray(t) ? t : Array.isArray(t == null ? void 0 : t.result) ? t.result : Array.isArray(t == null ? void 0 : t.list) ? t.list : [];
558
+ },
559
+ /**
560
+ * 媒介供应商全量列表(下拉)
561
+ * GET /yhAccount/mediaSupplier/listAll
562
+ */
563
+ listMediaSupplierAll() {
564
+ return e.GET("/yhAccount/mediaSupplier/listAll");
565
+ },
566
+ /**
567
+ * 账号库平台配置全量列表(下拉)
568
+ * GET /yhAccount/platformInfo/listAll
569
+ */
570
+ listPlatformInfoAll() {
571
+ return e.GET("/yhAccount/platformInfo/listAll");
572
+ },
573
+ /**
574
+ * 标签配置全量列表
575
+ * GET /yhShared/tagConfig/queryAllTagConfigs
576
+ * @param {object} [params]
577
+ * @param {string} [params.businessKey]
578
+ */
579
+ queryAllTagConfigs(t = {}) {
580
+ return e.GET("/yhShared/tagConfig/queryAllTagConfigs", {
581
+ params: v(t)
582
+ });
583
+ },
584
+ /**
585
+ * 写入埋点数据
586
+ * POST /yhAdmin/trace/addTraceData
587
+ * userId / projectId(系统 id) / clientType 由组件库自动填充,宿主勿传
588
+ * @param {object} params 宿主业务参数
589
+ * @param {string} params.traceId 事件 ID
590
+ * @param {string} [params.route] 页面路由
591
+ * @param {string} [params.wxUserId] 微信用户 ID
592
+ */
593
+ addTraceData(t = {}) {
594
+ const { userId: r, projectId: n, clientType: i, ...o } = t && typeof t == "object" ? t : {};
595
+ return e.POST(
596
+ "/yhAdmin/trace/addTraceData",
597
+ v({
598
+ ...o,
599
+ userId: Te(),
600
+ projectId: O(),
601
+ clientType: 1
602
+ })
603
+ );
604
+ },
605
+ // ---------- OSS ----------
606
+ getOssSts(t) {
607
+ return e.GET("/yhAdmin/oss/getStsToken", { params: { dir: t } });
608
+ }
609
+ };
610
+ }
611
+ const ne = "__MGACN_COMMONSDK_API__";
612
+ function Nt(e) {
613
+ globalThis[ne] = e;
614
+ }
615
+ function Ze() {
616
+ const e = globalThis[ne];
617
+ if (!e)
618
+ throw new Error("[mgacn-commonsdk] 请先 app.use(MgacnCommonSdk, { tokenKey, baseURL })");
619
+ return e;
620
+ }
621
+ const ie = "__MGACN_COMMONSDK_PERMISSION_GETTER__";
622
+ function Tt(e) {
623
+ globalThis[ie] = typeof e == "function" ? e : null;
624
+ }
625
+ function et() {
626
+ return globalThis[ie] || null;
627
+ }
628
+ function tt(e, t, r = "and") {
629
+ const n = (Array.isArray(t) ? t : [t]).map((o) => String(o ?? "").trim()).filter(Boolean);
630
+ if (!n.length) return !0;
631
+ const i = new Set((e || []).map(String));
632
+ return r === "or" ? n.some((o) => i.has(o)) : n.every((o) => i.has(o));
633
+ }
634
+ function Et(e, t = "and") {
635
+ const r = et();
636
+ return typeof r != "function" ? !0 : tt(r(), e, t);
637
+ }
638
+ const rt = (e, t) => {
639
+ const r = e.__vccOpts || e;
640
+ for (const [n, i] of t)
641
+ r[n] = i;
642
+ return r;
643
+ }, nt = {
644
+ key: 0,
645
+ class: "mg-file-preview__empty"
646
+ }, it = {
647
+ key: 1,
648
+ class: "mg-file-preview__fallback"
649
+ }, ot = {
650
+ key: 0,
651
+ class: "mg-file-preview__fallback-name"
652
+ }, st = {
653
+ key: 2,
654
+ class: "mg-file-preview__image"
655
+ }, ut = {
656
+ key: 3,
657
+ class: "mg-file-preview__video-wrap"
658
+ }, lt = {
659
+ key: 0,
660
+ class: "mg-file-preview__tip"
661
+ }, at = { class: "mg-file-preview__video" }, ct = {
662
+ key: 4,
663
+ class: "mg-file-preview__pdf"
664
+ }, ft = {
665
+ key: 5,
666
+ class: "mg-file-preview__word"
667
+ }, mt = /* @__PURE__ */ Object.assign({ name: "MgFilePreview" }, {
668
+ __name: "FilePreview",
669
+ props: {
670
+ /** 文件地址(URL / Blob URL) */
671
+ src: {
672
+ type: String,
673
+ default: ""
674
+ },
675
+ /** 文件名(用于识别类型;可不带路径) */
676
+ name: {
677
+ type: String,
678
+ default: ""
679
+ },
680
+ /**
681
+ * 强制指定类型:image | video | pdf | word | excel | unsupported
682
+ * 不传则根据 name / src 扩展名推断
683
+ */
684
+ fileType: {
685
+ type: String,
686
+ default: ""
687
+ },
688
+ /** 预览区高度,如 70vh / 600 */
689
+ height: {
690
+ type: [String, Number],
691
+ default: "70vh"
692
+ }
693
+ },
694
+ emits: ["ready", "error", "download"],
695
+ setup(e, { emit: t }) {
696
+ const r = e, n = t, i = j(null), o = j(!1);
697
+ let c = null;
698
+ const u = D(
699
+ () => X({
700
+ src: r.src,
701
+ name: r.name,
702
+ fileType: r.fileType
703
+ })
704
+ ), d = D(() => {
705
+ const s = String(r.name || "").trim();
706
+ if (s) return s;
707
+ const m = String(r.src || "").trim();
708
+ if (!m) return "";
709
+ const A = m.split("?")[0].split("#")[0];
710
+ return A.slice(A.lastIndexOf("/") + 1) || m;
711
+ }), f = D(() => u.value !== "video" ? !1 : (h(r.name) || h(r.src)) === "mov"), a = D(() => {
712
+ const s = r.height;
713
+ return s == null || s === "" ? {} : { height: typeof s == "number" ? `${s}px` : String(s) };
714
+ });
715
+ function l() {
716
+ if (c) {
717
+ try {
718
+ c.dispose();
719
+ } catch {
720
+ }
721
+ c = null;
722
+ }
723
+ }
724
+ async function p() {
725
+ l(), !(u.value !== "video" || !r.src) && (await we(), i.value && (c = he(i.value, {
726
+ controls: !0,
727
+ fill: !0,
728
+ fluid: !1,
729
+ preload: "metadata",
730
+ sources: W(r.src, r.name)
731
+ }), c.ready(() => n("ready", { type: "video" })), c.on("error", () => n("error", { type: "video", message: "视频加载失败" }))));
732
+ }
733
+ function _() {
734
+ o.value = !1, n("ready", { type: "pdf" });
735
+ }
736
+ function N(s) {
737
+ o.value = !1, n("error", { type: "pdf", message: (s == null ? void 0 : s.message) || "PDF 加载失败", error: s });
738
+ }
739
+ function y() {
740
+ n("ready", { type: u.value });
741
+ }
742
+ function F(s) {
743
+ n("error", {
744
+ type: u.value,
745
+ message: (s == null ? void 0 : s.message) || "文档预览失败",
746
+ error: s
747
+ });
748
+ }
749
+ function P() {
750
+ if (n("download", { src: r.src, name: d.value }), !r.src || typeof window > "u") return;
751
+ const s = document.createElement("a");
752
+ s.href = r.src, s.download = d.value || `file.${h(r.name || r.src) || "bin"}`, s.target = "_blank", s.rel = "noopener noreferrer", document.body.appendChild(s), s.click(), document.body.removeChild(s);
753
+ }
754
+ return le(
755
+ () => [r.src, u.value],
756
+ ([s, m]) => {
757
+ m === "pdf" && s ? o.value = !0 : o.value = !1, m === "video" && s ? p() : l(), m === "image" && s && n("ready", { type: "image" });
758
+ },
759
+ { immediate: !0 }
760
+ ), ae(() => {
761
+ l();
762
+ }), (s, m) => {
763
+ const A = U("el-button"), oe = U("el-image"), se = ce("loading");
764
+ return g(), w("div", {
765
+ class: me(["mg-file-preview", [`is-${u.value}`]]),
766
+ style: fe(a.value)
767
+ }, [
768
+ e.src ? u.value === "unsupported" ? (g(), w("div", it, [
769
+ m[1] || (m[1] = b("p", { class: "mg-file-preview__fallback-title" }, "暂不支持在线预览该格式", -1)),
770
+ d.value ? (g(), w("p", ot, de(d.value), 1)) : x("", !0),
771
+ M(A, {
772
+ type: "primary",
773
+ onClick: P
774
+ }, {
775
+ default: L(() => [...m[0] || (m[0] = [
776
+ pe("下载文件", -1)
777
+ ])]),
778
+ _: 1
779
+ })
780
+ ])) : u.value === "image" ? (g(), w("div", st, [
781
+ M(oe, {
782
+ src: e.src,
783
+ fit: "contain",
784
+ "preview-src-list": [e.src],
785
+ "preview-teleported": "",
786
+ "hide-on-click-modal": ""
787
+ }, {
788
+ error: L(() => [...m[2] || (m[2] = [
789
+ b("div", { class: "mg-file-preview__empty" }, "图片加载失败", -1)
790
+ ])]),
791
+ _: 1
792
+ }, 8, ["src", "preview-src-list"])
793
+ ])) : u.value === "video" ? (g(), w("div", ut, [
794
+ f.value ? (g(), w("div", lt, [
795
+ m[3] || (m[3] = b("span", null, " .mov 受浏览器解码能力限制(如 HEVC),若无法播放请 ", -1)),
796
+ b("button", {
797
+ type: "button",
798
+ class: "mg-file-preview__tip-link",
799
+ onClick: P
800
+ }, "下载原文件"),
801
+ m[4] || (m[4] = b("span", null, "查看。", -1))
802
+ ])) : x("", !0),
803
+ b("div", at, [
804
+ (g(), w("video", {
805
+ key: e.src,
806
+ ref_key: "videoEl",
807
+ ref: i,
808
+ class: "video-js vjs-big-play-centered mg-file-preview__video-el",
809
+ playsinline: ""
810
+ }))
811
+ ])
812
+ ])) : u.value === "pdf" ? ge((g(), w("div", ct, [
813
+ M($(be), {
814
+ source: e.src,
815
+ class: "mg-file-preview__pdf-embed",
816
+ onLoaded: _,
817
+ onLoadingFailed: N
818
+ }, null, 8, ["source"])
819
+ ])), [
820
+ [se, o.value]
821
+ ]) : u.value === "word" ? (g(), w("div", ft, [
822
+ b("div", { class: "mg-file-preview__tip" }, [
823
+ m[5] || (m[5] = b("span", null, " Word 在线预览对复杂排版(文本框、形状、绝对定位等)支持有限,可能出现内容缺失;如预览不完整请 ", -1)),
824
+ b("button", {
825
+ type: "button",
826
+ class: "mg-file-preview__tip-link",
827
+ onClick: P
828
+ }, "下载原文件"),
829
+ m[6] || (m[6] = b("span", null, "查看。", -1))
830
+ ]),
831
+ M($(Se), {
832
+ src: e.src,
833
+ class: "mg-file-preview__office",
834
+ onRendered: y,
835
+ onError: F
836
+ }, null, 8, ["src"])
837
+ ])) : u.value === "excel" ? (g(), ye($(_e), {
838
+ key: 6,
839
+ src: e.src,
840
+ class: "mg-file-preview__office",
841
+ onRendered: y,
842
+ onError: F
843
+ }, null, 8, ["src"])) : x("", !0) : (g(), w("div", nt, "暂无预览文件"))
844
+ ], 6);
845
+ };
846
+ }
847
+ }), At = /* @__PURE__ */ rt(mt, [["__scopeId", "data-v-2dc0862c"]]);
848
+ export {
849
+ At as F,
850
+ rt as _,
851
+ ve as a,
852
+ Ae as b,
853
+ tt as c,
854
+ h as d,
855
+ C as e,
856
+ v as f,
857
+ Ze as g,
858
+ Be as h,
859
+ Q as i,
860
+ J as j,
861
+ k,
862
+ ze as l,
863
+ Et as m,
864
+ Tt as n,
865
+ je as o,
866
+ ht as p,
867
+ vt as q,
868
+ St as r,
869
+ Ne as s,
870
+ qe as t,
871
+ Nt as u,
872
+ Ee as v,
873
+ et as w,
874
+ O as x,
875
+ Te as y,
876
+ _t as z
877
+ };