SDrawer.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { ref as f, watch as b, watchEffect as g, openBlock as l, createBlock as r, withCtx as n, createElementVNode as c, renderSlot as m, createCommentVNode as s, createTextVNode as p, toDisplayString as h } from "vue";
  2. import { n as $, B as C } from "./index2.js";
  3. import { _ as k } from "./index7.js";
  4. const S = { class: "s-drawer-body" }, B = { class: "s-drawer-footer" }, N = {
  5. __name: "SDrawer",
  6. props: {
  7. value: {
  8. type: Boolean,
  9. default: !1
  10. },
  11. title: {
  12. type: String,
  13. default: ""
  14. },
  15. mode: {
  16. type: String,
  17. default: "right"
  18. },
  19. width: {
  20. type: Number,
  21. default: 500
  22. },
  23. height: {
  24. type: Number,
  25. default: 378
  26. },
  27. footer: {
  28. type: Boolean,
  29. default: !1
  30. }
  31. },
  32. emits: ["update:value", "confirm"],
  33. setup(t, { emit: y }) {
  34. const a = y, o = t, d = f(o.value);
  35. b(
  36. () => o.value,
  37. (e) => {
  38. d.value = e;
  39. },
  40. { immediate: !0 }
  41. );
  42. const v = f(o.mode);
  43. g(() => {
  44. const e = {
  45. left: "",
  46. right: "",
  47. top: "",
  48. bottom: ""
  49. };
  50. Object.keys(e).includes(o.mode) || (console.warn(`当前设置mode【${o.mode}】不在【${e}】中,已默认为【right】`), v.value = "right");
  51. });
  52. const i = () => {
  53. a("update:value", !1);
  54. }, w = () => {
  55. a("update:value", !1), a("confirm");
  56. };
  57. return (e, D) => {
  58. const u = C, _ = k;
  59. return l(), r(_, {
  60. rootClassName: "s-drawer-wrap",
  61. title: t.title,
  62. placement: t.mode,
  63. width: t.width,
  64. visible: d.value,
  65. onClose: i,
  66. bodyStyle: {
  67. padding: 0,
  68. display: "flex",
  69. flexDirection: "column"
  70. }
  71. }, {
  72. default: n(() => [
  73. c("div", S, [
  74. m(e.$slots, "default", {}, void 0, !0)
  75. ]),
  76. c("div", B, [
  77. e.$slots.footer ? m(e.$slots, "footer", {}, void 0, !0, 0) : s("", !0),
  78. !e.$slots.footer && t.footer ? (l(), r(u, {
  79. key: 1,
  80. onClick: i
  81. }, {
  82. default: n(() => [
  83. p(h(e.$l("取消")), 1)
  84. ]),
  85. _: 1
  86. })) : s("", !0),
  87. !e.$slots.footer && t.footer ? (l(), r(u, {
  88. key: 2,
  89. type: "primary",
  90. onClick: w
  91. }, {
  92. default: n(() => [
  93. p(h(e.$l("确定")), 1)
  94. ]),
  95. _: 1
  96. })) : s("", !0)
  97. ])
  98. ]),
  99. _: 3
  100. }, 8, ["title", "placement", "width", "visible"]);
  101. };
  102. }
  103. }, I = /* @__PURE__ */ $(N, [["__scopeId", "data-v-30da4429"]]);
  104. export {
  105. I as default
  106. };