el-plus-powerful-table
Version:
## [DOCS](https://peng-xiao-shuai.github.io/vite-vue-admin-docs/zh-CN/component_directive/component/powerful-table-doc.html)
128 lines (127 loc) • 3.85 kB
JavaScript
import { defineComponent as g, inject as y, createVNode as e, Fragment as p, isVNode as k, mergeProps as w } from "vue";
import { ElDropdown as B, ElDropdownMenu as P, ElDropdownItem as h, ElButton as j, ElTooltip as C } from "element-plus";
import { JustifyFunSymbol as M, SizeSymbol as E } from "../../keys.mjs";
import { powerfulTableComponentProp as S, isProperty as T } from "../../powerful-table/src/powerful-table-data.mjs";
import { t as _ } from "../../locale/lang.mjs";
import { LangKey as z } from "../../locale/packages.mjs";
function s(t) {
return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !k(t);
}
const a = /* @__PURE__ */ g({
name: "PTButton",
props: {
...S,
prop: {
type: Object,
default: () => ({})
}
},
emits: ["return-emit", "component-emit"],
setup(t, {
emit: c
}) {
const m = y(M), x = y(E), i = (o, r) => e(j, w({
size: x,
style: o.style || {},
type: "primary",
onClick: (l) => {
if (l.stopPropagation(), !o.isMore) {
if (typeof o.click == "function") {
o.click({
props: t.prop,
params: o.params,
row: t.row,
index: t.index,
btnIndex: r
});
return;
}
typeof o.beforeClick == "function" ? new Promise((n) => {
o.beforeClick({
row: t.row,
index: t.index,
btnIndex: r,
props: t.prop,
params: o.params
}, n);
}).then((n) => {
n && c("return-emit", "btn-click", {
props: t.prop,
params: o.params,
row: t.row,
index: t.index,
btnIndex: r
});
}) : c("return-emit", "btn-click", {
props: t.prop,
params: o.params,
row: t.row,
index: t.index,
btnIndex: r
});
}
}
}, T({
row: t.row,
index: t.index,
props: t.prop
}, o == null ? void 0 : o.property)), {
default: () => [o.text]
}), d = (o, r) => {
let l;
return e(p, null, [o.tip ? e(C, w({
"popper-class": o.tip ? "" : "no-tooltip",
effect: "dark",
content: o.tip,
placement: "top"
}, o.tipProperty), s(l = i(o, r)) ? l : {
default: () => [l]
}) : e(p, null, [i(o, r)])]);
};
return () => {
var o;
return e(p, null, [e("div", {
class: "btnType",
style: {
display: "flex",
alignItems: "center",
width: "100%",
flexWrap: "wrap",
justifyContent: m(t.aligning)
}
}, [e("span", {
style: {
marginRight: t.prop.text ? "10px" : "0px"
}
}, [t.prop.text || ""]), (o = t.prop.data) == null ? void 0 : o.filter((r) => typeof r.showBtn == "function" ? r.showBtn(t.row, t.index) : r.showBtn === void 0 ? !0 : r.showBtn).map((r, l) => Array.isArray(r) ? e(B, {
class: "el-dropdown-more"
}, {
default: () => [e("div", null, [(r.some((n) => n.isMore) ? [r.find((n) => n.isMore)] : [{
tip: _(z.More)
}]).map((n) => e(p, null, [i(n, [l])]))])],
dropdown: () => {
let n;
return e(P, null, s(n = r.filter((u) => !u.isMore).map((u, b) => {
let f;
return e(h, {
key: l
}, s(f = d(u, [l, b])) ? f : {
default: () => [f]
});
})) ? n : {
default: () => [n]
});
}
}) : d(r, [l]))])]);
};
}
});
a.install = (t) => {
t.component(a.name, a);
};
const R = a;
export {
R as PTButton,
a as default
};
//# sourceMappingURL=button.mjs.map