SSuperListLayout.js 18 KB

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