SListTableTreeLayout.js 16 KB

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