UNPKG

quick-admin-vue3-core

Version:

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

105 lines (104 loc) 3.27 kB
import { defineComponent as P, ref as A, watch as L, computed as M, resolveComponent as V, createElementBlock as y, openBlock as p, createBlock as h, createCommentVNode as F, unref as i, Fragment as q, renderList as E, mergeProps as I } from "vue"; import { p as w, g as N } from "./index-C0qRtkRj.js"; import { m as $, o as z, p as x, b as D } from "./platform-DsTwHxm6.js"; import { _ as G } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const H = { class: "footer-btns f-c-c f-0 pt-h pb-h" }, J = /* @__PURE__ */ P({ __name: "FooterBtns", props: { loading: { type: Boolean }, submitBtn: { default: "提交" }, resetBtn: { default: "重置" }, moreBtns: { default: () => [] }, omits: { type: [Boolean, Array], default: !0 }, log: { type: [Boolean, String] }, debug: { type: Boolean }, params: {}, formRef: {}, fetch: {}, afterSuccess: {}, afterFail: {}, afterReset: {} }, emits: ["moreBtns", "submit"], setup(C, { expose: R, emit: S }) { const o = C, B = S, f = A(o.loading), _ = w(o.submitBtn, "submit"), g = w(o.resetBtn, "reset"); L( () => o.loading, (t) => { f.value = t; } ); const j = M(() => o.moreBtns.map((t) => N(t))); function b() { const { log: t, debug: a, omits: e } = o; return new Promise((s, r) => { let { params: n } = o; const { formRef: l } = o; l && l.validate((c, m) => { if (c) { if (n = $(n), n = z(n, e), (t || a) && (x(n, "req", t), a)) return; s(n); } else { const u = Object.values(m)[0][0]; D(u.message, "error"), r(u); } }); }); } function v(...t) { const [a, e, s, r] = t; b().then((n) => { const { fetch: l, log: c, afterSuccess: m, afterFail: u } = o; if (!l) return B("submit", n, s, r); f.value = !0, l(n).then((d) => { if (c && x(d, "res", c), !m) return s(); m(d, s); }).catch((d) => u == null ? void 0 : u(d)).finally(() => { f.value = !1; }); }); } function k(...t) { const { formRef: a, afterReset: e } = o; a.resetFields(), e == null || e(...t); } function O(...t) { const [a, e, s, r] = t, { name: n, validateForm: l, to: c } = e; if (!c) { if (!l) return B("moreBtns", n, o.params, s, r); b().then((m) => { B("moreBtns", n, m, s, r); }).catch(() => { }); } } return R({ validate: b, submit: v, reset: k }), (t, a) => { const e = V("BaseBtn"); return p(), y("div", H, [ i(_) ? (p(), h(e, { key: 0, tpl: i(_), loading: i(f), onClick: v }, null, 8, ["tpl", "loading"])) : F("", !0), (p(!0), y(q, null, E(i(j), (s, r) => (p(), h(e, { onClick: O, tpl: s, key: r }, null, 8, ["tpl"]))), 128)), i(g) ? (p(), h(e, I({ key: 1 }, i(g).attrs, { tpl: i(g).name, onClick: k }), null, 16, ["tpl"])) : F("", !0) ]); }; } }), W = /* @__PURE__ */ G(J, [["__scopeId", "data-v-982326ab"]]); export { W as F };