SFormBasicLayout.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import { ref as s, computed as W, watch as X, onMounted as Y, resolveComponent as _, openBlock as a, createElementBlock as c, createVNode as l, withCtx as o, createElementVNode as r, toDisplayString as y, createBlock as f, createTextVNode as k, createCommentVNode as i, renderSlot as g, Fragment as A, renderList as V, normalizeClass as Z, normalizeStyle as ee } from "vue";
  2. import { n as te, aB as ae, y as ne, B as oe } from "./index2.js";
  3. import { S as le } from "./index9.js";
  4. import { _ as se, S as ie } from "./index12.js";
  5. import { T as ue, _ as ce } from "./index13.js";
  6. const re = { class: "title" }, fe = { style: { "margin-right": "10px" } }, de = { class: "btns" }, me = ["id"], ye = {
  7. key: 1,
  8. class: "collapses-content-wrap"
  9. }, pe = { class: "modal" }, ve = /* @__PURE__ */ Object.assign({ name: "SFormBasicLayout" }, {
  10. __name: "SFormBasicLayout",
  11. props: {
  12. loading: {
  13. type: Boolean,
  14. default: !1
  15. },
  16. // 表单主体容器的 id(锚点/表单定位用)
  17. commonId: {
  18. type: String,
  19. default: "form-container"
  20. },
  21. // 页面标题
  22. title: {
  23. type: String,
  24. required: !0
  25. },
  26. subTitle: {
  27. type: String,
  28. default: ""
  29. },
  30. showBtnIcon: {
  31. type: Boolean,
  32. default: !0
  33. },
  34. steps: {
  35. type: Array,
  36. default: () => []
  37. },
  38. stepDefaultActive: {
  39. type: Number,
  40. default: 0
  41. },
  42. // 上一步校验:返回 Promise<boolean>,resolve(false) 时停在当前步
  43. stepValid: {
  44. type: Function,
  45. default: void 0
  46. },
  47. tabs: {
  48. type: Array,
  49. default: () => []
  50. },
  51. tabKey: {
  52. type: Object,
  53. default: () => ({
  54. label: "label",
  55. value: "value"
  56. })
  57. },
  58. formStyle: {
  59. type: Object,
  60. default: () => ({})
  61. },
  62. goBack: {
  63. type: Boolean,
  64. default: !0
  65. },
  66. isShowSave: {
  67. type: Boolean,
  68. default: !0
  69. },
  70. saveBtnText: {
  71. type: String,
  72. default: "保存"
  73. }
  74. },
  75. emits: ["footer-callback", "tabsChange"],
  76. setup(e, { expose: z, emit: D }) {
  77. const u = e, d = D, I = s(null), K = s(null), L = s(null), N = s(null), F = s(null), O = s(null), B = s(8), n = s(0), S = W(() => u.tabKey && u.tabKey.value || "value"), p = s("");
  78. X(() => u.tabs, () => {
  79. const t = u.tabs || [];
  80. if (!t.length) {
  81. p.value = "";
  82. return;
  83. }
  84. const v = S.value;
  85. t.some((m) => m && m[v] === p.value) || (p.value = t[0][v]);
  86. }, { immediate: !0, deep: !0 });
  87. function w() {
  88. d("footer-callback", "cancel");
  89. }
  90. function C() {
  91. n.value--, d("footer-callback", "prev", n.value);
  92. }
  93. function T() {
  94. if (typeof u.stepValid != "function") {
  95. n.value++, d("footer-callback", "next", n.value);
  96. return;
  97. }
  98. u.stepValid(n.value).then((t) => {
  99. t && (n.value++, d("footer-callback", "next", n.value));
  100. });
  101. }
  102. function $() {
  103. d("footer-callback", "save");
  104. }
  105. function j(t) {
  106. p.value = t;
  107. const v = u.tabs.find((m) => m[S.value] === t);
  108. d("tabsChange", v);
  109. }
  110. return Y(() => {
  111. n.value = u.stepDefaultActive;
  112. }), z({
  113. save: $,
  114. rollback: w,
  115. handNext: T,
  116. handPrev: C,
  117. stepActive: n
  118. }), (t, v) => {
  119. const m = _("InfoCircleOutlined"), E = ne, R = le, M = ie, q = se, x = ce, P = ue, G = _("close-outlined"), h = oe, H = _("arrow-left-outlined"), J = _("arrow-right-outlined"), Q = _("save-outlined"), U = ae;
  120. return a(), c("div", {
  121. class: "s-form-basic-layout",
  122. ref_key: "layoutRef",
  123. ref: I
  124. }, [
  125. l(U, { spinning: e.loading }, {
  126. default: o(() => [
  127. r("div", {
  128. class: "tools",
  129. ref_key: "toolsRef",
  130. ref: K
  131. }, [
  132. r("div", re, [
  133. r("span", fe, y(e.title), 1),
  134. e.subTitle ? (a(), f(E, {
  135. key: 0,
  136. placement: "topLeft",
  137. mouseEnterDelay: 0.5,
  138. mouseLeaveDelay: 0.5
  139. }, {
  140. title: o(() => [
  141. k(y(e.subTitle), 1)
  142. ]),
  143. default: o(() => [
  144. l(m)
  145. ]),
  146. _: 1
  147. })) : i("", !0)
  148. ]),
  149. r("div", de, [
  150. l(R, { size: B.value }, {
  151. default: o(() => [
  152. g(t.$slots, "otherBtns", {}, void 0, !0)
  153. ]),
  154. _: 3
  155. }, 8, ["size"])
  156. ])
  157. ], 512),
  158. e.steps && e.steps.length ? (a(), c("div", {
  159. key: 0,
  160. class: "step-wrap",
  161. ref_key: "stepRef",
  162. ref: L
  163. }, [
  164. l(q, {
  165. current: n.value,
  166. type: "navigation"
  167. }, {
  168. default: o(() => [
  169. (a(!0), c(A, null, V(e.steps, (b) => (a(), f(M, {
  170. title: b,
  171. key: b,
  172. disabled: ""
  173. }, null, 8, ["title"]))), 128))
  174. ]),
  175. _: 1
  176. }, 8, ["current"])
  177. ], 512)) : i("", !0),
  178. e.tabs && e.tabs.length ? (a(), c("div", {
  179. key: 1,
  180. class: "tabs-wrap",
  181. ref_key: "tabsRef",
  182. ref: N
  183. }, [
  184. l(P, {
  185. "active-key": p.value,
  186. onChange: j
  187. }, {
  188. default: o(() => [
  189. (a(!0), c(A, null, V(e.tabs, (b) => (a(), f(x, {
  190. tab: b[e.tabKey.label],
  191. key: b[S.value]
  192. }, null, 8, ["tab"]))), 128))
  193. ]),
  194. _: 1
  195. }, 8, ["active-key"])
  196. ], 512)) : i("", !0),
  197. r("div", {
  198. class: Z(["form-layout-main", { whiteBg: !!t.$slots.form }]),
  199. id: e.commonId,
  200. ref_key: "formMain",
  201. ref: F
  202. }, [
  203. t.$slots.form ? (a(), c("div", {
  204. key: 0,
  205. class: "form-container-wrap",
  206. style: ee(e.formStyle)
  207. }, [
  208. g(t.$slots, "form", {}, void 0, !0)
  209. ], 4)) : i("", !0),
  210. t.$slots.collapses ? (a(), c("div", ye, [
  211. g(t.$slots, "collapses", {}, void 0, !0)
  212. ])) : i("", !0)
  213. ], 10, me),
  214. r("div", pe, [
  215. g(t.$slots, "other", {}, void 0, !0)
  216. ]),
  217. r("div", {
  218. class: "s-form-basic-fixed-footer",
  219. ref_key: "footerRef",
  220. ref: O
  221. }, [
  222. l(R, { size: B.value }, {
  223. default: o(() => [
  224. e.goBack ? (a(), f(h, {
  225. key: 0,
  226. class: "btn",
  227. onClick: w
  228. }, {
  229. default: o(() => [
  230. l(G),
  231. k(y(t.$l("取消")), 1)
  232. ]),
  233. _: 1
  234. })) : i("", !0),
  235. e.steps.length ? (a(), f(h, {
  236. key: 1,
  237. class: "btn",
  238. disabled: n.value === e.stepDefaultActive,
  239. onClick: C
  240. }, {
  241. default: o(() => [
  242. l(H),
  243. k(y(t.$l("上一步")), 1)
  244. ]),
  245. _: 1
  246. }, 8, ["disabled"])) : i("", !0),
  247. e.steps.length ? (a(), f(h, {
  248. key: 2,
  249. class: "btn",
  250. type: "primary",
  251. disabled: n.value === e.steps.length - 1,
  252. onClick: T
  253. }, {
  254. default: o(() => [
  255. l(J),
  256. k(y(t.$l("下一步")), 1)
  257. ]),
  258. _: 1
  259. }, 8, ["disabled"])) : i("", !0),
  260. e.isShowSave ? (a(), f(h, {
  261. key: 3,
  262. type: "primary",
  263. onClick: $
  264. }, {
  265. default: o(() => [
  266. l(Q),
  267. k(" " + y(t.$l(e.saveBtnText)), 1)
  268. ]),
  269. _: 1
  270. })) : i("", !0),
  271. g(t.$slots, "footer", {}, void 0, !0)
  272. ]),
  273. _: 3
  274. }, 8, ["size"])
  275. ], 512)
  276. ]),
  277. _: 3
  278. }, 8, ["spinning"])
  279. ], 512);
  280. };
  281. }
  282. }), Be = /* @__PURE__ */ te(ve, [["__scopeId", "data-v-bdf042a5"]]);
  283. export {
  284. Be as default
  285. };