SSuperListLayout.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. var Ee = Object.defineProperty;
  2. var Y = Object.getOwnPropertySymbols;
  3. var Ke = Object.prototype.hasOwnProperty, qe = Object.prototype.propertyIsEnumerable;
  4. var Z = (r, u, d) => u in r ? Ee(r, u, { enumerable: !0, configurable: !0, writable: !0, value: d }) : r[u] = d, L = (r, u) => {
  5. for (var d in u || (u = {}))
  6. Ke.call(u, d) && Z(r, d, u[d]);
  7. if (Y)
  8. for (var d of Y(u))
  9. qe.call(u, d) && Z(r, d, u[d]);
  10. return r;
  11. };
  12. import { ref as a, computed as M, watch as ee, onMounted as Ue, onActivated as Ve, resolveComponent as b, resolveDirective as Ne, openBlock as l, createElementBlock as s, createElementVNode as p, toDisplayString as g, createVNode as c, withCtx as v, Fragment as te, renderList as je, withDirectives as ne, createBlock as R, createTextVNode as D, resolveDynamicComponent as He, createCommentVNode as f, vShow as oe, renderSlot as y, unref as We, nextTick as le, h as Ge } from "vue";
  13. import { n as Je, B as Qe, y as Xe, d0 as Ye } from "./index2.js";
  14. import { S as Ze } from "./index9.js";
  15. const et = { class: "tools" }, tt = { class: "title" }, nt = { class: "btns" }, ot = { class: "list-layout-main" }, lt = {
  16. key: 0,
  17. class: "layout-list-content"
  18. }, at = {
  19. key: 0,
  20. class: "filter-content"
  21. }, it = { class: "filter" }, st = {
  22. key: 1,
  23. class: "reset-wrap"
  24. }, rt = {
  25. key: 1,
  26. class: "filter-more-content"
  27. }, ut = {
  28. key: 2,
  29. class: "desc-wrap"
  30. }, dt = { class: "table-content" }, ct = { class: "table-container" }, ft = ["onClick"], mt = {
  31. key: 1,
  32. class: "layout-list-content"
  33. }, pt = { class: "other" }, vt = /* @__PURE__ */ Object.assign({ name: "SSuperListLayout" }, {
  34. __name: "SSuperListLayout",
  35. props: {
  36. // 页面标题
  37. title: {
  38. type: String,
  39. required: !0
  40. },
  41. // 工具栏按钮配置
  42. buttons: {
  43. type: Array,
  44. default: () => [
  45. {
  46. name: window.$l("添加"),
  47. key: "add",
  48. show: !0,
  49. type: "primary",
  50. icon: !0,
  51. api: null
  52. },
  53. {
  54. name: window.$l("批量删除"),
  55. key: "remove",
  56. action: "remove",
  57. show: !0,
  58. icon: !0,
  59. api: null
  60. },
  61. {
  62. name: window.$l("导入"),
  63. key: "import",
  64. show: !0,
  65. icon: !0,
  66. importColumns: [],
  67. // 预览的表头信息
  68. importUploadUrl: null,
  69. // 上传url
  70. importApis: {
  71. templateDownload: null,
  72. importPreview: null,
  73. importData: null,
  74. exportExceptionData: null
  75. }
  76. },
  77. {
  78. name: window.$l("导出"),
  79. key: "export",
  80. show: !0,
  81. icon: !0,
  82. api: null
  83. }
  84. ]
  85. },
  86. // 列表checkbox列
  87. isSelection: {
  88. type: Boolean,
  89. default: !1
  90. },
  91. // 是否显示分页
  92. showPagination: {
  93. type: Boolean,
  94. default: !0
  95. },
  96. /**
  97. title = String:列标题
  98. * @dataIndex = String:列数据字段名
  99. * @align = String:left || right || center
  100. * @ellipsis = true:是否自动换行
  101. * @isClick = true:是否支持点击跳转
  102. * @template = true:是否使用自定义模板
  103. * @customRender = Function:自定义jsx模板
  104. * @fixed = null:是否固定列 left || right || null 默认null
  105. * @isFixed = false:是否固定列 Boolean fixed存在时无效
  106. * @width = null:列宽 不要写百分比 组件内强制转换成Number
  107. * @filterConfig = 默认null | Object: 自定义筛选配置 {
  108. @filterType = String: SINGLE_SELECT:单选/ MULTIPLE_SELECT:多选/ GANDER:性别/ IS:是否/ USER:用户/ OFFICE:组织机构/ DATE:日期/ DATETIME:时间/ INPUT:输入框 INT:整数/ FLOAT:浮点数/
  109. @filterApi = null:自定义接口 Function => filterType = SINGLE_SELECT || MULTIPLE_SELECT || GANDER || IS 时生效
  110. @filterData = []:自定义数据 Array => filterType = SINGLE_SELECT || MULTIPLE_SELECT || GANDER || IS 时生效 优先级大于 filterApi
  111. @props = Object:自定义属性 使用filterApi时 处理 结果集中的 key、value 键值对映射内容使用
  112. @precision = 0:小数点后保留位数 filterType = FLOAT 时生效
  113. @step = 1:步长 filterType = INT || FLOAT 时生效
  114. @minValue = 0:最小值 filterType = INT || FLOAT 时生效
  115. @maxValue = 0:最大值 filterType = INT || FLOAT 时生效
  116. @length = 200:长度 filterType = INPUT 时生效
  117. @startDate = null :开始可选时间 filterType = DATE || DATETIME 时生效
  118. @endDate = null :结束可选时间 filterType = DATE || DATETIME 时生效
  119. * }
  120. */
  121. columns: {
  122. type: Array,
  123. default: () => []
  124. },
  125. // 行主键字段名
  126. rowKey: {
  127. type: [Function, String],
  128. default: "id"
  129. },
  130. // 取数函数,返回 { list, total }
  131. loadData: {
  132. type: Function,
  133. required: !0
  134. },
  135. // 每页条数
  136. pSize: {
  137. type: [String, Number],
  138. default: 20
  139. }
  140. },
  141. emits: ["reset", "btnCallback", "tableColCallback"],
  142. setup(r, { expose: u, emit: d }) {
  143. const C = r, _ = d, ae = a(null), ie = a(null), se = a(null), m = a(null), E = a(null), K = a(null), re = a(8), I = a(!1), O = a(!1), q = a(300), k = a(!1), U = a(20), V = a(!1), w = a([]), T = a([]), h = a([]), S = a([]), z = a({}), ue = {
  144. add: "PlusCircleOutlined",
  145. edit: "FormOutlined",
  146. delete: "DeleteOutlined",
  147. remove: "DeleteOutlined",
  148. import: "UploadOutlined",
  149. export: "DownloadOutlined",
  150. assign: "ClusterOutlined",
  151. execute: "PlayCircleOutlined",
  152. pause: "PauseCircleOutlined",
  153. resume: "PoweroffOutlined",
  154. approve: "HighlightOutlined",
  155. setting: "SettingOutlined",
  156. TopOfType: "VerticalAlignTopOutlined",
  157. TOP: "VerticalAlignTopOutlined",
  158. synchronize: "SyncOutlined"
  159. }, de = M(() => h.value.filter((e) => e.show !== !1)), N = M(() => S.value.map((e) => e.key).includes("import")), A = M(() => S.value.find((e) => e.key === "import") || {});
  160. ee(
  161. () => C.buttons,
  162. (e) => {
  163. e && e.length && ce(e);
  164. },
  165. { immediate: !0, deep: !0 }
  166. ), ee(
  167. () => C.columns,
  168. (e) => {
  169. W(e || []);
  170. },
  171. { deep: !0, immediate: !0 }
  172. );
  173. function j(e, t = "") {
  174. return !!(e && typeof e == "function");
  175. }
  176. function H(e) {
  177. return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && ue[e.key] || "";
  178. }
  179. function ce(e) {
  180. S.value = e.map((t) => (t.key === "remove" && (V.value = !0), t));
  181. }
  182. function fe(e) {
  183. le(() => {
  184. x(), U.value = C.pSize, h.value = e.map((n) => ((n.template || n.isClick || n.dataIndex === "action" && !n.customRender) && !n.scopedSlots && (n.scopedSlots = { customRender: n.dataIndex }), (n.dataIndex === "action" || n.title === "操作") && (n.fixed = "right"), n));
  185. });
  186. const t = setTimeout(() => {
  187. const n = document.querySelector(".ant-table-cell.ant-table-cell-scrollbar"), i = document.querySelector(".ant-table-thead tr");
  188. n && i && i.removeChild(n), clearTimeout(t);
  189. }, 100);
  190. }
  191. function W(e = []) {
  192. fe(e);
  193. }
  194. function B() {
  195. m.value && m.value.refresh(!0);
  196. }
  197. function G(e) {
  198. _("btnCallback", e.key, w.value);
  199. const t = De[e.key];
  200. typeof t == "function" ? t(e) : P(e);
  201. }
  202. function P(e) {
  203. if (e.selection !== !1 && !w.value.length) {
  204. window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`);
  205. return;
  206. }
  207. if (j(e.api, e.name, e.key)) {
  208. if (e.confirm) {
  209. window.$confirm({
  210. title: `${window.$l(e.name)}`,
  211. content: () => Ge(
  212. "div",
  213. { style: "color:var(--s-color-error)" },
  214. `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}`
  215. ),
  216. onOk: () => {
  217. k.value = !0, e.api(w.value).then(() => {
  218. window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), _("reset");
  219. }).finally(() => {
  220. k.value = !1;
  221. });
  222. }
  223. });
  224. return;
  225. }
  226. k.value = !0, e.api(w.value).then(() => {
  227. window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), _("reset");
  228. }).finally(() => {
  229. k.value = !1;
  230. });
  231. }
  232. }
  233. function J(e, t) {
  234. typeof e == "string" ? Q(e, t) : e.forEach((n) => {
  235. Q(n, t);
  236. });
  237. }
  238. function Q(e, t) {
  239. const n = S.value.find((i) => i.key === e);
  240. if (!n) {
  241. console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`);
  242. return;
  243. }
  244. Object.keys(t).forEach((i) => {
  245. n[i] = t[i];
  246. });
  247. }
  248. function me() {
  249. }
  250. function pe(e) {
  251. P(e);
  252. }
  253. function ve() {
  254. if (!N.value) {
  255. _("btnCallback", "import");
  256. return;
  257. }
  258. I.value = !0;
  259. }
  260. function ye(e) {
  261. j(e.api, e.name, e.key) && (k.value = !0, e.api().then(() => {
  262. k.value = !1;
  263. }));
  264. }
  265. function we(e) {
  266. return C.loadData(L(L({}, e), z.value));
  267. }
  268. function he(e = [], t = 1) {
  269. const n = { filterMode: t, filterConditions: e };
  270. e.forEach((i) => {
  271. ["equal", "includes"].includes(i.equals) && n[i.dataIndex] === void 0 && (n[i.dataIndex] = i.value);
  272. }), z.value = n, m.value && m.value.refresh(!0);
  273. }
  274. function ke() {
  275. z.value = {}, m.value && m.value.refresh(!0);
  276. }
  277. function $e(e) {
  278. h.value = e;
  279. }
  280. function be() {
  281. W(C.columns || []);
  282. }
  283. function ge(e, t) {
  284. _("tableColCallback", e, t);
  285. }
  286. function F(e) {
  287. return h.value.find((t) => t.dataIndex === e);
  288. }
  289. function _e(e) {
  290. const t = F(e);
  291. return !!(t && t.template);
  292. }
  293. function Se(e) {
  294. const t = F(e);
  295. return !!(t && t.isClick);
  296. }
  297. function Ce(e) {
  298. return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e;
  299. }
  300. function Oe(e) {
  301. w.value = e;
  302. }
  303. function x() {
  304. le(Re);
  305. }
  306. function Re() {
  307. const e = m.value && m.value.$el, t = e && e.querySelector(".ant-table-body"), n = t && t.clientHeight;
  308. n && (q.value = Math.max(n - 8, 0));
  309. }
  310. function Ie() {
  311. O.value = !O.value, x();
  312. }
  313. function xe() {
  314. _("reset");
  315. }
  316. const De = {
  317. add: me,
  318. delete: pe,
  319. import: ve,
  320. export: ye,
  321. reload: B,
  322. setStateBtn: J,
  323. handAction: P
  324. };
  325. return Ue(() => {
  326. }), Ve(() => x()), u({
  327. reload: B,
  328. spinning: k,
  329. selectedRowKeys: w,
  330. expandedRowKeys: T,
  331. renderColumns: h,
  332. renderButtons: S,
  333. setStateBtn: J,
  334. btnCallback: G,
  335. table: m,
  336. importVisible: I,
  337. measureLayout: x
  338. }), (e, t) => {
  339. const n = Qe, i = b("SearchOutlined"), Te = b("SettingOutlined"), ze = Ze, X = b("double-right-outlined"), Ae = b("sync-outlined"), Be = Xe, Pe = b("setting-filter"), Fe = b("setting-columns"), Le = b("s-import-modal"), Me = Ne("action");
  340. return l(), s("div", {
  341. class: "list-layout",
  342. ref_key: "layout",
  343. ref: ae
  344. }, [
  345. p("div", et, [
  346. p("div", tt, g(r.title), 1),
  347. p("div", nt, [
  348. c(ze, { size: re.value }, {
  349. default: v(() => [
  350. (l(!0), s(te, null, je(S.value, (o) => (l(), s("span", {
  351. class: "item-btn",
  352. key: o.key
  353. }, [
  354. ne((l(), R(n, {
  355. class: "btn",
  356. disabled: !!o.disabled,
  357. type: o.type || o.key === "add" ? "primary" : "default",
  358. onClick: ($) => G(o)
  359. }, {
  360. icon: v(() => [
  361. H(o) ? (l(), R(He(H(o)), { key: 0 })) : f("", !0)
  362. ]),
  363. default: v(() => [
  364. D(" " + g(e.$l(o.name)), 1)
  365. ]),
  366. _: 2
  367. }, 1032, ["disabled", "type", "onClick"])), [
  368. [Me, o.action || o.key],
  369. [oe, o.show !== !1]
  370. ])
  371. ]))), 128)),
  372. y(e.$slots, "otherBtns", { selections: w.value }, void 0, !0),
  373. c(n, {
  374. class: "btn",
  375. onClick: t[0] || (t[0] = (o) => {
  376. var $;
  377. return ($ = E.value) == null ? void 0 : $.show(h.value);
  378. })
  379. }, {
  380. default: v(() => [
  381. c(i),
  382. D(" " + g(e.$l("高级搜索")), 1)
  383. ]),
  384. _: 1
  385. }),
  386. c(n, {
  387. class: "btn",
  388. onClick: t[1] || (t[1] = (o) => {
  389. var $;
  390. return ($ = K.value) == null ? void 0 : $.show();
  391. })
  392. }, {
  393. default: v(() => [
  394. c(Te),
  395. D(" " + g(e.$l("高级表格")), 1)
  396. ]),
  397. _: 1
  398. })
  399. ]),
  400. _: 3
  401. }, 8, ["size"])
  402. ])
  403. ]),
  404. p("div", ot, [
  405. e.$slots.empty ? (l(), s("div", mt, [
  406. y(e.$slots, "empty", {}, void 0, !0)
  407. ])) : (l(), s("div", lt, [
  408. e.$slots.filter || e.$slots.desc ? (l(), s("div", {
  409. key: 0,
  410. class: "list-filter-wrap",
  411. ref_key: "filters",
  412. ref: ie
  413. }, [
  414. e.$slots.filter ? (l(), s("div", at, [
  415. p("div", it, [
  416. y(e.$slots, "filter", {}, void 0, !0)
  417. ]),
  418. e.$slots.filterMore ? (l(), s("a", {
  419. key: 0,
  420. class: "filter-more-btn",
  421. onClick: Ie
  422. }, [
  423. D(g(O.value ? e.$l("收起") : e.$l("更多")) + " ", 1),
  424. O.value ? (l(), R(X, {
  425. key: 1,
  426. style: { "font-size": "12px", transform: "rotate(-90deg)" }
  427. })) : (l(), R(X, {
  428. key: 0,
  429. style: { "font-size": "12px", transform: "rotate(90deg)" }
  430. }))
  431. ])) : f("", !0),
  432. e.$slots.filter ? (l(), s("div", st, [
  433. c(Be, {
  434. placement: "top",
  435. overlayStyle: { maxWidth: "500px" },
  436. mouseEnterDelay: 1.5,
  437. mouseLeaveDelay: 0.5
  438. }, {
  439. title: v(() => [
  440. p("span", null, g(e.$l("条件重置")), 1)
  441. ]),
  442. default: v(() => [
  443. c(n, {
  444. style: { "padding-bottom": "2px" },
  445. onClick: xe
  446. }, {
  447. icon: v(() => [
  448. c(Ae)
  449. ]),
  450. _: 1
  451. })
  452. ]),
  453. _: 1
  454. })
  455. ])) : f("", !0)
  456. ])) : f("", !0),
  457. e.$slots.filterMore ? ne((l(), s("div", rt, [
  458. y(e.$slots, "filterMore", {}, void 0, !0)
  459. ], 512)), [
  460. [oe, O.value]
  461. ]) : f("", !0),
  462. e.$slots.desc ? (l(), s("div", ut, [
  463. y(e.$slots, "desc", {}, void 0, !0)
  464. ])) : f("", !0)
  465. ], 512)) : f("", !0),
  466. p("div", dt, [
  467. e.$slots.tabs ? (l(), s("div", {
  468. key: 0,
  469. class: "tabs-wrap",
  470. ref_key: "tabs",
  471. ref: se
  472. }, [
  473. y(e.$slots, "tabs", {}, void 0, !0)
  474. ], 512)) : f("", !0),
  475. p("div", ct, [
  476. c(We(Ye), {
  477. ref_key: "table",
  478. ref: m,
  479. size: "middle",
  480. scroll: { y: q.value, x: "100%" },
  481. pageSize: U.value,
  482. rowKey: r.rowKey,
  483. columns: de.value,
  484. data: we,
  485. "expanded-row-keys": T.value,
  486. "onUpdate:expandedRowKeys": t[2] || (t[2] = (o) => T.value = o),
  487. rowSelection: V.value || r.isSelection ? { selectedRowKeys: w.value, onChange: Oe } : null,
  488. showPagination: r.showPagination
  489. }, {
  490. bodyCell: v((o) => [
  491. o.column ? (l(), s(te, { key: 0 }, [
  492. _e(o.column.dataIndex) ? y(e.$slots, o.column.dataIndex, {
  493. text: o.text,
  494. record: o.record,
  495. index: o.index,
  496. item: F(o.column.dataIndex)
  497. }, void 0, !0, 0) : Se(o.column.dataIndex) ? (l(), s("a", {
  498. key: 1,
  499. onClick: ($) => ge(o.column.dataIndex, o.record)
  500. }, g(Ce(o.text)), 9, ft)) : o.column.dataIndex === "action" ? y(e.$slots, "action", {
  501. record: o.record
  502. }, void 0, !0, 2) : f("", !0)
  503. ], 64)) : f("", !0)
  504. ]),
  505. _: 3
  506. }, 8, ["scroll", "pageSize", "rowKey", "columns", "expanded-row-keys", "rowSelection", "showPagination"])
  507. ])
  508. ])
  509. ]))
  510. ]),
  511. c(Pe, {
  512. ref_key: "filterRef",
  513. ref: E,
  514. columns: h.value,
  515. onSubmit: he,
  516. onReset: ke
  517. }, null, 8, ["columns"]),
  518. c(Fe, {
  519. ref_key: "columnsRef",
  520. ref: K,
  521. pageCode: "demo",
  522. columns: h.value,
  523. onSave: $e,
  524. onReset: be
  525. }, null, 8, ["columns"]),
  526. p("div", pt, [
  527. y(e.$slots, "other", {}, void 0, !0)
  528. ]),
  529. N.value ? (l(), R(Le, {
  530. key: 0,
  531. ref: "importModalRef",
  532. "upload-url": A.value.importUploadUrl,
  533. value: I.value,
  534. "onUpdate:value": t[3] || (t[3] = (o) => I.value = o),
  535. columns: A.value.importColumns,
  536. apis: A.value.importApis,
  537. onReload: B
  538. }, null, 8, ["upload-url", "value", "columns", "apis"])) : f("", !0)
  539. ], 512);
  540. };
  541. }
  542. }), $t = /* @__PURE__ */ Je(vt, [["__scopeId", "data-v-40ddab8f"]]);
  543. export {
  544. $t as default
  545. };