UNPKG

@aplus-frontend/ui

Version:

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