SSkeletonLayout.js 9.3 KB

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