UNPKG

quick-admin-vue3-core

Version:

以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板

294 lines (293 loc) 8.28 kB
import { X as $, Y as k, _ as L, l as T, t as _, aP as F, D as M, f as N, G as x, C as R, u as U, n as V, c as h, aQ as S } from "./platform-DsTwHxm6.js"; import { b as Y } from "./_utils-CpYRDY0G.js"; function y(s = [], r) { return r ? s.filter((l) => { const { auth: t, attrs: e } = l; if (!(t != null && t.length)) return !0; const a = r(t); return a ? (a === "disabled" && (e.disabled = !0), !0) : !1; }) : s; } const { merge: z } = L, et = "operateBtns", { gapLarge: at = "8px", gapDefault: rt = "6px", gapSmall: st = "4px" } = V; function lt(s, r, l) { const { operateBtns: t, handleAuth: e, disabled: a } = l; if (!(t != null && t.length)) return []; const n = Y(s, r, t, { attrs: { disabled: a } }); return (y == null ? void 0 : y(n, e)) ?? n; } function W(s, r) { const l = r.split("."); let t = s; for (const e of l) if (t = s[e], typeof t > "u") return U; return t; } function G(s) { const { width: r, minWidth: l, type: t, prop: e, label: a, formatter: i } = s; if (typeof a != "string") return; const n = {}, u = !x && (e == null ? void 0 : e.includes(".")) && !i; return u && (n.formatter = (p) => W(p, e)), !r && !l && (a != null && a.includes("时间") && (n.minWidth = 164, t !== "slot" && (n.formatter = (p) => { const d = u ? W(p, e) : p[e]; return R(d); })), x || a != null && a.includes("备注") && Object.assign(n, m.T_Remark)), n; } function C(s, r = 0, l = T) { let t = r; const { getInferredAttrs: e, ...a } = s, { children: i, type: n, visible: u = !0, exportable: f = !0 } = a, p = n && J.includes(n), d = p ? void 0 : G(a), o = z({ visible: u, exportable: f }, Q, d, e == null ? void 0 : e(a), a); return p ? { col: o, level: 1 } : (_(o.prop) === "Array" && (o.prop = o.prop.join(N)), i != null && i.length && (o.children = i.map((c) => { if (_(c) !== "Object") return 0; const { col: g, level: b } = C(c, r++, l); return b > t && (t = b), g; })), { col: o, level: t }); } function K(s) { let r = _(s); if (r === "Boolean" && (s = F, r = "String"), r === "String") return (l, t) => M(l[t.property]).format(s); if (r === "Function") return s; throw new Error(`暂未处理此类型:${r}`); } function E(s = []) { return s.filter((l) => !!l).map((l) => { let { tpl: t, ...e } = l; if ($) { const { type: n } = e; if (!t && m[n] && (t = n), t) { const u = k(t, m); e = z(u, e); } } const { children: a, formatter: i } = e; return i && (e.formatter = K(i)), a != null && a.length && (e.children = E(a)), e; }); } function nt(s, r, l = !1) { let t = !1, e = 0; const { operateBtns: a, currPage: i, pageSize: n, size: u } = s; let { cols: f = [] } = s; l || (f = E(f)); const p = f.map((d) => { let { col: o, level: c } = C(d, 1, u); const { type: g } = o; return g === "operate" ? (t = !0, o = { ...m.T_Operate, ...o }) : g === "index" && i && n && o.index === void 0 && (o.index = (b) => b + 1 + (i - 1) * n), c > e && (e = c), o; }); return !t && (a != null && a.length) && p.push(C(m.T_Operate, 1, u).col), r == null || r(e, p), p.filter((d) => !!d && d.visible); } const J = ["index", "sort", "selection", "operate"]; var B; const it = Object.assign( { // stripe: true, rowKey: "id", border: !0, // size: "small", tableLayout: "auto", //auto, fixed highlightCurrentRow: !0, defaultExpandAll: !1 //为树形表格时,展开所有节点 }, (B = h.element) == null ? void 0 : B.table ); var v; const Q = Object.assign( { align: "center", headerAlign: "center" }, (v = h.element) == null ? void 0 : v.tableColumn ); var w; const ot = Object.assign( { // small: true, background: !0, // defaultPageSize: 20, // defaultCurrentPage: 1, layout: "total, sizes, prev, pager, next, jumper" }, (w = h.element) == null ? void 0 : w.pagination ), X = { large: 250, default: 210, small: 170 }, q = { large: 156, default: 136, small: 114 }; var A, O, I, P; const H = { /*** 系统内置基础列 ***/ //序号列 T_Index: { prop: "$index", label: "序号", type: "index", width: 74, // 54, fixed: "left" // index: (ind: number) => ind + 1 + (currPage - 1) * pageSize, }, //排序列 T_Sort: { prop: "$sort", label: "排序", type: "sort", width: 74, //54, fixed: "left" }, //多选列 T_Selection: { prop: "$selection", label: "选择", type: "selection", width: 48, fixed: "left" }, //操作列 T_Operate: { prop: "$operate", label: "操作", type: "operate", width: X[T], // 按三个按钮计算的宽度(每个按钮均有图标,按钮文字均为两个字符) fixed: "right" }, /*** 系统内置组件列 ***/ //是否启用状态 T_BaseTag: { prop: "status", label: "状态", minWidth: 90, type: "BaseTag", attrs: { name: "D_EnableStatus" } }, //头像 T_Avatar: { prop: "avatar_url", label: "头像", type: "BaseAvatar", // minWidth: defaultBaseImgColWidthMap[defaultCommonSize], attrs: { size: "8.6em", style: "margin: 0 auto" } }, //图片 T_BaseImg: { prop: "img_url", label: "图片", type: "BaseImg", minWidth: q[T], attrs: { size: "8.6em", style: "margin: 0 auto" } }, //文本省略显示,点击查看更多 T_BaseText: { prop: "content", label: "内容", type: "BaseText", minWidth: 250 }, // 文本复制 T_BaseCopy: { minWidth: 190, type: "BaseCopy" }, /*** 表单控件列 ***/ //switch开关 T_Switch: { prop: "status", label: "启用状态", minWidth: 80, type: "switch", attrs: (O = (A = S) == null ? void 0 : A.switch) == null ? void 0 : O.attrs // attrs: { // // onChange(e) { // // ElMessage.warning("暂未处理【启用/禁用】事件"); // // }, // }, }, // input输入框 T_Input: { prop: "value", label: "编辑内容", type: "input", minWidth: 200, attrs: (P = (I = S) == null ? void 0 : I.input) == null ? void 0 : P.attrs, getInferredAttrs(s) { const { label: r, attrs: l = {} } = s, { placeholder: t } = l; return { placeholder: t == null ? void 0 : t.replace("${label}", r) }; } } /*** 外部组件列 ***/ // 例:用户信息 // T_UserInfo: { // prop: "user_data", // label: "用户信息", // fixed: "left", // type: "UserInfo", // getInferredAttrs(col: TableColAttrs) { // return { // width: col?.attrs?.simple ? 222 : 440, // }; // }, // }, }; var j, D; const m = Object.assign( { ...H, // 基础表格列类型 /*** 扩展模板列 ***/ //id列:唯一标识id(不可复制id) T_Id: { prop: "id", label: "ID", minWidth: 70, type: "BaseCopy", fixed: "left" }, // 电话号码 T_Phone: { prop: "phone", label: "电话号码", minWidth: 110 }, // 启用状态 T_EnableStatus: { prop: "status", label: "启用状态", minWidth: 80, type: "BaseTag", attrs: { name: "D_EnableStatus" } }, // 是否状态列 T_YesNoStatus: { label: "是否状态", minWidth: 80, type: "BaseTag", attrs: { name: "D_YesNoStatus" } }, // // 时分秒列 // time: { minWidth: 80 }, // // 年月日时分秒列 // dateTime: { minWidth: 160 }, //创建人/创建列 T_Create: { prop: "create_time", label: "创建时间", minWidth: 160, type: "UserTime", attrs: { userProp: "create_user", timeProp: "create_time" } }, //修改人/修改时间列 T_Update: { prop: "update_time", label: "修改时间", minWidth: 160, type: "UserTime", attrs: { userProp: "update_user", timeProp: "update_time" } }, // 备注列 T_Remark: { // prop: "remark", // 省略不写时,prop 跟模板名称保持一致 label: "备注", minWidth: 140, type: "BaseText" } }, (D = (j = h) == null ? void 0 : j.tpls) == null ? void 0 : D.tableCol ); export { lt as a, ot as b, y as c, it as d, E as e, nt as g, et as o, J as s };