@das-fed/utils 6.4.0-dev.28 → 6.4.0-dev.29

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.
Binary file
@@ -1,150 +1,150 @@
1
- import { iotMinio as C, iotProgress as Q } from "@das-fed/utils/api-services/modules/iot";
2
- import { extractFilename as W } from "@das-fed/utils/common-tools";
1
+ import { iotMinio as I, iotProgress as Q } from "@das-fed/utils/api-services/modules/iot";
3
2
  import { ref as f } from "vue";
4
- import Z from "dayjs";
5
- import { getConfig as O } from "@das-fed/utils/config";
6
- let F = (e = 21) => {
3
+ import W from "dayjs";
4
+ import { getConfig as B } from "@das-fed/utils/config";
5
+ let Z = (e = 21) => {
7
6
  let o = "", i = crypto.getRandomValues(new Uint8Array(e));
8
7
  for (; e--; ) {
9
- let s = i[e] & 63;
10
- s < 36 ? o += s.toString(36) : s < 62 ? o += (s - 26).toString(36).toUpperCase() : s < 63 ? o += "_" : o += "-";
8
+ let t = i[e] & 63;
9
+ t < 36 ? o += t.toString(36) : t < 62 ? o += (t - 26).toString(36).toUpperCase() : t < 63 ? o += "_" : o += "-";
11
10
  }
12
11
  return o;
13
12
  };
14
- const ee = C.get("token"), te = C.post("put-object", (e) => (e.headers || (e.headers = {}), e.headers["Content-Type"] = "multipart/form-data", e.responseType = "blob", e)), se = C.post("upload-objects", (e) => (e.headers || (e.headers = {}), e.headers["Content-Type"] = "multipart/form-data", e.responseType = "blob", e)), ae = Q.get("progress"), me = () => {
15
- let e = f(!1), o = f(""), i = f(0), s = f("normal"), d = f(!1), p, w = f(""), g = f(""), y = f(""), h = f(""), T = f(!1), R = f(""), L = "", N;
16
- const H = () => {
17
- g.value = "", y.value = "", h.value = "", T.value = !1, R.value = "";
18
- }, q = async () => {
19
- const [a, r] = await ee().run();
20
- return a ? { stauts: !1 } : { status: !0, data: r };
21
- }, A = (a) => new Promise((r, l) => {
13
+ const F = I.get("token"), ee = I.post("put-object", (e) => (e.headers || (e.headers = {}), e.headers["Content-Type"] = "multipart/form-data", e.responseType = "blob", e)), te = I.post("upload-objects", (e) => (e.headers || (e.headers = {}), e.headers["Content-Type"] = "multipart/form-data", e.responseType = "blob", e)), se = Q.get("progress"), ce = () => {
14
+ let e = f(!1), o = f(""), i = f(0), t = f("normal"), g = f(!1), p, h = f(""), v = f(""), y = f(""), w = f(""), T = f(!1), P = f(""), L = "", U;
15
+ const q = () => {
16
+ v.value = "", y.value = "", w.value = "", T.value = !1, P.value = "";
17
+ }, Y = async () => {
18
+ const [s, r] = await F().run();
19
+ return s ? { stauts: !1 } : { status: !0, data: r };
20
+ }, K = (s) => new Promise((r, l) => {
22
21
  const u = [];
23
- let t = 0;
24
- for (; t < a.size; ) {
25
- const m = a.slice(t, t + 1048576);
26
- u.push(m), t += 1048576;
22
+ let a = 0;
23
+ for (; a < s.size; ) {
24
+ const m = s.slice(a, a + 1048576);
25
+ u.push(m), a += 1048576;
27
26
  }
28
- const v = new Blob(u, { type: a.type });
29
- r(v);
30
- }), Y = async (a, r, l, n = !0, u = "", t = !1) => {
31
- var z, E;
32
- L = u, n && (s.value = "normal", i.value = 0, o.value = "导入进度", e.value = !0, w.value = ""), N = r;
33
- const v = await q();
34
- if (!v.status) return;
35
- let m = v.data, c = null, { autoContentType: x, bucketName: j, importFileName: D } = l;
36
- const X = t ? se : te;
37
- if (t) {
27
+ const d = new Blob(u, { type: s.type });
28
+ r(d);
29
+ }), J = async (s, r, l, n = !0, u = "", a = !1) => {
30
+ var E, O;
31
+ L = u, n && (t.value = "normal", i.value = 0, o.value = "导入进度", e.value = !0, h.value = ""), U = r;
32
+ const d = await Y();
33
+ if (!d.status) return;
34
+ let m = d.data, c = null, { autoContentType: $, bucketName: x, importFileName: j } = l;
35
+ const N = a ? te : ee;
36
+ if (a) {
38
37
  let M = [];
39
- await r.forEach(async ($) => {
40
- let U = await A($);
41
- M.push(U);
42
- }), c = new FormData(), c.append("accessKeyId", m.accessKeyId), c.append("secretAccessKey", m.secretAccessKey), c.append("sessionToken", m.sessionToken), c.append("bucketName", j), r.forEach(($, U) => {
43
- c.append("file", M[U]);
44
- }), D.forEach(($) => {
45
- c.append("filePaths", $);
38
+ await r.forEach(async (R) => {
39
+ let A = await K(R);
40
+ M.push(A);
41
+ }), c = new FormData(), c.append("accessKeyId", m.accessKeyId), c.append("secretAccessKey", m.secretAccessKey), c.append("sessionToken", m.sessionToken), c.append("bucketName", x), r.forEach((R, A) => {
42
+ c.append("file", M[A]);
43
+ }), j.forEach((R) => {
44
+ c.append("filePaths", R);
46
45
  });
47
46
  } else {
48
- const M = await A(r);
47
+ const M = await K(r);
49
48
  c = {
50
49
  accessKeyId: m.accessKeyId,
51
50
  secretAccessKey: m.secretAccessKey,
52
51
  sessionToken: m.sessionToken,
53
52
  file: M,
54
- bucketName: j,
55
- filePath: D,
56
- autoContentType: x
53
+ bucketName: x,
54
+ filePath: j,
55
+ autoContentType: $
57
56
  };
58
57
  }
59
- const [_, G] = await X(c).run();
58
+ const [_, G] = await N(c).run();
60
59
  if (_) return e.value = !1;
61
- const b = await oe(G.data);
60
+ const b = await re(G.data);
62
61
  if ((b == null ? void 0 : b.statusCode) != 200) {
63
- e.value = !1, (z = window.DasMessage) == null || z.error({
62
+ e.value = !1, (E = window.DasMessage) == null || E.error({
64
63
  message: (b == null ? void 0 : b.errorMsg) || "上传失败",
65
64
  grouping: !0,
66
65
  repeatNum: 1
67
66
  });
68
67
  return;
69
68
  }
70
- const P = await (a == null ? void 0 : a(b));
69
+ const C = await (s == null ? void 0 : s(b));
71
70
  if (n) {
72
- if (!P.status) {
73
- e.value = !1, s.value = "error";
71
+ if (!C.status) {
72
+ e.value = !1, t.value = "error";
74
73
  return;
75
74
  }
76
- o.value = "导入进度", e.value = !0, k(P.taskId, "import", "");
75
+ o.value = "导入进度", e.value = !0, k(C.taskId, "import", "");
77
76
  } else {
78
- if (!P.status) return;
79
- s.value = "success", (E = window.DasMessage) == null || E.success({
77
+ if (!C.status) return;
78
+ t.value = "success", (O = window.DasMessage) == null || O.success({
80
79
  message: "导入成功",
81
80
  grouping: !0,
82
81
  repeatNum: 1
83
82
  });
84
83
  }
85
- }, J = async (a, r = "", l = "") => {
86
- s.value = "normal", i.value = 0, o.value = l || "导出进度", e.value = !0;
87
- const n = await (a == null ? void 0 : a());
84
+ }, V = async (s, r = "", l = "") => {
85
+ t.value = "normal", i.value = 0, o.value = l || "导出进度", e.value = !0;
86
+ const n = await (s == null ? void 0 : s());
88
87
  if (!n.status) {
89
- e.value = !1, s.value = "error";
88
+ e.value = !1, t.value = "error";
90
89
  return;
91
90
  }
92
91
  k(n.taskId, "action", "");
93
- }, V = async (a, r = "", l = "", n = !0) => {
94
- n && (s.value = "normal", i.value = 0, o.value = "导出进度", e.value = !0);
95
- const u = await (a == null ? void 0 : a());
92
+ }, X = async (s, r = "", l = "", n = !0) => {
93
+ n && (t.value = "normal", i.value = 0, o.value = "导出进度", e.value = !0);
94
+ const u = await (s == null ? void 0 : s());
96
95
  if (!u.status) {
97
- e.value = !1, s.value = "error";
96
+ e.value = !1, t.value = "error";
98
97
  return;
99
98
  }
100
- Z().format("YYYYMMDDHHmmss") + "", k(u.taskId, "export", r || "", l);
101
- }, k = async (a, r, l, n = "") => {
102
- d.value = !0, K(a, r, l, n), p = setTimeout(() => {
99
+ W().format("YYYYMMDDHHmmss") + "", k(u.taskId, "export", r || "", l);
100
+ }, k = async (s, r, l, n = "") => {
101
+ g.value = !0, D(s, r, l, n), p = setTimeout(() => {
103
102
  }, 50);
104
- }, I = () => {
103
+ }, S = () => {
105
104
  clearTimeout(p), p = null, e.value = !1;
106
- }, K = async (a, r = "export", l, n = "") => {
107
- var m, c;
108
- const [u, t] = await ae("", {
109
- url: `progress/${a}`
105
+ }, D = async (s, r = "export", l, n = "") => {
106
+ var m, c, $;
107
+ const [u, a] = await se("", {
108
+ url: `progress/${s}`
110
109
  }).run();
111
110
  if (u) {
112
- d.value = !1;
111
+ g.value = !1;
113
112
  return;
114
113
  }
115
- i.value = t.percentage;
116
- const v = r == "export" ? "导出" : "导入";
114
+ i.value = a.percentage;
115
+ const d = r == "export" ? "导出" : "导入";
117
116
  if (i.value == 100)
118
- if (w.value = t, d.value = !1, I(), r == "export")
119
- t.status == 1 ? (s.value = "success", B(`${O().baseURL}/oss${t.filePath}`, l, n), d.value = !1) : t.status == 2 && (h.value = t.message || `${v}失败`, (m = window.DasMessage) == null || m.error({
120
- message: t.message || `${v}失败`,
117
+ if (h.value = a, g.value = !1, S(), r == "export")
118
+ a.status == 1 ? (t.value = "success", H(`${B().baseURL}/oss${a.filePath}`, l, n), g.value = !1) : a.status == 2 && (w.value = a.message || `${d}失败`, (m = window.DasMessage) == null || m.error({
119
+ message: a.message || `${d}失败`,
121
120
  grouping: !0,
122
121
  repeatNum: 1
123
122
  }));
124
123
  else if (r == "import") {
125
- if (t.filePath) {
126
- s.value = "error", T.value = !0;
127
- let x = await W(`/oss/${t == null ? void 0 : t.filePath}`);
128
- const j = ((c = x == null ? void 0 : x.split("/")) == null ? void 0 : c.pop()) || "";
129
- g.value = L || j, y.value = N.sizeText, h.value = "部分数据校验不通过,请下载附件并修改,重新导入!", R.value = `${O().baseURL}/oss/${t == null ? void 0 : t.filePath}`;
124
+ if (a.filePath) {
125
+ t.value = "error";
126
+ const x = (c = U.name) == null ? void 0 : c.match(/(.*?)(\.[^.]*$|$)/), j = x.length ? x[2] : "";
127
+ T.value = !0;
128
+ const N = ($ = a.filePath) == null ? void 0 : $.replace(/(.*\/)*([^.]+).*/gi, "$2");
129
+ v.value = L || `${N}${j}`, y.value = U.sizeText, w.value = "部分数据校验不通过,请下载附件并修改,重新导入!", P.value = `${B().baseURL}/oss${a.filePath}`;
130
130
  }
131
- S(t.status, v, t.message);
132
- } else r == "action" && (s.value = "success");
131
+ z(a.status, d, a.message);
132
+ } else r == "action" && (t.value = "success");
133
133
  else
134
- p && t.status != 2 ? p = setTimeout(() => {
135
- K(a, r, l, n);
136
- }, 50) : (w.value = t, d.value = !1, S(t.status, v, t.message), I(), T.value = !0, h.value = (t == null ? void 0 : t.message) || "");
137
- }, S = (a, r, l) => {
138
- var n, u, t;
139
- a == 1 ? (s.value = "success", (n = window.DasMessage) == null || n.success({
134
+ p && a.status != 2 ? p = setTimeout(() => {
135
+ D(s, r, l, n);
136
+ }, 50) : (h.value = a, g.value = !1, z(a.status, d, a.message), S(), T.value = !0, w.value = (a == null ? void 0 : a.message) || "");
137
+ }, z = (s, r, l) => {
138
+ var n, u, a;
139
+ s == 1 ? (t.value = "success", (n = window.DasMessage) == null || n.success({
140
140
  message: `${r}成功`,
141
141
  grouping: !0,
142
142
  repeatNum: 1
143
- }), g.value = "", y.value = "", h.value = "") : a == 2 ? (s.value = "error", (u = window.DasMessage) == null || u.error({
143
+ }), v.value = "", y.value = "", w.value = "") : s == 2 ? (t.value = "error", (u = window.DasMessage) == null || u.error({
144
144
  message: l || `${r}失败`,
145
145
  grouping: !0,
146
146
  repeatNum: 1
147
- }), h.value = l || "部分数据校验不通过,请下载附件并修改,重新导入!") : a == 3 && (s.value = "error", (t = window.DasMessage) == null || t.error({
147
+ }), w.value = l || "部分数据校验不通过,请下载附件并修改,重新导入!") : s == 3 && (t.value = "error", (a = window.DasMessage) == null || a.error({
148
148
  message: `部分${r}失败`,
149
149
  grouping: !0,
150
150
  repeatNum: 1
@@ -154,26 +154,26 @@ const ee = C.get("token"), te = C.post("put-object", (e) => (e.headers || (e.hea
154
154
  showProgressDialog: e,
155
155
  progressTitle: o,
156
156
  percent: i,
157
- progressStatus: s,
158
- progressLoading: d,
159
- progressResult: w,
160
- errorFileName: g,
157
+ progressStatus: t,
158
+ progressLoading: g,
159
+ progressResult: h,
160
+ errorFileName: v,
161
161
  errorFileSize: y,
162
- errorMessage: h,
162
+ errorMessage: w,
163
163
  errorImport: T,
164
- errorFilePath: R,
165
- fileImport: Y,
166
- fileExport: V,
167
- fileAction: J,
168
- generateUniqueName: (a) => {
169
- const r = a == null ? void 0 : a.match(/(.*?)(\.[^.]*$|$)/), l = r.length ? r[2] : "";
170
- return `${r.length ? r[1] : a}${F()}${l}`;
164
+ errorFilePath: P,
165
+ fileImport: J,
166
+ fileExport: X,
167
+ fileAction: V,
168
+ generateUniqueName: (s) => {
169
+ const r = s == null ? void 0 : s.match(/(.*?)(\.[^.]*$|$)/), l = r.length ? r[2] : "";
170
+ return `${r.length ? r[1] : s}${Z()}${l}`;
171
171
  },
172
- downloadFile: B,
173
- resetStataus: H,
172
+ downloadFile: H,
173
+ resetStataus: q,
174
174
  checkProgress: k
175
175
  };
176
- }, re = (e) => {
176
+ }, ae = (e) => {
177
177
  let o = e == null ? void 0 : e.toLocaleLowerCase();
178
178
  return {
179
179
  excel: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -202,27 +202,27 @@ const ee = C.get("token"), te = C.post("put-object", (e) => (e.headers || (e.hea
202
202
  der: "application/x-x509-ca-cert",
203
203
  cer: "application/pkix-cert"
204
204
  }[o];
205
- }, B = (e, o, i = "excel") => {
206
- const s = new XMLHttpRequest();
207
- s.open("get", e), s.setRequestHeader("Content-Type", "application/json; charset=UTF-8"), s.responseType = "blob", s.onload = function(d) {
205
+ }, H = (e, o, i = "excel") => {
206
+ const t = new XMLHttpRequest();
207
+ t.open("get", e), t.setRequestHeader("Content-Type", "application/json; charset=UTF-8"), t.responseType = "blob", t.onload = function(g) {
208
208
  const p = new Blob([this.response], {
209
- type: re(i)
210
- }), w = URL.createObjectURL(p);
209
+ type: ae(i)
210
+ }), h = URL.createObjectURL(p);
211
211
  if (window.navigator.msSaveOrOpenBlob)
212
212
  navigator.msSaveBlob(p, o);
213
213
  else {
214
- const g = document.createElement("a");
215
- g.href = w, g.download = o, g.click(), window.URL.revokeObjectURL(w);
214
+ const v = document.createElement("a");
215
+ v.href = h, v.download = o, v.click(), window.URL.revokeObjectURL(h);
216
216
  }
217
- }, s.send();
218
- }, oe = (e) => new Promise((o, i) => {
219
- var s = new FileReader();
220
- s.onload = function(d) {
217
+ }, t.send();
218
+ }, re = (e) => new Promise((o, i) => {
219
+ var t = new FileReader();
220
+ t.onload = function(g) {
221
221
  let p = "";
222
- typeof s.result == "string" && (p = JSON.parse(s.result)), o(p);
223
- }, s.readAsText(e);
222
+ typeof t.result == "string" && (p = JSON.parse(t.result)), o(p);
223
+ }, t.readAsText(e);
224
224
  });
225
225
  export {
226
- B as downloadFile,
227
- me as useFile
226
+ H as downloadFile,
227
+ ce as useFile
228
228
  };