UNPKG

quick-admin-vue3-core

Version:

以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板

208 lines (207 loc) 9.65 kB
import { defineComponent as v, computed as B, resolveComponent as E, createElementBlock as c, createBlock as b, unref as t, openBlock as l, mergeProps as C, createVNode as S, createSlots as ee, withCtx as $, createCommentVNode as q, renderSlot as te, Fragment as g, toDisplayString as x, createElementVNode as re, createTextVNode as F, normalizeClass as oe, isRef as R, resolveDynamicComponent as se, renderList as ne } from "vue"; import { _ as ie, Z as le, aM as P, aQ as _, Y as ae, b1 as L, E as ue, b2 as pe, t as h, j, b3 as de, u as N, i as fe } from "./platform-DsTwHxm6.js"; import "./index-C0qRtkRj.js"; /* empty css */ import { u as ce } from "./dict-C-wULPWV.js"; import { E as me } from "./ExplainPopover-BlICMCY2.js"; import { _ as ye } from "./Index.vue_vue_type_script_setup_true_lang-CZl5bpVW.js"; import { c as ke } from "./index-9d6RO4hD.js"; import { _ as ge } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const Ae = { key: 0, class: "mr-h" }, be = { class: "color-danger" }, xe = { key: 0, class: "ml-h" }, qe = ["innerHTML"], Te = /* @__PURE__ */ v({ __name: "Index", props: { modelValue: {}, field: {}, prefixProp: {}, pureText: { type: Boolean }, labelSuffix: {}, inputDebounce: { type: Boolean }, hideLabel: { type: Boolean }, tplType: { default: "common" } }, emits: ["update:modelValue", "blur", "focus", "change"], setup(M, { expose: O, emit: H }) { const { merge: I } = ie, T = M, A = H, { getOpts: U } = ce(); let y = B({ get: () => T.modelValue, set: (o) => A("update:modelValue", o) }); const z = le[T.tplType], r = B(() => { var i; const { field: o, hideLabel: e } = T; if (o.type === "custom") return o; const { tpl: s, type: u = P, rules: d = [], ...f } = o, { rules: a = [], ...p } = _[u] ?? {}, { rules: k = [], ...m } = s ? ae(s, z) : {}, n = I({}, p, m, f, { type: u, rules: Y([...a, ...k, ...d]) }); return (i = p == null ? void 0 : p.attrs) != null && i.getInferredAttrs && (I(n.attrs, p.attrs.getInferredAttrs(n), o.attrs), delete n.attrs.getInferredAttrs), n.rules = G(n), e && delete n.label, delete n.tpl, n; }); function G(o) { const { label: e = "", rules: s = [], required: u } = o; return !u || s.find((d) => d.required) || s.unshift({ required: u, message: e + "必填" }), s; } const w = B(() => { const { before: o, after: e, middleFlexGrow: s = 1 } = r.value.quickAttrs ?? {}; return { [`f-${s}`]: o || e }; }); function J(o) { const e = o.charCodeAt(0); return e >= 97 && e <= 122; } function Q(o) { const e = o.charCodeAt(0); return e >= 65 && e <= 90; } function Y(o = []) { const e = [], s = ["required", "min", "max", "pattern", "validator"]; return o.forEach((u) => { const { type: d } = u, f = o.findIndex((a) => d ? a.type === d : !!s.find((p) => u[p] !== void 0 && a[p] !== void 0)); f === -1 ? e.push(u) : e[f] = u; }), e; } async function Z(o) { if (!o) return []; const e = h(o); if (e === "String") { const s = U(o), u = h(s); if (u === "Array") return s; throw new Error(`暂未处理此类型:${u}`); } if (e === "Array") return o; if (e === "Promise") return await o; throw new Error(`暂未处理此种options的类型:${e}`); } const K = ke(async () => (await W(r.value, y.value)).value); async function W(o, e) { var p, k, m, n; const { type: s = P, label: u, attrs: d = {}, quickAttrs: f = {} } = o, a = await Z(d.options); if (["select", "radio-group"].includes(s)) e = (p = a == null ? void 0 : a.find((i) => i.value === e)) == null ? void 0 : p.label; else if (s.includes("Time") || s.includes("date")) { const { format: i } = I({}, (k = _[s]) == null ? void 0 : k.attrs, d), V = h(e) === "Array", D = ` ${j} `; f != null && f.pureText || T.pureText ? e = V ? e.join(D) : e : e = V ? e.map((X) => X.format(i)).join(D) : e == null ? void 0 : e.format(i); } else if (s === "checkbox-group") e = (m = a == null ? void 0 : a.filter((i) => e.includes(i.value))) == null ? void 0 : m.map((i) => i.label).join(","); else if (s === "input-number") { const { after: i = "" } = f; e && (e = e + i); } else if (s === "switch") { const { activeText: i = "是", inactiveText: V = "否", activeValue: D } = d; e = D === e ? i : V; } else s === "checkbox" ? e = (n = a.find((i) => i.value === e)) == null ? void 0 : n.label : s === "cascader" ? e = de(a, e) : s === "BaseNumberRange" ? e = e == null ? void 0 : e.join(j) : s === "slot" && (e = N); return fe.includes(e) && (e = N), { label: u, value: e }; } return O({}), (o, e) => { var d, f; const s = E("BaseRender"), u = E("el-form-item"); return t(r).type === "custom" ? (l(), c("div", C({ key: 0, class: "mb-18" }, t(r).attrs), [ S(s, { renderData: t(r).renderData ?? t(L)("缺乏renderData") }, null, 8, ["renderData"]) ], 16)) : (l(), b(u, C({ key: 1, class: ["field-item", { "label-h-center": (d = t(r).quickAttrs) == null ? void 0 : d.explain, [`value-v-${((f = t(r).quickAttrs) == null ? void 0 : f.valueAlignContent) ?? ""}`]: !0 }] }, t(ue)(t(r), ["attrs", "quickAttrs", "slots", "tpl"]), { prop: o.prefixProp ? `${o.prefixProp}.${t(r).prop}` : t(r).prop }), ee({ default: $(() => { var a, p, k, m; return [ (a = t(r).quickAttrs) != null && a.before ? (l(), c(g, { key: 0 }, [ typeof t(r).quickAttrs.before == "string" ? (l(), c("div", Ae, x(t(r).quickAttrs.before), 1)) : (l(), b(s, { key: 1, renderData: t(r).quickAttrs.before }, null, 8, ["renderData"])) ], 64)) : q("", !0), t(r).type === "slot" ? te(o.$slots, "custom", { key: 1, field: t(r) }, () => [ re("div", be, "【自定义】" + x(`${t(r).label}${t(r).prop})`), 1) ], !0) : (l(), c(g, { key: 2 }, [ (p = t(r).quickAttrs) != null && p.pureText || o.pureText ? (l(), c(g, { key: 0 }, [ F(x(t(K)), 1) ], 64)) : (l(), c(g, { key: 1 }, [ J(t(r).type) ? (l(), b(ye, { key: 0, modelValue: t(y), "onUpdate:modelValue": e[0] || (e[0] = (n) => R(y) ? y.value = n : y = n), is: t(r).type, class: oe(t(w)), field: t(r), onBlur: e[1] || (e[1] = (n, i) => A("blur", n, t(r).prop, i)), onFocus: e[2] || (e[2] = (n, i) => A("focus", n, t(r).prop, i)), onChange: e[3] || (e[3] = (n, i) => A("change", n, t(r).prop, i)) }, null, 8, ["modelValue", "is", "class", "field"])) : Q(t(r).type) ? (l(), b(se(t(r).type), C({ key: 1, modelValue: t(y), "onUpdate:modelValue": e[4] || (e[4] = (n) => R(y) ? y.value = n : y = n), class: t(w), prefixProp: ["BaseAnyEleList", "BaseAddDelList"].includes(t(r).type) ? t(r).prop : void 0 }, t(r).attrs, { onBlur: e[5] || (e[5] = (n, i) => A("blur", n, t(r).prop, i)), onFocus: e[6] || (e[6] = (n, i) => A("focus", n, t(r).prop, i)), onChange: e[7] || (e[7] = (n, i) => A("change", n, t(r).prop, i)) }), null, 16, ["modelValue", "class", "prefixProp"])) : (l(), c(g, { key: 2 }, [ F(x(t(L)(`不存在此类型:${t(r).type}`)), 1) ], 64)) ], 64)) ], 64)), (k = t(r).quickAttrs) != null && k.after ? (l(), c(g, { key: 3 }, [ typeof t(r).quickAttrs.after == "string" ? (l(), c("div", xe, x(t(r).quickAttrs.after), 1)) : (l(), b(s, { key: 1, renderData: t(r).quickAttrs.after }, null, 8, ["renderData"])) ], 64)) : q("", !0), (m = t(r).quickAttrs) != null && m.tips ? (l(), c(g, { key: 4 }, [ typeof t(r).quickAttrs.tips == "string" ? (l(), c("div", { key: 0, class: "notice", innerHTML: "注:" + t(r).quickAttrs.tips }, null, 8, qe)) : (l(), b(s, { key: 1, renderData: t(r).quickAttrs.tips }, null, 8, ["renderData"])) ], 64)) : q("", !0) ]; }), _: 2 }, [ ne(t(pe)(t(r)), (a, p) => ({ name: p, fn: $((k) => { var m, n; return [ S(s, { renderData: a, scope: k }, null, 8, ["renderData", "scope"]), (m = t(r).quickAttrs) != null && m.explain ? (l(), b(me, { key: 0, explain: (n = t(r).quickAttrs) == null ? void 0 : n.explain }, null, 8, ["explain"])) : q("", !0), o.labelSuffix ? (l(), c(g, { key: 1 }, [ F(x(o.labelSuffix), 1) ], 64)) : q("", !0) ]; }) })) ]), 1040, ["class", "prop"])); }; } }), Se = /* @__PURE__ */ ge(Te, [["__scopeId", "data-v-d146d92a"]]); export { Se as F };