SSuperListLayout.js 18 KB

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