| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- import { ref as l, computed as Y, watch as M, onMounted as Re, onActivated as ze, nextTick as P, onBeforeUnmount as Ae, resolveComponent as K, resolveDirective as De, openBlock as n, createElementBlock as a, createElementVNode as d, toDisplayString as b, createVNode as g, withCtx as f, Fragment as Z, renderList as Ie, withDirectives as L, createBlock as C, createTextVNode as ee, resolveDynamicComponent as Be, createCommentVNode as i, vShow as te, renderSlot as r, normalizeStyle as Te, unref as oe, h as xe } from "vue";
- import { n as Me, B as Pe, y as Ke, d0 as Le } from "./index2.js";
- import { c as Ue } from "./side-drag.js";
- import { S as Ee } from "./index9.js";
- const Fe = { class: "tools" }, Ve = { class: "title" }, qe = { class: "btns" }, Ne = { class: "list-layout-main" }, je = {
- key: 1,
- class: "side-bar s-theme-bg"
- }, He = {
- key: 2,
- class: "layout-list-content"
- }, We = {
- key: 0,
- class: "desc-wrap"
- }, Ge = {
- key: 0,
- class: "filter-content"
- }, Je = { class: "filter" }, Qe = {
- key: 1,
- class: "reset-wrap"
- }, Xe = {
- key: 1,
- class: "filter-more-content"
- }, Ye = { class: "table-content" }, Ze = { class: "table-container" }, et = ["onClick"], tt = {
- key: 3,
- class: "layout-list-content"
- }, ot = { class: "other" }, nt = /* @__PURE__ */ Object.assign({ name: "SListLayout" }, {
- __name: "SListLayout",
- props: {
- // 页面标题
- 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
- }
- ]
- },
- // 列表checkbox列
- isSelection: {
- type: Boolean,
- default: !1
- },
- showPagination: {
- type: Boolean,
- default: !0
- },
- columns: {
- type: Array,
- default: () => []
- },
- rowKey: {
- type: [Function, String],
- default: "id"
- },
- loadData: {
- type: Function,
- required: !0
- },
- pSize: {
- type: [String, Number],
- default: 20
- },
- // 初始勾选的表格行 key(选择表格弹窗等场景由外部带入)
- selectedRowKeysArr: {
- type: Array,
- default: () => []
- }
- },
- emits: ["reset", "btnCallback", "tableColCallback"],
- setup(m, { expose: ne, emit: le }) {
- const k = m, p = le, _ = l(null), ae = l(null), ie = l(null), y = l(null), se = l(8), S = l(!1), h = l(!1), U = l(300), c = l(!1), E = l(20), O = l(232), F = l(!1), u = l([]), V = l([]), R = l([]), v = l([]), re = {
- 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"
- }, q = Y(() => v.value.map((e) => e.key).includes("import")), z = Y(() => v.value.find((e) => e.key === "import") || {});
- M(
- () => k.buttons,
- (e) => {
- e && e.length && ue(e);
- },
- { immediate: !0, deep: !0 }
- ), M(
- () => k.columns,
- () => H()
- ), M(
- () => k.selectedRowKeysArr,
- (e) => {
- u.value = e || [];
- },
- { immediate: !0 }
- );
- function N(e, t = "") {
- return !!(e && typeof e == "function");
- }
- function j(e) {
- return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && re[e.key] || "";
- }
- function ue(e) {
- v.value = e.map((t) => (t.key === "remove" && (F.value = !0), t));
- }
- function de() {
- P(() => {
- Q(), E.value = k.pSize, R.value = k.columns.map((e) => ((e.template || e.isClick || e.dataIndex === "action" && !e.customRender) && !e.scopedSlots && (e.scopedSlots = { customRender: e.dataIndex }), e));
- }), setTimeout(() => {
- const e = document.querySelector(".ant-table-cell.ant-table-cell-scrollbar"), t = document.querySelector(".ant-table-thead tr");
- e && t && t.removeChild(e);
- }, 100);
- }
- function H() {
- de();
- }
- function A() {
- h.value = !h.value, Q();
- }
- function D() {
- p("reset");
- }
- function I() {
- y.value && y.value.refresh(!0);
- }
- function W(e) {
- p("btnCallback", e.key, u.value);
- const t = $e[e.key];
- typeof t == "function" ? t(e) : B(e);
- }
- function B(e) {
- if (e.selection !== !1 && !u.value.length) {
- window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`);
- return;
- }
- if (N(e.api, e.name, e.key)) {
- if (e.confirm) {
- window.$confirm({
- title: `${e.name}`,
- content: () => xe(
- "div",
- { style: "color:var(--s-color-error)" },
- `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}`
- ),
- onOk: () => {
- c.value = !0, e.api(u.value).then(() => {
- window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), p("reset");
- }).finally(() => {
- c.value = !1;
- });
- }
- });
- return;
- }
- c.value = !0, e.api(u.value).then(() => {
- window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), p("reset");
- }).finally(() => {
- c.value = !1;
- });
- }
- }
- function G(e, t) {
- typeof e == "string" ? J(e, t) : e.forEach((s) => {
- J(s, t);
- });
- }
- function J(e, t) {
- const s = v.value.find((w) => w.key === e);
- if (!s) {
- console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`);
- return;
- }
- Object.keys(t).forEach((w) => {
- s[w] = t[w];
- });
- }
- function ce() {
- }
- function fe(e) {
- B(e);
- }
- function me() {
- if (!q.value) {
- p("btnCallback", "import");
- return;
- }
- S.value = !0;
- }
- function pe(e) {
- N(e.api, e.name, e.key) && (c.value = !0, e.api().then(() => {
- c.value = !1;
- }));
- }
- function ye(e, t) {
- p("tableColCallback", e, t);
- }
- function T(e) {
- return R.value.find((t) => t.dataIndex === e);
- }
- function ve(e) {
- const t = T(e);
- return !!(t && t.template);
- }
- function we(e) {
- const t = T(e);
- return !!(t && t.isClick);
- }
- function ke(e) {
- return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e;
- }
- function he(e) {
- u.value = e;
- }
- function Q() {
- P(x);
- }
- function x() {
- const e = y.value && y.value.$el, t = e && e.querySelector(".ant-table-body"), s = t && t.clientHeight;
- s && (U.value = Math.max(s - 8, 0));
- }
- const $e = {
- add: ce,
- delete: fe,
- import: me,
- export: pe,
- reload: I,
- filterReset: D,
- toggleFilter: A,
- setStateBtn: G,
- handAction: B
- }, be = Ue(
- () => O.value,
- (e) => O.value = e,
- { min: 232 }
- );
- let $ = null;
- return Re(() => {
- H(), window.ResizeObserver && _.value && ($ = new ResizeObserver(() => x()), $.observe(_.value));
- }), ze(() => {
- P(x);
- }), Ae(() => {
- $ && ($.disconnect(), $ = null);
- }), ne({
- reload: I,
- spinning: c,
- selectedRowKeys: u,
- renderButtons: v,
- setStateBtn: G,
- btnCallback: W,
- filterReset: D,
- toggleFilter: A,
- table: y,
- importVisible: S
- }), (e, t) => {
- const s = Pe, w = Ee, X = K("double-right-outlined"), ge = K("sync-outlined"), Ce = Ke, Se = K("s-import-modal"), _e = De("action");
- return n(), a("div", {
- class: "list-layout",
- ref_key: "layoutRef",
- ref: _
- }, [
- d("div", Fe, [
- d("div", Ve, b(m.title), 1),
- d("div", qe, [
- g(w, { size: se.value }, {
- default: f(() => [
- (n(!0), a(Z, null, Ie(v.value, (o) => (n(), a("span", {
- class: "item-btn",
- key: o.key
- }, [
- L((n(), C(s, {
- class: "btn",
- disabled: !!o.disabled,
- type: o.type || o.key === "add" ? "primary" : "default",
- onClick: (Oe) => W(o)
- }, {
- icon: f(() => [
- j(o) ? (n(), C(Be(j(o)), { key: 0 })) : i("", !0)
- ]),
- default: f(() => [
- ee(" " + b(e.$l(o.name)), 1)
- ]),
- _: 2
- }, 1032, ["disabled", "type", "onClick"])), [
- [_e, o.action || o.key],
- [te, o.show !== !1]
- ])
- ]))), 128)),
- r(e.$slots, "otherBtns", { selections: u.value }, void 0, !0)
- ]),
- _: 3
- }, 8, ["size"])
- ])
- ]),
- d("div", Ne, [
- e.$slots.tree ? (n(), a("div", {
- key: 0,
- class: "side s-side-tree",
- ref: "side",
- style: Te([{ width: O.value + "px" }, { "overflow-y": "auto" }])
- }, [
- r(e.$slots, "tree", {}, void 0, !0)
- ], 4)) : i("", !0),
- e.$slots.tree ? L((n(), a("div", je, null, 512)), [
- [oe(be)]
- ]) : i("", !0),
- e.$slots.empty ? (n(), a("div", tt, [
- r(e.$slots, "empty", {}, void 0, !0)
- ])) : (n(), a("div", He, [
- e.$slots.desc ? (n(), a("div", We, [
- r(e.$slots, "desc", {}, void 0, !0)
- ])) : i("", !0),
- e.$slots.filter || e.$slots.filterMore ? (n(), a("div", {
- key: 1,
- class: "list-filter-wrap",
- ref_key: "filters",
- ref: ae
- }, [
- e.$slots.filter ? (n(), a("div", Ge, [
- d("div", Je, [
- r(e.$slots, "filter", {}, void 0, !0)
- ]),
- e.$slots.filterMore ? (n(), a("a", {
- key: 0,
- class: "filter-more-btn",
- onClick: A
- }, [
- ee(b(h.value ? e.$l("收起") : e.$l("更多")) + " ", 1),
- h.value ? (n(), C(X, {
- key: 1,
- style: { "font-size": "12px", transform: "rotate(-90deg)" }
- })) : (n(), C(X, {
- key: 0,
- style: { "font-size": "12px", transform: "rotate(90deg)" }
- }))
- ])) : i("", !0),
- e.$slots.filter ? (n(), a("div", Qe, [
- g(Ce, {
- placement: "top",
- overlayStyle: { maxWidth: "500px" },
- mouseEnterDelay: 1.5,
- mouseLeaveDelay: 0.5
- }, {
- title: f(() => [
- d("span", null, b(e.$l("条件重置")), 1)
- ]),
- default: f(() => [
- g(s, {
- style: { "padding-bottom": "2px" },
- onClick: D
- }, {
- icon: f(() => [
- g(ge)
- ]),
- _: 1
- })
- ]),
- _: 1
- })
- ])) : i("", !0)
- ])) : i("", !0),
- e.$slots.filterMore ? L((n(), a("div", Xe, [
- r(e.$slots, "filterMore", {}, void 0, !0)
- ], 512)), [
- [te, h.value]
- ]) : i("", !0)
- ], 512)) : i("", !0),
- d("div", Ye, [
- e.$slots.tabs ? (n(), a("div", {
- key: 0,
- class: "tabs-wrap",
- ref_key: "tabs",
- ref: ie
- }, [
- r(e.$slots, "tabs", {}, void 0, !0)
- ], 512)) : i("", !0),
- d("div", Ze, [
- g(oe(Le), {
- ref_key: "table",
- ref: y,
- size: "middle",
- scroll: { y: U.value, x: "100%" },
- pageSize: E.value,
- rowKey: m.rowKey,
- columns: R.value,
- data: m.loadData,
- "expanded-row-keys": V.value,
- "onUpdate:expandedRowKeys": t[0] || (t[0] = (o) => V.value = o),
- rowSelection: F.value || m.isSelection ? { selectedRowKeys: u.value, onChange: he } : null,
- showPagination: m.showPagination
- }, {
- bodyCell: f((o) => [
- o.column ? (n(), a(Z, { key: 0 }, [
- ve(o.column.dataIndex) ? r(e.$slots, o.column.dataIndex, {
- text: o.text,
- record: o.record,
- index: o.index,
- item: T(o.column.dataIndex)
- }, void 0, !0, 0) : we(o.column.dataIndex) ? (n(), a("a", {
- key: 1,
- onClick: (Oe) => ye(o.column.dataIndex, o.record)
- }, b(ke(o.text)), 9, et)) : o.column.dataIndex === "action" ? r(e.$slots, "action", {
- record: o.record
- }, void 0, !0, 2) : i("", !0)
- ], 64)) : i("", !0)
- ]),
- _: 3
- }, 8, ["scroll", "pageSize", "rowKey", "columns", "data", "expanded-row-keys", "rowSelection", "showPagination"])
- ])
- ])
- ]))
- ]),
- d("div", ot, [
- r(e.$slots, "other", {}, void 0, !0)
- ]),
- q.value ? (n(), C(Se, {
- key: 0,
- ref: "importModalRef",
- "upload-url": z.value.importUploadUrl,
- value: S.value,
- "onUpdate:value": t[1] || (t[1] = (o) => S.value = o),
- columns: z.value.importColumns,
- apis: z.value.importApis,
- onReload: I
- }, null, 8, ["upload-url", "value", "columns", "apis"])) : i("", !0)
- ], 512);
- };
- }
- }), rt = /* @__PURE__ */ Me(nt, [["__scopeId", "data-v-bd5d259b"]]);
- export {
- rt as default
- };
|