SFormBasicLayout.js 8.2 KB

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