| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- import { ref as i, computed as Q, watch as U, onMounted as W, resolveComponent as _, openBlock as a, createElementBlock as c, createVNode as u, withCtx as o, createElementVNode as r, toDisplayString as y, createBlock as f, createTextVNode as k, createCommentVNode as l, renderSlot as g, Fragment as $, renderList as R, normalizeClass as X, normalizeStyle as Y } from "vue";
- import { n as Z, aA as ee, y as te, B as ae } from "./index2.js";
- import { _ as ne, S as oe } from "./index11.js";
- import { T as le, _ as se } from "./index12.js";
- const ie = { class: "title" }, ue = { style: { "margin-right": "10px" } }, ce = { class: "btns" }, re = ["id"], fe = {
- key: 1,
- class: "collapses-content-wrap"
- }, de = { class: "modal" }, me = /* @__PURE__ */ Object.assign({ name: "SFormBasicLayout" }, {
- __name: "SFormBasicLayout",
- props: {
- loading: {
- type: Boolean,
- default: !1
- },
- // 表单主体容器的 id(锚点/表单定位用)
- commonId: {
- type: String,
- default: "form-container"
- },
- // 页面标题
- title: {
- type: String,
- required: !0
- },
- subTitle: {
- type: String,
- default: ""
- },
- showBtnIcon: {
- type: Boolean,
- default: !0
- },
- steps: {
- type: Array,
- default: () => []
- },
- stepDefaultActive: {
- type: Number,
- default: 0
- },
- // 上一步校验:返回 Promise<boolean>,resolve(false) 时停在当前步
- stepValid: {
- type: Function,
- default: void 0
- },
- tabs: {
- type: Array,
- default: () => []
- },
- tabKey: {
- type: Object,
- default: () => ({
- label: "label",
- value: "value"
- })
- },
- formStyle: {
- type: Object,
- default: () => ({})
- },
- goBack: {
- type: Boolean,
- default: !0
- },
- isShowSave: {
- type: Boolean,
- default: !0
- },
- saveBtnText: {
- type: String,
- default: "保存"
- }
- },
- emits: ["footer-callback", "tabsChange"],
- setup(e, { expose: A, emit: V }) {
- const s = e, d = V, D = i(null), I = i(null), K = i(null), L = i(null), N = i(null), F = i(null), n = i(0), B = Q(() => s.tabKey && s.tabKey.value || "value"), v = i("");
- U(() => s.tabs, () => {
- const t = s.tabs || [];
- if (!t.length) {
- v.value = "";
- return;
- }
- const p = B.value;
- t.some((m) => m && m[p] === v.value) || (v.value = t[0][p]);
- }, { immediate: !0, deep: !0 });
- function S() {
- d("footer-callback", "cancel");
- }
- function w() {
- n.value--, d("footer-callback", "prev", n.value);
- }
- function C() {
- if (typeof s.stepValid != "function") {
- n.value++, d("footer-callback", "next", n.value);
- return;
- }
- s.stepValid(n.value).then((t) => {
- t && (n.value++, d("footer-callback", "next", n.value));
- });
- }
- function T() {
- d("footer-callback", "save");
- }
- function O(t) {
- v.value = t;
- const p = s.tabs.find((m) => m[B.value] === t);
- d("tabsChange", p);
- }
- return W(() => {
- n.value = s.stepDefaultActive;
- }), A({
- save: T,
- rollback: S,
- handNext: C,
- handPrev: w,
- stepActive: n
- }), (t, p) => {
- const m = _("InfoCircleOutlined"), j = te, E = oe, M = ne, x = se, z = le, q = _("close-outlined"), h = ae, P = _("arrow-left-outlined"), G = _("arrow-right-outlined"), H = _("save-outlined"), J = ee;
- return a(), c("div", {
- class: "s-form-basic-layout",
- ref_key: "layoutRef",
- ref: D
- }, [
- u(J, { spinning: e.loading }, {
- default: o(() => [
- r("div", {
- class: "tools",
- ref_key: "toolsRef",
- ref: I
- }, [
- r("div", ie, [
- r("span", ue, y(e.title), 1),
- e.subTitle ? (a(), f(j, {
- key: 0,
- placement: "topLeft",
- mouseEnterDelay: 0.5,
- mouseLeaveDelay: 0.5
- }, {
- title: o(() => [
- k(y(e.subTitle), 1)
- ]),
- default: o(() => [
- u(m)
- ]),
- _: 1
- })) : l("", !0)
- ]),
- r("div", ce, [
- g(t.$slots, "otherBtns", {}, void 0, !0)
- ])
- ], 512),
- e.steps && e.steps.length ? (a(), c("div", {
- key: 0,
- class: "step-wrap",
- ref_key: "stepRef",
- ref: K
- }, [
- u(M, {
- current: n.value,
- type: "navigation"
- }, {
- default: o(() => [
- (a(!0), c($, null, R(e.steps, (b) => (a(), f(E, {
- title: b,
- key: b,
- disabled: ""
- }, null, 8, ["title"]))), 128))
- ]),
- _: 1
- }, 8, ["current"])
- ], 512)) : l("", !0),
- e.tabs && e.tabs.length ? (a(), c("div", {
- key: 1,
- class: "tabs-wrap",
- ref_key: "tabsRef",
- ref: L
- }, [
- u(z, {
- "active-key": v.value,
- onChange: O
- }, {
- default: o(() => [
- (a(!0), c($, null, R(e.tabs, (b) => (a(), f(x, {
- tab: b[e.tabKey.label],
- key: b[B.value]
- }, null, 8, ["tab"]))), 128))
- ]),
- _: 1
- }, 8, ["active-key"])
- ], 512)) : l("", !0),
- r("div", {
- class: X(["form-layout-main", { whiteBg: !!t.$slots.form }]),
- id: e.commonId,
- ref_key: "formMain",
- ref: N
- }, [
- t.$slots.form ? (a(), c("div", {
- key: 0,
- class: "form-container-wrap",
- style: Y(e.formStyle)
- }, [
- g(t.$slots, "form", {}, void 0, !0)
- ], 4)) : l("", !0),
- t.$slots.collapses ? (a(), c("div", fe, [
- g(t.$slots, "collapses", {}, void 0, !0)
- ])) : l("", !0)
- ], 10, re),
- r("div", de, [
- g(t.$slots, "other", {}, void 0, !0)
- ]),
- r("div", {
- class: "s-form-basic-fixed-footer",
- ref_key: "footerRef",
- ref: F
- }, [
- e.goBack ? (a(), f(h, {
- key: 0,
- class: "btn",
- onClick: S
- }, {
- default: o(() => [
- u(q),
- k(y(t.$l("取消")), 1)
- ]),
- _: 1
- })) : l("", !0),
- e.steps.length ? (a(), f(h, {
- key: 1,
- class: "btn",
- disabled: n.value === e.stepDefaultActive,
- onClick: w
- }, {
- default: o(() => [
- u(P),
- k(y(t.$l("上一步")), 1)
- ]),
- _: 1
- }, 8, ["disabled"])) : l("", !0),
- e.steps.length ? (a(), f(h, {
- key: 2,
- class: "btn",
- type: "primary",
- disabled: n.value === e.steps.length - 1,
- onClick: C
- }, {
- default: o(() => [
- u(G),
- k(y(t.$l("下一步")), 1)
- ]),
- _: 1
- }, 8, ["disabled"])) : l("", !0),
- e.isShowSave ? (a(), f(h, {
- key: 3,
- style: { "margin-right": "8px" },
- type: "primary",
- onClick: T
- }, {
- default: o(() => [
- u(H),
- k(" " + y(t.$l(e.saveBtnText)), 1)
- ]),
- _: 1
- })) : l("", !0),
- g(t.$slots, "footer", {}, void 0, !0)
- ], 512)
- ]),
- _: 3
- }, 8, ["spinning"])
- ], 512);
- };
- }
- }), ke = /* @__PURE__ */ Z(me, [["__scopeId", "data-v-362c02d8"]]);
- export {
- ke as default
- };
|