SListBasicLayout.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. import { ref as o, watch as M, onMounted as ee, onActivated as te, nextTick as N, resolveComponent as g, openBlock as l, createElementBlock as s, createVNode as f, withCtx as y, createElementVNode as u, normalizeStyle as $, renderSlot as a, createTextVNode as ne, toDisplayString as R, createBlock as P, createCommentVNode as i, withDirectives as oe, vShow as le, Fragment as se } from "vue";
  2. import { n as ae, ao as ie, y as ue, B as re } from "./index2.js";
  3. const ce = {
  4. key: 0,
  5. class: "filter-content"
  6. }, de = { class: "filter" }, fe = {
  7. key: 1,
  8. class: "reset-wrap"
  9. }, ye = {
  10. key: 1,
  11. class: "filter-more-content"
  12. }, me = {
  13. key: 2,
  14. class: "desc-wrap"
  15. }, pe = { class: "table-content" }, ve = { class: "table-container" }, he = ["onClick"], _e = { class: "other" }, ge = /* @__PURE__ */ Object.assign({ name: "SListBasicLayout" }, {
  16. __name: "SListBasicLayout",
  17. props: {
  18. // 列表 checkbox 列
  19. isSelection: {
  20. type: Boolean,
  21. default: !1
  22. },
  23. showPagination: {
  24. type: Boolean,
  25. default: !0
  26. },
  27. columns: {
  28. type: Array,
  29. default: () => []
  30. },
  31. rowKey: {
  32. type: [Function, String],
  33. default: "id"
  34. },
  35. loadData: {
  36. type: Function,
  37. required: !0
  38. },
  39. pSize: {
  40. type: [String, Number],
  41. default: 10
  42. },
  43. // 初始勾选的表格行 key
  44. selectedRowKeysArr: {
  45. type: Array,
  46. default: () => []
  47. }
  48. },
  49. emits: ["reset", "tableColCallback"],
  50. setup(c, { expose: T, emit: V }) {
  51. const m = c, x = V, k = o(null), B = o(null), H = o(null), p = o(null), d = o(!1), r = o(0), I = o(0), K = o(!1), z = o(10), E = o(!1), v = o([]), L = o([]), b = o([]);
  52. M(
  53. () => m.columns,
  54. () => D()
  55. ), M(
  56. () => m.selectedRowKeysArr,
  57. (e) => {
  58. v.value = e || [];
  59. },
  60. { immediate: !0 }
  61. );
  62. function j() {
  63. var e;
  64. r.value = (((e = k.value) == null ? void 0 : e.offsetHeight) || 0) - 48, z.value = m.pSize, b.value = m.columns.map((t) => ((t.template || t.isClick || t.dataIndex === "action" && !t.customRender) && !t.scopedSlots && (t.scopedSlots = { customRender: t.dataIndex }), t)), C();
  65. }
  66. function D() {
  67. j();
  68. }
  69. function A() {
  70. d.value = !d.value, C();
  71. }
  72. function F() {
  73. x("reset");
  74. }
  75. function q() {
  76. p.value && p.value.refresh(!0);
  77. }
  78. function O(e, t) {
  79. x("tableColCallback", e, t);
  80. }
  81. function U(e) {
  82. v.value = e;
  83. }
  84. function w(e) {
  85. return b.value.find((t) => t.dataIndex === e);
  86. }
  87. function W(e) {
  88. const t = w(e);
  89. return !!(t && t.template);
  90. }
  91. function G(e) {
  92. const t = w(e);
  93. return !!(t && t.isClick);
  94. }
  95. function J(e) {
  96. return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e;
  97. }
  98. function C() {
  99. N(() => {
  100. var h, _;
  101. const t = ((h = B.value) == null ? void 0 : h.offsetHeight) || 0, S = ((_ = H.value) == null ? void 0 : _.offsetHeight) || 0;
  102. I.value = r.value - t - 134 - S - 24;
  103. });
  104. }
  105. return ee(() => {
  106. D();
  107. }), te(() => {
  108. N(() => {
  109. var e;
  110. r.value = (((e = k.value) == null ? void 0 : e.offsetHeight) || 0) - 48, C();
  111. });
  112. }), T({
  113. reload: q,
  114. table: p,
  115. spinning: K,
  116. selectedRowKeys: v,
  117. filterReset: F,
  118. toggleFilter: A
  119. }), (e, t) => {
  120. const S = g("down-outlined"), h = g("up-outlined"), _ = g("sync-outlined"), Q = re, X = ue, Y = g("s-table"), Z = ie;
  121. return l(), s("div", {
  122. class: "s-list-basic-layout",
  123. ref_key: "layoutRef",
  124. ref: k
  125. }, [
  126. f(Z, { spinning: K.value }, {
  127. default: y(() => [
  128. u("div", {
  129. class: "s-list-basic-layout-main",
  130. style: $({ height: r.value + "px" })
  131. }, [
  132. e.$slots.empty ? (l(), s("div", {
  133. key: 1,
  134. class: "s-list-basic-content",
  135. style: $({ height: r.value + "px" })
  136. }, [
  137. a(e.$slots, "empty", {}, void 0, !0)
  138. ], 4)) : (l(), s("div", {
  139. key: 0,
  140. class: "s-list-basic-content",
  141. style: $({ height: r.value + "px" })
  142. }, [
  143. u("div", {
  144. class: "filter-wrap",
  145. ref_key: "filtersRef",
  146. ref: B
  147. }, [
  148. e.$slots.filter ? (l(), s("div", ce, [
  149. u("div", de, [
  150. a(e.$slots, "filter", {}, void 0, !0)
  151. ]),
  152. e.$slots.filterMore ? (l(), s("a", {
  153. key: 0,
  154. class: "filter-more-btn",
  155. onClick: A
  156. }, [
  157. ne(R(d.value ? e.$l("收起筛选") : e.$l("更多筛选")) + " ", 1),
  158. d.value ? (l(), P(h, {
  159. key: 1,
  160. style: { "font-size": "12px" }
  161. })) : (l(), P(S, {
  162. key: 0,
  163. style: { "font-size": "12px" }
  164. }))
  165. ])) : i("", !0),
  166. e.$slots.filter ? (l(), s("div", fe, [
  167. f(X, {
  168. placement: "top",
  169. overlayStyle: { maxWidth: "500px" },
  170. mouseEnterDelay: 1.5,
  171. mouseLeaveDelay: 0.5
  172. }, {
  173. title: y(() => [
  174. u("span", null, R(e.$l("条件重置")), 1)
  175. ]),
  176. default: y(() => [
  177. f(Q, {
  178. style: { "padding-bottom": "2px" },
  179. onClick: F
  180. }, {
  181. icon: y(() => [
  182. f(_)
  183. ]),
  184. _: 1
  185. })
  186. ]),
  187. _: 1
  188. })
  189. ])) : i("", !0)
  190. ])) : i("", !0),
  191. e.$slots.filterMore ? oe((l(), s("div", ye, [
  192. a(e.$slots, "filterMore", {}, void 0, !0)
  193. ], 512)), [
  194. [le, d.value]
  195. ]) : i("", !0),
  196. e.$slots.desc ? (l(), s("div", me, [
  197. a(e.$slots, "desc", {}, void 0, !0)
  198. ])) : i("", !0)
  199. ], 512),
  200. u("div", pe, [
  201. e.$slots.tabs ? (l(), s("div", {
  202. key: 0,
  203. class: "tabs-wrap",
  204. ref_key: "tabsRef",
  205. ref: H
  206. }, [
  207. a(e.$slots, "tabs", {}, void 0, !0)
  208. ], 512)) : i("", !0),
  209. u("div", ve, [
  210. f(Y, {
  211. ref_key: "table",
  212. ref: p,
  213. size: "middle",
  214. scroll: { y: I.value, x: "100%" },
  215. pageSize: z.value,
  216. rowKey: c.rowKey,
  217. columns: b.value,
  218. data: c.loadData,
  219. "expanded-row-keys": L.value,
  220. "onUpdate:expandedRowKeys": t[0] || (t[0] = (n) => L.value = n),
  221. rowSelection: E.value || c.isSelection ? { selectedRowKeys: v.value, onChange: U } : null,
  222. showPagination: c.showPagination
  223. }, {
  224. bodyCell: y((n) => [
  225. n.column ? (l(), s(se, { key: 0 }, [
  226. W(n.column.dataIndex) ? a(e.$slots, n.column.dataIndex, {
  227. text: n.text,
  228. record: n.record,
  229. index: n.index,
  230. item: w(n.column.dataIndex)
  231. }, void 0, !0, 0) : G(n.column.dataIndex) ? (l(), s("a", {
  232. key: 1,
  233. onClick: (ke) => O(n.column.dataIndex, n.record)
  234. }, R(J(n.text)), 9, he)) : n.column.dataIndex === "action" ? a(e.$slots, "action", {
  235. record: n.record
  236. }, void 0, !0, 2) : i("", !0)
  237. ], 64)) : i("", !0)
  238. ]),
  239. _: 3
  240. }, 8, ["scroll", "pageSize", "rowKey", "columns", "data", "expanded-row-keys", "rowSelection", "showPagination"])
  241. ])
  242. ])
  243. ], 4))
  244. ], 4),
  245. u("div", _e, [
  246. a(e.$slots, "other", {}, void 0, !0)
  247. ])
  248. ]),
  249. _: 3
  250. }, 8, ["spinning"])
  251. ], 512);
  252. };
  253. }
  254. }), Ce = /* @__PURE__ */ ae(ge, [["__scopeId", "data-v-e643138c"]]);
  255. export {
  256. Ce as default
  257. };