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

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 I, iotProgress as Q } from "@das-fed/utils/api-services/modules/iot";
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";
2
3
  import { ref as f } from "vue";
3
- import W from "dayjs";
4
- import { getConfig as B } from "@das-fed/utils/config";
5
- let Z = (e = 21) => {
4
+ import Z from "dayjs";
5
+ import { getConfig as O } from "@das-fed/utils/config";
6
+ let F = (e = 21) => {
6
7
  let o = "", i = crypto.getRandomValues(new Uint8Array(e));
7
8
  for (; e--; ) {
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 += "-";
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 += "-";
10
11
  }
11
12
  return o;
12
13
  };
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) => {
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) => {
21
22
  const u = [];
22
- let a = 0;
23
- for (; a < s.size; ) {
24
- const m = s.slice(a, a + 1048576);
25
- u.push(m), a += 1048576;
23
+ let t = 0;
24
+ for (; t < a.size; ) {
25
+ const m = a.slice(t, t + 1048576);
26
+ u.push(m), t += 1048576;
26
27
  }
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) {
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) {
37
38
  let M = [];
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);
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", $);
45
46
  });
46
47
  } else {
47
- const M = await K(r);
48
+ const M = await A(r);
48
49
  c = {
49
50
  accessKeyId: m.accessKeyId,
50
51
  secretAccessKey: m.secretAccessKey,
51
52
  sessionToken: m.sessionToken,
52
53
  file: M,
53
- bucketName: x,
54
- filePath: j,
55
- autoContentType: $
54
+ bucketName: j,
55
+ filePath: D,
56
+ autoContentType: x
56
57
  };
57
58
  }
58
- const [_, G] = await N(c).run();
59
+ const [_, G] = await X(c).run();
59
60
  if (_) return e.value = !1;
60
- const b = await re(G.data);
61
+ const b = await oe(G.data);
61
62
  if ((b == null ? void 0 : b.statusCode) != 200) {
62
- e.value = !1, (E = window.DasMessage) == null || E.error({
63
+ e.value = !1, (z = window.DasMessage) == null || z.error({
63
64
  message: (b == null ? void 0 : b.errorMsg) || "上传失败",
64
65
  grouping: !0,
65
66
  repeatNum: 1
66
67
  });
67
68
  return;
68
69
  }
69
- const C = await (s == null ? void 0 : s(b));
70
+ const P = await (a == null ? void 0 : a(b));
70
71
  if (n) {
71
- if (!C.status) {
72
- e.value = !1, t.value = "error";
72
+ if (!P.status) {
73
+ e.value = !1, s.value = "error";
73
74
  return;
74
75
  }
75
- o.value = "导入进度", e.value = !0, k(C.taskId, "import", "");
76
+ o.value = "导入进度", e.value = !0, k(P.taskId, "import", "");
76
77
  } else {
77
- if (!C.status) return;
78
- t.value = "success", (O = window.DasMessage) == null || O.success({
78
+ if (!P.status) return;
79
+ s.value = "success", (E = window.DasMessage) == null || E.success({
79
80
  message: "导入成功",
80
81
  grouping: !0,
81
82
  repeatNum: 1
82
83
  });
83
84
  }
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());
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());
87
88
  if (!n.status) {
88
- e.value = !1, t.value = "error";
89
+ e.value = !1, s.value = "error";
89
90
  return;
90
91
  }
91
92
  k(n.taskId, "action", "");
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());
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());
95
96
  if (!u.status) {
96
- e.value = !1, t.value = "error";
97
+ e.value = !1, s.value = "error";
97
98
  return;
98
99
  }
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(() => {
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(() => {
102
103
  }, 50);
103
- }, S = () => {
104
+ }, I = () => {
104
105
  clearTimeout(p), p = null, e.value = !1;
105
- }, D = async (s, r = "export", l, n = "") => {
106
- var m, c, $;
107
- const [u, a] = await se("", {
108
- url: `progress/${s}`
106
+ }, K = async (a, r = "export", l, n = "") => {
107
+ var m, c;
108
+ const [u, t] = await ae("", {
109
+ url: `progress/${a}`
109
110
  }).run();
110
111
  if (u) {
111
- g.value = !1;
112
+ d.value = !1;
112
113
  return;
113
114
  }
114
- i.value = a.percentage;
115
- const d = r == "export" ? "导出" : "导入";
115
+ i.value = t.percentage;
116
+ const v = r == "export" ? "导出" : "导入";
116
117
  if (i.value == 100)
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}失败`,
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}失败`,
120
121
  grouping: !0,
121
122
  repeatNum: 1
122
123
  }));
123
124
  else if (r == "import") {
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}`;
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}`;
130
130
  }
