SFormLayout.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import { useSlots as ue, ref as o, computed as I, watch as j, nextTick as re, onMounted as de, onUnmounted as fe, resolveComponent as p, openBlock as l, createElementBlock as f, createVNode as i, withCtx as c, createElementVNode as u, toDisplayString as h, createBlock as m, createTextVNode as w, createCommentVNode as r, renderSlot as g, Fragment as M, renderList as q, normalizeStyle as S, normalizeClass as me } from "vue";
  2. import { n as ve, aA as ye, y as pe, B as he } from "./index2.js";
  3. import { S as be } from "./index9.js";
  4. import { _ as _e, S as ke } from "./index12.js";
  5. import { T as we, _ as ge } from "./index13.js";
  6. const Se = { class: "title" }, $e = { style: { "margin-right": "10px" } }, Be = { class: "btns" }, Ce = { class: "form-layout-main-content" }, Te = {
  7. key: 1,
  8. class: "collapses-content-wrap"
  9. }, Ae = { class: "collapese-container" }, ze = { class: "modal" }, Re = { class: "form-fixed-footer" }, Ve = /* @__PURE__ */ Object.assign({ name: "SFormLayout" }, {
  10. __name: "SFormLayout",
  11. props: {
  12. viewHeight: {
  13. type: Number,
  14. default: 0
  15. },
  16. showAnchor: {
  17. type: Boolean,
  18. default: !0
  19. },
  20. loading: {
  21. type: Boolean,
  22. default: !1
  23. },
  24. // 页面标题
  25. title: {
  26. type: String,
  27. required: !0
  28. },
  29. subTitle: {
  30. type: String,
  31. default: ""
  32. },
  33. showBtnIcon: {
  34. type: Boolean,
  35. default: !0
  36. },
  37. steps: {
  38. type: Array,
  39. default: () => []
  40. },
  41. stepDefaultActive: {
  42. type: Number,
  43. default: 0
  44. },
  45. stepValid: {
  46. type: Function,
  47. default: void 0
  48. },
  49. tabs: {
  50. type: Array,
  51. default: () => []
  52. },
  53. tabKey: {
  54. type: Object,
  55. default: () => ({
  56. label: "label",
  57. value: "value"
  58. })
  59. },
  60. formStyle: {
  61. type: Object,
  62. default: () => ({})
  63. },
  64. goBack: {
  65. type: Boolean,
  66. default: !0
  67. },
  68. isShowSave: {
  69. type: Boolean,
  70. default: !0
  71. },
  72. saveBtnText: {
  73. type: String,
  74. default: window.$l("保存")
  75. },
  76. width: {
  77. type: String,
  78. default: "1000px"
  79. }
  80. },
  81. emits: ["footer-callback", "tabsChange"],
  82. setup(t, { expose: H, emit: P }) {
  83. const n = t, v = P, U = ue(), T = o(null), R = o(null), G = o(null), J = o(null), Q = o(null), V = o(null), F = o(null), N = o(8), W = o({}), $ = o("100%"), D = o(0), a = o(0), A = I(() => n.tabKey && n.tabKey.value || "value"), b = o("");
  84. j(() => n.tabs, () => {
  85. const e = n.tabs || [];
  86. if (!e.length) {
  87. b.value = "";
  88. return;
  89. }
  90. const s = A.value;
  91. e.some((d) => d && d[s] === b.value) || (b.value = e[0][s]);
  92. }, { immediate: !0, deep: !0 });
  93. const X = I(() => n.showAnchor && n.width);
  94. j(X, () => z(), { immediate: !0, deep: !0 });
  95. function K() {
  96. z();
  97. }
  98. function L() {
  99. v("footer-callback", "cancel");
  100. }
  101. function O() {
  102. a.value--, v("footer-callback", "prev", a.value);
  103. }
  104. function E() {
  105. if (!window.$utils.isFunction(n.stepValid)) {
  106. a.value++, v("footer-callback", "next", a.value);
  107. return;
  108. }
  109. n.stepValid(a.value).then((e) => {
  110. e && (a.value++, v("footer-callback", "next", a.value));
  111. });
  112. }
  113. function x() {
  114. v("footer-callback", "save");
  115. }
  116. function Y(e) {
  117. b.value = e;
  118. const s = n.tabs.find((d) => d[A.value] === e);
  119. v("tabsChange", s);
  120. }
  121. function z() {
  122. re(() => {
  123. var B, _;
  124. const e = {}, s = ((B = R.value) == null ? void 0 : B.offsetWidth) || 0, d = ((_ = F.value) == null ? void 0 : _.offsetWidth) || 0;
  125. d + 200 > s ? e.right = "0px" : e.left = n.width, W.value = e, n.showAnchor && U.collapses ? $.value = d + 200 > s ? `${s - 200}px` : n.width : $.value = d > s ? `${s}px` : n.width, D.value = V.value.offsetWidth - 10 + "px";
  126. });
  127. }
  128. let y = null;
  129. return de(() => {
  130. K(), a.value = n.stepDefaultActive, window.ResizeObserver && T.value && (y = new ResizeObserver(() => {
  131. K(), z();
  132. }), y.observe(T.value));
  133. }), fe(() => {
  134. y == null || y.disconnect(), y = null;
  135. }), H({
  136. save: x,
  137. rollback: L,
  138. handNext: E,
  139. handPrev: O,
  140. stepActive: a,
  141. formWidth: $
  142. }), (e, s) => {
  143. const d = p("InfoCircleOutlined"), B = pe, _ = be, Z = ke, ee = _e, te = ge, le = we, ne = p("s-anchor"), oe = p("close-outlined"), C = he, ae = p("arrow-left-outlined"), se = p("arrow-right-outlined"), ie = p("save-outlined"), ce = ye;
  144. return l(), f("div", {
  145. class: "form-layout",
  146. ref_key: "layout",
  147. ref: T
  148. }, [
  149. i(ce, { spinning: t.loading }, {
  150. default: c(() => [
  151. t.title || t.subTitle || e.$slots.otherBtns ? (l(), f("div", {
  152. key: 0,
  153. class: "tools",
  154. ref_key: "toolsRef",
  155. ref: G
  156. }, [
  157. u("div", Se, [
  158. u("span", $e, h(t.title), 1),
  159. t.subTitle ? (l(), m(B, {
  160. key: 0,
  161. placement: "topLeft",
  162. mouseEnterDelay: 0.5,
  163. mouseLeaveDelay: 0.5
  164. }, {
  165. title: c(() => [
  166. w(h(t.subTitle), 1)
  167. ]),
  168. default: c(() => [
  169. i(d)
  170. ]),
  171. _: 1
  172. })) : r("", !0)
  173. ]),
  174. u("div", Be, [
  175. i(_, { size: N.value }, {
  176. default: c(() => [
  177. g(e.$slots, "otherBtns", {}, void 0, !0)
  178. ]),
  179. _: 3
  180. }, 8, ["size"])
  181. ])
  182. ], 512)) : r("", !0),
  183. t.steps && t.steps.length ? (l(), f("div", {
  184. key: 1,
  185. class: "step-wrap",
  186. ref_key: "stepRef",
  187. ref: J
  188. }, [
  189. i(ee, {
  190. current: a.value,
  191. type: "navigation",
  192. size: "small"
  193. }, {
  194. default: c(() => [
  195. (l(!0), f(M, null, q(t.steps, (k) => (l(), m(Z, {
  196. title: k,
  197. key: k,
  198. disabled: !0
  199. }, null, 8, ["title"]))), 128))
  200. ]),
  201. _: 1
  202. }, 8, ["current"])
  203. ], 512)) : r("", !0),
  204. t.tabs && t.tabs.length ? (l(), f("div", {
  205. key: 2,
  206. class: "tabs-wrap",
  207. ref_key: "tabsRef",
  208. ref: Q
  209. }, [
  210. i(le, {
  211. "active-key": b.value,
  212. onChange: Y
  213. }, {
  214. default: c(() => [
  215. (l(!0), f(M, null, q(t.tabs, (k) => (l(), m(te, {
  216. tab: k[t.tabKey.label],
  217. key: k[A.value]
  218. }, null, 8, ["tab"]))), 128))
  219. ]),
  220. _: 1
  221. }, 8, ["active-key"])
  222. ], 512)) : r("", !0),
  223. u("div", Ce, [
  224. u("div", {
  225. class: "border-top",
  226. style: S({
  227. width: D.value
  228. })
  229. }, null, 4),
  230. u("div", {
  231. class: "form-layout-main-scroll",
  232. ref_key: "mainScroll",
  233. ref: R
  234. }, [
  235. u("div", {
  236. class: me(["form-layout-main", { whiteBg: !!e.$slots.form || !!e.$slots.collapses }]),
  237. ref_key: "formMain",
  238. ref: V,
  239. style: S({
  240. width: $.value
  241. }),
  242. id: "form-container"
  243. }, [
  244. e.$slots.form ? (l(), f("div", {
  245. key: 0,
  246. class: "form-container-wrap",
  247. style: S(t.formStyle)
  248. }, [
  249. g(e.$slots, "form", {}, void 0, !0)
  250. ], 4)) : r("", !0),
  251. e.$slots.collapses ? (l(), f("div", Te, [
  252. u("div", Ae, [
  253. g(e.$slots, "collapses", {}, void 0, !0)
  254. ])
  255. ])) : r("", !0)
  256. ], 6)
  257. ], 512),
  258. t.showAnchor && e.$slots.collapses ? (l(), f("div", {
  259. key: 0,
  260. class: "collapses-nav",
  261. style: S(W.value)
  262. }, [
  263. i(ne, { el: "form-layout-main-scroll" })
  264. ], 4)) : r("", !0)
  265. ]),
  266. u("div", ze, [
  267. g(e.$slots, "other", {}, void 0, !0)
  268. ]),
  269. u("div", Re, [
  270. i(_, { size: N.value }, {
  271. default: c(() => [
  272. t.goBack ? (l(), m(C, {
  273. key: 0,
  274. onClick: L,
  275. class: "btn"
  276. }, {
  277. default: c(() => [
  278. i(oe),
  279. w(h(e.$l("取消")), 1)
  280. ]),
  281. _: 1
  282. })) : r("", !0),
  283. t.steps.length ? (l(), m(C, {
  284. key: 1,
  285. class: "btn",
  286. disabled: a.value === t.stepDefaultActive,
  287. onClick: O
  288. }, {
  289. default: c(() => [
  290. i(ae),
  291. w(h(e.$l("上一步")), 1)
  292. ]),
  293. _: 1
  294. }, 8, ["disabled"])) : r("", !0),
  295. t.steps.length ? (l(), m(C, {
  296. key: 2,
  297. class: "btn",
  298. type: "primary",
  299. disabled: a.value === t.steps.length - 1,
  300. onClick: E
  301. }, {
  302. default: c(() => [
  303. i(se),
  304. w(h(e.$l("下一步")), 1)
  305. ]),
  306. _: 1
  307. }, 8, ["disabled"])) : r("", !0),
  308. t.isShowSave ? (l(), m(C, {
  309. key: 3,
  310. type: "primary",
  311. onClick: x
  312. }, {
  313. default: c(() => [
  314. i(ie),
  315. w(" " + h(e.$l(t.saveBtnText)), 1)
  316. ]),
  317. _: 1
  318. })) : r("", !0),
  319. g(e.$slots, "footer", {}, void 0, !0)
  320. ]),
  321. _: 3
  322. }, 8, ["size"])
  323. ]),
  324. u("div", {
  325. class: "calc-width",
  326. ref_key: "caclWidth",
  327. ref: F,
  328. style: S({ width: t.width })
  329. }, null, 4)
  330. ]),
  331. _: 3
  332. }, 8, ["spinning"])
  333. ], 512);
  334. };
  335. }
  336. }), Oe = /* @__PURE__ */ ve(Ve, [["__scopeId", "data-v-6804600c"]]);
  337. export {
  338. Oe as default
  339. };