UNPKG

@aplus-frontend/ui

Version:

112 lines (111 loc) 3.76 kB
import { defineComponent as O, useSlots as j, computed as o, createBlock as l, createCommentVNode as x, openBlock as p, unref as r, mergeProps as f, createSlots as S, withCtx as n, createElementVNode as E, normalizeStyle as q, resolveDynamicComponent as k, h as L, createVNode as i, renderList as g, renderSlot as A, normalizeProps as b, guardReactiveProps as v, normalizeClass as F } from "vue"; import { DownOutlined as H } from "@ant-design/icons-vue"; import { DropdownButton as J, Dropdown as K } from "@aplus-frontend/antdv"; import { usePermission as M } from "@aplus-frontend/hooks"; import { useInjectApTable as Q } from "../../ap-table/context.mjs"; import "../../ap-button/index.mjs"; import "../../config-provider/index.mjs"; import "./MenuItemGroup.vue.mjs"; import U from "./style/index.mjs"; import { useNamespace as W } from "../../config-provider/hooks/use-namespace.mjs"; import { useLocale as X } from "../../config-provider/hooks/use-locale.mjs"; import B from "./MenuItemGroup.vue2.mjs"; import Y from "../../ap-button/ap-button.vue.mjs"; const de = /* @__PURE__ */ O({ __name: "ApBatchActionGroup", props: { selectedRows: {}, buttonProps: {}, menuList: {} }, setup(C, { expose: $ }) { const { b: h } = W("ap-batch-action-group"), D = U("ap-batch-action-group"), { t: R } = X(), { columns: T, dataSource: N } = Q(), e = C, { hasPermission: z } = M(), y = j(), w = o( () => e?.buttonProps?.dropdownType || "default" ), a = o( () => e?.buttonProps?.type || "borderLink" ), P = o( () => e?.buttonProps?.content || R("ap.apApBatchActionGroup.batchOperation") ), V = o(() => e?.selectedRows || []), c = o( () => e?.buttonProps?.disabled ?? (Array.isArray(e.selectedRows) ? V.value.length === 0 : !1) ), G = o(() => a.value === "borderLink" ? c.value ? void 0 : "var(--ap-button-border-link-color)" : void 0), u = o(() => e?.menuList?.filter((t) => { if (t === "divider") return !0; let d = t?.ifShow; return !t?.ifShow && t?.auth && (d = () => z(t.auth)), d?.() ?? !0; }) || []); function _() { return e?.buttonProps ? { ...e.buttonProps, type: a.value === "borderLink" ? "default" : a.value } : {}; } return $({ columns: T, dataSource: N }), (t, d) => u.value.length && w.value === "dropdown" ? (p(), l(r(J), f({ key: 0, class: [r(h)(), r(D)] }, { ...t.$attrs, ..._(), disabled: c.value }), S({ overlay: n(() => [ i(B, f({ ...e }, { "menu-list": u.value }), null, 16, ["menu-list"]) ]), default: n(() => [ E("span", { style: q({ color: G.value }) }, [ (p(), l(k(L("span", [P.value])))) ], 4) ]), _: 2 }, [ g(y, (I, s) => ({ name: s, fn: n((m) => [ A(t.$slots, s, b(v(m || {}))) ]) })) ]), 1040, ["class"])) : u.value.length && w.value === "default" ? (p(), l(r(K), { key: 1, class: F([r(h)()]), disabled: c.value }, S({ overlay: n(() => [ i(B, f({ ...e }, { "menu-list": u.value }), null, 16, ["menu-list"]) ]), default: n(() => [ i(r(Y), b(v({ ...t.$attrs, ..._(), type: a.value })), { default: n(() => [ (p(), l(k(L("span", [P.value])))), i(r(H)) ]), _: 1 }, 16) ]), _: 2 }, [ g(y, (I, s) => ({ name: s, fn: n((m) => [ A(t.$slots, s, b(v(m || {}))) ]) })) ]), 1032, ["class", "disabled"])) : x("", !0); } }); export { de as default };