SListBasicLayout.js 8.5 KB

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