UNPKG

@aplus-frontend/ui

Version:

196 lines (195 loc) 5.61 kB
import { defineComponent as A, ref as L, unref as n, computed as O, watch as $, createElementBlock as y, openBlock as r, normalizeClass as c, createVNode as m, createElementVNode as v, withCtx as g, toDisplayString as k, createTextVNode as q, createCommentVNode as p, createBlock as b } from "vue"; import { Flex as G, Button as H, Divider as J } from "@aplus-frontend/antdv"; import N from "vuedraggable"; import "../sortable/index.vue.mjs"; import "../../../../config-provider/index.mjs"; import { useProvideSorterMethods as K } from "./context.mjs"; import { useNamespace as P } from "../../../../config-provider/hooks/use-namespace.mjs"; import { useLocale as Q } from "../../../../config-provider/hooks/use-locale.mjs"; import R from "../sortable/index.vue2.mjs"; const W = { key: 0 }, X = { key: 1 }, Y = { key: 2 }, re = /* @__PURE__ */ A({ __name: "index", props: { value: {}, onReset: { type: Function } }, emits: ["update:value"], setup(V, { emit: B }) { const l = L([]), i = L([]), s = L([]), { b: u } = P("column-setting-sorter"), { t: h } = Q(), x = V, S = B; K({ fixedToLeft: I, fixedToRight: M, unFixed: U }); function F(e, t) { const o = t[0].findIndex( (a) => a.key === e.key ); if (~o) t[0].splice(o, 1); else { const a = t[1].findIndex( (f) => f.key === e.key ); t[1].splice(a, 1); } } function _(e, t) { const o = [...n(l.value)], a = [...n(s.value)], f = [...n(i.value)], w = { left: { target: o, search: [f, a] }, right: { target: a, search: [f, o] }, normal: { target: f, search: [o, a] } }[t]; return t === "right" ? w.target.unshift(e) : w.target.push(e), F( e, w.search ), [...o, ...f, ...a]; } function I(e) { const t = _(e, "left"); d(t); } function M(e) { const t = _(e, "right"); d(t); } function U(e) { const t = _(e, "normal"); d(t); } function C(e) { return e.children?.length ? e.children.some((t) => t.show) : e.show; } function T(e, t) { e.value ? e.value.push(t) : e.value = [t]; } const z = O(() => { let e = 0; function t(o) { for (const a of o) a.children?.length ? t(a.children) : a.show && (e += 1); } return t(x.value), e; }); function D(e) { d([...e, ...n(i), ...n(s)]); } function E(e) { d([...n(l), ...e, ...n(s)]); } function j(e) { d([...n(l), ...n(i), ...e]); } function d(e) { S("update:value", e); } return $( () => x.value, (e) => { if (e) { l.value = [], i.value = [], s.value = []; for (const t of e) t.fixed === "left" ? T(l, t) : t.fixed === "right" ? T(s, t) : T(i, t); } }, { immediate: !0 } ), (e, t) => (r(), y("div", { class: c(n(u)()) }, [ m(n(G), { class: c(n(u)("header")), align: "center", justify: "space-between" }, { default: g(() => [ v("span", { class: c(n(u)("header-title")) }, k(n(h)("ap.apTable.setting.selectCount", { count: z.value })), 3), m(n(H), { type: "link", size: "small", style: { padding: "0" }, onClick: x.onReset }, { default: g(() => [ q(k(n(h)("ap.apTable.setting.reset")), 1) ]), _: 1 }, 8, ["onClick"]) ]), _: 1 }, 8, ["class"]), m(n(J), { style: { margin: "0px" } }), v("div", { class: c(n(u)("content")) }, [ l.value.length ? (r(), y("div", W, [ v("span", { class: c(n(u)("section-title")) }, k(n(h)("ap.apTable.setting.fixToLeft")), 3), m(n(N), { "model-value": l.value, "item-key": "key", "onUpdate:modelValue": D }, { item: g(({ element: o }) => [ C(o) ? (r(), b(R, { key: 0, value: o }, null, 8, ["value"])) : p("", !0) ]), _: 1 }, 8, ["model-value"]) ])) : p("", !0), i.value.length ? (r(), y("div", X, [ v("span", { class: c(n(u)("section-title")) }, k(n(h)("ap.apTable.setting.unFixed")), 3), m(n(N), { "model-value": i.value, "item-key": "key", "onUpdate:modelValue": E }, { item: g(({ element: o }) => [ C(o) ? (r(), b(R, { key: 0, value: o }, null, 8, ["value"])) : p("", !0) ]), _: 1 }, 8, ["model-value"]) ])) : p("", !0), s.value.length ? (r(), y("div", Y, [ v("span", { class: c(n(u)("section-title")) }, k(n(h)("ap.apTable.setting.fixToRight")), 3), m(n(N), { "model-value": s.value, "item-key": "key", "onUpdate:modelValue": j }, { item: g(({ element: o }) => [ C(o) ? (r(), b(R, { key: 0, value: o }, null, 8, ["value"])) : p("", !0) ]), _: 1 }, 8, ["model-value"]) ])) : p("", !0) ], 2) ], 2)); } }); export { re as default };