131
- z(a.status, d, a.message);
132
- } else r == "action" && (t.value = "success");
131
+ S(t.status, v, t.message);
132
+ } else r == "action" && (s.value = "success");
133
133
  else
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({
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({
140
140
  message: `${r}成功`,
141
141
  grouping: !0,
142
142
  repeatNum: 1
143
- }), v.value = "", y.value = "", w.value = "") : s == 2 ? (t.value = "error", (u = window.DasMessage) == null || u.error({
143
+ }), g.value = "", y.value = "", h.value = "") : a == 2 ? (s.value = "error", (u = window.DasMessage) == null || u.error({
144
144
  message: l || `${r}失败`,
145
145
  grouping: !0,
146
146
  repeatNum: 1
147
- }), w.value = l || "部分数据校验不通过,请下载附件并修改,重新导入!") : s == 3 && (t.value = "error", (a = window.DasMessage) == null || a.error({
147
+ }), h.value = l || "部分数据校验不通过,请下载附件并修改,重新导入!") : a == 3 && (s.value = "error", (t = window.DasMessage) == null || t.error({
148
148
  message: `部分${r}失败`,
149
149
  grouping: !0,
150
150
  repeatNum: 1
@@ -154,26 +154,26 @@ const F = I.get("token"), ee = I.post("put-object", (e) => (e.headers || (e.head
154
154
  showProgressDialog: e,
155
155
  progressTitle: o,
156
156
  percent: i,
157
- progressStatus: t,
158
- progressLoading: g,
159
- progressResult: h,
160
- errorFileName: v,
157
+ progressStatus: s,
158
+ progressLoading: d,
159
+ progressResult: w,
160
+ errorFileName: g,
161
161
  errorFileSize: y,
162
- errorMessage: w,
162
+ errorMessage: h,
163
163
  errorImport: T,
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}`;
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}`;
171
171
  },
172
- downloadFile: H,
173
- resetStataus: q,
172
+ downloadFile: B,
173
+ resetStataus: H,
174
174
  checkProgress: k
175
175
  };
176
- }, ae = (e) => {
176
+ }, re = (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 F = I.get("token"), ee = I.post("put-object", (e) => (e.headers || (e.head
202
202
  der: "application/x-x509-ca-cert",
203
203
  cer: "application/pkix-cert"
204
204
  }[o];
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) {
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) {
208
208
  const p = new Blob([this.response], {
209
- type: ae(i)
210
- }), h = URL.createObjectURL(p);
209
+ type: re(i)
210
+ }), w = URL.createObjectURL(p);
211
211
  if (window.navigator.msSaveOrOpenBlob)
212
212
  navigator.msSaveBlob(p, o);
213
213
  else {
214
- const v = document.createElement("a");
215
- v.href = h, v.download = o, v.click(), window.URL.revokeObjectURL(h);
214
+ const g = document.createElement("a");
215
+ g.href = w, g.download = o, g.click(), window.URL.revokeObjectURL(w);
216
216
  }
217
- }, t.send();
218
- }, re = (e) => new Promise((o, i) => {
219
- var t = new FileReader();
220
- t.onload = function(g) {
217
+ }, s.send();
218
+ }, oe = (e) => new Promise((o, i) => {
219
+ var s = new FileReader();
220
+ s.onload = function(d) {
221
221
  let p = "";
222
- typeof t.result == "string" && (p = JSON.parse(t.result)), o(p);
223
- }, t.readAsText(e);
222
+ typeof s.result == "string" && (p = JSON.parse(s.result)), o(p);
223
+ }, s.readAsText(e);
224
224
  });
225
225
  export {
226
- H as downloadFile,
227
- ce as useFile
226
+ B as downloadFile,
227
+ me as useFile
228
228
  };