@duxweb/dvha-core 1.0.23 → 1.0.24
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/dist/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/components/loader/iframe.cjs +1 -1
- package/dist/cjs/components/loader/remote/loader.cjs +1 -1
- package/dist/cjs/components/loader/remote/render.cjs +1 -1
- package/dist/cjs/components/overlay/overlay.cjs +1 -1
- package/dist/cjs/components/status/exception.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/export.cjs +1 -1
- package/dist/cjs/hooks/exportCsv.cjs +2 -2
- package/dist/cjs/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/formExtend.cjs +1 -1
- package/dist/cjs/hooks/i18n.cjs +1 -1
- package/dist/cjs/hooks/import.cjs +1 -1
- package/dist/cjs/hooks/importCsv.cjs +2 -2
- package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
- package/dist/cjs/hooks/json/vFor.cjs +1 -1
- package/dist/cjs/hooks/json/vOn.cjs +1 -1
- package/dist/cjs/hooks/json/vShow.cjs +1 -1
- package/dist/cjs/hooks/json.cjs +1 -1
- package/dist/cjs/hooks/list.cjs +1 -1
- package/dist/cjs/hooks/manage.cjs +1 -1
- package/dist/cjs/hooks/menu.cjs +1 -1
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +3 -3
- package/dist/cjs/hooks/tree.cjs +1 -1
- package/dist/cjs/hooks/upload/s3.cjs +1 -1
- package/dist/cjs/hooks/upload.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/router/route.cjs +1 -1
- package/dist/cjs/stores/auth.cjs +1 -1
- package/dist/cjs/stores/i18n.cjs +1 -1
- package/dist/cjs/stores/jsonSchema.cjs +1 -1
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/cjs/stores/route.cjs +1 -1
- package/dist/cjs/stores/tab.cjs +1 -1
- package/dist/cjs/stores/theme.cjs +1 -1
- package/dist/cjs/utils/tree.cjs +1 -1
- package/dist/esm/components/auth/can.js +8 -11
- package/dist/esm/components/loader/iframe.js +14 -17
- package/dist/esm/components/loader/remote/loader.js +103 -105
- package/dist/esm/components/loader/remote/render.js +10 -11
- package/dist/esm/components/overlay/overlay.js +7 -7
- package/dist/esm/components/status/exception.js +10 -13
- package/dist/esm/directive/permission.js +6 -7
- package/dist/esm/hooks/auth.js +73 -83
- package/dist/esm/hooks/data.js +290 -345
- package/dist/esm/hooks/export.js +16 -17
- package/dist/esm/hooks/exportCsv.js +26 -27
- package/dist/esm/hooks/form.js +49 -54
- package/dist/esm/hooks/formExtend.js +24 -25
- package/dist/esm/hooks/i18n.js +11 -29
- package/dist/esm/hooks/import.js +31 -32
- package/dist/esm/hooks/importCsv.js +24 -25
- package/dist/esm/hooks/json/utils/expressionParser.js +36 -42
- package/dist/esm/hooks/json/vFor.js +15 -16
- package/dist/esm/hooks/json/vOn.js +17 -18
- package/dist/esm/hooks/json/vShow.js +9 -10
- package/dist/esm/hooks/json.js +88 -94
- package/dist/esm/hooks/list.js +100 -127
- package/dist/esm/hooks/manage.js +13 -17
- package/dist/esm/hooks/menu.js +39 -52
- package/dist/esm/hooks/select.js +35 -40
- package/dist/esm/hooks/theme.js +127 -141
- package/dist/esm/hooks/tree.js +22 -28
- package/dist/esm/hooks/upload/s3.js +22 -23
- package/dist/esm/hooks/upload.js +152 -159
- package/dist/esm/preset/authProvider.js +63 -117
- package/dist/esm/preset/dataProvider.js +69 -76
- package/dist/esm/preset/i18nProvider.js +18 -18
- package/dist/esm/provider/app.js +74 -81
- package/dist/esm/router/route.js +16 -24
- package/dist/esm/stores/auth.js +17 -20
- package/dist/esm/stores/i18n.js +10 -10
- package/dist/esm/stores/jsonSchema.js +20 -23
- package/dist/esm/stores/manage.js +33 -33
- package/dist/esm/stores/route.js +38 -50
- package/dist/esm/stores/tab.js +38 -54
- package/dist/esm/stores/theme.js +28 -29
- package/dist/esm/utils/tree.js +23 -24
- package/package.json +1 -1
package/dist/esm/hooks/export.js
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useInfiniteList as
|
|
3
|
-
const
|
|
1
|
+
import { ref as P, computed as o } from "vue";
|
|
2
|
+
import { useInfiniteList as x } from "./data.js";
|
|
3
|
+
const d = (e) => new Promise((a) => setTimeout(a, e));
|
|
4
4
|
function b(e) {
|
|
5
|
-
const a =
|
|
6
|
-
const { onSuccess: n, onProgress:
|
|
5
|
+
const a = P(!1), l = o(() => {
|
|
6
|
+
const { onSuccess: n, onProgress: h, interval: w, maxPage: y, ...r } = e;
|
|
7
7
|
return {
|
|
8
|
-
...
|
|
8
|
+
...r,
|
|
9
9
|
options: {
|
|
10
|
-
...
|
|
10
|
+
...r.options,
|
|
11
11
|
enabled: !1,
|
|
12
12
|
refetchOnMount: !1,
|
|
13
13
|
refetchOnWindowFocus: !1,
|
|
14
14
|
refetchOnReconnect: !1
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
}),
|
|
18
|
-
var n, i, l;
|
|
17
|
+
}), i = o(() => e.interval || 300), { data: s, isLoading: u, fetchNextPage: c, hasNextPage: f, refetch: g, pagination: t } = x(l.value), v = async () => {
|
|
19
18
|
if (!a.value)
|
|
20
19
|
try {
|
|
21
|
-
a.value = !0, t.value.page = 1,
|
|
22
|
-
const
|
|
23
|
-
for (;
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
a.value = !0, t.value.page = 1, e.onProgress?.(t.value), await g();
|
|
21
|
+
const n = typeof e.maxPage == "function" ? e.maxPage() : e.maxPage || 0;
|
|
22
|
+
for (; f.value && !(n > 0 && t.value.page >= n); )
|
|
23
|
+
i.value > 0 && await d(i.value), await c(), e.onProgress?.(t.value);
|
|
24
|
+
e.onSuccess?.(s.value);
|
|
26
25
|
} finally {
|
|
27
26
|
a.value = !1;
|
|
28
27
|
}
|
|
29
|
-
},
|
|
28
|
+
}, m = o(() => u.value || a.value);
|
|
30
29
|
return {
|
|
31
30
|
data: s,
|
|
32
|
-
isLoading:
|
|
33
|
-
trigger:
|
|
31
|
+
isLoading: m,
|
|
32
|
+
trigger: v
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
export {
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
import { json2csv as
|
|
2
|
-
import { computed as
|
|
3
|
-
import { useExport as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
const { filename:
|
|
7
|
-
return
|
|
8
|
-
}),
|
|
9
|
-
const
|
|
1
|
+
import { json2csv as d } from "json-2-csv";
|
|
2
|
+
import { computed as a } from "vue";
|
|
3
|
+
import { useExport as l } from "./export.js";
|
|
4
|
+
function h(t) {
|
|
5
|
+
const c = a(() => {
|
|
6
|
+
const { filename: e, headers: o, csvOptions: n, ...s } = t;
|
|
7
|
+
return s;
|
|
8
|
+
}), i = a(() => {
|
|
9
|
+
const e = t.csvOptions || {}, o = e.quote;
|
|
10
10
|
return {
|
|
11
|
-
prependHeader:
|
|
12
|
-
keys: Array.isArray(
|
|
11
|
+
prependHeader: t.headers !== !1,
|
|
12
|
+
keys: Array.isArray(t.headers) ? t.headers : void 0,
|
|
13
13
|
delimiter: {
|
|
14
|
-
field:
|
|
15
|
-
wrap: typeof
|
|
16
|
-
eol:
|
|
14
|
+
field: e.delimiter || ",",
|
|
15
|
+
wrap: typeof o == "string" ? o : '"',
|
|
16
|
+
eol: e.eol || `
|
|
17
17
|
`
|
|
18
18
|
},
|
|
19
|
-
excelBOM:
|
|
19
|
+
excelBOM: e.writeBOM || !1
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
|
-
return
|
|
23
|
-
...
|
|
24
|
-
onSuccess: async (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(c = e.onError) == null || c.call(e, {
|
|
22
|
+
return l({
|
|
23
|
+
...c.value,
|
|
24
|
+
onSuccess: async (e) => {
|
|
25
|
+
if (!e?.data || !e?.data?.length) {
|
|
26
|
+
t.onError?.({
|
|
28
27
|
message: "No data to export",
|
|
29
28
|
status: 400
|
|
30
29
|
});
|
|
31
30
|
return;
|
|
32
31
|
}
|
|
33
32
|
try {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
} catch (
|
|
37
|
-
|
|
38
|
-
message: `CSV Export Error: ${
|
|
33
|
+
const o = await d(e.data, i.value), n = new Blob([o], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(n), r = document.createElement("a");
|
|
34
|
+
r.href = s, r.download = t.filename || "export.csv", r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(s), t.onSuccess?.(e);
|
|
35
|
+
} catch (o) {
|
|
36
|
+
t.onError?.({
|
|
37
|
+
message: `CSV Export Error: ${o}`,
|
|
39
38
|
status: 500
|
|
40
39
|
});
|
|
41
40
|
}
|
|
@@ -43,5 +42,5 @@ function b(e) {
|
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
export {
|
|
46
|
-
|
|
45
|
+
h as useExportCsv
|
|
47
46
|
};
|
package/dist/esm/hooks/form.js
CHANGED
|
@@ -1,80 +1,75 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
2
|
-
import { toRef as
|
|
3
|
-
import { useOne as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
1
|
+
import { cloneDeep as i } from "lodash-es";
|
|
2
|
+
import { toRef as d, ref as l, computed as m, watch as b } from "vue";
|
|
3
|
+
import { useOne as E, useCreate as L, useUpdate as O } from "./data.js";
|
|
4
|
+
function w(a) {
|
|
5
|
+
const t = d(a, "form", {}), u = d(a, "id", void 0), o = l(i(t.value || {})), v = l(i(t.value || {})), n = m(() => a.action === "edit" || !!u.value), { data: f, isLoading: g, refetch: h } = E({
|
|
6
6
|
get path() {
|
|
7
|
-
return
|
|
7
|
+
return a.path || "";
|
|
8
8
|
},
|
|
9
9
|
get id() {
|
|
10
|
-
return
|
|
10
|
+
return u.value;
|
|
11
11
|
},
|
|
12
12
|
options: {
|
|
13
|
-
enabled:
|
|
13
|
+
enabled: n.value
|
|
14
14
|
},
|
|
15
|
-
providerName:
|
|
16
|
-
}),
|
|
17
|
-
let
|
|
18
|
-
|
|
15
|
+
providerName: a.providerName
|
|
16
|
+
}), r = () => {
|
|
17
|
+
let e = {};
|
|
18
|
+
n.value ? e = i(o.value) : e = i(v.value), Object.assign(t.value, e);
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
d();
|
|
20
|
+
b([u, n], async () => {
|
|
21
|
+
if (!n.value) {
|
|
22
|
+
r();
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
|
-
await
|
|
27
|
-
const
|
|
28
|
-
Object.assign(
|
|
25
|
+
await h();
|
|
26
|
+
const e = i(f.value?.data || {});
|
|
27
|
+
Object.assign(t.value, e), Object.assign(o.value, e);
|
|
29
28
|
}, {
|
|
30
29
|
immediate: !0
|
|
31
30
|
});
|
|
32
|
-
const
|
|
33
|
-
path:
|
|
34
|
-
data:
|
|
35
|
-
onSuccess: (
|
|
36
|
-
|
|
37
|
-
d(), (t = e.onSuccess) == null || t.call(e, a);
|
|
31
|
+
const c = L({
|
|
32
|
+
path: a.path ?? "",
|
|
33
|
+
data: t.value,
|
|
34
|
+
onSuccess: (e) => {
|
|
35
|
+
r(), a.onSuccess?.(e);
|
|
38
36
|
},
|
|
39
|
-
onError: (
|
|
40
|
-
|
|
41
|
-
(t = e.onError) == null || t.call(e, a);
|
|
37
|
+
onError: (e) => {
|
|
38
|
+
a.onError?.(e);
|
|
42
39
|
},
|
|
43
|
-
providerName:
|
|
44
|
-
}),
|
|
40
|
+
providerName: a.providerName
|
|
41
|
+
}), s = O({
|
|
45
42
|
get path() {
|
|
46
|
-
return
|
|
43
|
+
return a.path ?? "";
|
|
47
44
|
},
|
|
48
45
|
get id() {
|
|
49
|
-
return
|
|
46
|
+
return u.value;
|
|
50
47
|
},
|
|
51
|
-
data:
|
|
52
|
-
onSuccess: (
|
|
53
|
-
|
|
54
|
-
(t = e.onSuccess) == null || t.call(e, a);
|
|
48
|
+
data: t.value,
|
|
49
|
+
onSuccess: (e) => {
|
|
50
|
+
a.onSuccess?.(e);
|
|
55
51
|
},
|
|
56
|
-
onError: (
|
|
57
|
-
|
|
58
|
-
(t = e.onError) == null || t.call(e, a);
|
|
52
|
+
onError: (e) => {
|
|
53
|
+
a.onError?.(e);
|
|
59
54
|
},
|
|
60
|
-
providerName:
|
|
61
|
-
}),
|
|
62
|
-
|
|
63
|
-
id:
|
|
64
|
-
data:
|
|
65
|
-
}) :
|
|
66
|
-
data:
|
|
55
|
+
providerName: a.providerName
|
|
56
|
+
}), D = (e) => {
|
|
57
|
+
n.value ? s.mutate({
|
|
58
|
+
id: u.value,
|
|
59
|
+
data: e || t.value
|
|
60
|
+
}) : c.mutate({
|
|
61
|
+
data: e || t.value
|
|
67
62
|
});
|
|
68
|
-
},
|
|
63
|
+
}, N = m(() => g.value || c.isLoading.value || s.isLoading.value);
|
|
69
64
|
return {
|
|
70
|
-
form:
|
|
71
|
-
initData:
|
|
72
|
-
isLoading:
|
|
73
|
-
isEdit:
|
|
74
|
-
onSubmit:
|
|
75
|
-
onReset:
|
|
65
|
+
form: t,
|
|
66
|
+
initData: n.value ? o.value : v.value,
|
|
67
|
+
isLoading: N,
|
|
68
|
+
isEdit: n,
|
|
69
|
+
onSubmit: D,
|
|
70
|
+
onReset: r
|
|
76
71
|
};
|
|
77
72
|
}
|
|
78
73
|
export {
|
|
79
|
-
|
|
74
|
+
w as useForm
|
|
80
75
|
};
|
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
import { toRef as
|
|
2
|
-
import { useForm as
|
|
3
|
-
import { useValidateForm as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
data:
|
|
7
|
-
rules:
|
|
8
|
-
}),
|
|
9
|
-
const { form: n, ...r } =
|
|
1
|
+
import { toRef as f, computed as d } from "vue";
|
|
2
|
+
import { useForm as c } from "./form.js";
|
|
3
|
+
import { useValidateForm as l } from "./formValidate.js";
|
|
4
|
+
function g(o) {
|
|
5
|
+
const e = f(o, "form", {}), { validate: s, reset: i } = l({
|
|
6
|
+
data: e,
|
|
7
|
+
rules: o.rules
|
|
8
|
+
}), m = d(() => {
|
|
9
|
+
const { form: n, ...r } = o;
|
|
10
10
|
return {
|
|
11
11
|
...r
|
|
12
12
|
};
|
|
13
|
-
}),
|
|
14
|
-
...
|
|
15
|
-
form:
|
|
16
|
-
}),
|
|
17
|
-
|
|
18
|
-
var i;
|
|
13
|
+
}), t = c({
|
|
14
|
+
...m.value,
|
|
15
|
+
form: e.value
|
|
16
|
+
}), u = (n) => {
|
|
17
|
+
s().then((r) => {
|
|
19
18
|
if (!r.valid) {
|
|
20
|
-
|
|
19
|
+
o.onError?.({
|
|
21
20
|
message: "表单验证失败"
|
|
22
21
|
});
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
t.onSubmit(n);
|
|
26
25
|
});
|
|
27
|
-
},
|
|
28
|
-
|
|
26
|
+
}, a = () => {
|
|
27
|
+
t.onReset(), i();
|
|
29
28
|
};
|
|
30
29
|
return {
|
|
31
|
-
isLoading:
|
|
32
|
-
isEdit:
|
|
33
|
-
form:
|
|
34
|
-
onSubmit:
|
|
35
|
-
onReset:
|
|
30
|
+
isLoading: t.isLoading,
|
|
31
|
+
isEdit: t.isEdit,
|
|
32
|
+
form: e,
|
|
33
|
+
onSubmit: u,
|
|
34
|
+
onReset: a
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
export {
|
|
39
|
-
|
|
38
|
+
g as useExtendForm
|
|
40
39
|
};
|
package/dist/esm/hooks/i18n.js
CHANGED
|
@@ -1,37 +1,19 @@
|
|
|
1
1
|
import "pinia";
|
|
2
2
|
import "vue";
|
|
3
|
-
import { useI18nStore as
|
|
3
|
+
import { useI18nStore as t } from "../stores/i18n.js";
|
|
4
4
|
import "lodash-es";
|
|
5
|
-
import { useManage as
|
|
6
|
-
function
|
|
7
|
-
const
|
|
5
|
+
import { useManage as a } from "./manage.js";
|
|
6
|
+
function P() {
|
|
7
|
+
const n = t(), o = a();
|
|
8
8
|
return {
|
|
9
|
-
t: (e,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return a.setLocale(e), (r = (o = c.config) == null ? void 0 : o.i18nProvider) == null ? void 0 : r.changeLocale(e);
|
|
16
|
-
},
|
|
17
|
-
getLocale: () => {
|
|
18
|
-
var e, o;
|
|
19
|
-
return (o = (e = c.config) == null ? void 0 : e.i18nProvider) == null ? void 0 : o.getLocale();
|
|
20
|
-
},
|
|
21
|
-
loadLocale: (e, o) => {
|
|
22
|
-
var r, n;
|
|
23
|
-
return (n = (r = c.config) == null ? void 0 : r.i18nProvider) == null ? void 0 : n.loadLocale(e, o);
|
|
24
|
-
},
|
|
25
|
-
mergeLocale: (e, o) => {
|
|
26
|
-
var r, n;
|
|
27
|
-
return (n = (r = c.config) == null ? void 0 : r.i18nProvider) == null ? void 0 : n.mergeLocale(e, o);
|
|
28
|
-
},
|
|
29
|
-
getLocales: () => {
|
|
30
|
-
var e, o;
|
|
31
|
-
return (o = (e = c.config) == null ? void 0 : e.i18nProvider) == null ? void 0 : o.getLocales();
|
|
32
|
-
}
|
|
9
|
+
t: (e, r, c) => o.config?.i18nProvider?.t(e, r, c),
|
|
10
|
+
changeLocale: (e) => (n.setLocale(e), o.config?.i18nProvider?.changeLocale(e)),
|
|
11
|
+
getLocale: () => o.config?.i18nProvider?.getLocale(),
|
|
12
|
+
loadLocale: (e, r) => o.config?.i18nProvider?.loadLocale(e, r),
|
|
13
|
+
mergeLocale: (e, r) => o.config?.i18nProvider?.mergeLocale(e, r),
|
|
14
|
+
getLocales: () => o.config?.i18nProvider?.getLocales()
|
|
33
15
|
};
|
|
34
16
|
}
|
|
35
17
|
export {
|
|
36
|
-
|
|
18
|
+
P as useI18n
|
|
37
19
|
};
|
package/dist/esm/hooks/import.js
CHANGED
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useCustomMutation as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const
|
|
1
|
+
import { ref as g, computed as u } from "vue";
|
|
2
|
+
import { useCustomMutation as d } from "./data.js";
|
|
3
|
+
const f = (t) => new Promise((s) => setTimeout(s, t));
|
|
4
|
+
function P(t) {
|
|
5
|
+
const s = g(!1), o = g({
|
|
6
6
|
totalItems: 0,
|
|
7
7
|
processedItems: 0,
|
|
8
8
|
totalBatches: 0,
|
|
9
9
|
processedBatches: 0,
|
|
10
10
|
percentage: 0
|
|
11
11
|
}), i = u(() => {
|
|
12
|
-
const { onComplete:
|
|
13
|
-
return
|
|
14
|
-
}), { mutate:
|
|
15
|
-
path:
|
|
12
|
+
const { onComplete: r, onProgress: c, onError: m, interval: a, chunkSize: n, ...l } = t;
|
|
13
|
+
return l;
|
|
14
|
+
}), { mutate: v } = d({
|
|
15
|
+
path: t.path,
|
|
16
16
|
method: "POST",
|
|
17
17
|
...i.value,
|
|
18
18
|
options: {
|
|
19
19
|
...i.value.options
|
|
20
20
|
}
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
if (a.value)
|
|
21
|
+
}), p = async (r) => {
|
|
22
|
+
if (s.value)
|
|
24
23
|
return;
|
|
25
|
-
const
|
|
26
|
-
for (let
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
totalItems:
|
|
24
|
+
const c = t.chunkSize || 100, m = t.interval || 100, a = r.length, n = [];
|
|
25
|
+
for (let e = 0; e < a; e += c)
|
|
26
|
+
n.push(r.slice(e, e + c));
|
|
27
|
+
const l = n.length;
|
|
28
|
+
o.value = {
|
|
29
|
+
totalItems: a,
|
|
31
30
|
processedItems: 0,
|
|
32
|
-
totalBatches:
|
|
31
|
+
totalBatches: l,
|
|
33
32
|
processedBatches: 0,
|
|
34
33
|
percentage: 0
|
|
35
|
-
},
|
|
34
|
+
}, s.value = !0;
|
|
36
35
|
try {
|
|
37
|
-
for (let
|
|
38
|
-
const
|
|
39
|
-
await
|
|
40
|
-
payload:
|
|
41
|
-
}),
|
|
36
|
+
for (let e = 0; e < n.length; e++) {
|
|
37
|
+
const h = n[e];
|
|
38
|
+
await v({
|
|
39
|
+
payload: h
|
|
40
|
+
}), o.value.processedBatches = e + 1, o.value.processedItems += h.length, o.value.percentage = Math.round(o.value.processedItems / a * 100), t.onProgress?.(o.value), e < n.length - 1 && await f(m);
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
} catch (
|
|
45
|
-
|
|
42
|
+
s.value = !1, t.onComplete?.(o.value);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
s.value = !1, t.onError?.(e);
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
47
|
return {
|
|
49
|
-
isLoading: u(() =>
|
|
50
|
-
progress: u(() =>
|
|
51
|
-
trigger:
|
|
48
|
+
isLoading: u(() => s.value),
|
|
49
|
+
progress: u(() => o.value),
|
|
50
|
+
trigger: p
|
|
52
51
|
};
|
|
53
52
|
}
|
|
54
53
|
export {
|
|
55
|
-
|
|
54
|
+
P as useImport
|
|
56
55
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useFileDialog as
|
|
2
|
-
import { csv2json as
|
|
3
|
-
import { computed as
|
|
4
|
-
import { useImport as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
const { csvOptions: e, ...
|
|
8
|
-
return
|
|
9
|
-
}),
|
|
10
|
-
const e =
|
|
1
|
+
import { useFileDialog as u } from "@vueuse/core";
|
|
2
|
+
import { csv2json as d } from "json-2-csv";
|
|
3
|
+
import { computed as n } from "vue";
|
|
4
|
+
import { useImport as f } from "./import.js";
|
|
5
|
+
function w(s) {
|
|
6
|
+
const a = n(() => {
|
|
7
|
+
const { csvOptions: e, ...t } = s;
|
|
8
|
+
return t;
|
|
9
|
+
}), l = n(() => {
|
|
10
|
+
const e = s.csvOptions || {};
|
|
11
11
|
return {
|
|
12
12
|
delimiter: {
|
|
13
13
|
field: e.delimiter || ",",
|
|
@@ -21,36 +21,35 @@ function C(t) {
|
|
|
21
21
|
trimHeaderFields: e.trimHeaderFields || !1,
|
|
22
22
|
trimFieldValues: e.trimFieldValues || !1
|
|
23
23
|
};
|
|
24
|
-
}), r =
|
|
25
|
-
...
|
|
26
|
-
}),
|
|
27
|
-
var s, a;
|
|
24
|
+
}), r = f({
|
|
25
|
+
...a.value
|
|
26
|
+
}), i = async (e) => {
|
|
28
27
|
try {
|
|
29
|
-
const
|
|
30
|
-
o && o.length > 0 ? await r.trigger(o) :
|
|
28
|
+
const t = await e.text(), o = await d(t, l.value);
|
|
29
|
+
o && o.length > 0 ? await r.trigger(o) : s.onError?.({
|
|
31
30
|
message: "CSV 文件为空或格式不正确",
|
|
32
31
|
status: 400
|
|
33
32
|
});
|
|
34
|
-
} catch (
|
|
35
|
-
|
|
36
|
-
message: `CSV 解析错误: ${
|
|
33
|
+
} catch (t) {
|
|
34
|
+
s.onError?.({
|
|
35
|
+
message: `CSV 解析错误: ${t}`,
|
|
37
36
|
status: 500
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
|
-
}, { open:
|
|
39
|
+
}, { open: c, reset: m, onChange: p } = u({
|
|
41
40
|
accept: ".csv",
|
|
42
41
|
multiple: !1
|
|
43
42
|
});
|
|
44
|
-
return
|
|
45
|
-
e && e.length > 0 &&
|
|
43
|
+
return p((e) => {
|
|
44
|
+
e && e.length > 0 && i(e[0]);
|
|
46
45
|
}), {
|
|
47
46
|
...r,
|
|
48
47
|
open: () => {
|
|
49
|
-
|
|
48
|
+
m(), c();
|
|
50
49
|
},
|
|
51
|
-
readFile:
|
|
50
|
+
readFile: i
|
|
52
51
|
};
|
|
53
52
|
}
|
|
54
53
|
export {
|
|
55
|
-
|
|
54
|
+
w as useImportCsv
|
|
56
55
|
};
|