| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- import { ref as l, computed as U, watch as X, onMounted as Y, resolveComponent as w, openBlock as a, createElementBlock as c, createVNode as d, withCtx as v, createElementVNode as s, toDisplayString as m, renderSlot as g, createCommentVNode as i, Fragment as O, renderList as W, createBlock as b, normalizeStyle as A, normalizeClass as Z, createTextVNode as T, nextTick as ee } from "vue";
- import { n as te, ao as ae, B as oe } from "./index2.js";
- import { _ as le, S as ne } from "./index10.js";
- import { T as se, _ as ie } from "./index11.js";
- const ue = { class: "row" }, ce = { class: "title" }, re = { class: "btns" }, fe = {
- key: 0,
- class: "row sub-title-wrap"
- }, de = { class: "sub-title" }, ve = ["id"], ye = {
- key: 1,
- class: "collapses-content-wrap"
- }, me = { class: "modal" }, be = /* @__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(t, { expose: z, emit: E }) {
- const n = t, y = E, R = l(null), q = l(null), V = l(null), K = l(null), N = l(null), x = l(null), F = l("0px"), D = l("100%"), o = l(0), C = U(() => n.tabKey && n.tabKey.value || "value"), p = l("");
- X(() => n.tabs, () => {
- const e = n.tabs || [];
- if (!e.length) {
- p.value = "";
- return;
- }
- const r = C.value;
- e.some((u) => u && u[r] === p.value) || (p.value = e[0][r]);
- }, { immediate: !0, deep: !0 });
- function P() {
- ee(() => {
- var k, _, f, S, B;
- const e = ((k = V.value) == null ? void 0 : k.offsetHeight) || 0, r = ((_ = K.value) == null ? void 0 : _.offsetHeight) || 0, u = ((f = x.value) == null ? void 0 : f.offsetHeight) || 0, $ = n.subTitle ? 34 : 0;
- F.value = (((S = R.value) == null ? void 0 : S.offsetHeight) || 0) - u - e - r - $ - 20 + "px";
- const H = 0;
- D.value = (((B = N.value) == null ? void 0 : B.offsetWidth) || 0) - H + "px";
- });
- }
- function I() {
- y("footer-callback", "cancel");
- }
- function L() {
- o.value--, y("footer-callback", "prev", o.value);
- }
- function j() {
- if (typeof n.stepValid != "function") {
- o.value++, y("footer-callback", "next", o.value);
- return;
- }
- n.stepValid(o.value).then((e) => {
- e && (o.value++, y("footer-callback", "next", o.value));
- });
- }
- function M() {
- y("footer-callback", "save");
- }
- function G(e) {
- p.value = e;
- const r = n.tabs.find((u) => u[C.value] === e);
- y("tabsChange", r);
- }
- return Y(() => {
- P(), o.value = n.stepDefaultActive;
- }), z({
- save: M,
- rollback: I,
- handNext: j,
- handPrev: L,
- stepActive: o
- }), (e, r) => {
- const u = ne, $ = le, H = ie, k = se, _ = w("close-outlined"), f = oe, S = w("arrow-left-outlined"), B = w("arrow-right-outlined"), J = w("save-outlined"), Q = ae;
- return a(), c("div", {
- class: "s-form-basic-layout",
- ref_key: "layoutRef",
- ref: R
- }, [
- d(Q, { spinning: t.loading }, {
- default: v(() => [
- s("div", {
- class: "tools",
- ref_key: "toolsRef",
- ref: q
- }, [
- s("div", ue, [
- s("div", ce, [
- s("span", null, m(t.title), 1)
- ]),
- s("div", re, [
- g(e.$slots, "otherBtns", {}, void 0, !0)
- ])
- ]),
- t.subTitle ? (a(), c("div", fe, [
- s("div", de, m(t.subTitle), 1)
- ])) : i("", !0)
- ], 512),
- t.steps && t.steps.length ? (a(), c("div", {
- key: 0,
- class: "step-wrap",
- ref_key: "stepRef",
- ref: V
- }, [
- d($, {
- current: o.value,
- type: "navigation"
- }, {
- default: v(() => [
- (a(!0), c(O, null, W(t.steps, (h) => (a(), b(u, {
- title: h,
- key: h,
- disabled: ""
- }, null, 8, ["title"]))), 128))
- ]),
- _: 1
- }, 8, ["current"])
- ], 512)) : i("", !0),
- t.tabs && t.tabs.length ? (a(), c("div", {
- key: 1,
- class: "tabs-wrap",
- ref_key: "tabsRef",
- ref: K
- }, [
- d(k, {
- "active-key": p.value,
- onChange: G
- }, {
- default: v(() => [
- (a(!0), c(O, null, W(t.tabs, (h) => (a(), b(H, {
- tab: h[t.tabKey.label],
- key: h[C.value]
- }, null, 8, ["tab"]))), 128))
- ]),
- _: 1
- }, 8, ["active-key"])
- ], 512)) : i("", !0),
- s("div", {
- class: Z(["form-layout-main", { whiteBg: !!e.$slots.form }]),
- id: t.commonId,
- ref_key: "formMain",
- ref: N,
- style: A({ height: F.value })
- }, [
- e.$slots.form ? (a(), c("div", {
- key: 0,
- class: "form-container-wrap",
- style: A(t.formStyle)
- }, [
- g(e.$slots, "form", {}, void 0, !0)
- ], 4)) : i("", !0),
- e.$slots.collapses ? (a(), c("div", ye, [
- g(e.$slots, "collapses", {}, void 0, !0)
- ])) : i("", !0)
- ], 14, ve),
- s("div", me, [
- g(e.$slots, "other", {}, void 0, !0)
- ]),
- s("div", {
- class: "s-form-basic-fixed-footer",
- ref_key: "footer",
- ref: x,
- style: A({ width: D.value })
- }, [
- t.goBack ? (a(), b(f, {
- key: 0,
- class: "btn",
- onClick: I
- }, {
- default: v(() => [
- d(_),
- T(m(e.$l("取消")), 1)
- ]),
- _: 1
- })) : i("", !0),
- t.steps.length ? (a(), b(f, {
- key: 1,
- class: "btn",
- disabled: o.value === t.stepDefaultActive,
- onClick: L
- }, {
- default: v(() => [
- d(S),
- T(m(e.$l("上一步")), 1)
- ]),
- _: 1
- }, 8, ["disabled"])) : i("", !0),
- t.steps.length ? (a(), b(f, {
- key: 2,
- class: "btn",
- type: "primary",
- disabled: o.value === t.steps.length - 1,
- onClick: j
- }, {
- default: v(() => [
- d(B),
- T(m(e.$l("下一步")), 1)
- ]),
- _: 1
- }, 8, ["disabled"])) : i("", !0),
- t.isShowSave ? (a(), b(f, {
- key: 3,
- style: { "margin-right": "8px" },
- type: "primary",
- onClick: M
- }, {
- default: v(() => [
- d(J),
- T(" " + m(e.$l(t.saveBtnText)), 1)
- ]),
- _: 1
- })) : i("", !0),
- g(e.$slots, "footer", {}, void 0, !0)
- ], 4)
- ]),
- _: 3
- }, 8, ["spinning"])
- ], 512);
- };
- }
- }), Se = /* @__PURE__ */ te(be, [["__scopeId", "data-v-3ea83b5c"]]);
- export {
- Se as default
- };
|