Files
zhibo/node_modules/ele-admin/es/ele-pro-layout/components/pro-tab-context.js
T
xiaoyu 5488f5f0a2 init
2023-05-22 14:07:59 +08:00

64 lines
1.7 KiB
JavaScript

import Locale from "element-ui/lib/mixins/locale";
const proTabContext = {
name: "ProTabContext",
mixins: [Locale],
props: {
active: String,
tabKey: String,
item: Object
},
emits: ["menu-click"],
methods: {
onClick(command) {
this.$emit("menu-click", {
key: command,
tabKey: this.tabKey,
item: this.item,
active: this.active
});
}
},
render(h) {
const hMI = (command, label, icon) => {
return h("el-dropdown-item", { props: { command, icon } }, [label]);
};
const itemNodes = (() => {
const ctxSlot = this.$scopedSlots["context-menu"];
if (typeof ctxSlot === "function") {
return ctxSlot({
tabKey: this.tabKey,
item: this.item,
active: this.active
});
}
return [
hMI("reload", this.t("ele.tabs.reload"), "el-icon-refresh-right"),
hMI("close", this.t("ele.tabs.close"), "el-icon-close"),
hMI("left", this.t("ele.tabs.closeLeft"), "el-icon-back"),
hMI("right", this.t("ele.tabs.closeRight"), "el-icon-right"),
hMI("other", this.t("ele.tabs.closeOther"), "el-icon-remove-outline")
];
})();
return h(
"el-dropdown",
{
class: "ele-admin-tab-context-menu",
props: { trigger: "click", placement: "bottom-start" },
on: { command: this.onClick },
nativeOn: { click: (e) => e.stopPropagation() }
},
[
h("div", { class: "ele-admin-tab-context-el" }),
h(
"el-dropdown-menu",
{ slot: "dropdown", class: "ele-dropdown-menu-pro" },
itemNodes
)
]
);
}
};
export {
proTabContext as default
};