SNewestDataListLayout.js 18 KB

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