SListTableTreeLayout.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. import { getCurrentInstance as ze, ref as a, reactive as Ae, computed as J, watch as De, onMounted as Ie, resolveComponent as K, resolveDirective as Be, openBlock as n, createElementBlock as i, createElementVNode as m, toDisplayString as k, createVNode as b, withCtx as y, Fragment as Q, renderList as Le, withDirectives as E, createBlock as C, createTextVNode as G, resolveDynamicComponent as Pe, createCommentVNode as s, vShow as X, renderSlot as u, normalizeStyle as Re, unref as Me, nextTick as Y, h as Z } from "vue";
  2. import { useRoute as Ke } from "vue-router";
  3. import { c as Ee } from "./side-drag.js";
  4. import { n as Fe, B as Ne, y as Ue } from "./index2.js";
  5. import { S as Ve } from "./index9.js";
  6. import { _ as qe } from "./index15.js";
  7. const He = { class: "tools" }, je = { class: "title" }, We = { class: "btns" }, Je = { class: "list-layout-main" }, Qe = {
  8. key: 1,
  9. class: "side-bar s-theme-bg"
  10. }, Ge = {
  11. key: 2,
  12. class: "layout-list-content"
  13. }, Xe = {
  14. key: 0,
  15. class: "filter-content"
  16. }, Ye = { class: "filter" }, Ze = {
  17. key: 1,
  18. class: "reset-wrap"
  19. }, et = {
  20. key: 1,
  21. class: "filter-more-content"
  22. }, tt = {
  23. key: 2,
  24. class: "desc-wrap"
  25. }, ot = { class: "table-content" }, nt = { class: "table-container" }, lt = ["onClick"], at = {
  26. key: 3,
  27. class: "layout-list-content"
  28. }, it = { class: "other" }, st = /* @__PURE__ */ Object.assign({ name: "SListTableTreeLayout" }, {
  29. __name: "SListTableTreeLayout",
  30. props: {
  31. // 页面标题
  32. title: {
  33. type: String,
  34. required: !0
  35. },
  36. buttons: {
  37. type: Array,
  38. default: () => [
  39. {
  40. name: window.$l("添加"),
  41. key: "add",
  42. show: !0,
  43. type: "primary",
  44. icon: "plus-circle",
  45. api: null
  46. },
  47. {
  48. name: window.$l("批量删除"),
  49. key: "remove",
  50. action: "remove",
  51. show: !0,
  52. icon: "delete",
  53. api: null
  54. },
  55. {
  56. name: window.$l("导入"),
  57. key: "import",
  58. show: !0,
  59. icon: "upload",
  60. importColumns: [],
  61. // 预览的表头信息
  62. importUploadUrl: null,
  63. // 上传url
  64. importApis: {
  65. templateDownload: null,
  66. importPreview: null,
  67. importData: null,
  68. exportExceptionData: null
  69. }
  70. },
  71. {
  72. name: window.$l("导出"),
  73. key: "export",
  74. show: !0,
  75. icon: "download",
  76. api: null
  77. }
  78. ]
  79. },
  80. // 列表checkbox列
  81. isSelection: {
  82. type: Boolean,
  83. default: !1
  84. },
  85. showBtnIcon: {
  86. type: Boolean,
  87. default: !0
  88. },
  89. showPagination: {
  90. type: Boolean,
  91. default: !0
  92. },
  93. columns: {
  94. type: Array,
  95. default: () => []
  96. },
  97. rowKey: {
  98. type: [Function, String],
  99. default: "id"
  100. },
  101. tableLoading: {
  102. type: Boolean,
  103. default: !1
  104. },
  105. loadData: {
  106. type: Function,
  107. required: !0
  108. },
  109. getCheckboxProps: {
  110. type: Function,
  111. default: (d = {}) => ({ props: d })
  112. }
  113. },
  114. emits: ["reset", "btnCallback", "tableColCallback", "handExpand"],
  115. setup(d, { expose: ee, emit: te }) {
  116. const _ = d, c = te;
  117. Ke(), ze();
  118. const oe = a(null), ne = a(null), le = a(null), S = a(null), ae = a(8), O = a(!1), F = a(300), v = a(!1), p = a(!1), z = a(232), r = a([]), T = a([]), w = a([]), N = a(!1), ie = a([]), A = a([]), D = a([]), f = Ae({
  119. current: 1,
  120. pageSize: 20,
  121. total: 0,
  122. showSizeChanger: !0,
  123. showQuickJumper: !0,
  124. pageSizeOptions: ["10", "20", "50", "100"],
  125. showTotal: (e) => `${window.$l("共")}${e}${window.$l("条")}`
  126. }), se = {
  127. add: "PlusCircleOutlined",
  128. edit: "FormOutlined",
  129. delete: "DeleteOutlined",
  130. remove: "DeleteOutlined",
  131. import: "UploadOutlined",
  132. export: "DownloadOutlined",
  133. assign: "ClusterOutlined",
  134. execute: "PlayCircleOutlined",
  135. pause: "PauseCircleOutlined",
  136. resume: "PoweroffOutlined",
  137. approve: "HighlightOutlined",
  138. setting: "SettingOutlined",
  139. TopOfType: "VerticalAlignTopOutlined",
  140. TOP: "VerticalAlignTopOutlined",
  141. synchronize: "SyncOutlined"
  142. }, U = J(() => w.value.map((e) => e.key).includes("import")), I = J(() => w.value.find((e) => e.key === "import") || {});
  143. De(
  144. () => _.buttons,
  145. (e) => {
  146. e && e.length && re(e);
  147. },
  148. { immediate: !0, deep: !0 }
  149. );
  150. function B(e, t = "") {
  151. return !!(e && typeof e == "function");
  152. }
  153. function V(e) {
  154. return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && se[e.key] || "";
  155. }
  156. function re(e) {
  157. w.value = e.map((t) => (t.key === "remove" && (N.value = !0), t));
  158. }
  159. function ue() {
  160. Y(() => {
  161. M(), T.value = _.columns.map((t) => ((t.template || t.isClick || t.dataIndex === "action" && !t.customRender) && !t.scopedSlots && (t.scopedSlots = { customRender: t.dataIndex }), t)), h();
  162. });
  163. const e = setTimeout(() => {
  164. const t = document.querySelector(".ant-table-cell.ant-table-cell-scrollbar"), l = document.querySelector(".ant-table-thead tr");
  165. t && l && l.removeChild(t), clearTimeout(e);
  166. }, 100);
  167. }
  168. function de() {
  169. ue();
  170. }
  171. function L() {
  172. v.value = !v.value, M();
  173. }
  174. function q(e, t) {
  175. const l = W[e];
  176. return l(t);
  177. }
  178. function P() {
  179. c("reset");
  180. }
  181. function h(e = !1) {
  182. e && (f.current = 1);
  183. const t = _.showPagination ? { pageNo: f.current, pageSize: f.pageSize } : { pageNo: 1, pageSize: 0 };
  184. return _.loadData(t).then((l) => {
  185. var g, x;
  186. const $ = l && (l.list || l.records) || [];
  187. return A.value = $.length ? $ : ie.value, f.total = Number((x = l && ((g = l.total) != null ? g : l.totalCount)) != null ? x : $.length), l;
  188. });
  189. }
  190. function ce(e) {
  191. f.current = e.current, f.pageSize = e.pageSize, h();
  192. }
  193. function H(e) {
  194. c("btnCallback", e.key, r.value);
  195. const t = W[e.key];
  196. typeof t == "function" ? t(e) : j(e);
  197. }
  198. function j(e) {
  199. if (e.selection !== !1 && !r.value.length) {
  200. window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`);
  201. return;
  202. }
  203. if (B(e.api, e.name)) {
  204. if (e.confirm) {
  205. window.$confirm({
  206. title: `${e.name}`,
  207. content: () => Z(
  208. "div",
  209. { style: "color:var(--s-color-error)" },
  210. `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}`
  211. ),
  212. onOk: () => {
  213. p.value = !0, e.api(r.value).then(() => {
  214. window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), c("reset");
  215. }).finally(() => {
  216. p.value = !1;
  217. });
  218. }
  219. });
  220. return;
  221. }
  222. p.value = !0, e.api(r.value).then(() => {
  223. window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), c("reset");
  224. }).finally(() => {
  225. p.value = !1;
  226. });
  227. }
  228. }
  229. function pe() {
  230. c("btnCallback", "add");
  231. }
  232. function me() {
  233. if (!r.value.length) {
  234. window.$notice.warn({
  235. key: "only-you",
  236. message: window.$l("操作失败"),
  237. description: window.$l("请选择要删除的数据")
  238. });
  239. return;
  240. }
  241. B("deletesApi") && window.$confirm({
  242. title: window.$l("确认删除"),
  243. content: () => Z("div", { style: "color: var(--s-color-error)" }, window.$l("确认要批量删除数据吗?")),
  244. onOk: () => {
  245. p.value = !0, q("deletesApi", r.value).then(() => {
  246. window.$notice.success({
  247. key: "only-you",
  248. message: window.$l("操作成功"),
  249. description: window.$l("删除成功")
  250. }), c("reset");
  251. }).finally(() => {
  252. p.value = !1;
  253. });
  254. }
  255. });
  256. }
  257. function fe() {
  258. if (!U.value) {
  259. c("btnCallback", "import");
  260. return;
  261. }
  262. O.value = !0;
  263. }
  264. function ye() {
  265. B("exportApi") && (p.value = !0, q("exportApi").then(() => {
  266. p.value = !1;
  267. }));
  268. }
  269. function ve(e, t) {
  270. c("tableColCallback", e, t);
  271. }
  272. function R(e) {
  273. return T.value.find((t) => t.dataIndex === e);
  274. }
  275. function we(e) {
  276. const t = R(e);
  277. return !!(t && t.template);
  278. }
  279. function he(e) {
  280. const t = R(e);
  281. return !!(t && t.isClick);
  282. }
  283. function $e(e) {
  284. return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e;
  285. }
  286. function ge(e) {
  287. r.value = e;
  288. }
  289. function M() {
  290. Y(ke);
  291. }
  292. function ke() {
  293. const e = S.value && S.value.$el, t = e && e.querySelector(".ant-table-body"), l = t && t.clientHeight;
  294. l && (F.value = Math.max(l - 8, 0));
  295. }
  296. function be(e, t) {
  297. c("handExpand", e, t);
  298. }
  299. const W = {
  300. add: pe,
  301. remove: me,
  302. import: fe,
  303. export: ye,
  304. reload: h,
  305. filterReset: P,
  306. toggleFilter: L,
  307. handAction: j
  308. }, Ce = Ee(
  309. () => z.value,
  310. (e) => z.value = e,
  311. { min: 232 }
  312. );
  313. return Ie(() => {
  314. de();
  315. }), ee({
  316. reload: h,
  317. spinning: p,
  318. selectedRowKeys: r,
  319. expandedRowKeys: D,
  320. renderColumns: T,
  321. renderButtons: w,
  322. tableData: A,
  323. pagination: f,
  324. table: S,
  325. importVisible: O,
  326. measureLayout: M,
  327. toggleFilter: L,
  328. filterReset: P,
  329. btnCallback: H
  330. }), (e, t) => {
  331. const l = Ne, $ = Ve, g = K("double-right-outlined"), x = K("sync-outlined"), _e = Ue, Se = qe, Oe = K("s-import-modal"), Te = Be("action");
  332. return n(), i("div", {
  333. class: "list-layout",
  334. ref_key: "layout",
  335. ref: oe
  336. }, [
  337. m("div", He, [
  338. m("div", je, k(d.title), 1),
  339. m("div", We, [
  340. b($, { size: ae.value }, {
  341. default: y(() => [
  342. (n(!0), i(Q, null, Le(w.value, (o) => (n(), i("span", {
  343. class: "item-btn",
  344. key: o.key
  345. }, [
  346. E((n(), C(l, {
  347. class: "btn",
  348. disabled: !!o.disabled,
  349. type: o.type || o.key === "add" ? "primary" : "default",
  350. onClick: (xe) => H(o)
  351. }, {
  352. icon: y(() => [
  353. V(o) ? (n(), C(Pe(V(o)), { key: 0 })) : s("", !0)
  354. ]),
  355. default: y(() => [
  356. G(" " + k(e.$l(o.name)), 1)
  357. ]),
  358. _: 2
  359. }, 1032, ["disabled", "type", "onClick"])), [
  360. [Te, o.action || o.key],
  361. [X, o.show !== !1]
  362. ])
  363. ]))), 128)),
  364. u(e.$slots, "otherBtns", { selections: r.value }, void 0, !0)
  365. ]),
  366. _: 3
  367. }, 8, ["size"])
  368. ])
  369. ]),
  370. m("div", Je, [
  371. e.$slots.tree ? (n(), i("div", {
  372. key: 0,
  373. class: "side s-side-tree",
  374. ref: "side",
  375. style: Re({ width: z.value + "px" })
  376. }, [
  377. u(e.$slots, "tree", {}, void 0, !0)
  378. ], 4)) : s("", !0),
  379. e.$slots.tree ? E((n(), i("div", Qe, null, 512)), [
  380. [Me(Ce)]
  381. ]) : s("", !0),
  382. e.$slots.empty ? (n(), i("div", at, [
  383. u(e.$slots, "empty", {}, void 0, !0)
  384. ])) : (n(), i("div", Ge, [
  385. e.$slots.filter || e.$slots.filterMore ? (n(), i("div", {
  386. key: 0,
  387. class: "list-filter-wrap",
  388. ref_key: "filters",
  389. ref: ne
  390. }, [
  391. e.$slots.filter ? (n(), i("div", Xe, [
  392. m("div", Ye, [
  393. u(e.$slots, "filter", {}, void 0, !0)
  394. ]),
  395. e.$slots.filterMore ? (n(), i("a", {
  396. key: 0,
  397. class: "filter-more-btn",
  398. onClick: L
  399. }, [
  400. G(k(v.value ? e.$l("收起") : e.$l("更多")) + " ", 1),
  401. v.value ? (n(), C(g, {
  402. key: 1,
  403. style: { "font-size": "12px", transform: "rotate(-90deg)" }
  404. })) : (n(), C(g, {
  405. key: 0,
  406. style: { "font-size": "12px", transform: "rotate(90deg)" }
  407. }))
  408. ])) : s("", !0),
  409. e.$slots.filter ? (n(), i("div", Ze, [
  410. b(_e, {
  411. placement: "top",
  412. overlayStyle: { maxWidth: "500px" },
  413. mouseEnterDelay: 1.5,
  414. mouseLeaveDelay: 0.5
  415. }, {
  416. title: y(() => [
  417. m("span", null, k(e.$l("条件重置")), 1)
  418. ]),
  419. default: y(() => [
  420. b(l, {
  421. style: { "padding-bottom": "2px" },
  422. onClick: P
  423. }, {
  424. icon: y(() => [
  425. b(x)
  426. ]),
  427. _: 1
  428. })
  429. ]),
  430. _: 1
  431. })
  432. ])) : s("", !0)
  433. ])) : s("", !0),
  434. e.$slots.filterMore ? E((n(), i("div", et, [
  435. u(e.$slots, "filterMore", {}, void 0, !0)
  436. ], 512)), [
  437. [X, v.value]
  438. ]) : s("", !0),
  439. e.$slots.desc ? (n(), i("div", tt, [
  440. u(e.$slots, "desc", {}, void 0, !0)
  441. ])) : s("", !0)
  442. ], 512)) : s("", !0),
  443. m("div", ot, [
  444. e.$slots.tabs ? (n(), i("div", {
  445. key: 0,
  446. class: "tabs-wrap",
  447. ref_key: "tabs",
  448. ref: le
  449. }, [
  450. u(e.$slots, "tabs", {}, void 0, !0)
  451. ], 512)) : s("", !0),
  452. m("div", nt, [
  453. b(Se, {
  454. ref_key: "table",
  455. ref: S,
  456. size: "middle",
  457. scroll: { y: F.value },
  458. rowKey: d.rowKey,
  459. tableLoading: d.tableLoading,
  460. columns: T.value,
  461. dataSource: A.value,
  462. expandedRowKeys: D.value,
  463. "onUpdate:expandedRowKeys": t[0] || (t[0] = (o) => D.value = o),
  464. rowSelection: N.value || d.isSelection ? {
  465. selectedRowKeys: r.value,
  466. onChange: ge,
  467. getcheckboxProps: d.getCheckboxProps
  468. } : null,
  469. pagination: d.showPagination ? f : !1,
  470. onExpand: be,
  471. onChange: ce
  472. }, {
  473. bodyCell: y((o) => [
  474. o.column ? (n(), i(Q, { key: 0 }, [
  475. we(o.column.dataIndex) ? u(e.$slots, o.column.dataIndex, {
  476. text: o.text,
  477. record: o.record,
  478. index: o.index,
  479. item: R(o.column.dataIndex)
  480. }, void 0, !0, 0) : he(o.column.dataIndex) ? (n(), i("a", {
  481. key: 1,
  482. onClick: (xe) => ve(o.column.dataIndex, o.record)
  483. }, k($e(o.text)), 9, lt)) : o.column.dataIndex === "action" ? u(e.$slots, "action", {
  484. record: o.record
  485. }, void 0, !0, 2) : s("", !0)
  486. ], 64)) : s("", !0)
  487. ]),
  488. _: 3
  489. }, 8, ["scroll", "rowKey", "tableLoading", "columns", "dataSource", "expandedRowKeys", "rowSelection", "pagination"])
  490. ])
  491. ])
  492. ]))
  493. ]),
  494. m("div", it, [
  495. u(e.$slots, "other", {}, void 0, !0)
  496. ]),
  497. U.value ? (n(), C(Oe, {
  498. key: 0,
  499. ref: "importModalRef",
  500. "upload-url": I.value.importUploadUrl,
  501. value: O.value,
  502. "onUpdate:value": t[1] || (t[1] = (o) => O.value = o),
  503. columns: I.value.importColumns,
  504. apis: I.value.importApis,
  505. onReload: h
  506. }, null, 8, ["upload-url", "value", "columns", "apis"])) : s("", !0)
  507. ], 512);
  508. };
  509. }
  510. }), ft = /* @__PURE__ */ Fe(st, [["__scopeId", "data-v-136ef62f"]]);
  511. export {
  512. ft as default
  513. };