UNPKG

@tuoyuan/web-plus

Version:

基于arco-design-vue的配置化表格表单组件

1,376 lines 915 kB
var dh = Object.defineProperty; var ph = (e, r, t) => r in e ? dh(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t; var Gi = (e, r, t) => ph(e, typeof r != "symbol" ? r + "" : r, t); import { Message as ji, Modal as xh } from "@tuoyuan/web"; import { unref as Y, ref as Se, defineComponent as mt, mergeModels as ft, useSlots as Pa, useAttrs as Ti, onMounted as Da, useModel as pt, reactive as Ut, resolveComponent as de, resolveDirective as G0, withDirectives as Ga, openBlock as te, createBlock as me, mergeProps as Ur, withCtx as ee, createVNode as _e, createElementBlock as Ce, Fragment as Dt, renderList as Xt, normalizeStyle as Ar, normalizeProps as ra, createSlots as Kr, renderSlot as Fe, resolveDynamicComponent as qa, createTextVNode as Ke, toDisplayString as He, createCommentVNode as ye, createElementVNode as Oe, normalizeClass as Ln, computed as ht, h as j0, guardReactiveProps as xn, nextTick as ca, getCurrentInstance as Ms, watch as In, toRefs as vh, isProxy as mh, onUnmounted as gh, isRef as cs, withModifiers as Sn, vShow as us, toRef as _h, watchEffect as wh, useCssVars as yh, onBeforeUnmount as Df, shallowRef as kh } from "vue"; import { d as hr, v as ua, a as Y0, b as Us, u as bh, c as F0, e as Eh } from "./index-D6cWX0HK.js"; import { h as PE, g as BE, f as LE } from "./index-D6cWX0HK.js"; import { request as Th } from "@tuoyuan/gateway-request"; import { Editor as Sh, Toolbar as Fh } from "@wangeditor/editor-for-vue"; import "@wangeditor/editor/dist/css/style.css"; import { Boot as Ch } from "@wangeditor/editor"; import Ah from "json-editor-vue"; async function Wo(e) { try { if (!navigator.clipboard) throw new Error("Clipboard API not supported in this browser"); await navigator.clipboard.writeText(e); } catch (r) { throw r instanceof Error ? r : new Error(`Failed to copy: ${String(r)}`); } } const Ho = { mounted(e, r) { const a = typeof r.value == "string" ? { value: r.value, showTip: !0 } : { showTip: !0, ...r.value }, n = async () => { var i, s; try { await Wo(a.value), a.showTip && ji.success("复制成功"), (i = a.success) == null || i.call(a); } catch (o) { const l = o instanceof Error ? o : new Error("Unknown error"); a.showTip && ji.error(`复制失败: ${l.message}`), (s = a.error) == null || s.call(a, l); } }; e.addEventListener("click", n), e.__copyHandler__ = n, e.__copyValue__ = a.value; }, updated(e, r) { const t = typeof r.value == "string" ? { value: r.value, showTip: !0 } : { showTip: !0, ...r.value }; if (e.__copyValue__ !== t.value) { e.__copyValue__ = t.value, e.__copyHandler__ && e.removeEventListener("click", e.__copyHandler__); const a = async () => { var n, i; try { await Wo(t.value), t.showTip && ji.success("复制成功"), (n = t.success) == null || n.call(t); } catch (s) { const o = s instanceof Error ? s : new Error("Unknown error"); t.showTip && ji.error(`复制失败: ${o.message}`), (i = t.error) == null || i.call(t, o); } }; e.addEventListener("click", a), e.__copyHandler__ = a; } }, unmounted(e) { e.__copyHandler__ && (e.removeEventListener("click", e.__copyHandler__), delete e.__copyHandler__), delete e.__copyValue__; } }, Dh = { install(e) { e.directive("copy", Ho); }, directive: Ho }, hs = /* @__PURE__ */ new WeakMap(), $o = new ResizeObserver((e) => { for (const r of e) { const t = hs.get(r.target); t && t({ width: r.borderBoxSize[0].inlineSize, height: r.borderBoxSize[0].blockSize }); } }), Xo = { mounted(e, r) { hs.set(e, r.value), $o.observe(e); }, updated(e, r) { hs.set(e, r.value); }, unmounted(e) { $o.unobserve(e), hs.delete(e); } }, Oh = { install(e) { e.directive("resize", Xo); }, directive: Xo }; function Go(e, r) { let t = null; return (a) => { t && clearTimeout(t), t = setTimeout(() => { e(a), t = null; }, r); }; } function jo(e) { return { event: "click", // 默认事件为 click delay: 300, // 默认延迟 300ms ...e.value }; } const Yo = { mounted(e, r) { const t = jo(r); if (!t.handler) return; const a = Go(t.handler, t.delay); e.addEventListener(t.event, a), e.__debounceHandler__ = a, e.__debounceEvent__ = t.event; }, updated(e, r) { e.__debounceHandler__ && e.__debounceEvent__ && e.removeEventListener(e.__debounceEvent__, e.__debounceHandler__); const t = jo(r); if (!t.handler) return; const a = Go(t.handler, t.delay); e.addEventListener(t.event, a), e.__debounceHandler__ = a, e.__debounceEvent__ = t.event; }, unmounted(e) { e.__debounceHandler__ && e.__debounceEvent__ && (e.removeEventListener(e.__debounceEvent__, e.__debounceHandler__), delete e.__debounceHandler__, delete e.__debounceEvent__); } }, Ko = { install(e) { e.directive("debounce", Yo); }, directive: Yo }; function Jo(e, r) { let t = null; return (a) => { const n = Date.now(); (!t || n - t >= r) && (e(a), t = n); }; } function qo(e) { return { event: "click", // 默认事件为 click delay: 300, // 默认间隔 300ms ...e.value }; } const Zo = { mounted(e, r) { const t = qo(r); if (!t.handler) return; const a = Jo(t.handler, t.delay); e.addEventListener(t.event, a), e.__throttleHandler__ = a, e.__throttleEvent__ = t.event; }, updated(e, r) { e.__throttleHandler__ && e.__throttleEvent__ && e.removeEventListener(e.__throttleEvent__, e.__throttleHandler__); const t = qo(r); if (!t.handler) return; const a = Jo(t.handler, t.delay); e.addEventListener(t.event, a), e.__throttleHandler__ = a, e.__throttleEvent__ = t.event; }, unmounted(e) { e.__throttleHandler__ && e.__throttleEvent__ && (e.removeEventListener(e.__throttleEvent__, e.__throttleHandler__), delete e.__throttleHandler__, delete e.__throttleEvent__); } }, Qo = { install(e) { e.directive("throttle", Zo); }, directive: Zo }, Ih = [ { name: "copy", directive: Dh.directive }, { name: "resize", directive: Oh.directive }, { name: "debounce", directive: Ko.directive }, { name: "deb", directive: Ko.directive }, { name: "throttle", directive: Qo.directive }, { name: "thr", directive: Qo.directive } ], Rh = (e) => { Ih.forEach(({ name: r, directive: t }) => { e.directive(r, t); }); }, Wr = (e) => (e.install = (r) => { const t = e.name || e.__name; r.component(t, e); }, e), Nh = (e, r) => { const t = {}; if ((r.type === "input" || r.type === void 0) && (t.allowClear = !0, t.placeholder = `请输入${r.label}`), r.type === "input-password") { const a = hr(r); return delete a.type, { ...t, ...a, msg: null }; } return r.type === "input-number" && (t.placeholder = `请输入${r.label}`), r.type === "textarea" && (t.allowClear = !0, t.showWordLimit = r.showWordLimit ?? !0, t.placeholder = `请输入${r.label}`), r.type === "select" && (t.allowClear = !0, t.placeholder = `请选择${r.label}`, t.options = [], t.options = e[r.field] || r.dicData), r.type === "cascader" && (t.allowClear = !0, t.placeholder = `请选择${r.label}`, t.options = e[r.field] || r.dicData), r.type === "radio" && (t.options = e[r.field] || r.dicData), r.type === "radio-group" && (t.options = e[r.field] || r.dicData), r.type === "checkbox-group" && (t.options = e[r.field] || r.dicData), r.type === "checkbox" && (t.options = e[r.field] || r.dicData), r.type === "date-picker" && (t.placeholder = "请选择日期"), r.type === "time-picker" && (t.allowClear = !0, t.placeholder = "请选择时间"), { ...t, ...r, msg: null, field: null, type: null, onChange: (...a) => { r.onChange && r.onChange(...a); } }; }; function Ph(e, r) { if (!r.trim()) throw new Error("函数体不能为空"); return { ...e }, new Function("builtIns", `with(builtIns) { ${r} }`); } function Bh(e, r) { return Th({ api: e, params: (r == null ? void 0 : r.params) ?? {}, config: { access_token: !0, method: (r == null ? void 0 : r.method) ?? "POST" } }); } const Lh = (e, r) => r.replace(/\[(\w+)\]/g, ".$1").split(".").reduce((t, a) => t && t[a], e), Mh = (e) => { if (typeof e == "string") try { return JSON.parse(e); } catch { return {}; } else if (typeof e == "object" && e !== null) return e; return {}; }; function K0(e) { Y(e).columns.forEach((r) => { r.dicUrl !== void 0 && r.dicUrl !== "" && Bh(r.dicUrl, { params: Mh(r.dicQuery), method: r.dicMethod ?? "POST" }).then((t) => { let a = r.dicBind ? Lh(t.data, r.dicBind ?? "") : t.data; r.dicFormatter !== void 0 && typeof r.dicFormatter == "function" ? (a = r.dicFormatter(a), Array.isArray(a) && Reflect.set(r, "dicData", Se(a))) : Array.isArray(a) && (r.dicData = a); }); }); } function Of(e) { return e.map((r) => { if (r.children && r.children.length > 0) return { ...r, children: Of(r.children) }; const { children: t, ...a } = r; return a; }); } const Uh = { key: 0, class: "form-plus-left-bot" }, Vh = /* @__PURE__ */ mt({ name: "aFormPlus", __name: "main", props: /* @__PURE__ */ ft({ menuRight: { type: Boolean, default: !1 }, option: {}, loading: { type: Boolean, default: !1 }, disabled: { type: Boolean, default: !1 }, alone: { type: Boolean, default: !0 } }, { modelValue: {}, modelModifiers: {} }), emits: /* @__PURE__ */ ft(["submit", "reset", "form-change"], ["update:modelValue"]), setup(e, { expose: r, emit: t }) { const a = Pa(), n = Ti(), i = e, s = Y0; Da(() => { i.alone === !0 && K0(i.option); }); const o = pt(e, "modelValue"), l = Se(null), f = t, c = Ut({}), u = Ut({ submit: !1, reset: !1 }); function h() { u.submit = !1; } const p = ({ values: w, errors: V }) => { V === void 0 && (u.submit = !0, f("submit", w, h)); }; function x() { l.value.resetFields(), l.value.clearValidate(), f("reset"); } function d(w) { return i.option.disabled ?? w ?? !1; } function v(w, V) { f("form-change", w, V, h); } r(new Proxy({}, { get(w, V) { var F; return V === "reset" ? x : V === "done" ? h : (F = l.value) == null ? void 0 : F[V]; }, has(w, V) { return V === "reset" || V === "done" || V in l.value; } })); function g(w) { return ua(w.bind) ? Reflect.get(o.value, w.field) : N(o.value, w.bind); } function y(w, V) { try { w.control && typeof w.control == "string" && Ph( { ev: V, item: w, columns: i.option.columns, form: Y(o) }, w.control )({ ev: V, item: w, columns: i.option.columns, form: Y(o), setColumn: T, getColumn: L }), w.control && typeof w.control == "function" && w.control({ ev: V, item: w, columns: i.option.columns, form: o.value, setColumn: T, getColumn: L }); } catch { } } function m(w, V) { ua(w.bind) ? Reflect.set(o.value, w.field, V) : (o[w.field] = V, B(o.value, w.bind, V)), y(w, V); } const N = (w, V) => V.split(".").reduce((F, U) => F && F[U], w), B = (w, V, F) => { const U = V.split("."), X = U.pop(), z = U.reduce((ne, W) => ne[W] = ne[W] || {}, w); z[X] = F; }, P = (w, V) => { const F = {}; if (Reflect.get(V, "fieldNames") === void 0 && (V.dicLabel || V.dicValue) && (V.fieldNames = { label: V.dicLabel || "label", value: V.dicValue || "value" }), (V.type === "input" || V.type === void 0) && (F.allowClear = !0, F.placeholder = `请输入${V.label}`), V.type === "input-password") { const U = hr(V); return delete U.type, { ...F, ...U, msg: null }; } return V.type === "input-number" && (F.placeholder = `请输入${V.label}`), V.type === "textarea" && (F.allowClear = !0, F.showWordLimit = V.showWordLimit ?? !0, F.placeholder = `请输入${V.label}`), V.type === "select" && (F.allowClear = !0, F.placeholder = `请选择${V.label}`, F.options = [], F.options = w[V.field] || V.dicData), V.type === "cascader" && (F.allowClear = !0, F.placeholder = `请选择${V.label}`, F.options = w[V.field] || V.dicData, V.removeEmptyChildren === !0 && (F.options = Of(F.options))), V.type === "radio" && (F.options = w[V.field] || V.dicData), V.type === "radio-group" && (F.options = w[V.field] || V.dicData), V.type === "checkbox-group" && (F.options = w[V.field] || V.dicData), V.type === "checkbox" && (F.options = w[V.field] || V.dicData), V.type === "date-picker" && (F.placeholder = "请选择日期"), V.type === "time-picker" && (F.allowClear = !0, F.placeholder = "请选择时间"), { ...F, ...V, msg: null, field: null, type: null }; }; function T(w, V, F) { const { found: U, config: X } = R(w, Y(i.option)); if (U) Reflect.set(X, V, F); else throw new Error("字段不存在"); } function L(w) { const { found: V, config: F } = R(w, Y(i.option)); if (V) return F; throw new Error("字段不存在"); } function R(w, V) { const F = V.columns.find((U) => U.field === w); if (F) return { found: !0, config: F }; if (!V.groups) return { found: !1, config: null }; for (const U of V.groups ?? []) { const X = U.columns.find((z) => z.field === w); if (X) return { found: !0, config: X, group: U.label // 可选:返回所属分组的标签 }; } return { found: !1, config: null }; } const K = Se(!1); function j(w) { K.value = w.width < 300; } return (w, V) => { const F = de("icon-question-circle-fill"), U = de("a-tooltip"), X = de("a-form-item"), z = de("a-col"), ne = de("a-row"), W = de("a-button"), we = de("a-space"), be = de("a-form"), b = G0("resize"); return Ga((te(), me(be, Ur({ ref_key: "formRef", ref: l, "auto-label-width": w.option.autoLabelWidth ?? Y(s).autoLabelWidth, layout: w.option.layout ?? Y(s).layout ?? "horizontal", scrollToFirstError: w.option.scrollToFirstError ?? Y(s).scrollToFirstError, size: w.option.size ?? Y(s).size, "label-align": w.option.labelAlign ?? Y(s).labelAlign, model: o.value, onSubmit: p, disabled: w.disabled }, Y(n)), { default: ee(() => [ _e(ne, { class: "form-row__container", justify: w.option.justify ?? Y(s).justify, align: w.option.align ?? Y(s).align, wrap: w.option.wrap ?? Y(s).wrap, cols: 24, fill: "", gutter: w.option.gutter || Y(s).gutter, colGap: w.option.colGap ?? Y(s).colGap, rowGap: w.option.rowGap ?? Y(s).rowGap }, { default: ee(() => [ (te(!0), Ce(Dt, null, Xt(w.option.columns, (I) => (te(), Ce(Dt, { key: I.field }, [ I.display ?? !0 ? (te(), me(z, { key: 0, style: Ar({ marginTop: w.option.marginTop ?? Y(s).marginTop }), span: K.value ? 24 : I.span ?? w.option.span ?? Y(s).span, offset: I.offset ?? 0, order: I.order ?? 0 }, { default: ee(() => [ _e(X, ra({ [(u.submit ? "" : "disabled") || ""]: d(I.disabled), label: I.label, tooltip: I.tooltip, help: I.help, extra: I.extra, "label-component": I.labelComponent, "hide-label": I.hideLabel, "hide-asterisk": I.hideAsterisk, "content-flex": I.contentFlex, feedback: I.feedback, "label-col-style": { paddingRight: "6px", paddingLeft: "2px" }, field: I.bind ?? I.field, rules: I.rules }), Kr({ default: ee(() => [ Y(a)[I.field] ? Fe(w.$slots, I.field, { key: 0, item: I, size: w.option.size ?? Y(s).size }, void 0, !0) : (te(), me(qa(I.component ? I.component : `a-${I.type || "input"}`), Ur({ key: 1, style: { width: I.type === "switch" ? "" : "100%" }, size: w.option.size ?? Y(s).size, disabled: w.option.detail ?? I.disabled ?? !1, modelValue: g(I), "onUpdate:modelValue": (S) => m(I, S), visibility: I.visibility, "onUpdate:visibility": (S) => I.visibility = S, ref_for: !0 }, P(c, I), { onChange: (S) => v(S, I) }), null, 16, ["style", "size", "disabled", "modelValue", "onUpdate:modelValue", "visibility", "onUpdate:visibility", "onChange"])) ]), _: 2 }, [ Y(a)[I.field + "Label"] ? { name: "label", fn: ee(() => [ Fe(w.$slots, I.field + "Label", {}, void 0, !0) ]), key: "0" } : void 0, Y(a)[I.field + "Label"] ? void 0 : { name: "label", fn: ee(() => [ Ke(He(I.label) + " ", 1), I.helpIconText ? (te(), me(U, { key: 0, content: I.helpIconText }, { default: ee(() => [ _e(F, { size: w.option.size ?? Y(s).size }, null, 8, ["size"]) ]), _: 2 }, 1032, ["content"])) : ye("", !0) ]), key: "1" }, Y(a)[I.field + "Help"] || I.help ? { name: "help", fn: ee(() => [ Fe(w.$slots, I.field + "Help", {}, void 0, !0), Oe("span", null, He(I.help), 1) ]), key: "2" } : void 0, Y(a)[I.field + "Extra"] || I.extra ? { name: "extra", fn: ee(() => [ Fe(w.$slots, I.field + "Extra", {}, void 0, !0), Oe("span", null, He(I.extra), 1) ]), key: "3" } : void 0 ]), 1040, ["label", "tooltip", "help", "extra", "label-component", "hide-label", "hide-asterisk", "content-flex", "feedback", "field", "rules"]) ]), _: 2 }, 1032, ["style", "span", "offset", "order"])) : ye("", !0) ], 64))), 128)) ]), _: 3 }, 8, ["justify", "align", "wrap", "gutter", "colGap", "rowGap"]), (te(!0), Ce(Dt, null, Xt(w.option.groups, (I) => (te(), Ce(Dt, null, [ (I.display, te(), me(ne, { key: 0, style: Ar(w.option.groupContainerStyle ?? {}) }, { default: ee(() => [ _e(z, { span: 24 }, { default: ee(() => [ !Y(a)[I.field + "GroupHeader"] && !Y(ua)(I.label) ? (te(), Ce("div", Uh, He(I.label), 1)) : Fe(w.$slots, I.field + "GroupHeader", { key: 1, label: I.label, record: I }, void 0, !0) ]), _: 2 }, 1024), _e(ne, { style: Ar([{ width: "100%" }, w.option.groupColStyle ?? {}]), gutter: I.gutter ?? w.option.gutter ?? 0 }, { default: ee(() => [ (te(!0), Ce(Dt, null, Xt(I.columns, (S) => (te(), Ce(Dt, { key: S.field }, [ S.display ?? !0 ? (te(), me(z, { key: 0, span: K.value ? 24 : S.span ?? w.option.span ?? Y(s).span, offset: S.offset ?? 0, order: S.order ?? 100 }, { default: ee(() => [ _e(X, ra({ "label-col-style": { width: "100px" }, [(u.submit ? "" : "disabled") || ""]: d(S.disabled), label: S.label, tooltip: S.tooltip, help: S.help, extra: S.extra, "label-component": S.labelComponent, "hide-label": S.hideLabel, "hide-asterisk": S.hideAsterisk, "content-flex": S.contentFlex, feedback: S.feedback, field: S.field, rules: S.rules }), Kr({ default: ee(() => [ Y(a)[S.field] ? Fe(w.$slots, S.field, { key: 0, item: S, size: w.option.size ?? Y(s).size }, void 0, !0) : (te(), me(qa(S.component ? S.component : `a-${S.type || "input"}`), Ur({ key: 1, style: { width: S.type === "switch" ? "" : "100%" }, size: w.option.size ?? Y(s).size, disabled: w.option.detail ?? S.disabled ?? !1, modelValue: g(S), "onUpdate:modelValue": (M) => m(S, M), visibility: S.visibility, "onUpdate:visibility": (M) => S.visibility = M, ref_for: !0 }, P(c, S), { onChange: (M) => v(M, S) }), null, 16, ["style", "size", "disabled", "modelValue", "onUpdate:modelValue", "visibility", "onUpdate:visibility", "onChange"])) ]), _: 2 }, [ Y(a)[S.field + "Label"] ? { name: "label", fn: ee(() => [ Fe(w.$slots, S.field + "Label", {}, void 0, !0) ]), key: "0" } : void 0, Y(a)[S.field + "Label"] ? void 0 : { name: "label", fn: ee(() => [ Ke(He(S.label) + " ", 1), S.helpIconText ? (te(), me(U, { key: 0, content: S.helpIconText }, { default: ee(() => [ _e(F, { size: w.option.size ?? Y(s).size }, null, 8, ["size"]) ]), _: 2 }, 1032, ["content"])) : ye("", !0) ]), key: "1" }, Y(a)[S.field + "Help"] || S.help ? { name: "help", fn: ee(() => [ Fe(w.$slots, S.field + "Help", {}, void 0, !0), Oe("span", null, He(S.help), 1) ]), key: "2" } : void 0, Y(a)[S.field + "Extra"] || S.extra ? { name: "extra", fn: ee(() => [ Fe(w.$slots, S.field + "Extra", {}, void 0, !0), Oe("span", null, He(S.extra), 1) ]), key: "3" } : void 0 ]), 1040, ["label", "tooltip", "help", "extra", "label-component", "hide-label", "hide-asterisk", "content-flex", "feedback", "field", "rules"]) ]), _: 2 }, 1032, ["span", "offset", "order"])) : ye("", !0) ], 64))), 128)) ]), _: 2 }, 1032, ["style", "gutter"]) ]), _: 2 }, 1032, ["style"])) ], 64))), 256)), !w.option.search && w.option.detail !== !0 ? (te(), me(ne, { key: 0, class: Ln({ formMenuContainer: w.option.menu ?? !w.option.detail ?? !0 }) }, { default: ee(() => [ w.option.menu ?? !w.option.detail ?? !0 ? (te(), me(z, { key: 0, order: 1e4, span: w.option.menuSpan ?? 24, style: Ar({ textAlign: w.option.menuAlign ?? "center" }) }, { default: ee(() => [ Y(a).menu ? Fe(w.$slots, "menu", { key: 0, size: w.option.size ?? Y(s).size, loading: u.submit }, void 0, !0) : ye("", !0), _e(we, { wrap: "" }, { default: ee(() => [ Fe(w.$slots, "menuLeft", { size: w.option.size ?? Y(s).size, loading: u.submit }, void 0, !0), Fe(w.$slots, "suffix", { loading: u.submit }, () => [ w.option.menuBtn ?? w.option.submitBtn ?? !0 ? (te(), me(W, { key: 0, size: w.option.size ?? Y(s).size, type: "primary", loading: u.submit, "html-type": "submit" }, { default: ee(() => [ Ke(He(w.option.submitBtnText ?? Y(s).submitBtnText), 1) ]), _: 1 }, 8, ["size", "loading"])) : ye("", !0), w.option.menuBtn ?? w.option.resetBtn ?? !0 ? (te(), me(W, { key: 1, size: w.option.size ?? Y(s).size, onClick: V[0] || (V[0] = (I) => x()) }, { default: ee(() => [ Ke(He(w.option.resetBtnText ?? Y(s).resetBtnText), 1) ]), _: 1 }, 8, ["size"])) : ye("", !0) ], !0), Fe(w.$slots, "menuright", { size: w.option.size ?? Y(s).size, loading: u.submit }, void 0, !0) ]), _: 3 }) ]), _: 3 }, 8, ["span", "style"])) : ye("", !0) ]), _: 3 }, 8, ["class"])) : ye("", !0) ]), _: 3 }, 16, ["auto-label-width", "layout", "scrollToFirstError", "size", "label-align", "model", "disabled"])), [ [b, j] ]); }; } }), ga = (e, r) => { const t = e.__vccOpts || e; for (const [a, n] of r) t[a] = n; return t; }, Vs = /* @__PURE__ */ ga(Vh, [["__scopeId", "data-v-87470a8b"]]), zh = { style: { display: "flex", "justify-content": "space-between" } }, Wh = /* @__PURE__ */ mt({ __name: "formModal", props: /* @__PURE__ */ ft({ option: { default: () => ({ columns: [] }) }, type: { default: "add" }, loading: { type: Boolean, default: !1 }, width: {} }, { visible: { default: !1 }, visibleModifiers: {}, formData: { default: {} }, formDataModifiers: {} }), emits: /* @__PURE__ */ ft(["submit", "close"], ["update:visible", "update:formData"]), setup(e, { emit: r }) { Se(Us.size); const t = e, a = r, n = Se(), i = ht(() => Ut({ span: 12, menu: !1, detail: t.type === "view", ...t.option, columns: t.option.columns.map( (h) => Ut({ ...h, slot: h.slot || h.key, slotRight: h.slotRight || h.key + "Right" }) ) })), s = pt(e, "visible"); function o() { n.value.validate().then((h) => { h === void 0 && (c.value = hr(Y(u)), a("submit")); }); } function l() { return a("close"), !1; } function f() { a("close"); } const c = pt(e, "formData"), u = Se({}); return Da(() => { u.value = hr(Y(c)); }), (h, p) => { const x = de("a-button"), d = de("a-space"), v = de("a-modal"); return te(), me(v, { visible: s.value, "onUpdate:visible": p[1] || (p[1] = (g) => s.value = g), okLoading: !0, "body-style": { maxHeight: "calc(100vh - 400px)" }, footer: h.type !== "view", width: h.width, onCancel: f, onClose: f, onBeforeCancel: l }, { title: ee(() => [ Ke(He(h.type === "add" ? "新增" : h.type === "edit" ? "修改" : (h.type === "view", "详情")), 1) ]), footer: ee((g) => [ Oe("div", zh, [ p[3] || (p[3] = Oe("div", null, null, -1)), _e(d, null, { default: ee(() => [ _e(x, { onClick: f, loading: h.loading }, { default: ee(() => p[2] || (p[2] = [ Ke("取消") ])), _: 1 }, 8, ["loading"]), _e(x, { type: "primary", onClick: o, loading: h.loading }, { default: ee(() => [ Ke(He((h.type == "add", "确定")), 1) ]), _: 1 }, 8, ["loading"]) ]), _: 1 }) ]) ]), default: ee(() => [ Fe(h.$slots, "after", { type: t.type }, void 0, !0), Pa().default ? (te(), me(Vs, { key: 1, alone: !1, class: Ln({ "form-modal--view": !0 }), disabled: h.loading, option: i.value, ref_key: "formRef", ref: n, modelValue: u.value, "onUpdate:modelValue": p[0] || (p[0] = (g) => u.value = g) }, null, 8, ["disabled", "option", "modelValue"])) : Fe(h.$slots, "default", { key: 0, type: t.type }, void 0, !0), Fe(h.$slots, "before", { type: t.type }, void 0, !0) ]), _: 3 }, 8, ["visible", "footer", "width"]); }; } }), Hh = /* @__PURE__ */ ga(Wh, [["__scopeId", "data-v-fc589799"]]), $h = { key: 1 }, Xh = { key: 2 }, Gh = ["innerHTML"], jh = { key: 3 }, Yh = /* @__PURE__ */ mt({ __name: "detailModal", props: /* @__PURE__ */ ft({ option: { default: () => ({ columns: [] }) }, type: { default: "add" }, loading: { type: Boolean, default: !1 }, width: {}, dicData: { default: () => ({}) } }, { visible: { default: !1 }, visibleModifiers: {}, formData: { default: {} }, formDataModifiers: {} }), emits: /* @__PURE__ */ ft(["close"], ["update:visible", "update:formData"]), setup(e, { emit: r }) { const t = Pa(), a = e, n = mt({ props: { render: { type: Function, required: !0 }, record: { type: Object, default: () => ({}) } }, render() { const h = { record: this.record }, p = this.render(h); return typeof p == "string" ? j0("div", {}, p) : p; } }), i = r, s = pt(e, "visible"), o = pt(e, "formData"); function l() { return i("close"), !1; } function f() { i("close"); } const c = ht(() => a.option.columns.filter((h) => h.display !== !1 && h.view !== !1).map((h) => ({ ...h, value: o[h.field] ?? "" // 确保每个 item 都有 value 属性 }))); function u(h, p) { const x = h.field, d = h.dicValue ?? "value", v = h.dicLabel ?? "label", g = a.dicData[x] || []; function y(N, B) { for (const P of N) { if (P[d] === B) return P[v]; if (P.children && P.children.length > 0) { const T = y(P.children, B); if (T !== void 0) return T; } } } const m = y(g, p[x]); return m !== void 0 ? m : p[x]; } return (h, p) => { const x = de("a-descriptions-item"), d = de("a-descriptions"), v = de("a-modal"); return te(), me(v, { visible: s.value, "onUpdate:visible": p[0] || (p[0] = (g) => s.value = g), footer: !1, title: "详情", width: h.width, onCancel: f, onClose: f, onBeforeCancel: l }, { default: ee(() => { var g, y; return [ Fe(h.$slots, "after", { type: a.type }), Y(t).default ? (te(), me(d, { key: 1, layout: ((g = h.option) == null ? void 0 : g.detailLayout) ?? "horizontal", column: ((y = a.option) == null ? void 0 : y.detailSpan) ?? 1, data: c.value, bordered: "" }, { default: ee(() => [ (te(!0), Ce(Dt, null, Xt(c.value, (m) => (te(), me(x, { label: m.label, span: 1 }, { default: ee(() => [ m.component ? (te(), me(qa(m.component), { key: 0, modelValue: o.value[m.field], "onUpdate:modelValue": (N) => o.value[m.field] = N, value: m.value }, null, 8, ["modelValue", "onUpdate:modelValue", "value"])) : m.render ? (te(), Ce("span", $h, [ (te(), me(qa(Y(n)), { render: m.render, record: o.value }, null, 8, ["render", "record"])) ])) : m.type === "editor-pro" && !m.component ? (te(), Ce("span", Xh, [ Oe("span", { innerHTML: o.value[m.field] }, null, 8, Gh) ])) : (te(), Ce("span", jh, He(u(m, o.value) ?? o.value[m.field]), 1)) ]), _: 2 }, 1032, ["label"]))), 256)) ]), _: 1 }, 8, ["layout", "column", "data"])) : Fe(h.$slots, "default", { key: 0, type: a.type }), Fe(h.$slots, "before", { type: a.type }) ]; }), _: 3 }, 8, ["visible", "width"]); }; } }), Kh = { key: 1 }, Jh = /* @__PURE__ */ mt({ name: "aCrud", __name: "main", props: /* @__PURE__ */ ft({ option: { default: () => ({ columns: [], data: () => [] }) }, data: {}, beforeOpen: {}, beforeClose: {} }, { modal: { type: Object, default: {} }, modalModifiers: {}, modelValue: { type: Object, default: () => ({}) }, modelModifiers: {} }), emits: /* @__PURE__ */ ft(["onAdd", "onDel", "onEdit", "close"], ["update:modal", "update:modelValue"]), setup(e, { expose: r, emit: t }) { var V; const a = Ti(), n = Pa(), i = Ut({ table: !1, form: !1 }), s = Se("add"), o = e; Da(() => { p(), l(); }); function l() { K0(o.option); } const f = ((V = o.option) == null ? void 0 : V.size) ?? Us.size, c = Ut({ visible: !1, detailVisible: !1, beforeOpen: o.beforeOpen, // 綁定 props 中的 beforeOpen beforeClose: o.beforeClose // 綁定 props 中的 beforeClose }), u = pt(e, "modal"), h = Ut({}); function p() { o.option.columns.forEach((F) => { h["" + F.field] = F.dicData ?? []; }); } const x = (F, U) => { F in h && (h[F] = U), o.option.columns.forEach((X) => { X.field === F && (X.dicData = U); }); }, d = ht(() => Object.assign( { menuWidth: 160 }, o.option, { columns: o.option.columns.map((F) => ({ ...F, slot: F.slot || F.key, slotRight: F.slotRight ?? F.field ?? "Right" })) } )), v = pt(e, "modelValue"), g = t; function y() { i.form = !1, c.visible = !1; } async function m() { c.beforeOpen ? await c.beforeOpen( () => { c.visible = !0, s.value = "add", u.value = {}; }, "add", i.form ) : (c.visible = !0, s.value = "add", u.value = {}); } async function N(F) { u.value = F, c.beforeOpen ? await c.beforeOpen( () => { c.visible = !0, s.value = "edit"; }, "edit", i.form ) : (c.visible = !0, s.value = "edit"); } async function B(F) { u.value = F, c.beforeOpen ? await c.beforeOpen( () => { c.detailVisible = !0, s.value = "view"; }, "view", i.form ) : (c.detailVisible = !0, s.value = "view"); } function P() { try { i.form = !0, s.value === "add" && L(), s.value === "edit" && R(); } catch { } finally { i.form = !1; } } async function T() { c.beforeClose ? await c.beforeClose(() => { c.visible = !1, c.detailVisible = !1, u.value = {}; }, Y(s)) : (c.visible = !1, c.detailVisible = !1, u.value = {}), g("close"); } function L() { ca(() => { g("onAdd", Y(u), y); }); } function R() { ca(() => { g("onEdit", Y(u), y); }); } function K(F) { ca(() => { g("onDel", F); }); } r({ updateDicData: x, updateDicDataAll: p, close: T, setDic: l }); function j(F, U, X) { const z = w.value[F] || [], ne = X.dicValue ?? "value", W = X.dicLabel ?? "label", we = /* @__PURE__ */ new Map(); function be(I) { for (const S of I) we.set(S[ne], S), S.children && S.children.length > 0 && be(S.children); } be(z); const b = we.get(U[X.field]); return b ? b[W] : U[X.field] ?? U[F]; } const w = ht(() => { let F = {}; return o.option.columns.forEach((U) => { F[U.field] = U.dicData ?? []; }), F; }); return (F, U) => { var we, be; const X = de("a-button"), z = de("a-popconfirm"), ne = de("icon-plus-circle"), W = de("a-table-plus"); return te(), Ce(Dt, null, [ _e(W, Ur({ modelValue: v.value, "onUpdate:modelValue": U[0] || (U[0] = (b) => v.value = b), alone: !1, option: d.value, data: F.data }, Y(a)), Kr({ menu: ee(({ record: b, rowIndex: I, column: S }) => { var M, re, J; return [ ((M = o.option) == null ? void 0 : M.viewBtn) ?? !0 ? (te(), me(X, { key: 0, type: "text", onClick: (G) => B(b), size: Y(f) }, { default: ee(() => { var G; return [ Ke(He(((G = o.option) == null ? void 0 : G.viewBtnText) ?? "详情"), 1) ]; }), _: 2 }, 1032, ["onClick", "size"])) : ye("", !0), ((re = o.option) == null ? void 0 : re.editBtn) ?? !0 ? (te(), me(X, { key: 1, type: "text", onClick: (G) => N(b), size: Y(f) }, { default: ee(() => { var G; return [ Ke(He(((G = o.option) == null ? void 0 : G.editBtnText) ?? "修改"), 1) ]; }), _: 2 }, 1032, ["onClick", "size"])) : ye("", !0), Fe(F.$slots, "menu", { record: b, rowIndex: I, column: S }), ((J = o.option) == null ? void 0 : J.delBtn) ?? !0 ? (te(), me(z, { key: 2, content: "确认删除?", position: "left", type: "warning", onOk: (G) => K(b) }, { default: ee(() => [ _e(X, { type: "text", status: "danger", size: Y(f) }, { default: ee(() => { var G; return [ Ke(He(((G = o.option) == null ? void 0 : G.delBtnText) ?? "删除"), 1) ]; }), _: 1 }, 8, ["size"]) ]), _: 2 }, 1032, ["onOk"])) : ye("", !0) ]; }), menuRight: ee(() => { var b; return [ ((b = o.option) == null ? void 0 : b.addBtn) ?? !0 ? (te(), me(X, { key: 0, type: "text", onClick: m }, { icon: ee(() => [ _e(ne) ]), default: ee(() => { var I; return [ Ke(" " + He(((I = o.option) == null ? void 0 : I.addBtnText) ?? "新增"), 1) ]; }), _: 1 })) : ye("", !0), Fe(F.$slots, "menuRight") ]; }), _: 2 }, [ Xt(F.option.columns, (b) => ({ name: b.field, fn: ee(({ record: I, rowIndex: S, column: M }) => [ b.field in Y(n) ? Fe(F.$slots, b.field, { key: 0, record: I, rowIndex: S, column: M, val: j(b.field, I, M) }) : (te(), Ce("span", Kh, He(j(b.field, I, M)), 1)) ]) })) ]), 1040, ["modelValue", "option", "data"]), c.visible ? (te(), me(Hh, { key: 0, visible: c.visible, "onUpdate:visible": U[1] || (U[1] = (b) => c.visible = b), formData: u.value, "onUpdate:formData": U[2] || (U[2] = (b) => u.value = b), option: F.option, loading: i.form, type: s.value, width: ((we = o.option) == null ? void 0 : we.modalWidth) ?? "800px", onSubmit: P, onClose: T }, Kr({ _: 2 }, [ Y(n).modalFormAfter ? { name: "after", fn: ee((b) => [ Fe(F.$slots, "modalFormAfter", ra(xn(b))) ]), key: "0" } : void 0, Y(n).modalFormBefore ? { name: "before", fn: ee((b) => [ Fe(F.$slots, "modalFormBefore", ra(xn(b))) ]), key: "1" } : void 0, Y(n).modalForm ? void 0 : { name: "default", fn: ee((b) => [ Fe(F.$slots, "modalForm", ra(xn(b))) ]), key: "2" } ]), 1032, ["visible", "formData", "option", "loading", "type", "width"])) : ye("", !0), c.detailVisible ? (te(), me(Yh, { key: 1, visible: c.detailVisible, "onUpdate:visible": U[3] || (U[3] = (b) => c.detailVisible = b), formData: u.value, "onUpdate:formData": U[4] || (U[4] = (b) => u.value = b), option: F.option, dicData: w.value, width: ((be = o.option) == null ? void 0 : be.modalWidth) ?? "800px", onClose: T }, Kr({ _: 2 }, [ Y(n).modalViewAfter ? { name: "after", fn: ee((b) => [ Fe(F.$slots, "modalViewAfter", ra(xn(b))) ]), key: "0" } : void 0, Y(n).modalViewBefore ? { name: "before", fn: ee((b) => [ Fe(F.$slots, "modalViewBefore", ra(xn(b))) ]), key: "1" } : void 0, Y(n).modalView ? void 0 : { name: "default", fn: ee((b) => [ Fe(F.$slots, "modalView", ra(xn(b))) ]), key: "2" } ]), 1032, ["visible", "formData", "option", "dicData", "width"])) : ye("", !0) ], 64); }; } }), qh = Wr(Jh), Zh = /* @__PURE__ */ mt({ name: "AEditor", __name: "index", props: { mode: { type: String, default: "default" }, defaultConfig: { type: Object, default: () => ({}) } }, setup(e) { const r = e, t = ht(() => ({ autoFocus: !1, ...r.defaultConfig })); return (a, n) => (te(), me(Y(Sh), { defaultConfig: t.value, mode: e.mode }, null, 8, ["defaultConfig", "mode"])); } }), Qh = /* @__PURE__ */ mt({ name: "AEditorToolbar", __name: "toolbar", props: { editorRef: { type: Object }, mode: { type: String, default: "default" }, defaultConfig: { type: Object, default: () => ({}) } }, setup(e) { const r = e, t = ht(() => ({ toolbarKeys: r.mode === "default" ? a : n, ...r.defaultConfig // insertKeys: { // index: 32, // 插入的位置,基于当前的 toolbarKeys // keys: ["preview"], // }, })), a = [ "headerSelect", "blockquote", "|", "bold", "underline", "italic", { key: "group-more-style", title: "更多", iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M204.8 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M505.6 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path><path d="M806.4 505.6m-76.8 0a76.8 76.8 0 1 0 153.6 0 76.8 76.8 0 1 0-153.6 0Z"></path></svg>', menuKeys: ["through", "code", "sup", "sub", "clearStyle"] }, "color", "bgColor", "|", "fontSize", "fontFamily", "lineHeight", "|", "bulletedList", "numberedList", "todo", { key: "group-justify", title: "对齐", iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M768 793.6v102.4H51.2v-102.4h716.8z m204.8-230.4v102.4H51.2v-102.4h921.6z m-204.8-230.4v102.4H51.2v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z"></path></svg>', menuKeys: ["justifyLeft", "justifyRight", "justifyCenter", "justifyJustify"] }, { key: "group-indent", title: "缩进", iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M0 64h1024v128H0z m384 192h640v128H384z m0 192h640v128H384z m0 192h640v128H384zM0 832h1024v128H0z m0-128V320l256 192z"></path></svg>', menuKeys: ["indent", "delIndent"] }, "|", "emotion", "insertLink", { key: "group-image", title: "图片", iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M959.877 128l0.123 0.123v767.775l-0.123 0.122H64.102l-0.122-0.122V128.123l0.122-0.123h895.775zM960 64H64C28.795 64 0 92.795 0 128v768c0 35.205 28.795 64 64 64h896c35.205 0 64-28.795 64-64V128c0-35.205-28.795-64-64-64zM832 288.01c0 53.023-42.988 96.01-96.01 96.01s-96.01-42.987-96.01-96.01S682.967 192 735.99 192 832 234.988 832 288.01zM896 832H128V704l224.01-384 256 320h64l224.01-192z"></path></svg>', menuKeys: ["insertImage", "uploadImage"] }, { key: "group-video", title: "视频", iconSvg: '<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>', menuKeys: ["insertVideo", "uploadVideo"] }