@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.
- package/api-services/index.js +710 -710
- package/api-services/index.js.gz +0 -0
- package/api-services/modules/file/index.js +116 -116
- package/api-services/modules/file/index.js.gz +0 -0
- package/api-services/modules/index.js +710 -710
- package/api-services/modules/index.js.gz +0 -0
- package/common-tools/extract-file-name/index.d.ts +1 -0
- package/common-tools/extract-file-name/index.js +1449 -0
- package/common-tools/extract-file-name/index.js.gz +0 -0
- package/esm-map.json +2 -1
- package/package.json +3 -3
package/api-services/index.js.gz
CHANGED
|
Binary file
|
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import { iotMinio as
|
|
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
|
|
5
|
-
import { getConfig as
|
|
6
|
-
let
|
|
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
|
|
10
|
-
|
|
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
|
|
15
|
-
let e = f(!1), o = f(""), i = f(0),
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
const [
|
|
20
|
-
return
|
|
21
|
-
},
|
|
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
|
|
24
|
-
for (;
|
|
25
|
-
const m =
|
|
26
|
-
u.push(m),
|
|
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
|
|
29
|
-
r(
|
|
30
|
-
}),
|
|
31
|
-
var
|
|
32
|
-
L = u, n && (
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
let m =
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
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
|
|
41
|
-
M.push(
|
|
42
|
-
}), c = new FormData(), c.append("accessKeyId", m.accessKeyId), c.append("secretAccessKey", m.secretAccessKey), c.append("sessionToken", m.sessionToken), c.append("bucketName",
|
|
43
|
-
c.append("file", M[
|
|
44
|
-
}),
|
|
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
|
|
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:
|
|
55
|
-
filePath:
|
|
56
|
-
autoContentType:
|
|
53
|
+
bucketName: x,
|
|
54
|
+
filePath: j,
|
|
55
|
+
autoContentType: $
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
|
-
const [_, G] = await
|
|
58
|
+
const [_, G] = await N(c).run();
|
|
60
59
|
if (_) return e.value = !1;
|
|
61
|
-
const b = await
|
|
60
|
+
const b = await re(G.data);
|
|
62
61
|
if ((b == null ? void 0 : b.statusCode) != 200) {
|
|
63
|
-
e.value = !1, (
|
|
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
|
|
69
|
+
const C = await (s == null ? void 0 : s(b));
|
|
71
70
|
if (n) {
|
|
72
|
-
if (!
|
|
73
|
-
e.value = !1,
|
|
71
|
+
if (!C.status) {
|
|
72
|
+
e.value = !1, t.value = "error";
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
76
|
-
o.value = "导入进度", e.value = !0, k(
|
|
75
|
+
o.value = "导入进度", e.value = !0, k(C.taskId, "import", "");
|
|
77
76
|
} else {
|
|
78
|
-
if (!
|
|
79
|
-
|
|
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
|
-
},
|
|
86
|
-
|
|
87
|
-
const n = await (
|
|
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,
|
|
88
|
+
e.value = !1, t.value = "error";
|
|
90
89
|
return;
|
|
91
90
|
}
|
|
92
91
|
k(n.taskId, "action", "");
|
|
93
|
-
},
|
|
94
|
-
n && (
|
|
95
|
-
const u = await (
|
|
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,
|
|
96
|
+
e.value = !1, t.value = "error";
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
}, k = async (
|
|
102
|
-
|
|
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
|
-
},
|
|
103
|
+
}, S = () => {
|
|
105
104
|
clearTimeout(p), p = null, e.value = !1;
|
|
106
|
-
},
|
|
107
|
-
var m, c
|
|
108
|
-
const [u,
|
|
109
|
-
url: `progress/${
|
|
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
|
-
|
|
111
|
+
g.value = !1;
|
|
113
112
|
return;
|
|
114
113
|
}
|
|
115
|
-
i.value =
|
|
116
|
-
const
|
|
114
|
+
i.value = a.percentage;
|
|
115
|
+
const d = r == "export" ? "导出" : "导入";
|
|
117
116
|
if (i.value == 100)
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
message:
|
|
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 (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
132
|
-
} else r == "action" && (
|
|
131
|
+
z(a.status, d, a.message);
|
|
132
|
+
} else r == "action" && (t.value = "success");
|
|
133
133
|
else
|
|
134
|
-
p &&
|
|
135
|
-
|
|
136
|
-
}, 50) : (
|
|
137
|
-
},
|
|
138
|
-
var n, u,
|
|
139
|
-
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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:
|
|
158
|
-
progressLoading:
|
|
159
|
-
progressResult:
|
|
160
|
-
errorFileName:
|
|
157
|
+
progressStatus: t,
|
|
158
|
+
progressLoading: g,
|
|
159
|
+
progressResult: h,
|
|
160
|
+
errorFileName: v,
|
|
161
161
|
errorFileSize: y,
|
|
162
|
-
errorMessage:
|
|
162
|
+
errorMessage: w,
|
|
163
163
|
errorImport: T,
|
|
164
|
-
errorFilePath:
|
|
165
|
-
fileImport:
|
|
166
|
-
fileExport:
|
|
167
|
-
fileAction:
|
|
168
|
-
generateUniqueName: (
|
|
169
|
-
const r =
|
|
170
|
-
return `${r.length ? r[1] :
|
|
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:
|
|
173
|
-
resetStataus:
|
|
172
|
+
downloadFile: H,
|
|
173
|
+
resetStataus: q,
|
|
174
174
|
checkProgress: k
|
|
175
175
|
};
|
|
176
|
-
},
|
|
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
|
-
},
|
|
206
|
-
const
|
|
207
|
-
|
|
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:
|
|
210
|
-
}),
|
|
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
|
|
215
|
-
|
|
214
|
+
const v = document.createElement("a");
|
|
215
|
+
v.href = h, v.download = o, v.click(), window.URL.revokeObjectURL(h);
|
|
216
216
|
}
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
var
|
|
220
|
-
|
|
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
|
|
223
|
-
},
|
|
222
|
+
typeof t.result == "string" && (p = JSON.parse(t.result)), o(p);
|
|
223
|
+
}, t.readAsText(e);
|
|
224
224
|
});
|
|
225
225
|
export {
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
H as downloadFile,
|
|
227
|
+
ce as useFile
|
|
228
228
|
};
|
|
Binary file
|