SListTableTreeLayout.js 17 KB

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