SListTableTreeLayout.js 17 KB

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