SListCardLayout.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. import { ref as n, computed as G, watch as ye, onMounted as ve, onActivated as we, nextTick as C, resolveComponent as S, resolveDirective as he, openBlock as o, createElementBlock as s, createElementVNode as u, toDisplayString as O, Fragment as $e, renderList as ke, withDirectives as D, createBlock as k, withCtx as g, createTextVNode as J, resolveDynamicComponent as ge, createCommentVNode as r, vShow as E, renderSlot as d, normalizeStyle as v, createVNode as R, h as _e } from "vue";
  2. import { useRoute as be } from "vue-router";
  3. import { n as Ce, B as Se, y as Oe } from "./index2.js";
  4. const De = { class: "tools" }, Be = { class: "title" }, He = { class: "btns" }, Le = {
  5. key: 0,
  6. style: { "margin-left": "8px" }
  7. }, Ae = {
  8. key: 0,
  9. class: "filter-content"
  10. }, Me = { class: "filter" }, Ne = {
  11. key: 1,
  12. class: "reset-wrap"
  13. }, ze = {
  14. key: 1,
  15. class: "filter-more-content"
  16. }, Pe = {
  17. key: 2,
  18. class: "desc-wrap"
  19. }, Te = { class: "table-content" }, Ee = { class: "other" }, Re = /* @__PURE__ */ Object.assign({ name: "SListCardLayout" }, {
  20. __name: "SListCardLayout",
  21. props: {
  22. col: {
  23. type: [Number, String],
  24. default: 4
  25. },
  26. cardHeight: {
  27. type: Number,
  28. default: 300
  29. },
  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: !0,
  44. api: null
  45. },
  46. {
  47. name: window.$l("批量删除"),
  48. key: "remove",
  49. action: "remove",
  50. show: !0,
  51. icon: !0,
  52. api: null
  53. },
  54. {
  55. name: window.$l("导入"),
  56. key: "import",
  57. show: !0,
  58. icon: !0,
  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: !0,
  75. api: null
  76. }
  77. ]
  78. },
  79. showPagination: {
  80. type: Boolean,
  81. default: !0
  82. },
  83. loadData: {
  84. type: Function,
  85. required: !0
  86. },
  87. pSize: {
  88. type: [String, Number],
  89. default: 20
  90. }
  91. },
  92. emits: ["reset", "btnCallback"],
  93. setup(B, { expose: Q, emit: Y }) {
  94. const V = B, w = Y;
  95. be();
  96. const H = n(null), Z = n(null), F = n(null), U = n(null), L = n(null), ee = n(null), _ = n(!1), c = n(0), I = n(0);
  97. n(!1);
  98. const h = n(!1), $ = n(!1), te = n(20), b = n(232), oe = n(!1), f = n([]), m = n([]), ne = {
  99. add: "PlusCircleOutlined",
  100. edit: "FormOutlined",
  101. delete: "DeleteOutlined",
  102. remove: "DeleteOutlined",
  103. import: "UploadOutlined",
  104. export: "DownloadOutlined",
  105. assign: "ClusterOutlined",
  106. execute: "PlayCircleOutlined",
  107. pause: "PauseCircleOutlined",
  108. resume: "PoweroffOutlined",
  109. approve: "HighlightOutlined",
  110. setting: "SettingOutlined",
  111. TopOfType: "VerticalAlignTopOutlined",
  112. TOP: "VerticalAlignTopOutlined",
  113. synchronize: "SyncOutlined"
  114. }, W = G(() => m.value.map((e) => e.key).includes("import")), A = G(() => m.value.find((e) => e.key === "import") || {});
  115. ye(
  116. () => V.buttons,
  117. (e) => {
  118. e && e.length && se(e);
  119. },
  120. { immediate: !0, deep: !0 }
  121. );
  122. function le(e, t = "") {
  123. return !!(e && typeof e == "function");
  124. }
  125. function x(e) {
  126. return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && ne[e.key] || "";
  127. }
  128. function se(e) {
  129. m.value = e.map((t) => (t.key === "remove" && (oe.value = !0), t));
  130. }
  131. function ie() {
  132. C(() => {
  133. T(), te.value = V.pSize;
  134. });
  135. }
  136. function M() {
  137. h.value = !h.value, T();
  138. }
  139. function N() {
  140. w("reset");
  141. }
  142. function z() {
  143. L.value && L.value.refresh(!0);
  144. }
  145. function X(e) {
  146. w("btnCallback", e.key, f.value);
  147. const t = de[e.key];
  148. typeof t == "function" ? t(e) : P(e);
  149. }
  150. function P(e) {
  151. if (e.selection !== !1 && !f.value.length) {
  152. window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`);
  153. return;
  154. }
  155. if (le(e.api, e.name, e.key)) {
  156. if (e.confirm) {
  157. window.$confirm({
  158. title: `${e.name}`,
  159. content: () => _e(
  160. "div",
  161. { style: "color:red" },
  162. `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}`
  163. ),
  164. onOk: () => {
  165. $.value = !0, e.api(f.value).then(() => {
  166. window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), w("reset");
  167. }).finally(() => {
  168. $.value = !1;
  169. });
  170. }
  171. });
  172. return;
  173. }
  174. $.value = !0, e.api(f.value).then(() => {
  175. window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), w("reset");
  176. }).finally(() => {
  177. $.value = !1;
  178. });
  179. }
  180. }
  181. function j(e, t) {
  182. typeof e == "string" ? q(e, t) : e.forEach((a) => {
  183. q(a, t);
  184. });
  185. }
  186. function q(e, t) {
  187. const a = m.value.find((l) => l.key === e);
  188. if (!a) {
  189. console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`);
  190. return;
  191. }
  192. Object.keys(t).forEach((l) => {
  193. a[l] = t[l];
  194. });
  195. }
  196. function ae() {
  197. }
  198. function re(e) {
  199. P(e);
  200. }
  201. function ue() {
  202. if (!W.value) {
  203. w("btnCallback", "import");
  204. return;
  205. }
  206. _.value = !0;
  207. }
  208. function T() {
  209. C(() => {
  210. var e, t;
  211. c.value = (((t = (e = H.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, K();
  212. });
  213. }
  214. function K() {
  215. C(() => {
  216. var l, y;
  217. const t = ((l = F.value) == null ? void 0 : l.offsetHeight) || 0, a = ((y = U.value) == null ? void 0 : y.offsetHeight) || 0;
  218. I.value = c.value - t - 0 - a;
  219. });
  220. }
  221. const de = {
  222. add: ae,
  223. delete: re,
  224. import: ue,
  225. reload: z,
  226. filterReset: N,
  227. toggleFilter: M,
  228. setStateBtn: j,
  229. handAction: P
  230. }, ce = {
  231. mounted(e) {
  232. e.style.cursor = "e-resize", document.addEventListener("selectstart", (t) => {
  233. t.preventDefault();
  234. }), e.onmousedown = (t) => {
  235. const a = t.clientX, l = b.value;
  236. document.onmousemove = (y) => {
  237. const p = y.clientX - a;
  238. if (p < 0) {
  239. if (l + p <= 232) return;
  240. b.value = l + p;
  241. } else {
  242. if (l + p >= 500) return;
  243. b.value = l + p;
  244. }
  245. }, document.onmouseup = () => {
  246. document.onmousemove = document.onmousedown = null;
  247. };
  248. };
  249. }
  250. };
  251. return ve(() => {
  252. ie();
  253. }), we(() => {
  254. C(() => {
  255. var e, t;
  256. c.value = (((t = (e = H.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, K();
  257. });
  258. }), Q({
  259. reload: z,
  260. spinning: $,
  261. selectedRowKeys: f,
  262. renderButtons: m,
  263. setStateBtn: j,
  264. btnCallback: X,
  265. filterReset: N,
  266. toggleFilter: M,
  267. table: L,
  268. importVisible: _,
  269. measureLayout: T
  270. }), (e, t) => {
  271. const a = Se, l = S("down-outlined"), y = S("up-outlined"), p = S("sync-outlined"), pe = Oe, fe = S("s-import-modal"), me = he("action");
  272. return o(), s("div", {
  273. class: "list-layout",
  274. ref_key: "layout",
  275. ref: H
  276. }, [
  277. u("div", De, [
  278. u("div", Be, O(B.title), 1),
  279. u("div", He, [
  280. (o(!0), s($e, null, ke(m.value, (i) => (o(), s("span", {
  281. class: "item-btn",
  282. key: i.key
  283. }, [
  284. D((o(), k(a, {
  285. class: "btn",
  286. disabled: !!i.disabled,
  287. type: i.type || i.key === "add" ? "primary" : "default",
  288. onClick: (Ve) => X(i)
  289. }, {
  290. icon: g(() => [
  291. x(i) ? (o(), k(ge(x(i)), { key: 0 })) : r("", !0)
  292. ]),
  293. default: g(() => [
  294. J(" " + O(e.$l(i.name)), 1)
  295. ]),
  296. _: 2
  297. }, 1032, ["disabled", "type", "onClick"])), [
  298. [me, i.action || i.key],
  299. [E, i.show !== !1]
  300. ])
  301. ]))), 128)),
  302. e.$slots.otherBtns ? (o(), s("span", Le, [
  303. d(e.$slots, "otherBtns", { selections: f.value }, void 0, !0)
  304. ])) : r("", !0)
  305. ])
  306. ]),
  307. u("div", {
  308. class: "list-layout-main",
  309. style: v({ height: c.value + "px" })
  310. }, [
  311. e.$slots.tree ? (o(), s("div", {
  312. key: 0,
  313. class: "side s-side-tree",
  314. ref_key: "side",
  315. ref: Z,
  316. style: v([{ height: c.value + "px", width: b.value + "px" }, { "overflow-y": "auto" }])
  317. }, [
  318. d(e.$slots, "tree", {}, void 0, !0)
  319. ], 4)) : r("", !0),
  320. e.$slots.tree ? D((o(), s("div", {
  321. key: 1,
  322. class: "side-bar s-theme-bg",
  323. style: v({ height: c.value + "px" })
  324. }, null, 4)), [
  325. [ce]
  326. ]) : r("", !0),
  327. e.$slots.empty ? (o(), s("div", {
  328. key: 3,
  329. class: "layout-list-content",
  330. style: v({ height: c.value + "px" })
  331. }, [
  332. d(e.$slots, "empty", {}, void 0, !0)
  333. ], 4)) : (o(), s("div", {
  334. key: 2,
  335. class: "layout-list-content",
  336. style: v({ height: c.value - 1 + "px" })
  337. }, [
  338. D(u("div", {
  339. class: "list-filter-wrap",
  340. ref_key: "filters",
  341. ref: F
  342. }, [
  343. e.$slots.filter ? (o(), s("div", Ae, [
  344. u("div", Me, [
  345. d(e.$slots, "filter", {}, void 0, !0)
  346. ]),
  347. e.$slots.filterMore ? (o(), s("a", {
  348. key: 0,
  349. class: "filter-more-btn",
  350. onClick: M
  351. }, [
  352. J(O(h.value ? e.$l("收起") : e.$l("更多")) + " ", 1),
  353. h.value ? (o(), k(y, {
  354. key: 1,
  355. style: { "font-size": "12px" }
  356. })) : (o(), k(l, {
  357. key: 0,
  358. style: { "font-size": "12px" }
  359. }))
  360. ])) : r("", !0),
  361. e.$slots.filter ? (o(), s("div", Ne, [
  362. R(pe, {
  363. placement: "top",
  364. overlayStyle: { maxWidth: "500px" },
  365. mouseEnterDelay: 1.5,
  366. mouseLeaveDelay: 0.5
  367. }, {
  368. title: g(() => [
  369. u("span", null, O(e.$l("条件重置")), 1)
  370. ]),
  371. default: g(() => [
  372. R(a, {
  373. style: { "padding-bottom": "2px" },
  374. onClick: N
  375. }, {
  376. icon: g(() => [
  377. R(p)
  378. ]),
  379. _: 1
  380. })
  381. ]),
  382. _: 1
  383. })
  384. ])) : r("", !0)
  385. ])) : r("", !0),
  386. e.$slots.filterMore ? D((o(), s("div", ze, [
  387. d(e.$slots, "filterMore", {}, void 0, !0)
  388. ], 512)), [
  389. [E, h.value]
  390. ]) : r("", !0),
  391. e.$slots.desc ? (o(), s("div", Pe, [
  392. d(e.$slots, "desc", {}, void 0, !0)
  393. ])) : r("", !0)
  394. ], 512), [
  395. [E, e.$slots.filter]
  396. ]),
  397. u("div", Te, [
  398. e.$slots.tabs ? (o(), s("div", {
  399. key: 0,
  400. class: "tabs-wrap",
  401. ref_key: "tabs",
  402. ref: U
  403. }, [
  404. d(e.$slots, "tabs", {}, void 0, !0)
  405. ], 512)) : r("", !0),
  406. u("div", {
  407. class: "table-container",
  408. style: v({
  409. display: "grid",
  410. gridTemplateColumns: `repeat(${B.col}, 1fr)`,
  411. gap: "12px",
  412. height: I.value - 1 + "px"
  413. })
  414. }, [
  415. d(e.$slots, "default", {}, void 0, !0)
  416. ], 4)
  417. ])
  418. ], 4))
  419. ], 4),
  420. u("div", Ee, [
  421. d(e.$slots, "other", {}, void 0, !0)
  422. ]),
  423. W.value ? (o(), k(fe, {
  424. key: 0,
  425. ref_key: "importModalRef",
  426. ref: ee,
  427. "upload-url": A.value.importUploadUrl,
  428. value: _.value,
  429. "onUpdate:value": t[0] || (t[0] = (i) => _.value = i),
  430. columns: A.value.importColumns,
  431. apis: A.value.importApis,
  432. onReload: z
  433. }, null, 8, ["upload-url", "value", "columns", "apis"])) : r("", !0)
  434. ], 512);
  435. };
  436. }
  437. }), We = /* @__PURE__ */ Ce(Re, [["__scopeId", "data-v-078574c4"]]);
  438. export {
  439. We as default
  440. };