UNPKG

@aplus-frontend/ui

Version:

185 lines (184 loc) 6.27 kB
import { defineComponent as I, ref as T, computed as z, watch as $, createBlock as L, openBlock as Y, unref as e, withCtx as t, createElementVNode as c, normalizeClass as r, createVNode as a, createSlots as E, toDisplayString as m, createTextVNode as v } from "vue"; import { Popover as K, Tooltip as R, Space as h, Checkbox as U } from "@aplus-frontend/antdv"; import "../../../config-provider/index.mjs"; import j from "../icons/line-eye.vue.mjs"; import "../../../ap-form/ap-form.vue.mjs"; import { ApField as q } from "../../../ap-field/index.mjs"; import "../../../ap-button/index.mjs"; import B from "dayjs"; import { useViewInject as M } from "../hooks/use-view-provide.mjs"; import { generateUniqueKey as O } from "../utils/uuid.mjs"; import { cloneDeep as g } from "lodash-unified"; import { useLocale as A } from "../../../config-provider/hooks/use-locale.mjs"; import { useNamespace as P } from "../../../config-provider/hooks/use-namespace.mjs"; import d from "../../../ap-form/ap-form.vue2.mjs"; import y from "../../../ap-button/ap-button.vue.mjs"; const me = /* @__PURE__ */ I({ __name: "main-button-content", props: { maxViewNum: {} }, setup(x) { const u = x, { t: o } = A(), { b: n } = P("ap-view"), w = T(), { tableKey: N, popoverOpen: s, viewList: p, saveDataSource: V, viewListCRUD: F } = M(), _ = z({ get: () => s.value && p.value.length < u.maxViewNum + 1, set: (l) => { p.value.length < u.maxViewNum + 1 && (s.value = l); } }); $(s, (l) => { l && (w.value?.resetFields(), setTimeout(() => { w.value?.setFieldsValue({ isDefault: !p.value.some((i) => i.isDefault) }); })); }); const b = async (l) => { const { viewName: i, isDefault: f } = l, D = O(), k = g( V?.getSearchFormValues?.( !!V?.searchFormTransform ) ), C = g(V?.getSearchFormSorterItems?.()), S = { searchForm: k, sorterItems: C }; await F.addView?.({ tableKey: N, viewKey: D, viewName: i, isDefault: f, viewConfig: S }), s.value = !1; }; return (l, i) => (Y(), L(e(K), { open: _.value, "onUpdate:open": i[1] || (i[1] = (f) => _.value = f), placement: "bottom", trigger: "click", arrow: !1, "overlay-inner-style": { padding: "12px 16px" } }, { content: t(() => [ c("div", { class: r([e(n)("main-content-popover")]) }, [ a(d, { ref_key: "formRef", ref: w, layout: "vertical", "initial-values": { viewName: `${e(o)("ap.apView.newView")} ${e(B)().format("YYYY-MM-DD").toString()}` }, onFinish: b }, { default: t(() => [ c("div", { class: r([e(n)("main-content-popover-title-content")]) }, [ c("div", { class: r([e(n)("main-content-popover-title-content-title")]) }, m(e(o)("ap.apView.saveNewView")), 3), a(d.FormItem, { name: "isDefault", "value-prop-name": "checked" }, { default: t(() => [ a(e(U), null, { default: t(() => [ v(m(e(o)("ap.apView.setDefault")), 1) ]), _: 1 }) ]), _: 1 }) ], 2), a(d.FormItem, { label: e(o)("ap.apView.viewName"), name: "viewName", rules: [{ required: !0, message: e(o)("ap.apView.notEmpty") }] }, { default: t(() => [ a(e(q).Text, { placeholder: e(o)("ap.apView.viewName"), maxlength: 20, "show-count": "" }, null, 8, ["placeholder"]) ]), _: 1 }, 8, ["label", "rules"]), a(d.FormItem, { class: r([e(n)("main-content-popover-btn")]) }, { default: t(() => [ a(e(h), { size: 8 }, { default: t(() => [ a(e(y), { size: "small", onClick: i[0] || (i[0] = (f) => s.value = !1) }, { default: t(() => [ v(m(e(o)("ap.apView.cancel")), 1) ]), _: 1 }), a(e(y), { type: "primary", size: "small", "html-type": "submit" }, { default: t(() => [ v(m(e(o)("ap.apView.save")), 1) ]), _: 1 }) ]), _: 1 }) ]), _: 1 }, 8, ["class"]) ]), _: 1 }, 8, ["initial-values"]) ], 2) ]), default: t(() => [ c("div", { class: r({ [e(n)("main-content")]: !0, [e(n)("main-content-disabled")]: e(p).length >= u.maxViewNum + 1 }) }, [ a(e(R), { placement: "bottom" }, E({ default: t(() => [ a(e(h), { size: 4 }, { default: t(() => [ a(j, { class: r([e(n)("icon")]) }, null, 8, ["class"]), c("div", null, m(e(o)("ap.apView.saveView")), 1) ]), _: 1 }) ]), _: 2 }, [ e(p).length >= u.maxViewNum + 1 ? { name: "title", fn: t(() => [ v(m(e(o)("ap.apView.maxTip")), 1) ]), key: "0" } : void 0 ]), 1024) ], 2) ]), _: 1 }, 8, ["open"])); } }); export { me as default };