| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- var ie = ($, H, _) => new Promise((f, y) => {
- var W = (v) => {
- try {
- z(_.next(v));
- } catch (A) {
- y(A);
- }
- }, X = (v) => {
- try {
- z(_.throw(v));
- } catch (A) {
- y(A);
- }
- }, z = (v) => v.done ? f(v.value) : Promise.resolve(v.value).then(W, X);
- z((_ = _.apply($, H)).next());
- });
- import { ref as a, computed as re, watch as Ae, onMounted as De, onActivated as Ne, nextTick as Z, resolveComponent as I, resolveDirective as Le, openBlock as n, createElementBlock as s, createElementVNode as u, toDisplayString as h, Fragment as ue, renderList as ce, withDirectives as R, createBlock as O, withCtx as w, createTextVNode as M, resolveDynamicComponent as Be, createCommentVNode as r, vShow as x, renderSlot as d, normalizeStyle as de, createVNode as k, h as Me } from "vue";
- import { n as Pe, B as Te, y as Fe, ao as Ee, ah as Ue, cO as Ve } from "./index2.js";
- const Ke = { class: "tools" }, Ie = { class: "title" }, Re = { class: "btns" }, He = {
- key: 0,
- style: { "margin-left": "8px" }
- }, We = { class: "list-layout-main" }, Xe = {
- key: 1,
- class: "side-bar s-theme-bg"
- }, je = {
- key: 2,
- class: "layout-list-content"
- }, qe = {
- key: 0,
- class: "filter-content"
- }, Ge = { class: "filter" }, Je = {
- key: 1,
- class: "reset-wrap"
- }, Qe = {
- key: 1,
- class: "filter-more-content"
- }, Ye = {
- key: 2,
- class: "desc-wrap"
- }, Ze = { class: "table-content" }, xe = { class: "table-container" }, et = {
- key: 0,
- class: "s-card-header"
- }, tt = { class: "s-card-body" }, ot = { class: "s-card-footer" }, nt = {
- key: 3,
- class: "layout-list-content"
- }, lt = { class: "other" }, st = /* @__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
- },
- loadData: {
- type: Function,
- required: !0
- },
- pSize: {
- type: [String, Number],
- default: 20
- }
- },
- emits: ["reset", "btnCallback", "cardAction"],
- setup($, { expose: H, emit: _ }) {
- const f = $, y = _, W = a(null), X = a(null), z = a(null), v = a(null), A = a(null), P = a(!1), D = a(!1), N = a(!1), L = a(20), T = a(232), pe = a(!1), b = a([]), C = a([]), B = a([]), F = a(0), m = a(1), E = a(!1), fe = {
- 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(() => C.value.map((e) => e.key).includes("import")), j = re(() => C.value.find((e) => e.key === "import") || {});
- Ae(
- () => f.buttons,
- (e) => {
- e && e.length && ve(e);
- },
- { immediate: !0, deep: !0 }
- );
- function ye(e, t = "") {
- return !!(e && typeof e == "function");
- }
- function te(e) {
- return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && fe[e.key] || "";
- }
- function ve(e) {
- C.value = e.map((t) => (t.key === "remove" && (pe.value = !0), t));
- }
- function me() {
- Z(() => {
- Y(), L.value = f.pSize, U();
- });
- }
- function q() {
- D.value = !D.value, Y();
- }
- function G() {
- y("reset");
- }
- function J(e = !1) {
- U(e);
- }
- function U(e = !1) {
- return ie(this, null, function* () {
- var t, l, i, S, p;
- if (typeof f.loadData == "function") {
- e && (m.value = 1), E.value = !0;
- try {
- const c = (yield f.loadData({ pageNo: m.value, pageSize: Number(L.value) })) || {}, V = c.list || c.data || [];
- B.value = Array.isArray(V) ? V : [], F.value = (S = (i = (l = c.total) != null ? l : (t = c.pagination) == null ? void 0 : t.total) != null ? i : c.totalCount) != null ? S : 0;
- const K = c.pageNo || c.pageNum || ((p = c.pagination) == null ? void 0 : p.current);
- K && (m.value = K);
- } catch (c) {
- console.warn("[SListCardLayout] 卡片数据加载失败:", c), B.value = [], F.value = 0;
- } finally {
- E.value = !1;
- }
- }
- });
- }
- function we(e, t) {
- t && Number(t) !== Number(L.value) ? (L.value = Number(t), m.value = 1) : m.value = e, U();
- }
- function oe(e, t, l) {
- y("cardAction", e, t, l);
- }
- function $e(e, t) {
- if (typeof f.rowKey == "function") return f.rowKey(e, t);
- const l = e == null ? void 0 : e[f.rowKey];
- return l == null || l === "" ? t : l;
- }
- function ne(e) {
- y("btnCallback", e.key, b.value);
- const t = _e[e.key];
- typeof t == "function" ? t(e) : Q(e);
- }
- function Q(e) {
- if (e.selection !== !1 && !b.value.length) {
- window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`);
- return;
- }
- if (ye(e.api, e.name, e.key)) {
- if (e.confirm) {
- window.$confirm({
- title: `${e.name}`,
- content: () => Me(
- "div",
- { style: "color:var(--s-color-error)" },
- `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}`
- ),
- onOk: () => {
- N.value = !0, e.api(b.value).then(() => {
- window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), y("reset");
- }).finally(() => {
- N.value = !1;
- });
- }
- });
- return;
- }
- N.value = !0, e.api(b.value).then(() => {
- window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), y("reset");
- }).finally(() => {
- N.value = !1;
- });
- }
- }
- function le(e, t) {
- typeof e == "string" ? se(e, t) : e.forEach((l) => {
- se(l, t);
- });
- }
- function se(e, t) {
- const l = C.value.find((i) => i.key === e);
- if (!l) {
- console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`);
- return;
- }
- Object.keys(t).forEach((i) => {
- l[i] = t[i];
- });
- }
- function ge() {
- }
- function he(e) {
- Q(e);
- }
- function ke() {
- if (!ee.value) {
- y("btnCallback", "import");
- return;
- }
- P.value = !0;
- }
- function Y() {
- Z(ae);
- }
- function ae() {
- }
- const _e = {
- add: ge,
- delete: he,
- import: ke,
- reload: J,
- filterReset: G,
- toggleFilter: q,
- setStateBtn: le,
- handAction: Q
- }, be = {
- mounted(e) {
- e.style.cursor = "e-resize", document.addEventListener("selectstart", (t) => {
- t.preventDefault();
- }), e.onmousedown = (t) => {
- const l = t.clientX, i = T.value;
- document.onmousemove = (S) => {
- const p = S.clientX - l;
- if (p < 0) {
- if (i + p <= 232) return;
- T.value = i + p;
- } else {
- if (i + p >= 500) return;
- T.value = i + p;
- }
- }, document.onmouseup = () => {
- document.onmousemove = document.onmousedown = null;
- };
- };
- }
- };
- return De(() => {
- me();
- }), Ne(() => {
- Z(ae);
- }), H({
- reload: J,
- spinning: N,
- selectedRowKeys: b,
- renderButtons: C,
- setStateBtn: le,
- btnCallback: ne,
- filterReset: G,
- toggleFilter: q,
- table: v,
- importVisible: P,
- measureLayout: Y,
- // 卡片列表
- list: B,
- total: F,
- pageNo: m,
- fetchList: U
- }), (e, t) => {
- const l = Te, i = I("down-outlined"), S = I("up-outlined"), p = I("sync-outlined"), c = Fe, V = Ue, K = Ee, Ce = Ve, Se = I("s-import-modal"), Oe = Le("action");
- return n(), s("div", {
- class: "list-layout",
- ref_key: "layout",
- ref: W
- }, [
- u("div", Ke, [
- u("div", Ie, h($.title), 1),
- u("div", Re, [
- (n(!0), s(ue, null, ce(C.value, (o) => (n(), s("span", {
- class: "item-btn",
- key: o.key
- }, [
- R((n(), O(l, {
- class: "btn",
- disabled: !!o.disabled,
- type: o.type || o.key === "add" ? "primary" : "default",
- onClick: (g) => ne(o)
- }, {
- icon: w(() => [
- te(o) ? (n(), O(Be(te(o)), { key: 0 })) : r("", !0)
- ]),
- default: w(() => [
- M(" " + h(e.$l(o.name)), 1)
- ]),
- _: 2
- }, 1032, ["disabled", "type", "onClick"])), [
- [Oe, o.action || o.key],
- [x, o.show !== !1]
- ])
- ]))), 128)),
- e.$slots.otherBtns ? (n(), s("span", He, [
- d(e.$slots, "otherBtns", { selections: b.value }, void 0, !0)
- ])) : r("", !0)
- ])
- ]),
- u("div", We, [
- e.$slots.tree ? (n(), s("div", {
- key: 0,
- class: "side s-side-tree",
- ref: "side",
- style: de([{ width: T.value + "px" }, { "overflow-y": "auto" }])
- }, [
- d(e.$slots, "tree", {}, void 0, !0)
- ], 4)) : r("", !0),
- e.$slots.tree ? R((n(), s("div", Xe, null, 512)), [
- [be]
- ]) : r("", !0),
- e.$slots.empty ? (n(), s("div", nt, [
- d(e.$slots, "empty", {}, void 0, !0)
- ])) : (n(), s("div", je, [
- R(u("div", {
- class: "list-filter-wrap",
- ref_key: "filters",
- ref: X
- }, [
- e.$slots.filter ? (n(), s("div", qe, [
- u("div", Ge, [
- d(e.$slots, "filter", {}, void 0, !0)
- ]),
- e.$slots.filterMore ? (n(), s("a", {
- key: 0,
- class: "filter-more-btn",
- onClick: q
- }, [
- M(h(D.value ? e.$l("收起") : e.$l("更多")) + " ", 1),
- D.value ? (n(), O(S, {
- key: 1,
- style: { "font-size": "12px" }
- })) : (n(), O(i, {
- key: 0,
- style: { "font-size": "12px" }
- }))
- ])) : r("", !0),
- e.$slots.filter ? (n(), s("div", Je, [
- k(c, {
- placement: "top",
- overlayStyle: { maxWidth: "500px" },
- mouseEnterDelay: 1.5,
- mouseLeaveDelay: 0.5
- }, {
- title: w(() => [
- u("span", null, h(e.$l("条件重置")), 1)
- ]),
- default: w(() => [
- k(l, {
- style: { "padding-bottom": "2px" },
- onClick: G
- }, {
- icon: w(() => [
- k(p)
- ]),
- _: 1
- })
- ]),
- _: 1
- })
- ])) : r("", !0)
- ])) : r("", !0),
- e.$slots.filterMore ? R((n(), s("div", Qe, [
- d(e.$slots, "filterMore", {}, void 0, !0)
- ], 512)), [
- [x, D.value]
- ]) : r("", !0),
- e.$slots.desc ? (n(), s("div", Ye, [
- d(e.$slots, "desc", {}, void 0, !0)
- ])) : r("", !0)
- ], 512), [
- [x, e.$slots.filter]
- ]),
- u("div", Ze, [
- e.$slots.tabs ? (n(), s("div", {
- key: 0,
- class: "tabs-wrap",
- ref_key: "tabs",
- ref: z
- }, [
- d(e.$slots, "tabs", {}, void 0, !0)
- ], 512)) : r("", !0),
- u("div", xe, [
- k(K, { spinning: E.value }, {
- default: w(() => [
- u("div", {
- class: "s-card-grid",
- style: de({ gridTemplateColumns: `repeat(${$.column}, 1fr)` })
- }, [
- (n(!0), s(ue, null, ce(B.value, (o, g) => (n(), s("div", {
- class: "s-card-item",
- key: $e(o, g)
- }, [
- e.$slots.cardHeader || o.title ? (n(), s("div", et, [
- d(e.$slots, "cardHeader", {
- item: o,
- index: g
- }, () => [
- M(h(o.title), 1)
- ], !0)
- ])) : r("", !0),
- u("div", tt, [
- d(e.$slots, "default", {
- item: o,
- index: g
- }, void 0, !0)
- ]),
- u("div", ot, [
- d(e.$slots, "cardFooter", {
- item: o,
- index: g
- }, () => [
- k(l, {
- type: "link",
- size: "small",
- onClick: (ze) => oe("edit", o, g)
- }, {
- default: w(() => [
- M(h(e.$l("编辑")), 1)
- ]),
- _: 1
- }, 8, ["onClick"]),
- k(l, {
- type: "link",
- size: "small",
- danger: "",
- onClick: (ze) => oe("delete", o, g)
- }, {
- default: w(() => [
- M(h(e.$l("删除")), 1)
- ]),
- _: 1
- }, 8, ["onClick"])
- ], !0)
- ])
- ]))), 128)),
- !E.value && !B.value.length ? (n(), O(V, {
- key: 0,
- class: "s-card-empty",
- description: e.$l("暂无数据")
- }, null, 8, ["description"])) : r("", !0)
- ], 4)
- ]),
- _: 3
- }, 8, ["spinning"])
- ]),
- $.showPagination ? (n(), s("div", {
- key: 1,
- class: "s-card-pagination",
- ref_key: "pager",
- ref: A
- }, [
- k(Ce, {
- size: "small",
- current: m.value,
- "onUpdate:current": t[0] || (t[0] = (o) => m.value = o),
- "page-size": Number(L.value),
- total: F.value,
- "show-size-changer": "",
- "page-size-options": $.pageSizeOptions,
- "show-total": (o) => `${e.$l("共")}${o}${e.$l("条")}`,
- onChange: we
- }, null, 8, ["current", "page-size", "total", "page-size-options", "show-total"])
- ], 512)) : r("", !0)
- ])
- ]))
- ]),
- u("div", lt, [
- d(e.$slots, "other", {}, void 0, !0)
- ]),
- ee.value ? (n(), O(Se, {
- key: 0,
- ref: "importModalRef",
- "upload-url": j.value.importUploadUrl,
- value: P.value,
- "onUpdate:value": t[1] || (t[1] = (o) => P.value = o),
- columns: j.value.importColumns,
- apis: j.value.importApis,
- onReload: J
- }, null, 8, ["upload-url", "value", "columns", "apis"])) : r("", !0)
- ], 512);
- };
- }
- }), ut = /* @__PURE__ */ Pe(st, [["__scopeId", "data-v-e22cc55e"]]);
- export {
- ut as default
- };
|