SFormBasicLayout.js 9.1 KB

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