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