@done-coding/admin-core 0.1.4 → 0.2.1-alpha.0
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/es/components/misc/ActionBtn.vue.mjs +117 -0
- package/es/components/misc/ActionBtn.vue2.mjs +4 -0
- package/es/components/misc/ActionConfirm.vue.mjs +7 -0
- package/es/components/misc/ActionConfirm.vue2.mjs +113 -0
- package/es/components/misc/index.mjs +11 -5
- package/es/components/modal/ModalPorter.vue.mjs +52 -0
- package/es/components/modal/ModalPorter.vue2.mjs +4 -0
- package/es/components/modal/ModalShelf.vue.mjs +38 -0
- package/es/components/modal/ModalShelf.vue2.mjs +4 -0
- package/es/components/modal/index.mjs +17 -11
- package/es/components/modal/modal-shelf-core.mjs +52 -0
- package/es/components/modal/modal-shelf-hierarchy.mjs +21 -0
- package/es/components/panel/PanelEditSwitch.vue.mjs +7 -0
- package/es/components/panel/PanelEditSwitch.vue2.mjs +93 -0
- package/es/components/panel/PanelItem.vue.mjs +54 -0
- package/es/components/panel/PanelItem.vue2.mjs +4 -0
- package/es/components/panel/PanelMain.vue.mjs +80 -0
- package/es/components/panel/PanelMain.vue2.mjs +4 -0
- package/es/components/panel/index.mjs +20 -0
- package/es/index.mjs +126 -109
- package/es/inject/key.mjs +8 -4
- package/es/style.css +1 -1
- package/package.json +2 -2
- package/types/components/misc/ActionBtn.vue.d.ts +26 -0
- package/types/components/misc/ActionConfirm.vue.d.ts +41 -0
- package/types/components/misc/index.d.ts +4 -1
- package/types/components/misc/types.d.ts +80 -0
- package/types/components/modal/ConfirmModal.vue.d.ts +2 -2
- package/types/components/modal/ModalPorter.vue.d.ts +29 -0
- package/types/components/modal/ModalShelf.vue.d.ts +36 -0
- package/types/components/modal/index.d.ts +5 -1
- package/types/components/modal/modal-shelf-core.d.ts +10 -0
- package/types/components/modal/modal-shelf-hierarchy.d.ts +7 -0
- package/types/components/modal/modal-shelf-types.d.ts +74 -0
- package/types/components/panel/PanelEditSwitch.vue.d.ts +31 -0
- package/types/components/panel/PanelItem.vue.d.ts +21 -0
- package/types/components/panel/PanelMain.vue.d.ts +17 -0
- package/types/components/panel/index.d.ts +9 -0
- package/types/components/panel/types.d.ts +62 -0
- package/types/components/table/TableToolbar.vue.d.ts +8 -8
- package/types/index.d.ts +3 -1
- package/types/inject/key.d.ts +8 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { defineComponent as A, getCurrentInstance as b, ref as s, computed as P, openBlock as g, createBlock as v, withCtx as f, createVNode as T, unref as k, mergeProps as B, renderSlot as C } from "vue";
|
|
2
|
+
import { ElButton as h } from "element-plus";
|
|
3
|
+
import w from "./ActionConfirm.vue.mjs";
|
|
4
|
+
const E = /* @__PURE__ */ A({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "ActionBtn",
|
|
7
|
+
props: {
|
|
8
|
+
size: {},
|
|
9
|
+
disabled: { type: Boolean },
|
|
10
|
+
type: {},
|
|
11
|
+
icon: {},
|
|
12
|
+
nativeType: {},
|
|
13
|
+
loadingIcon: {},
|
|
14
|
+
plain: { type: Boolean },
|
|
15
|
+
text: { type: Boolean },
|
|
16
|
+
link: { type: Boolean },
|
|
17
|
+
bg: { type: Boolean },
|
|
18
|
+
autofocus: { type: Boolean },
|
|
19
|
+
round: { type: Boolean },
|
|
20
|
+
circle: { type: Boolean },
|
|
21
|
+
dashed: { type: Boolean },
|
|
22
|
+
color: {},
|
|
23
|
+
dark: { type: Boolean },
|
|
24
|
+
autoInsertSpace: { type: Boolean },
|
|
25
|
+
tag: {},
|
|
26
|
+
confirmMode: {},
|
|
27
|
+
confirmConfig: {}
|
|
28
|
+
},
|
|
29
|
+
emits: ["click"],
|
|
30
|
+
setup(x) {
|
|
31
|
+
const t = x, n = b(), u = s(), r = s(!1), a = s(!1);
|
|
32
|
+
let p;
|
|
33
|
+
const m = P(() => {
|
|
34
|
+
const e = t, o = {}, l = [
|
|
35
|
+
"type",
|
|
36
|
+
"size",
|
|
37
|
+
"plain",
|
|
38
|
+
"text",
|
|
39
|
+
"bg",
|
|
40
|
+
"link",
|
|
41
|
+
"round",
|
|
42
|
+
"circle",
|
|
43
|
+
"color",
|
|
44
|
+
"dark",
|
|
45
|
+
"disabled",
|
|
46
|
+
"autofocus",
|
|
47
|
+
"nativeType",
|
|
48
|
+
"autoInsertSpace",
|
|
49
|
+
"tag",
|
|
50
|
+
"icon",
|
|
51
|
+
"loadingIcon"
|
|
52
|
+
];
|
|
53
|
+
for (const i of l) e[i] !== void 0 && (o[i] = e[i]);
|
|
54
|
+
return { ...n == null ? void 0 : n.attrs, ...o };
|
|
55
|
+
}), _ = (e) => !!e && typeof e.then == "function", I = () => {
|
|
56
|
+
var o;
|
|
57
|
+
const e = (o = n == null ? void 0 : n.vnode.props) == null ? void 0 : o.onClick;
|
|
58
|
+
return e ? Array.isArray(e) ? e : [e] : [];
|
|
59
|
+
}, d = () => {
|
|
60
|
+
const e = I();
|
|
61
|
+
if (!e.length) return;
|
|
62
|
+
const o = p;
|
|
63
|
+
let l;
|
|
64
|
+
try {
|
|
65
|
+
l = e.map((c) => c(o));
|
|
66
|
+
} catch (c) {
|
|
67
|
+
throw r.value = !1, c;
|
|
68
|
+
}
|
|
69
|
+
const i = l.filter(_);
|
|
70
|
+
if (i.length)
|
|
71
|
+
return r.value = !0, Promise.all(i).finally(() => {
|
|
72
|
+
r.value = !1;
|
|
73
|
+
});
|
|
74
|
+
}, y = (e) => {
|
|
75
|
+
var o;
|
|
76
|
+
r.value || a.value || (p = e, t.confirmConfig ? (a.value = !0, Promise.resolve((o = u.value) == null ? void 0 : o.run()).finally(() => {
|
|
77
|
+
a.value = !1;
|
|
78
|
+
})) : d());
|
|
79
|
+
};
|
|
80
|
+
return (e, o) => t.confirmConfig ? (g(), v(w, {
|
|
81
|
+
key: 0,
|
|
82
|
+
ref_key: "confirmRef",
|
|
83
|
+
ref: u,
|
|
84
|
+
mode: t.confirmMode || "popconfirm",
|
|
85
|
+
title: t.confirmConfig.title,
|
|
86
|
+
content: t.confirmConfig.content,
|
|
87
|
+
"confirm-text": t.confirmConfig.confirmText,
|
|
88
|
+
"cancel-text": t.confirmConfig.cancelText,
|
|
89
|
+
type: t.confirmConfig.type,
|
|
90
|
+
action: d
|
|
91
|
+
}, {
|
|
92
|
+
default: f(() => [
|
|
93
|
+
T(k(h), B(m.value, {
|
|
94
|
+
loading: r.value,
|
|
95
|
+
onClick: y
|
|
96
|
+
}), {
|
|
97
|
+
default: f(() => [
|
|
98
|
+
C(e.$slots, "default")
|
|
99
|
+
]),
|
|
100
|
+
_: 3
|
|
101
|
+
}, 16, ["loading"])
|
|
102
|
+
]),
|
|
103
|
+
_: 3
|
|
104
|
+
}, 8, ["mode", "title", "content", "confirm-text", "cancel-text", "type"])) : (g(), v(k(h), B({ key: 1 }, m.value, {
|
|
105
|
+
loading: r.value,
|
|
106
|
+
onClick: y
|
|
107
|
+
}), {
|
|
108
|
+
default: f(() => [
|
|
109
|
+
C(e.$slots, "default")
|
|
110
|
+
]),
|
|
111
|
+
_: 3
|
|
112
|
+
}, 16, ["loading"]));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
E as default
|
|
117
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { defineComponent as S, ref as _, computed as x, openBlock as i, createBlock as u, unref as f, withCtx as s, createElementVNode as g, createElementBlock as C, resolveDynamicComponent as w, createCommentVNode as T, createVNode as h, createTextVNode as k, toDisplayString as B, renderSlot as N, h as b } from "vue";
|
|
2
|
+
import { ElPopover as $, ElButton as E, ElMessageBox as j } from "element-plus";
|
|
3
|
+
const q = { class: "action-confirm" }, F = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "action-confirm__title"
|
|
6
|
+
}, G = {
|
|
7
|
+
key: 1,
|
|
8
|
+
class: "action-confirm__content"
|
|
9
|
+
}, H = { class: "action-confirm__actions" }, O = /* @__PURE__ */ S({
|
|
10
|
+
__name: "ActionConfirm",
|
|
11
|
+
props: {
|
|
12
|
+
mode: {},
|
|
13
|
+
title: {},
|
|
14
|
+
content: {},
|
|
15
|
+
confirmText: { default: "确定" },
|
|
16
|
+
cancelText: { default: "取消" },
|
|
17
|
+
type: {},
|
|
18
|
+
action: {}
|
|
19
|
+
},
|
|
20
|
+
setup(a, { expose: P }) {
|
|
21
|
+
const e = a, c = _(!1), l = _(!1);
|
|
22
|
+
let n = null;
|
|
23
|
+
const r = (t) => {
|
|
24
|
+
if (t != null)
|
|
25
|
+
return typeof t == "function" ? t() : t;
|
|
26
|
+
}, m = (t) => {
|
|
27
|
+
if (!(t == null || t === ""))
|
|
28
|
+
return typeof t == "string" ? () => b("span", t) : () => t;
|
|
29
|
+
}, d = x(() => m(r(e.title))), y = x(() => m(r(e.content))), V = async () => {
|
|
30
|
+
l.value = !0;
|
|
31
|
+
try {
|
|
32
|
+
await Promise.resolve(e.action());
|
|
33
|
+
} finally {
|
|
34
|
+
l.value = !1;
|
|
35
|
+
}
|
|
36
|
+
}, z = async () => {
|
|
37
|
+
await V(), c.value = !1, n == null || n(!0), n = null;
|
|
38
|
+
}, A = () => {
|
|
39
|
+
c.value = !1, n == null || n(!1), n = null;
|
|
40
|
+
}, D = async () => {
|
|
41
|
+
const t = r(e.title), o = r(e.content), L = typeof o == "string" ? o : o ? b("div", o) : "";
|
|
42
|
+
try {
|
|
43
|
+
return await j.confirm(L, {
|
|
44
|
+
title: typeof t == "string" ? t : void 0,
|
|
45
|
+
confirmButtonText: e.confirmText,
|
|
46
|
+
cancelButtonText: e.cancelText,
|
|
47
|
+
type: e.type === "danger" ? "warning" : void 0,
|
|
48
|
+
beforeClose: async (M, v, p) => {
|
|
49
|
+
if (M !== "confirm") return p();
|
|
50
|
+
v.confirmButtonLoading = !0;
|
|
51
|
+
try {
|
|
52
|
+
await Promise.resolve(e.action());
|
|
53
|
+
} finally {
|
|
54
|
+
v.confirmButtonLoading = !1;
|
|
55
|
+
}
|
|
56
|
+
p();
|
|
57
|
+
}
|
|
58
|
+
}), !0;
|
|
59
|
+
} catch {
|
|
60
|
+
return !1;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return P({ run: () => e.mode === "messageConfirm" ? D() : (c.value = !0, new Promise((t) => {
|
|
64
|
+
n = t;
|
|
65
|
+
})) }), (t, o) => e.mode === "popconfirm" ? (i(), u(f($), {
|
|
66
|
+
key: 0,
|
|
67
|
+
visible: c.value,
|
|
68
|
+
width: 240,
|
|
69
|
+
persistent: !1
|
|
70
|
+
}, {
|
|
71
|
+
reference: s(() => [
|
|
72
|
+
N(t.$slots, "default", {}, void 0, !0)
|
|
73
|
+
]),
|
|
74
|
+
default: s(() => [
|
|
75
|
+
g("div", q, [
|
|
76
|
+
d.value ? (i(), C("div", F, [
|
|
77
|
+
(i(), u(w(d.value)))
|
|
78
|
+
])) : T("", !0),
|
|
79
|
+
y.value ? (i(), C("div", G, [
|
|
80
|
+
(i(), u(w(y.value)))
|
|
81
|
+
])) : T("", !0),
|
|
82
|
+
g("div", H, [
|
|
83
|
+
h(f(E), {
|
|
84
|
+
size: "small",
|
|
85
|
+
disabled: l.value,
|
|
86
|
+
onClick: A
|
|
87
|
+
}, {
|
|
88
|
+
default: s(() => [
|
|
89
|
+
k(B(a.cancelText), 1)
|
|
90
|
+
]),
|
|
91
|
+
_: 1
|
|
92
|
+
}, 8, ["disabled"]),
|
|
93
|
+
h(f(E), {
|
|
94
|
+
size: "small",
|
|
95
|
+
type: a.type,
|
|
96
|
+
loading: l.value,
|
|
97
|
+
onClick: z
|
|
98
|
+
}, {
|
|
99
|
+
default: s(() => [
|
|
100
|
+
k(B(a.confirmText), 1)
|
|
101
|
+
]),
|
|
102
|
+
_: 1
|
|
103
|
+
}, 8, ["type", "loading"])
|
|
104
|
+
])
|
|
105
|
+
])
|
|
106
|
+
]),
|
|
107
|
+
_: 3
|
|
108
|
+
}, 8, ["visible"])) : N(t.$slots, "default", { key: 1 }, void 0, !0);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
export {
|
|
112
|
+
O as default
|
|
113
|
+
};
|
|
@@ -3,24 +3,30 @@ import i from "./AutoRefresh.vue.mjs";
|
|
|
3
3
|
import m from "./ActionButton.vue.mjs";
|
|
4
4
|
import c from "./ActionButtonDanger.vue.mjs";
|
|
5
5
|
import s from "./ActionButtonWarn.vue.mjs";
|
|
6
|
-
|
|
6
|
+
import a from "./ActionBtn.vue.mjs";
|
|
7
|
+
import f from "./ActionConfirm.vue.mjs";
|
|
8
|
+
const e = {
|
|
7
9
|
TriggerAutoImport: r,
|
|
8
10
|
AutoRefresh: i,
|
|
9
11
|
ActionButton: m,
|
|
10
12
|
ActionButtonDanger: c,
|
|
11
|
-
ActionButtonWarn: s
|
|
12
|
-
|
|
13
|
+
ActionButtonWarn: s,
|
|
14
|
+
ActionBtn: a,
|
|
15
|
+
ActionConfirm: f
|
|
16
|
+
}, $ = {
|
|
13
17
|
install(t) {
|
|
14
|
-
Object.entries(
|
|
18
|
+
Object.entries(e).forEach(([o, n]) => {
|
|
15
19
|
t.component(o, n);
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
};
|
|
19
23
|
export {
|
|
24
|
+
a as ActionBtn,
|
|
20
25
|
m as ActionButton,
|
|
21
26
|
c as ActionButtonDanger,
|
|
22
27
|
s as ActionButtonWarn,
|
|
28
|
+
f as ActionConfirm,
|
|
23
29
|
i as AutoRefresh,
|
|
24
30
|
r as TriggerAutoImport,
|
|
25
|
-
|
|
31
|
+
$ as miscInstall
|
|
26
32
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineComponent as S, getCurrentInstance as h, inject as c, renderSlot as v } from "vue";
|
|
2
|
+
import { getModalShelfInjectionKey as u } from "../../inject/key.mjs";
|
|
3
|
+
import { useActivatedEvent as y } from "../../hooks/activated.mjs";
|
|
4
|
+
const k = /* @__PURE__ */ S({
|
|
5
|
+
__name: "ModalPorter",
|
|
6
|
+
props: {
|
|
7
|
+
modalList: {}
|
|
8
|
+
},
|
|
9
|
+
setup(i, { expose: p }) {
|
|
10
|
+
var s;
|
|
11
|
+
const o = i, f = ((s = h()) == null ? void 0 : s.uid) ?? Math.floor(Math.random() * 1e9), d = {
|
|
12
|
+
app: c(u("app"), null),
|
|
13
|
+
page: c(u("page"), null)
|
|
14
|
+
};
|
|
15
|
+
function a(e) {
|
|
16
|
+
return `p${f}:${e}`;
|
|
17
|
+
}
|
|
18
|
+
function l(e) {
|
|
19
|
+
if (e === "app" || e === "page") {
|
|
20
|
+
const t = d[e];
|
|
21
|
+
return t || (console.error(`[ModalPorter] 未找到 level="${e}" 的 ModalShelf`), null);
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
function m(e, t) {
|
|
26
|
+
const r = o.modalList.find((g) => g.key === e);
|
|
27
|
+
if (!r)
|
|
28
|
+
return console.error(`[ModalPorter] 未配置的弹窗 key: ${String(e)}`), null;
|
|
29
|
+
const n = l(r.shelf);
|
|
30
|
+
return n ? n.evoke(a(String(e)), r.component, {
|
|
31
|
+
payload: t,
|
|
32
|
+
sameKeyStrategy: r.sameKeyStrategy
|
|
33
|
+
}) : null;
|
|
34
|
+
}
|
|
35
|
+
return y(
|
|
36
|
+
() => {
|
|
37
|
+
},
|
|
38
|
+
() => {
|
|
39
|
+
const e = /* @__PURE__ */ new Map();
|
|
40
|
+
o.modalList.forEach((t) => {
|
|
41
|
+
const r = l(t.shelf);
|
|
42
|
+
if (!r) return;
|
|
43
|
+
const n = e.get(r) ?? [];
|
|
44
|
+
n.push(a(String(t.key))), e.set(r, n);
|
|
45
|
+
}), e.forEach((t, r) => r.remove(t));
|
|
46
|
+
}
|
|
47
|
+
), p({ evoke: m }), (e, t) => v(e.$slots, "default");
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export {
|
|
51
|
+
k as default
|
|
52
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineComponent as h, provide as v, onMounted as y, inject as a, openBlock as s, createElementBlock as c, Fragment as u, renderSlot as w, renderList as C, unref as l, createBlock as F, resolveDynamicComponent as _, defineAsyncComponent as k } from "vue";
|
|
2
|
+
import { createShelfController as S } from "./modal-shelf-core.mjs";
|
|
3
|
+
import { assertLevelHierarchy as g } from "./modal-shelf-hierarchy.mjs";
|
|
4
|
+
import { getModalShelfInjectionKey as p } from "../../inject/key.mjs";
|
|
5
|
+
const E = /* @__PURE__ */ h({
|
|
6
|
+
__name: "ModalShelf",
|
|
7
|
+
props: {
|
|
8
|
+
level: {}
|
|
9
|
+
},
|
|
10
|
+
setup(f, { expose: m }) {
|
|
11
|
+
const r = f.level, n = S(r);
|
|
12
|
+
m(n), v(p(r), n);
|
|
13
|
+
function d(o) {
|
|
14
|
+
return typeof o == "function" ? k(o) : o;
|
|
15
|
+
}
|
|
16
|
+
return y(() => {
|
|
17
|
+
const o = [];
|
|
18
|
+
["app", "page", "custom"].forEach((e) => {
|
|
19
|
+
e !== r && a(p(e), null) && o.push(e);
|
|
20
|
+
});
|
|
21
|
+
const t = a(p(r), null);
|
|
22
|
+
t && t !== n && o.push(r), g(r, o);
|
|
23
|
+
}), (o, t) => (s(), c(u, null, [
|
|
24
|
+
w(o.$slots, "default"),
|
|
25
|
+
(s(!0), c(u, null, C(l(n).items.value, (e) => (s(), F(_(d(e.component)), {
|
|
26
|
+
key: e.id,
|
|
27
|
+
show: e.show,
|
|
28
|
+
payload: e.payload,
|
|
29
|
+
closeFn: () => l(n).close(e),
|
|
30
|
+
removeFn: () => l(n).remove(e.nsKey),
|
|
31
|
+
"onUpdate:show": (i) => !i && l(n).close(e)
|
|
32
|
+
}, null, 40, ["show", "payload", "closeFn", "removeFn", "onUpdate:show"]))), 128))
|
|
33
|
+
], 64));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export {
|
|
37
|
+
E as default
|
|
38
|
+
};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import l from "./ConfirmModal.vue.mjs";
|
|
2
|
+
import r from "./DetailModal.vue.mjs";
|
|
3
|
+
import m from "./ModalShelf.vue.mjs";
|
|
4
|
+
import n from "./ModalPorter.vue.mjs";
|
|
5
|
+
const e = {
|
|
6
|
+
ConfirmModal: l,
|
|
7
|
+
DetailModal: r,
|
|
8
|
+
ModalShelf: m,
|
|
9
|
+
ModalPorter: n
|
|
10
|
+
}, d = {
|
|
7
11
|
install(o) {
|
|
8
|
-
Object.entries(
|
|
9
|
-
o.component(
|
|
12
|
+
Object.entries(e).forEach(([a, t]) => {
|
|
13
|
+
o.component(a, t);
|
|
10
14
|
});
|
|
11
15
|
}
|
|
12
16
|
};
|
|
13
17
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
l as ConfirmModal,
|
|
19
|
+
r as DetailModal,
|
|
20
|
+
n as ModalPorter,
|
|
21
|
+
m as ModalShelf,
|
|
22
|
+
d as modalInstall
|
|
17
23
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ref as h } from "vue";
|
|
2
|
+
const x = 300;
|
|
3
|
+
function g(s) {
|
|
4
|
+
let l = 0;
|
|
5
|
+
const r = h([]);
|
|
6
|
+
function d(e) {
|
|
7
|
+
return r.value.findIndex((t) => t.nsKey === e);
|
|
8
|
+
}
|
|
9
|
+
function u(e) {
|
|
10
|
+
e.timer !== void 0 && (clearTimeout(e.timer), e.timer = void 0);
|
|
11
|
+
}
|
|
12
|
+
function a(e) {
|
|
13
|
+
(Array.isArray(e) ? e : [e]).forEach((i) => {
|
|
14
|
+
const n = d(i);
|
|
15
|
+
n > -1 && (u(r.value[n]), r.value.splice(n, 1));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function c(e) {
|
|
19
|
+
const t = r.value.find((i) => i.id === e.id);
|
|
20
|
+
t && t.timer === void 0 && (t.show = !1, t.timer = setTimeout(() => {
|
|
21
|
+
const i = r.value.findIndex((n) => n.id === e.id);
|
|
22
|
+
i > -1 && r.value.splice(i, 1);
|
|
23
|
+
}, x));
|
|
24
|
+
}
|
|
25
|
+
function f(e) {
|
|
26
|
+
return {
|
|
27
|
+
close: () => {
|
|
28
|
+
const t = r.value.find((i) => i.nsKey === e);
|
|
29
|
+
t && c(t);
|
|
30
|
+
},
|
|
31
|
+
update: (t) => {
|
|
32
|
+
const i = r.value.find((n) => n.nsKey === e);
|
|
33
|
+
i && (i.payload = { ...i.payload, ...t });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function v(e, t, i) {
|
|
38
|
+
const { payload: n, sameKeyStrategy: m = "recreate" } = i;
|
|
39
|
+
if (m === "update") {
|
|
40
|
+
const o = r.value.find((y) => y.nsKey === e);
|
|
41
|
+
if (o)
|
|
42
|
+
return u(o), o.show = !0, o.payload = n, f(e);
|
|
43
|
+
}
|
|
44
|
+
a(e);
|
|
45
|
+
const p = { id: ++l, nsKey: e, component: t, payload: n, show: !0 };
|
|
46
|
+
return r.value.push(p), f(e);
|
|
47
|
+
}
|
|
48
|
+
return { level: s, items: r, evoke: v, remove: a, close: c };
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
g as createShelfController
|
|
52
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function l(o, e) {
|
|
2
|
+
if (o === "app" && e.length > 0) {
|
|
3
|
+
console.error(
|
|
4
|
+
`[ModalShelf] level="app" 必须最顶层,但其上存在: ${e.join(
|
|
5
|
+
", "
|
|
6
|
+
)}`
|
|
7
|
+
);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (o === "page") {
|
|
11
|
+
const r = e.filter((a) => a === "page" || a === "custom");
|
|
12
|
+
r.length > 0 && console.error(
|
|
13
|
+
`[ModalShelf] level="page" 之上不得套 page/custom,发现: ${r.join(
|
|
14
|
+
", "
|
|
15
|
+
)}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
l as assertLevelHierarchy
|
|
21
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ElButton as E } from "element-plus/es";
|
|
2
|
+
import "element-plus/es/components/base/style/css";
|
|
3
|
+
import "element-plus/es/components/button/style/css";
|
|
4
|
+
import { defineComponent as h, ref as d, watch as B, openBlock as u, createElementBlock as f, unref as m, createBlock as C, withCtx as c, createTextVNode as p, createCommentVNode as S, renderSlot as v, Fragment as N, createElementVNode as P, createVNode as g } from "vue";
|
|
5
|
+
import V from "lodash/cloneDeep";
|
|
6
|
+
const $ = { class: "panel-edit-switch-actions" }, j = /* @__PURE__ */ h({
|
|
7
|
+
name: "PanelEditSwitch",
|
|
8
|
+
__name: "PanelEditSwitch",
|
|
9
|
+
props: {
|
|
10
|
+
data: {},
|
|
11
|
+
editing: { type: Boolean },
|
|
12
|
+
submitFn: { type: Function }
|
|
13
|
+
},
|
|
14
|
+
emits: ["update:editing", "submitFinish"],
|
|
15
|
+
setup(a, { emit: b }) {
|
|
16
|
+
const o = a, i = b, s = d(!1), l = d(!1), n = d({});
|
|
17
|
+
B(
|
|
18
|
+
() => o.editing,
|
|
19
|
+
(t, e) => {
|
|
20
|
+
t && !e && (n.value = V(o.data));
|
|
21
|
+
},
|
|
22
|
+
{ immediate: !0 }
|
|
23
|
+
);
|
|
24
|
+
const y = () => {
|
|
25
|
+
i("update:editing", !0);
|
|
26
|
+
}, k = () => {
|
|
27
|
+
i("update:editing", !1);
|
|
28
|
+
}, w = async () => {
|
|
29
|
+
if (!o.submitFn) {
|
|
30
|
+
console.error("[PanelEditSwitch] editable 项缺少 submitFn,无法提交");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
l.value = !0;
|
|
34
|
+
try {
|
|
35
|
+
await o.submitFn(n.value), i("submitFinish", !0, n.value), i("update:editing", !1);
|
|
36
|
+
} catch (t) {
|
|
37
|
+
console.error("[PanelEditSwitch] submitFn 失败", t), i("submitFinish", !1, n.value);
|
|
38
|
+
} finally {
|
|
39
|
+
l.value = !1;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return (t, e) => {
|
|
43
|
+
const r = E;
|
|
44
|
+
return u(), f("div", {
|
|
45
|
+
class: "panel-edit-switch",
|
|
46
|
+
onMouseenter: e[0] || (e[0] = (F) => s.value = !0),
|
|
47
|
+
onMouseleave: e[1] || (e[1] = (F) => s.value = !1)
|
|
48
|
+
}, [
|
|
49
|
+
!a.editing && m(s) ? (u(), C(r, {
|
|
50
|
+
key: 0,
|
|
51
|
+
class: "panel-edit-switch-edit-btn",
|
|
52
|
+
type: "primary",
|
|
53
|
+
link: "",
|
|
54
|
+
size: "small",
|
|
55
|
+
onClick: y
|
|
56
|
+
}, {
|
|
57
|
+
default: c(() => [...e[2] || (e[2] = [
|
|
58
|
+
p("编辑", -1)
|
|
59
|
+
])]),
|
|
60
|
+
_: 1
|
|
61
|
+
})) : S("", !0),
|
|
62
|
+
a.editing ? (u(), f(N, { key: 2 }, [
|
|
63
|
+
v(t.$slots, "editor", { data: m(n) }, void 0, !0),
|
|
64
|
+
P("div", $, [
|
|
65
|
+
g(r, {
|
|
66
|
+
size: "small",
|
|
67
|
+
onClick: k
|
|
68
|
+
}, {
|
|
69
|
+
default: c(() => [...e[3] || (e[3] = [
|
|
70
|
+
p("取消", -1)
|
|
71
|
+
])]),
|
|
72
|
+
_: 1
|
|
73
|
+
}),
|
|
74
|
+
g(r, {
|
|
75
|
+
type: "primary",
|
|
76
|
+
size: "small",
|
|
77
|
+
loading: m(l),
|
|
78
|
+
onClick: w
|
|
79
|
+
}, {
|
|
80
|
+
default: c(() => [...e[4] || (e[4] = [
|
|
81
|
+
p("提交", -1)
|
|
82
|
+
])]),
|
|
83
|
+
_: 1
|
|
84
|
+
}, 8, ["loading"])
|
|
85
|
+
])
|
|
86
|
+
], 64)) : v(t.$slots, "default", { key: 1 }, void 0, !0)
|
|
87
|
+
], 32);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
export {
|
|
92
|
+
j as default
|
|
93
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineComponent as P, computed as c, unref as r, openBlock as n, createElementBlock as f, Fragment as w, toDisplayString as k, createBlock as l, resolveDynamicComponent as u, normalizeProps as g, mergeProps as m, withCtx as h } from "vue";
|
|
2
|
+
import S from "./PanelEditSwitch.vue.mjs";
|
|
3
|
+
const x = { key: 0 }, C = { key: 0 }, E = { key: 0 }, I = /* @__PURE__ */ P({
|
|
4
|
+
name: "PanelItem",
|
|
5
|
+
__name: "PanelItem",
|
|
6
|
+
props: {
|
|
7
|
+
data: {},
|
|
8
|
+
config: {},
|
|
9
|
+
editing: { type: Boolean }
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:editing", "submitFinish", "refresh"],
|
|
12
|
+
setup(e, { emit: b }) {
|
|
13
|
+
const t = e, o = b, a = c(() => ({
|
|
14
|
+
data: t.data,
|
|
15
|
+
value: t.data[t.config.key],
|
|
16
|
+
config: t.config,
|
|
17
|
+
refresh: () => o("refresh")
|
|
18
|
+
})), p = c(() => {
|
|
19
|
+
const { editable: i } = t.config;
|
|
20
|
+
return typeof i == "function" ? !!i(a.value) : !!i;
|
|
21
|
+
}), v = c(() => String(a.value.value ?? "")), y = c(() => ({
|
|
22
|
+
data: a.value.data,
|
|
23
|
+
value: a.value.value,
|
|
24
|
+
config: a.value.config,
|
|
25
|
+
refresh: () => o("refresh"),
|
|
26
|
+
onRefresh: () => o("refresh")
|
|
27
|
+
})), B = (i) => ({
|
|
28
|
+
data: i,
|
|
29
|
+
value: i[t.config.key],
|
|
30
|
+
config: t.config
|
|
31
|
+
});
|
|
32
|
+
return (i, s) => r(p) ? (n(), l(S, {
|
|
33
|
+
key: 1,
|
|
34
|
+
data: e.data,
|
|
35
|
+
editing: e.editing,
|
|
36
|
+
"submit-fn": e.config.submitFn,
|
|
37
|
+
"onUpdate:editing": s[0] || (s[0] = (d) => o("update:editing", d)),
|
|
38
|
+
onSubmitFinish: s[1] || (s[1] = (d, F) => o("submitFinish", d, F))
|
|
39
|
+
}, {
|
|
40
|
+
editor: h(({ data: d }) => [
|
|
41
|
+
e.config.editorRender === void 0 ? (n(), f("span", E)) : (n(), l(u(e.config.editorRender), g(m({ key: 1 }, B(d))), null, 16))
|
|
42
|
+
]),
|
|
43
|
+
default: h(() => [
|
|
44
|
+
e.config.render === void 0 ? (n(), f("span", C, k(r(v)), 1)) : (n(), l(u(e.config.render), g(m({ key: 1 }, r(y))), null, 16))
|
|
45
|
+
]),
|
|
46
|
+
_: 1
|
|
47
|
+
}, 8, ["data", "editing", "submit-fn"])) : (n(), f(w, { key: 0 }, [
|
|
48
|
+
e.config.render === void 0 ? (n(), f("span", x, k(r(v)), 1)) : (n(), l(u(e.config.render), g(m({ key: 1 }, r(y))), null, 16))
|
|
49
|
+
], 64));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
export {
|
|
53
|
+
I as default
|
|
54
|
+
};
|