@aplus-frontend/ui
Version:
154 lines (153 loc) • 5.04 kB
JavaScript
import { defineComponent as T, ref as y, watch as $, createElementBlock as c, openBlock as m, normalizeClass as V, unref as e, createElementVNode as o, createCommentVNode as f, toDisplayString as r, createVNode as i, withModifiers as L, withCtx as v } from "vue";
import { Space as C, Popconfirm as b } from "@aplus-frontend/antdv";
import { ApField as B } from "../../../ap-field/index.mjs";
import "../../../ap-form/ap-form.vue.mjs";
import "../../../config-provider/index.mjs";
import { useToken as F } from "../../../config-provider/hooks/use-token.mjs";
import "../../ap-tag/index.mjs";
import { useViewInject as M } from "../hooks/use-view-provide.mjs";
import Y from "../icons/line-delete.vue.mjs";
import j from "../style/index.mjs";
import { SYSTEM_VIEW_KEY as h } from "../utils/enum.mjs";
import { useNamespace as A } from "../../../config-provider/hooks/use-namespace.mjs";
import { useLocale as O } from "../../../config-provider/hooks/use-locale.mjs";
import P from "../../ap-tag/ap-tag.vue.mjs";
import x from "../../../ap-form/ap-form.vue2.mjs";
const U = { class: "menu-list-content-name" }, W = ["title"], q = {
key: 0,
class: "menu-list-content-default"
}, G = { class: "menu-list-content-action-delete" }, H = { class: "menu-list-content-edit" }, ve = /* @__PURE__ */ T({
__name: "menu-list-content",
props: {
view: {}
},
setup(N) {
const { b: s } = A("ap-view"), d = j("ap-view"), { token: K } = F(), { t: n } = O(), t = N, {
currentViewKey: D,
changeCurrentViewKey: S,
viewListCRUD: p,
tableKey: w,
menuOpen: _
} = M(), l = y(!1), k = y(), g = () => {
S(t.view.viewKey), _.value = !1;
}, E = () => {
p?.changeView?.({
...t.view,
tableKey: w,
isDefault: !0
});
}, z = () => {
p?.removeView?.({
tableKey: w,
viewKey: t.view.viewKey
});
}, I = async () => {
const u = await k.value?.validate?.();
p?.changeView?.({
...t.view,
tableKey: w,
viewName: u?.viewName || t.view.viewName
}), l.value = !1;
};
return $(
() => _.value,
(u) => {
u && (l.value = !1);
}
), (u, a) => l.value === !1 ? (m(), c("div", {
key: 0,
class: V({
[e(s)()]: !0,
[e(s)("menu-list-content")]: !0,
[e(s)("menu-list-content-active")]: t.view?.viewKey === e(D),
[e(d)]: !0
}),
onClick: g
}, [
o("div", U, [
o("span", {
title: t.view?.viewName
}, r(t.view?.viewName), 9, W)
]),
t.view?.viewKey !== e(h) && t.view?.isDefault ? (m(), c("div", q, [
i(e(P), {
text: e(n)("ap.apView.default"),
size: "small",
color: e(K).colorLink
}, null, 8, ["text", "color"])
])) : f("", !0),
t.view?.viewKey !== e(h) ? (m(), c("div", {
key: 1,
class: "menu-list-content-action",
onClick: a[1] || (a[1] = L(() => {
}, ["stop"]))
}, [
i(e(C), { size: 8 }, {
default: v(() => [
o("div", {
class: "menu-list-content-action-text",
onClick: a[0] || (a[0] = (R) => l.value = !0)
}, r(e(n)("ap.apView.rename")), 1),
t.view?.isDefault ? f("", !0) : (m(), c("div", {
key: 0,
class: "menu-list-content-action-text",
onClick: E
}, r(e(n)("ap.apView.setDefault")), 1)),
o("div", G, [
i(e(b), {
title: e(n)("ap.apView.deleteTip"),
"ok-text": e(n)("ap.apView.ok"),
onConfirm: z
}, {
default: v(() => [
i(Y)
]),
_: 1
}, 8, ["title", "ok-text"])
])
]),
_: 1
})
])) : f("", !0)
], 2)) : (m(), c("div", {
key: 1,
class: V([e(s)("menu-list-content"), e(s)("menu-list-content-edit"), e(d)])
}, [
i(x, {
ref_key: "formRef",
ref: k,
"initial-values": {
viewName: t.view?.viewName
}
}, {
default: v(() => [
o("div", H, [
i(e(C), { size: 8 }, {
default: v(() => [
i(x.FormItem, { name: "viewName" }, {
default: v(() => [
i(e(B).Text, { maxlength: 20 })
]),
_: 1
}),
o("div", {
class: "menu-list-content-action-text",
onClick: I
}, r(e(n)("ap.apView.save")), 1),
o("div", {
class: "menu-list-content-action-text",
onClick: a[2] || (a[2] = (R) => l.value = !1)
}, r(e(n)("ap.apView.cancel")), 1)
]),
_: 1
})
])
]),
_: 1
}, 8, ["initial-values"])
], 2));
}
});
export {
ve as default
};