SSkeletonLayout.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import { ref as u, computed as Y, watch as Z, onMounted as ee, onActivated as te, resolveComponent as V, resolveDirective as ne, openBlock as n, createElementBlock as a, normalizeStyle as v, createElementVNode as d, toDisplayString as C, Fragment as K, renderList as L, withDirectives as j, createBlock as m, withCtx as f, createTextVNode as A, resolveDynamicComponent as le, createCommentVNode as r, vShow as se, renderSlot as D, createVNode as h, nextTick as oe } from "vue";
  2. import { n as ae, B as ie } from "./index2.js";
  3. import { _ as ue, S as re } from "./index10.js";
  4. import { T as ce, _ as de } from "./index11.js";
  5. const fe = { class: "title" }, ye = { class: "btns" }, pe = {
  6. key: 0,
  7. style: { "margin-left": "8px" }
  8. }, ve = {
  9. key: 1,
  10. class: "steps-btns"
  11. }, me = /* @__PURE__ */ Object.assign({ name: "SSkeletonLayout" }, {
  12. __name: "SSkeletonLayout",
  13. props: {
  14. // 页面标题
  15. title: {
  16. type: String,
  17. required: !0
  18. },
  19. // 工具条按钮:[{ key, name, icon, type, show, disabled, action }]
  20. buttons: {
  21. type: Array,
  22. default: () => []
  23. },
  24. tabs: {
  25. type: Array,
  26. default: () => []
  27. },
  28. tabKey: {
  29. type: Object,
  30. default: () => ({
  31. label: "label",
  32. value: "value"
  33. })
  34. },
  35. steps: {
  36. type: Array,
  37. default: () => []
  38. }
  39. },
  40. emits: ["tabsChange", "btnCallback", "stepChange", "stepConfirm"],
  41. setup(s, { emit: F }) {
  42. const _ = F, g = s, x = u(null), N = u(null), P = u(null), O = u(232), y = u(0), b = u(""), z = u(null), R = u(null), p = u(0), E = u(0), B = Y(() => g.tabKey && g.tabKey.value || "value");
  43. Z(() => g.tabs, I, { immediate: !0, deep: !0 });
  44. const I = () => {
  45. const e = g.tabs || [];
  46. if (!e.length) {
  47. b.value = "";
  48. return;
  49. }
  50. const l = B.value;
  51. e.some((o) => o && o[l] === b.value) || (b.value = e[0][l]);
  52. };
  53. function q(e) {
  54. b.value = e;
  55. const l = g.tabs.find((o) => o[B.value] === e);
  56. _("tabsChange", l);
  57. }
  58. function M(e) {
  59. p.value += e === "prev" ? -1 : 1, _("stepChange", e, p.value);
  60. }
  61. function U() {
  62. _("stepConfirm", p.value);
  63. }
  64. function W() {
  65. oe(() => {
  66. var i, S, w, $, H, T;
  67. const e = ((S = (i = x.value) == null ? void 0 : i.parentNode) == null ? void 0 : S.offsetHeight) || 0, l = ((w = N.value) == null ? void 0 : w.offsetHeight) || 0, o = (($ = P.value) == null ? void 0 : $.offsetHeight) || 0;
  68. y.value = Math.max(e - l - o, 0);
  69. const c = ((H = z.value) == null ? void 0 : H.offsetHeight) || 0, k = ((T = R.value) == null ? void 0 : T.offsetHeight) || 0;
  70. E.value = y.value - c - k;
  71. });
  72. }
  73. ee(() => W()), te(() => W());
  74. const G = {
  75. add: "PlusCircleOutlined",
  76. edit: "FormOutlined",
  77. delete: "DeleteOutlined",
  78. remove: "DeleteOutlined",
  79. import: "UploadOutlined",
  80. export: "DownloadOutlined",
  81. assign: "ClusterOutlined",
  82. execute: "PlayCircleOutlined",
  83. pause: "PauseCircleOutlined",
  84. resume: "PoweroffOutlined",
  85. approve: "HighlightOutlined",
  86. setting: "SettingOutlined",
  87. TopOfType: "VerticalAlignTopOutlined",
  88. TOP: "VerticalAlignTopOutlined",
  89. synchronize: "SyncOutlined"
  90. };
  91. function J(e) {
  92. _("btnCallback", e.key);
  93. }
  94. function X(e) {
  95. return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && G[e.key] || "";
  96. }
  97. const Q = {
  98. mounted(e) {
  99. e.style.cursor = "e-resize", document.addEventListener("selectstart", (l) => {
  100. l.preventDefault();
  101. }), e.onmousedown = (l) => {
  102. const o = l.clientX, c = O.value;
  103. document.onmousemove = (k) => {
  104. const i = k.clientX - o;
  105. if (i < 0) {
  106. if (c + i <= 232) return;
  107. O.value = c + i;
  108. } else {
  109. if (c + i >= 500) return;
  110. O.value = c + i;
  111. }
  112. }, document.onmouseup = () => {
  113. document.onmousemove = document.onmousedown = null;
  114. };
  115. };
  116. }
  117. };
  118. return (e, l) => {
  119. const o = ie, c = V("arrow-left-outlined"), k = V("arrow-right-outlined"), i = V("save-outlined"), S = re, w = ue, $ = de, H = ce, T = ne("action");
  120. return n(), a("div", {
  121. class: "s-skeleton-layout",
  122. ref_key: "layout",
  123. ref: x,
  124. style: v({ backgroundColor: e.bgColor })
  125. }, [
  126. d("div", {
  127. class: "tools",
  128. ref_key: "tools",
  129. ref: N
  130. }, [
  131. d("div", fe, C(s.title), 1),
  132. d("div", ye, [
  133. (n(!0), a(K, null, L(s.buttons, (t) => (n(), a("span", {
  134. class: "item-btn",
  135. key: t.key
  136. }, [
  137. j((n(), m(o, {
  138. class: "btn",
  139. disabled: !!t.disabled,
  140. type: t.type || t.key === "add" ? "primary" : "default",
  141. onClick: (he) => J(t)
  142. }, {
  143. icon: f(() => [
  144. X(t) ? (n(), m(le(X(t)), { key: 0 })) : r("", !0)
  145. ]),
  146. default: f(() => [
  147. A(" " + C(e.$l(t.name)), 1)
  148. ]),
  149. _: 2
  150. }, 1032, ["disabled", "type", "onClick"])), [
  151. [T, t.action || t.key],
  152. [se, t.show !== !1]
  153. ])
  154. ]))), 128)),
  155. e.$slots.otherBtns ? (n(), a("span", pe, [
  156. D(e.$slots, "otherBtns", {}, void 0, !0)
  157. ])) : r("", !0),
  158. s.steps.length > 0 ? (n(), a("span", ve, [
  159. s.steps.length ? (n(), m(o, {
  160. key: 0,
  161. class: "btn",
  162. disabled: p.value === e.stepDefaultActive,
  163. onClick: l[0] || (l[0] = (t) => M("prev"))
  164. }, {
  165. default: f(() => [
  166. h(c),
  167. A(C(e.$l("上一步")), 1)
  168. ]),
  169. _: 1
  170. }, 8, ["disabled"])) : r("", !0),
  171. s.steps.length ? (n(), m(o, {
  172. key: 1,
  173. class: "btn",
  174. type: "primary",
  175. disabled: p.value === s.steps.length - 1,
  176. onClick: l[1] || (l[1] = (t) => M("next"))
  177. }, {
  178. default: f(() => [
  179. h(k),
  180. A(C(e.$l("下一步")), 1)
  181. ]),
  182. _: 1
  183. }, 8, ["disabled"])) : r("", !0),
  184. h(o, {
  185. style: { "margin-right": "8px" },
  186. type: "primary",
  187. onClick: U
  188. }, {
  189. default: f(() => [
  190. h(i),
  191. A(" " + C(e.$l("确认")), 1)
  192. ]),
  193. _: 1
  194. })
  195. ])) : r("", !0)
  196. ])
  197. ], 512),
  198. d("div", {
  199. class: "skeleton-layout-main",
  200. style: v({ height: y.value + "px" })
  201. }, [
  202. e.$slots.tree ? (n(), a("div", {
  203. key: 0,
  204. class: "side s-side-tree",
  205. ref: "side",
  206. style: v([{ height: y.value + "px", width: O.value + "px" }, { "overflow-y": "auto" }])
  207. }, [
  208. D(e.$slots, "tree", {}, void 0, !0)
  209. ], 4)) : r("", !0),
  210. e.$slots.tree ? j((n(), a("div", {
  211. key: 1,
  212. class: "side-bar s-theme-bg",
  213. style: v({ height: y.value + "px" })
  214. }, null, 4)), [
  215. [Q]
  216. ]) : r("", !0),
  217. d("div", {
  218. class: "skeleton-content",
  219. style: v({ height: y.value + "px" })
  220. }, [
  221. s.steps && s.steps.length ? (n(), a("div", {
  222. key: 0,
  223. class: "step-wrap",
  224. ref_key: "stepRef",
  225. ref: R
  226. }, [
  227. h(w, {
  228. current: p.value,
  229. type: "navigation",
  230. size: "small"
  231. }, {
  232. default: f(() => [
  233. (n(!0), a(K, null, L(s.steps, (t) => (n(), m(S, {
  234. title: t,
  235. key: t,
  236. disabled: !0
  237. }, null, 8, ["title"]))), 128))
  238. ]),
  239. _: 1
  240. }, 8, ["current"])
  241. ], 512)) : r("", !0),
  242. s.tabs && s.tabs.length ? (n(), a("div", {
  243. key: 1,
  244. class: "tabs-wrap",
  245. ref_key: "tabsRef",
  246. ref: z
  247. }, [
  248. h(H, {
  249. "active-key": b.value,
  250. onChange: q
  251. }, {
  252. default: f(() => [
  253. (n(!0), a(K, null, L(s.tabs, (t) => (n(), m($, {
  254. tab: t[s.tabKey.label],
  255. key: t[B.value]
  256. }, null, 8, ["tab"]))), 128))
  257. ]),
  258. _: 1
  259. }, 8, ["active-key"])
  260. ], 512)) : r("", !0),
  261. d("div", {
  262. class: "skeleton-container",
  263. style: v({ height: E.value + "px" })
  264. }, [
  265. D(e.$slots, "default", {}, void 0, !0)
  266. ], 4)
  267. ], 4)
  268. ], 4),
  269. d("div", {
  270. class: "other",
  271. ref_key: "other",
  272. ref: P
  273. }, [
  274. D(e.$slots, "other", {}, void 0, !0)
  275. ], 512)
  276. ], 4);
  277. };
  278. }
  279. }), _e = /* @__PURE__ */ ae(me, [["__scopeId", "data-v-b3f920e1"]]);
  280. export {
  281. _e as default
  282. };