| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- var ie = ($, I, k) => new Promise((d, p) => {
- var R = (f) => {
- try {
- S(k.next(f));
- } catch (O) {
- p(O);
- }
- }, H = (f) => {
- try {
- S(k.throw(f));
- } catch (O) {
- p(O);
- }
- }, S = (f) => f.done ? d(f.value) : Promise.resolve(f.value).then(R, H);
- S((k = k.apply($, I)).next());
- });
- import { ref as s, computed as re, watch as De, onMounted as Ne, onActivated as Be, nextTick as Y, resolveComponent as Z, resolveDirective as Le, openBlock as n, createElementBlock as a, createElementVNode as i, toDisplayString as h, createVNode as w, withCtx as v, Fragment as ue, renderList as ce, withDirectives as K, createBlock as C, createTextVNode as L, resolveDynamicComponent as Me, createCommentVNode as r, vShow as x, renderSlot as c, normalizeStyle as de, unref as Pe, h as Te } from "vue";
- import { c as Fe } from "./side-drag.js";
- import { n as Ue, B as Ve, y as Ee, aB as Ke, ai as Ie, c$ as Re } from "./index2.js";
- import { S as He } from "./index9.js";
- const je = { class: "tools" }, qe = { class: "title" }, We = { class: "btns" }, Ge = { class: "list-layout-main" }, Je = {
- key: 1,
- class: "side-bar s-theme-bg"
- }, Qe = {
- key: 2,
- class: "layout-list-content"
- }, Xe = {
- key: 0,
- class: "filter-content"
- }, Ye = { class: "filter" }, Ze = {
- key: 1,
- class: "reset-wrap"
- }, xe = {
- key: 1,
- class: "filter-more-content"
- }, et = {
- key: 2,
- class: "desc-wrap"
- }, tt = { class: "table-content" }, ot = { class: "table-container" }, nt = {
- key: 0,
- class: "s-card-header"
- }, lt = { class: "s-card-body" }, st = { class: "s-card-footer" }, at = {
- key: 3,
- class: "layout-list-content"
- }, it = { class: "other" }, rt = /* @__PURE__ */ Object.assign({ name: "SListCardLayout" }, {
- __name: "SListCardLayout",
- props: {
- // 每行卡片个数(不传默认每行 5 个)
- column: {
- type: [Number, String],
- default: 5
- },
- // 卡片数据主键字段(用于 v-for key)
- rowKey: {
- type: [Function, String],
- default: "id"
- },
- // 每页条数可选项
- pageSizeOptions: {
- type: Array,
- default: () => ["10", "20", "40", "80"]
- },
- // 页面标题
- title: {
- type: String,
- required: !0
- },
- // 工具栏按钮配置
- buttons: {
- type: Array,
- default: () => [
- {
- name: window.$l("添加"),
- key: "add",
- show: !0,
- type: "primary",
- icon: !0,
- api: null
- },
- {
- name: window.$l("批量删除"),
- key: "remove",
- action: "remove",
- show: !0,
- icon: !0,
- api: null
- },
- {
- name: window.$l("导入"),
- key: "import",
- show: !0,
- icon: !0,
- importColumns: [],
- // 预览的表头信息
- importUploadUrl: null,
- // 上传url
- importApis: {
- templateDownload: null,
- importPreview: null,
- importData: null,
- exportExceptionData: null
- }
- },
- {
- name: window.$l("导出"),
- key: "export",
- show: !0,
- icon: !0,
- api: null
- }
- ]
- },
- // 是否显示分页
- showPagination: {
- type: Boolean,
- default: !0
- },
- // 取数函数,返回 { list, total }
- loadData: {
- type: Function,
- required: !0
- },
- // 每页条数
- pSize: {
- type: [String, Number],
- default: 20
- }
- },
- emits: ["reset", "btnCallback", "cardAction"],
- setup($, { expose: I, emit: k }) {
- const d = $, p = k, R = s(null), H = s(null), S = s(null), f = s(null), O = s(null), pe = s(8), M = s(!1), z = s(!1), A = s(!1), D = s(20), j = s(232), fe = s(!1), _ = s([]), b = s([]), N = s([]), P = s(0), m = s(1), T = s(!1), ye = {
- add: "PlusCircleOutlined",
- edit: "FormOutlined",
- delete: "DeleteOutlined",
- remove: "DeleteOutlined",
- import: "UploadOutlined",
- export: "DownloadOutlined",
- assign: "ClusterOutlined",
- execute: "PlayCircleOutlined",
- pause: "PauseCircleOutlined",
- resume: "PoweroffOutlined",
- approve: "HighlightOutlined",
- setting: "SettingOutlined",
- TopOfType: "VerticalAlignTopOutlined",
- TOP: "VerticalAlignTopOutlined",
- synchronize: "SyncOutlined"
- }, ee = re(() => b.value.map((e) => e.key).includes("import")), q = re(() => b.value.find((e) => e.key === "import") || {});
- De(
- () => d.buttons,
- (e) => {
- e && e.length && me(e);
- },
- { immediate: !0, deep: !0 }
- );
- function ve(e, t = "") {
- return !!(e && typeof e == "function");
- }
- function te(e) {
- return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && ye[e.key] || "";
- }
- function me(e) {
- b.value = e.map((t) => (t.key === "remove" && (fe.value = !0), t));
- }
- function we() {
- Y(() => {
- X(), D.value = d.pSize, F();
- });
- }
- function W() {
- z.value = !z.value, X();
- }
- function G() {
- p("reset");
- }
- function J(e = !1) {
- F(e);
- }
- function F(e = !1) {
- return ie(this, null, function* () {
- var t, l, y, B, U;
- if (typeof d.loadData == "function") {
- e && (m.value = 1), T.value = !0;
- try {
- const u = (yield d.loadData({ pageNo: m.value, pageSize: Number(D.value) })) || {}, V = u.list || u.data || [];
- N.value = Array.isArray(V) ? V : [], P.value = (B = (y = (l = u.total) != null ? l : (t = u.pagination) == null ? void 0 : t.total) != null ? y : u.totalCount) != null ? B : 0;
- const E = u.pageNo || u.pageNum || ((U = u.pagination) == null ? void 0 : U.current);
- E && (m.value = E);
- } catch (u) {
- console.warn("[SListCardLayout] 卡片数据加载失败:", u), N.value = [], P.value = 0;
- } finally {
- T.value = !1;
- }
- }
- });
- }
- function $e(e, t) {
- t && Number(t) !== Number(D.value) ? (D.value = Number(t), m.value = 1) : m.value = e, F();
- }
- function oe(e, t, l) {
- p("cardAction", e, t, l);
- }
- function ge(e, t) {
- if (typeof d.rowKey == "function") return d.rowKey(e, t);
- const l = e == null ? void 0 : e[d.rowKey];
- return l == null || l === "" ? t : l;
- }
- function ne(e) {
- p("btnCallback", e.key, _.value);
- const t = be[e.key];
- typeof t == "function" ? t(e) : Q(e);
- }
- function Q(e) {
- if (e.selection !== !1 && !_.value.length) {
- window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`);
- return;
- }
- if (ve(e.api, e.name, e.key)) {
- if (e.confirm) {
- window.$confirm({
- title: `${e.name}`,
- content: () => Te(
- "div",
- { style: "color:var(--s-color-error)" },
- `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}`
- ),
- onOk: () => {
- A.value = !0, e.api(_.value).then(() => {
- window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), p("reset");
- }).finally(() => {
- A.value = !1;
- });
- }
- });
- return;
- }
- A.value = !0, e.api(_.value).then(() => {
- window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), p("reset");
- }).finally(() => {
- A.value = !1;
- });
- }
- }
- function le(e, t) {
- typeof e == "string" ? se(e, t) : e.forEach((l) => {
- se(l, t);
- });
- }
- function se(e, t) {
- const l = b.value.find((y) => y.key === e);
- if (!l) {
- console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`);
- return;
- }
- Object.keys(t).forEach((y) => {
- l[y] = t[y];
- });
- }
- function he() {
- }
- function ke(e) {
- Q(e);
- }
- function _e() {
- if (!ee.value) {
- p("btnCallback", "import");
- return;
- }
- M.value = !0;
- }
- function X() {
- Y(ae);
- }
- function ae() {
- }
- const be = {
- add: he,
- delete: ke,
- import: _e,
- reload: J,
- filterReset: G,
- toggleFilter: W,
- setStateBtn: le,
- handAction: Q
- }, Ce = Fe(
- () => j.value,
- (e) => j.value = e,
- { min: 232 }
- );
- return Ne(() => {
- we();
- }), Be(() => {
- Y(ae);
- }), I({
- reload: J,
- spinning: A,
- selectedRowKeys: _,
- renderButtons: b,
- setStateBtn: le,
- btnCallback: ne,
- filterReset: G,
- toggleFilter: W,
- table: f,
- importVisible: M,
- measureLayout: X,
- // 卡片列表
- list: N,
- total: P,
- pageNo: m,
- fetchList: F
- }), (e, t) => {
- const l = Ve, y = He, B = Z("double-right-outlined"), U = Z("sync-outlined"), u = Ee, V = Ie, E = Ke, Se = Re, Oe = Z("s-import-modal"), ze = Le("action");
- return n(), a("div", {
- class: "list-layout",
- ref_key: "layout",
- ref: R
- }, [
- i("div", je, [
- i("div", qe, h($.title), 1),
- i("div", We, [
- w(y, { size: pe.value }, {
- default: v(() => [
- (n(!0), a(ue, null, ce(b.value, (o) => (n(), a("span", {
- class: "item-btn",
- key: o.key
- }, [
- K((n(), C(l, {
- class: "btn",
- disabled: !!o.disabled,
- type: o.type || o.key === "add" ? "primary" : "default",
- onClick: (g) => ne(o)
- }, {
- icon: v(() => [
- te(o) ? (n(), C(Me(te(o)), { key: 0 })) : r("", !0)
- ]),
- default: v(() => [
- L(" " + h(e.$l(o.name)), 1)
- ]),
- _: 2
- }, 1032, ["disabled", "type", "onClick"])), [
- [ze, o.action || o.key],
- [x, o.show !== !1]
- ])
- ]))), 128)),
- c(e.$slots, "otherBtns", { selections: _.value }, void 0, !0)
- ]),
- _: 3
- }, 8, ["size"])
- ])
- ]),
- i("div", Ge, [
- e.$slots.tree ? (n(), a("div", {
- key: 0,
- class: "side s-side-tree",
- ref: "side",
- style: de([{ width: j.value + "px" }, { "overflow-y": "auto" }])
- }, [
- c(e.$slots, "tree", {}, void 0, !0)
- ], 4)) : r("", !0),
- e.$slots.tree ? K((n(), a("div", Je, null, 512)), [
- [Pe(Ce)]
- ]) : r("", !0),
- e.$slots.empty ? (n(), a("div", at, [
- c(e.$slots, "empty", {}, void 0, !0)
- ])) : (n(), a("div", Qe, [
- K(i("div", {
- class: "list-filter-wrap",
- ref_key: "filters",
- ref: H
- }, [
- e.$slots.filter ? (n(), a("div", Xe, [
- i("div", Ye, [
- c(e.$slots, "filter", {}, void 0, !0)
- ]),
- e.$slots.filterMore ? (n(), a("a", {
- key: 0,
- class: "filter-more-btn",
- onClick: W
- }, [
- L(h(z.value ? e.$l("收起") : e.$l("更多")) + " ", 1),
- z.value ? (n(), C(B, {
- key: 1,
- style: { "font-size": "12px", transform: "rotate(-90deg)" }
- })) : (n(), C(B, {
- key: 0,
- style: { "font-size": "12px", transform: "rotate(90deg)" }
- }))
- ])) : r("", !0),
- e.$slots.filter ? (n(), a("div", Ze, [
- w(u, {
- placement: "top",
- overlayStyle: { maxWidth: "500px" },
- mouseEnterDelay: 1.5,
- mouseLeaveDelay: 0.5
- }, {
- title: v(() => [
- i("span", null, h(e.$l("条件重置")), 1)
- ]),
- default: v(() => [
- w(l, {
- style: { "padding-bottom": "2px" },
- onClick: G
- }, {
- icon: v(() => [
- w(U)
- ]),
- _: 1
- })
- ]),
- _: 1
- })
- ])) : r("", !0)
- ])) : r("", !0),
- e.$slots.filterMore ? K((n(), a("div", xe, [
- c(e.$slots, "filterMore", {}, void 0, !0)
- ], 512)), [
- [x, z.value]
- ]) : r("", !0),
- e.$slots.desc ? (n(), a("div", et, [
- c(e.$slots, "desc", {}, void 0, !0)
- ])) : r("", !0)
- ], 512), [
- [x, e.$slots.filter]
- ]),
- i("div", tt, [
- e.$slots.tabs ? (n(), a("div", {
- key: 0,
- class: "tabs-wrap",
- ref_key: "tabs",
- ref: S
- }, [
- c(e.$slots, "tabs", {}, void 0, !0)
- ], 512)) : r("", !0),
- i("div", ot, [
- w(E, { spinning: T.value }, {
- default: v(() => [
- i("div", {
- class: "s-card-grid",
- style: de({ gridTemplateColumns: `repeat(${$.column}, 1fr)` })
- }, [
- (n(!0), a(ue, null, ce(N.value, (o, g) => (n(), a("div", {
- class: "s-card-item",
- key: ge(o, g)
- }, [
- e.$slots.cardHeader || o.title ? (n(), a("div", nt, [
- c(e.$slots, "cardHeader", {
- item: o,
- index: g
- }, () => [
- L(h(o.title), 1)
- ], !0)
- ])) : r("", !0),
- i("div", lt, [
- c(e.$slots, "default", {
- item: o,
- index: g
- }, void 0, !0)
- ]),
- i("div", st, [
- c(e.$slots, "cardFooter", {
- item: o,
- index: g
- }, () => [
- w(l, {
- type: "link",
- size: "small",
- onClick: (Ae) => oe("edit", o, g)
- }, {
- default: v(() => [
- L(h(e.$l("编辑")), 1)
- ]),
- _: 1
- }, 8, ["onClick"]),
- w(l, {
- type: "link",
- size: "small",
- danger: "",
- onClick: (Ae) => oe("delete", o, g)
- }, {
- default: v(() => [
- L(h(e.$l("删除")), 1)
- ]),
- _: 1
- }, 8, ["onClick"])
- ], !0)
- ])
- ]))), 128)),
- !T.value && !N.value.length ? (n(), C(V, {
- key: 0,
- class: "s-card-empty",
- description: e.$l("暂无数据")
- }, null, 8, ["description"])) : r("", !0)
- ], 4)
- ]),
- _: 3
- }, 8, ["spinning"])
- ]),
- $.showPagination ? (n(), a("div", {
- key: 1,
- class: "s-card-pagination",
- ref_key: "pager",
- ref: O
- }, [
- w(Se, {
- size: "small",
- current: m.value,
- "onUpdate:current": t[0] || (t[0] = (o) => m.value = o),
- "page-size": Number(D.value),
- total: P.value,
- "show-size-changer": "",
- "page-size-options": $.pageSizeOptions,
- "show-total": (o) => `${e.$l("共")}${o}${e.$l("条")}`,
- onChange: $e
- }, null, 8, ["current", "page-size", "total", "page-size-options", "show-total"])
- ], 512)) : r("", !0)
- ])
- ]))
- ]),
- i("div", it, [
- c(e.$slots, "other", {}, void 0, !0)
- ]),
- ee.value ? (n(), C(Oe, {
- key: 0,
- ref: "importModalRef",
- "upload-url": q.value.importUploadUrl,
- value: M.value,
- "onUpdate:value": t[1] || (t[1] = (o) => M.value = o),
- columns: q.value.importColumns,
- apis: q.value.importApis,
- onReload: J
- }, null, 8, ["upload-url", "value", "columns", "apis"])) : r("", !0)
- ], 512);
- };
- }
- }), yt = /* @__PURE__ */ Ue(rt, [["__scopeId", "data-v-bf6ac3cf"]]);
- export {
- yt as default
- };
|