UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,650 lines 69.4 kB
var $e = Object.defineProperty; var Ve = (t, e, l) => e in t ? $e(t, e, { enumerable: !0, configurable: !0, writable: !0, value: l }) : t[e] = l; var Y = (t, e, l) => Ve(t, typeof e != "symbol" ? e + "" : e, l); import { defineComponent as K, toRefs as pe, createVNode as n, Fragment as te, createTextVNode as k, ref as M, watch as I, inject as ne, getCurrentInstance as _e, onMounted as fe, onUnmounted as ve, computed as q, reactive as Qe, createApp as We, Transition as Ye, mergeProps as Xe, provide as Ge, resolveComponent as Z, onBeforeMount as Je } from "vue"; import { isPlainObject as we, cloneDeep as Ee } from "lodash-es"; import { useDateFormat as Ze, withInstall as Ie } from "../common/index.esm.js"; const Ke = { // 是否被选中 checked: { type: Boolean, default: !1 }, // 进度条状态 默认'normal' id: { type: String, default: "" }, // 禁用 disabled: { type: Boolean, default: !1 } }, et = { // 是否显示进度条信息 showInfo: { type: Boolean, default: !0 }, // 进度条状态 默认'normal' status: { type: String, default: "normal" }, // 已完成的分段百分比 percent: { type: Number, default: 0 }, maxWidth: { type: Number, default: 0 } }, tt = { /** * 按钮文本 */ selectText: { type: String, default: "选择文件" }, /** * 禁用 */ disabled: { type: Boolean, default: !1 }, /** * 启用多选 */ enableMulti: { type: Boolean, default: !0 }, /** * 允许上传类型 */ accept: { type: String, default: "*" }, /** * 配置对象 */ options: { type: Object, default: {} }, /** * 已上传附件个数 */ uploadedCount: { type: Number, default: 0 }, /** * 发起服务器端请求,某个组件使用的特殊的参数 */ extendConfig: { type: Object, default: {} }, /** * 附件服务器端服务注入的Token */ uploadServerToken: { type: String, default: "" } }, nt = /* @__PURE__ */ K({ name: "FUploadProgress", props: et, setup(t, e) { const { showInfo: l, status: i, maxWidth: a, percent: s } = pe(t); return () => n("div", { class: ["f-progress upload-progress", "upload-progress-status-" + i.value, "f-progress-status-" + i.value, "upload-progress-line", l.value ? "upload-progress-show-info" : ""] }, [n("div", { class: "upload-progress-outer", style: { "max-width": a.value > 0 ? a.value + "px" : "auto" } }, [n("div", { class: "upload-progress-inner" }, [n("div", { class: "upload-progress-bg f-progress-bg", style: { width: s.value + "%" } }, null)])]), l.value ? n("span", { class: "upload-progress-text" }, [i.value === "error" || i.value === "success" ? n("span", { class: ["upload-progress-text-icon f-icon", "f-icon-" + i.value] }, null) : n(te, null, [s.value, k("%")])]) : ""]); } }), Be = /* @__PURE__ */ K({ name: "FPreviewCheckbox", props: Ke, emits: ["checkedChange"], setup(t, e) { const { disabled: l } = pe(t), i = M(t.checked), a = (s) => { s.stopPropagation(), l.value || (i.value = !i.value, e.emit("checkedChange", { checked: i.value, id: t.id })); }; return I(() => t.checked, (s) => { i.value = s; }), () => n("div", { class: "preview-checkbox d-inline-flex align-middle" }, [n("div", { class: "custom-control custom-checkbox f-checkradio-single m-0" }, [n("input", { title: "custom-control-input", class: "custom-control-input", type: "checkbox", disabled: l.value, checked: i.value }, null), n("label", { class: "custom-control-label", onClick: (s) => a(s), onMousedown: (s) => s.stopPropagation() }, null)])]); } }), De = /* @__PURE__ */ K({ name: "FFileSelect", props: tt, emits: ["change", "stateChange"], setup(t, e) { const l = ne("uploaderService"); l.setUploadContext(e); const i = _e(), a = M("*"); let s; const u = () => { s.files && (e.emit("change", s.files), l.handleFiles(s.files), s.value = null); }; function r() { s.value = null, l.reset(); } I(() => t.disabled, () => { r(); }), I(() => t.uploadedCount, (d) => { l.setOptions({ uploadedCount: d }); }), I(() => t.extendConfig, (d) => { l.setExtendServerConfig(d); }); function h(d) { d && d.stopPropagation(), s.click(); } function p(d) { l.handleUploadEvent(d); } return fe(() => { var d, v; s = (d = i == null ? void 0 : i.proxy) == null ? void 0 : d.$refs.uploadInput, r(), l.setOptions(t.options), l.setExtendServerConfig(t.extendConfig), a.value = (((v = t.options) == null ? void 0 : v.allowedContentTypes) || ["*"]).join(","); }), ve(() => { }), e.expose({ handleUploadEvent: p }), () => n(te, null, [n("input", { ref: "uploadInput", type: "file", class: "ffileupload--browser", disabled: t.disabled, multiple: t.enableMulti, accept: a.value, onChange: () => u(), style: "width: 10px", title: "uploadInput" }, null), n("div", { class: ["upload-container", t.disabled ? "f-state-disabled" : ""], onClick: (d) => h(d), title: t.selectText }, [n("i", { class: "f-icon f-icon-upload upload-icon", style: "top: 2px;position: relative;" }, null), t.selectText])]); } }), Ae = {}, He = {}; function me(t) { const { properties: e, title: l, ignore: i } = t, a = i && Array.isArray(i), s = Object.keys(e).reduce((u, r) => ((!a || !i.find((h) => h === r)) && (u[r] = e[r].type === "object" && e[r].properties ? me(e[r]) : Ee(e[r].default)), u), {}); if (l && (!a || !i.find((u) => u === "id"))) { const u = l.toLowerCase().replace(/-/g, "_"); s.id = `${u}_${Math.random().toString().slice(2, 6)}`; } return s; } function lt(t) { const { properties: e, title: l, required: i } = t; if (i && Array.isArray(i)) { const a = i.reduce((s, u) => (s[u] = e[u].type === "object" && e[u].properties ? me(e[u]) : Ee(e[u].default), s), {}); if (l && i.find((s) => s === "id")) { const s = l.toLowerCase().replace(/-/g, "_"); a.id = `${s}_${Math.random().toString().slice(2, 6)}`; } return a; } return { type: l }; } function Me(t, e = {}, l) { const i = Ae[t]; if (i) { let a = lt(i); const s = He[t]; return a = s ? s({ getSchemaByType: Me }, a, e, l) : a, a; } return null; } function it(t, e) { const l = me(e); return Object.keys(l).reduce((i, a) => (Object.prototype.hasOwnProperty.call(t, a) && (i[a] && we(i[a]) && we(t[a] || !t[a]) ? Object.assign(i[a], t[a] || {}) : i[a] = t[a]), i), l), l; } function Pe(t, e) { return Object.keys(t).filter((i) => t[i] != null).reduce((i, a) => { if (e.has(a)) { const s = e.get(a); if (typeof s == "string") i[s] = t[a]; else { const u = s(a, t[a], t); Object.assign(i, u); } } else i[a] = t[a]; return i; }, {}); } function st(t, e, l = /* @__PURE__ */ new Map()) { const i = it(t, e); return Pe(i, l); } function at(t = {}) { function e(p, d, v, f) { if (typeof v == "number") return f[p].length === v; if (typeof v == "object") { const F = Object.keys(v)[0], w = v[F]; if (F === "not") return Number(f[p].length) !== Number(w); if (F === "moreThan") return Number(f[p].length) >= Number(w); if (F === "lessThan") return Number(f[p].length) <= Number(w); } return !1; } function l(p, d, v, f) { return f[p] && f[p].propertyValue && String(f[p].propertyValue.value) === String(v); } const i = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", l] ]); Object.keys(t).reduce((p, d) => (p.set(d, t[d]), p), i); function a(p, d) { const v = p; return typeof d == "number" ? [{ target: v, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: v, operator: "getProperty", param: p, value: !!d }] : typeof d == "object" ? Object.keys(d).map((f) => { if (f === "length") return { target: v, operator: "length", param: null, value: d[f] }; const F = f, w = d[f]; return { target: v, operator: "getProperty", param: F, value: w }; }) : []; } function s(p) { return Object.keys(p).reduce((v, f) => { const F = a(f, p[f]); return v.push(...F), v; }, []); } function u(p, d) { if (i.has(p.operator)) { const v = i.get(p.operator); return v && v(p.target, p.param, p.value, d) || !1; } return !1; } function r(p, d) { return s(p).reduce((F, w) => F && u(w, d), !0); } function h(p, d) { const v = Object.keys(p), f = v.includes("allOf"), F = v.includes("anyOf"), w = f || F, T = (w ? p[w ? f ? "allOf" : "anyOf" : "allOf"] : [p]).map((x) => r(x, d)); return f ? !T.includes(!1) : T.includes(!0); } return { parseValueSchema: h }; } const ot = {}, rt = {}; at(); function ut(t, e, l = /* @__PURE__ */ new Map(), i = (u, r, h, p) => r, a = {}, s = (u) => u) { return Ae[e.title] = e, He[e.title] = i, ot[e.title] = a, rt[e.title] = s, (u = {}, r = !0) => { if (!r) return Pe(u, l); const h = st(u, e, l), p = Object.keys(t).reduce((d, v) => (d[v] = t[v].default, d), {}); return Object.assign(p, h); }; } const ct = "https://json-schema.org/draft/2020-12/schema", dt = "https://farris-design.gitee.io/uploader.schema.json", pt = "uploader", ft = "A Farris Component", vt = "object", mt = { id: { description: "The unique identifier for uploader", type: "string" }, type: { description: "The type string of uploader", type: "string", default: "uploader" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, disable: { type: "boolean", default: !1 }, placeholder: { description: "", type: "string", default: "" }, readonly: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, visible: { description: "", type: "boolean", default: !0 } }, ht = [ "id", "type" ], gt = { $schema: ct, $id: dt, title: pt, description: ft, type: vt, properties: mt, required: ht }; function yt(t, e) { return { customClass: e.class, customStyle: e.style }; } const bt = /* @__PURE__ */ new Map([ ["appearance", yt] ]); function wt(t, e, l) { return e; } const xt = "uploader", St = "A Farris Component", Ct = "object", Ft = { basic: { description: "Basic Infomation", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } }, appearance: { description: "外观", title: "外观", properties: { contentFill: { description: "内容填充", title: "内容填充", type: "boolean" } } }, server: { description: "服务器配置", title: "服务器配置", properties: { rootId: { description: "附件服务器根目录", title: "附件服务器根目录", type: "string" }, formId: { description: "必填,根据【附件信息】业务字段所在位置区分:1、在子表,二级目录建议绑定主表ID。2:在主表:二级目录建议填写当前表数据ID", title: "二级目录", type: "string" } } }, upload: { description: "上传配置", title: "上传配置", properties: { uploadVisible: { description: "上传按钮是否可见", title: "上传是否可见", type: "boolean" }, uploadDisabled: { description: "禁用时,上传按钮可见,但不可用", title: "上传是否禁用", type: "boolean" }, allowEmpty: { description: "运行时是否允许不上传附件", title: "是否允许为空", type: "boolean" }, uploadSelectText: { description: "选择文件按钮文本", title: "选择文件按钮文本", type: "string" }, uploadOptions: { description: "附件上传配置", title: "附件上传配置", type: "cascade", isExpand: !0, properties: { maxUploads: { description: "值为0时表示不限制上传个数", title: "最大上传个数", type: "number" }, maxFileSize: { description: "单个附件最大值(MB)", title: "单个附件最大值(MB)", type: "number" }, allowedContentTypes: { description: "允许上传附件类型", title: "允许上传附件类型", type: "string" }, notAllowedCharsInFileName: { description: "文件名禁用字符", title: "文件名禁用字符", type: "string" } } }, enableUploadedCount: { description: "是否启用已上传个数限制", title: "是否启用已上传个数限制", type: "select", editor: { type: "waiting for modification", enum: [] } }, uploadEnableMulti: { description: "是否启用多选附件上传", title: "是否启用多选附件上传", type: "select", editor: { type: "waiting for modification", enum: [] } }, enableSliceUpload: { description: "是否启用分片上传", title: "是否启用分片上传", type: "select", editor: { type: "waiting for modification", enum: [] } }, chunkSize: { description: "分片上传时,每片的大小。单位:M", title: "分片大小(M)", type: "number" } } }, preview: { description: "附件预览", title: "附件预览", properties: { previewVisible: { description: "预览是否可见", title: "预览是否可见", type: "boolean" }, previewReadonly: { description: "预览是否只读", title: "预览是否只读", type: "boolean" }, fieldIdKey: { description: "附件ID字段", title: "附件ID字段", type: "string", editor: { type: "field-selector" } }, fileNameKey: { description: "附件名称字段", title: "附件名称字段", type: "string", editor: { type: "field-selector" } }, previewEnableMulti: { description: "是否启用批量操作", title: "是否启用批量操作", type: "boolean" }, noDelete: { description: "是否禁止删除附件", title: "是否禁止删除附件", type: "boolean" }, noPreview: { description: "是否禁止预览", title: "是否禁止预览", type: "boolean" }, previewDateFormat: { description: "附件上传时间字段的格式化设置,请注意此属性仅针对附件上传时间一个字段,若有自定义预览列,请在预览列编辑器中单独设置时间格式。", title: "附件上传时间格式化", type: "select", editor: { type: "waiting for modification", enum: [] } }, fileSortOrderKey: { description: "排序字段", title: "排序字段", type: "string" }, orderType: { description: "排序类型", title: "排序类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } } }, Tt = { title: xt, description: St, type: Ct, categories: Ft }, he = { /** 内容区域填充 */ contentFill: { type: Boolean, default: !1 }, /** 排序字段 */ orderField: { type: String, default: "createTime" }, previewColumns: { type: Array, default: [ { field: "name", width: 200, title: "文件名", checkbox: !0 }, { field: "size", width: 100, title: "大小" }, { field: "createTime", width: 100, title: "日期" }, { field: "state", width: 100, title: "状态" }, { field: "action", width: 100, title: "操作" } ] }, previewVisible: { type: Boolean, default: !0 }, /** 是否启用批量操作 */ previewEnableMulti: { type: Boolean, default: !0 }, /** 默认重命名 */ previewDefaultRename: { type: String, default: "" }, /** 附件上传部分禁用状态 */ uploadDisabled: { type: Boolean, default: !1 }, // 附件上传部分是否可见 uploadVisible: { type: Boolean, default: !0 }, // 需要重置,通过不断的赋值来改变 // @Input() uploadNeedReset: Observable<any> = new Subject(); /** 选择文件按钮上的文字 */ uploadSelectText: { type: String, default: "选择文件" }, /** 启用多选 */ uploadEnableMulti: { type: Boolean, default: !0 }, /** 已经上传文件 */ uploadedCount: { type: Number, default: 0 }, /** 整个控件禁用 */ disabled: { type: Boolean, default: !1 }, /** 下载按钮是否禁用 */ downloadButtonDisable: { type: Boolean, default: !1 }, /** 预览按钮是否禁用 */ previewButtonDisable: { type: Boolean, default: !1 }, /** 删除按钮是否禁用 */ deleteButtonDisable: { type: Boolean, default: !1 }, /** * 自定义展示信息 */ customInfo: { type: String, default: "" }, /** * 处理传递预览的数据 */ fileInfos: { type: Array, default: [] }, /** * 上传配置 */ uploadOptions: { type: Object, default: null }, /** * 发起服务器端请求,某个组件使用的特殊的参数 */ extendConfig: { type: Object, default: {} }, /** * 附件服务器端服务注入的Token */ uploadServerToken: { type: String, default: "" }, /** * 提示服务注入的Token */ notifyServiceToken: { type: String, default: "" } }, Oe = ut(he, gt, bt, wt, Tt); var X = /* @__PURE__ */ ((t) => (t[t.Queue = 0] = "Queue", t[t.Uploading = 1] = "Uploading", t[t.Done = 2] = "Done", t[t.Cancelled = 3] = "Cancelled", t[t.Remove = 4] = "Remove", t[t.Error = 5] = "Error", t))(X || {}); class kt { constructor(e = {}, l = {}) { /** * 上传配置 */ Y(this, "uploadConfig"); /** * 删除配置 */ Y(this, "removeConfig"); const i = { type: "config", url: "", timeout: 0, headers: null, data: {} }; this.uploadConfig = Object.assign({}, i, e), this.removeConfig = Object.assign({}, i, l); } } function ge(t, e) { const { formatTo: l } = Ze(); return l(t, e); } function xe(t, e) { if (!e) return ""; let l = ""; return t.indexOf(".") === -1 && e.hasOwnProperty(t) ? l = e[t] : l = t.split(".").reduce((i, a) => i ? i[a] : null, e), l; } function Et(t) { return (e, l) => { if (!e.hasOwnProperty(t) || e[t] === void 0 || e[t] === null) return 1; if (!l.hasOwnProperty(t) || l[t] === void 0 || l[t] === null) return -1; if (t !== "createTime") { let s = "", u = ""; return t.indexOf(".") > -1 ? (s = xe(t, e), u = xe(t, l)) : (s = e[t], u = l[t]), s > u ? 1 : -1; } const i = new Date(e[t]), a = new Date(l[t]); return i.getTime() > a.getTime() ? -1 : 1; }; } function Ne(t) { return (t || []).findIndex((l) => l === "*") === -1; } function Re(t) { return t !== "0 Byte"; } function ie(t) { if (t === 0) return "0 Byte"; const e = 1024, l = ["Bytes", "KB", "MB", "GB", "TB", "PB"], i = Math.floor(Math.log(t) / Math.log(e)); return parseFloat((t / e ** i).toFixed(2)) + " " + l[i]; } function Ue(t, e) { return t && (t.hasOwnProperty("allowedContentTypes") && (e.allowedContentTypes = t.allowedContentTypes || ["*"], e.allowedContentTypes = e.allowedContentTypes && e.allowedContentTypes.length > 0 ? e.allowedContentTypes : ["*"]), t.hasOwnProperty("maxUploads") && (e.maxUploads = t.maxUploads || 0), t.hasOwnProperty("maxFileSize") && (e.maxFileSize = ie(1024 * 1024 * (parseInt(String(t.maxFileSize), 10) || 1)))), e; } function Se(t) { let e = "ffilepreview--filetype"; if (!t) return e + "-any"; const l = t.lastIndexOf("."); let i = ""; switch (l > -1 && (i = t.substring(l + 1).toLocaleLowerCase()), i) { case "pdf": e += "-pdf"; break; case "jpeg": case "jpg": case "gif": case "svg": case "png": case "bmp": e += "-img"; break; case "ppt": case "pptx": e += "-ppt"; break; case "doc": case "docx": e += "-doc"; break; case "xls": case "xlsx": e += "-xls"; break; case "txt": e += "-txt"; break; case "zip": e += "-zip"; break; case "wps": e += "-wps"; break; case "wpt": e += "-wpt"; break; default: e += "-any"; } return e; } function Ce(t) { var e; if (t.type === "done") return 100; if (t.file && t.file.progress) { if (t.file.progress.status === X.Uploading) { const l = ((e = t.file.progress.data) == null ? void 0 : e.percentage) || 5; return l > 5 ? l : 5; } return 5; } return 5; } function Bt(t) { let e = t; return t ? (typeof t == "string" && (e = parseInt(t, 10)), ie(e)) : "0 Byte"; } const Dt = () => Math.random().toString(36).substring(7); function Fe(t, e) { return { fileIndex: e, id: Dt(), name: t.name, size: t.size, type: t.type, form: new FormData(), progress: { status: X.Queue, data: { percentage: 0, speed: 0, speedHuman: `${ie(0)}/s`, startTime: null, endTime: null, eta: null, etaHuman: null } }, lastModifiedDate: ge(new Date(t.lastModified), "yyyy-MM-dd HH:mm:ss"), nativeFile: t }; } function Te(t) { const e = []; return t.forEach((l) => { const i = { id: "", name: "", size: 0, type: "", extend: null, extendHeaders: null, createTime: "" }; for (const a in i) { const s = a.replace("extend", "response").replace("createTime", "lastModifiedDate"); l.hasOwnProperty(s) && (s === "lastModifiedDate" ? i[a] = ge(l[s], "yyyy-MM-dd HH:mm:ss") : i[a] = l[s]); } e.push(i); }), e; } function At(t, e) { return t ? e <= t * 1024 * 1024 : !0; } function Ht(t) { return t.find((e) => e === "*") !== void 0; } function Mt(t, e) { if (!t || t.length === 0 || Ht(t)) return !0; if (e.lastIndexOf(".") < 0) return !1; const l = e.substr(e.lastIndexOf(".")); return t.findIndex( (i) => i.toLowerCase() === l.toLowerCase() ) > -1; } function Pt(t) { if (t) return t.split(` `).map((e) => e.split(/: */, 2)).filter((e) => e[0]).reduce((e, l) => (e[l[0]] = l[1], e), {}); } function ke(t) { return new Date(t * 1e3).toISOString().substr(11, 8); } class Ot extends kt { upload(e, l, i, a) { const s = e[0]; return new Promise((u, r) => { var T, N; const h = l.url || i.url || "", p = l.method || "POST", d = l.data || {}, v = l.headers || {}, f = new XMLHttpRequest(), F = (/* @__PURE__ */ new Date()).getTime(); let w = ((T = s.progress) == null ? void 0 : T.data) && s.progress.data.startTime || F, A = 0, y = null; f.upload.addEventListener("progress", (x) => { var R; if (x.lengthComputable) { const P = Math.round(x.loaded * 100 / x.total), _ = (/* @__PURE__ */ new Date()).getTime() - F; A = Math.round(x.loaded / _ * 1e3), w = ((R = s.progress) == null ? void 0 : R.data) && s.progress.data.startTime || (/* @__PURE__ */ new Date()).getTime(), y = Math.ceil((x.total - x.loaded) / A), s.progress = { status: X.Uploading, data: { percentage: P, speed: A, speedHuman: `${ie(A)}/s`, startTime: w, endTime: null, eta: y, etaHuman: ke(y) } }, a({ type: "uploading", files: [s] }); } }, !1), f.upload.addEventListener("error", (x) => { r(x); }), f.onreadystatechange = () => { if (f.readyState === XMLHttpRequest.DONE) { const x = Math.round(s.size / ((/* @__PURE__ */ new Date()).getTime() - w) * 1e3); s.progress = { status: X.Done, data: { percentage: 100, speed: x, speedHuman: `${ie(x)}/s`, startTime: w, endTime: (/* @__PURE__ */ new Date()).getTime(), eta: y, etaHuman: ke(y || 0) } }, s.responseStatus = f.status; try { s.response = JSON.parse(f.response); } catch { s.response = f.response; } s.responseHeaders = Pt(f.getAllResponseHeaders()), u({ type: "done", files: [s] }); } }, f.open(p, h, !0), f.withCredentials = !!l.withCredentials; try { const x = s.nativeFile; Object.keys(v).forEach((P) => f.setRequestHeader(P, v[P])); let R; l.includeWebKitFormBoundary !== !1 ? (Object.keys(d).forEach((P) => { var _; return (_ = s.form) == null ? void 0 : _.append(P, d[P]); }), (N = s.form) == null || N.append(l.fieldName || "file", x, x.name), R = s.form) : R = x, f.send(R); } catch (x) { r(x); } return () => { f.abort(); }; }); } // 删除附件 remove(e, l, i, a) { return new Promise((s, u) => { s({ type: "removed", files: e }); }); } } const Nt = { showCloseButton: { type: Boolean, default: !0 }, position: { type: String, default: "top-center" }, timeout: { type: Number, default: 3e3 }, theme: { type: String, default: "bootstrap" }, left: { type: Number }, right: { type: Number }, top: { type: Number }, bottom: { type: Number }, id: { type: String }, animate: { type: String, default: "fadeIn" }, options: { type: Object }, safeHtml: { type: Boolean, default: !0 } }, Rt = { showCloseButton: { type: Boolean, default: !0 }, animate: { type: String, default: "fadeIn" }, options: { type: Object } }, de = /* @__PURE__ */ K({ name: "Toast", props: Rt, emits: ["close", "click"], setup: (t, e) => { const l = M(t.animate), i = "fadeOut", a = q(() => t.options), s = M(!1), u = q(() => { const T = { animated: s.value, toast: !0 }; return T[t.animate] = !1, T[i] = s.value, T[a.value.type] = !0, a.value.theme && (T[a.value.theme] = !0), T; }), r = q(() => { const x = `f-icon-${a.value && a.value.type ? a.value.type.replace("toasty-type-", "") : "default"}`, R = { "f-icon": !0 }; return R[x] = !0, R; }), h = q(() => a.value.title || a.value.message), p = q(() => a.value.title && a.value.message), d = q(() => !a.value.title && a.value.message), v = q(() => t.showCloseButton), f = q(() => !!a.value.buttons || !!e.slots.default); function F(T) { T.stopPropagation(), T.preventDefault(), s.value = !1, setTimeout(() => { e.emit("close", a.value); }, 200); } function w(T, N) { } function A(T) { return `f-preten-link ${T.customClass ? T.customClass : ""}`; } I(l, () => { l.value; }); const y = () => { var T; return n(te, null, [n("div", { class: "after-toast-msg text-right" }, [!e.slots.default && ((T = a.value.buttons) == null ? void 0 : T.map((N) => n("span", { class: A(N), onClick: (x) => void 0 }, [N.text]))), e.slots.default && e.slots.default()])]); }; return () => n("div", { class: u.value, style: "min-height:44px" }, [v.value && n("button", { title: "关闭", class: "toast-close f-btn-icon f-bare", onClick: F }, [n("span", { class: "f-icon modal_close" }, null)]), h.value && n("section", { class: "modal-tips" }, [n("div", { class: "float-left modal-tips-iconwrap" }, [n("span", { class: r.value }, null)]), n("div", { class: "modal-tips-content" }, [p.value && n(te, null, [n("h5", { class: "toast-title modal-tips-title", innerHTML: a.value.title }, null), n("p", { class: "toast-msg", innerHTML: a.value.message }, null), f.value && y()]), d.value && (a.value.buttons ? n("div", { class: "toast-title-btns-wrapper d-flex" }, [n("h5", { class: "toast-title modal-tips-title only-toast-msg", innerHTML: a.value.message }, null), n("div", { class: "after-toast-title text-right ml-auto" }, [y()])]) : n("h5", { class: "toast-title modal-tips-title only-toast-msg", innerHTML: a.value.message }, null))])])]); } }), re = /* @__PURE__ */ K({ name: "Notify", props: Nt, emits: ["close", "empty"], setup(t, e) { const l = q(() => ({ "farris-notify": !0 })), i = { left: 12, right: 12, top: 20, bottom: 12 }, a = M(), s = M(t.options), u = M(t.showCloseButton), r = q(() => t.position || "bottom-right"), h = q(() => t.timeout != null ? t.timeout : 3e3), p = q(() => { const f = t.bottom ? t.bottom : i.bottom, F = t.top ? t.top : i.top, w = { transition: "all 0.2s ease", left: r.value.indexOf("left") > -1 ? `${t.left ? t.left : i.left}px` : "", right: r.value.indexOf("right") > -1 ? `${t.right ? t.right : i.right}px` : "", top: r.value.indexOf("top") > -1 ? `${F}px` : "", bottom: r.value.indexOf("bottom") > -1 ? `${f}px` : "" }; return r.value.indexOf("center") > -1 && (w.left = "50%", w.marginLeft = "calc(-24rem / 2)", r.value === "center-center" && (w.top = "50%", w.transform = "translate(-50%, -50%)")), w; }); function d(f) { e.emit("close"); } h.value && setTimeout(() => { d(); }, h.value), e.expose({ closeToast: d, container: a, notifyPosition: r }); function v(f, F) { d(); } return () => n("div", { class: l.value, style: p.value, ref: a }, [n(de, { options: s.value, showCloseButton: u.value, animate: t.animate, onClose: (f) => v(f, s.value) }, null)]); } }); class je { constructor() { Y(this, "notifyRefs", []); Y(this, "globalConfig", Qe({})); } escapeAllHtml(e) { if (typeof e != "string" || !e) return ""; const l = document.createElement("div"); return l.textContent = e || "", l.innerHTML.replace(/ /g, "&nbsp;").replace(/\\n/g, "<br>").replace(/\\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\\r/g, ""); } createNotifyInstance(e) { const l = this, a = Object.assign({ timeout: 3e3, position: "bottom-right", showCloseButton: !0, safeHtml: !0 }, this.globalConfig, { ...e }), s = document.createElement("div"); s.style.display = "contents"; const u = We({ setup() { var p; const r = M(); function h() { r.value.container.style.transform = "scale(0)", setTimeout(() => { l.updateNotifyPositionForClose(a, r), u.unmount(); }, 220); } if (a.position.indexOf("top") > -1) { const d = l.getNotifyInstances(a.position), v = d[d.length - 1]; if (v) { const f = v.value.container.getBoundingClientRect(); a.top = f.bottom; } } return a.safeHtml && ((p = a.options) != null && p.message) && (a.options.message = l.escapeAllHtml(a.options.message)), ve(() => { document.body.removeChild(s); }), fe(() => { l.updateNotifyPositionForCreate(a, r); }), () => n(Ye, { mode: "out-in", name: "fade", appear: !0 }, { default: () => [n(re, Xe({ ref: r }, a, { onClose: h }), null)] }); } }); return u.provide("NotifyService", this), document.body.appendChild(s), u.mount(s), u; } getNotifyInstances(e) { return this.notifyRefs.filter((l) => l.value.notifyPosition === e); } updateNotifyPositionForCreate(e, l) { if (this.notifyRefs && this.notifyRefs.length) { const i = window.innerHeight; e.position.indexOf("bottom") > -1 && this.getNotifyInstances(e.position).forEach((a) => { const s = a.value.container.getBoundingClientRect(); a.value.container.style.bottom = s.height + i - s.bottom + "px"; }); } this.notifyRefs = [...this.notifyRefs, l]; } updateNotifyPositionForClose(e, l) { const i = this.notifyRefs.indexOf(l); if (e.position.indexOf("top") > -1) { const a = this.getNotifyInstances(e.position), s = a.indexOf(l); a.slice(s + 1).forEach((u) => { u.value.container.style.top = u.value.container.offsetTop - u.value.container.offsetHeight + "px"; }); } i > -1 && this.notifyRefs.splice(i, 1); } show(e) { return this.createNotifyInstance(e); } buildNotifyProps(e, l) { let i = "", a = "", s, u, r; typeof l == "string" ? i = l : l && (i = l.message || "", a = l.title || "", u = l.position || null, r = l.showCloseButton != null ? l.showCloseButton : null, s = l.timeout != null ? l.timeout : null); const p = { options: { type: e, message: i, title: a } }; return u != null && (p.position = u), r != null && (p.showCloseButton = r), s != null && (p.timeout = s), p; } info(e) { const l = this.buildNotifyProps("info", e); return this.show(l); } success(e) { const l = this.buildNotifyProps("success", e); return this.show(l); } warning(e) { const l = this.buildNotifyProps("warning", e); return this.show(l); } error(e) { const l = this.buildNotifyProps("error", e); return this.show(l); } close(e) { e && e.unmount(); } closeAll() { this.notifyRefs.forEach((e) => { e == null || e.value.closeToast(); }), this.notifyRefs.length = 0; } } const Ut = Symbol("NOTIFY_SERVICE_TOKEN"); re.install = (t) => { t.component(re.name, re), t.component(de.name, de); const e = new je(); t.provide(Ut, e), t.provide("FNotifyService", e); }; const jt = (t = "") => { let e; return t && ne(t, null) && (e = ne(t)), e || (e = new je()), e; }, zt = (t = "") => { let e; if (t && ne(t, null)) { const l = ne(t); l && l() && (e = l()); } return e || (e = new Ot()), e; }, ze = { getNotify: jt, getServerAPI: zt }; function Le(t, e, l) { const i = ze.getNotify(t.notifyServiceToken), a = M(t.fileInfos), { disabled: s, uploadVisible: u, uploadDisabled: r, previewVisible: h, orderField: p, previewEnableMulti: d, downloadButtonDisable: v, previewColumns: f, uploadEnableMulti: F, previewButtonDisable: w } = pe(t), A = M(!1), y = M([]), T = q(() => y.value.length), N = M([]), x = M(""); function R(o) { (!o.length || y.value.length !== o.length) && (A.value = !1); const b = [...o.map((C) => (C.hasOwnProperty("size") || (C.size = void 0), C.hasOwnProperty("createTime") || (C.createTime = void 0), d.value && (C.checked = !!y.value.find((Q) => Q.id === C.id) || A.value), C))]; return b.sort(Et(p.value)), d.value && (y.value = [...b].filter((C) => C.checked)), b; } const P = M(R(a.value)); I(() => t.fileInfos, (o) => { P.value = R(o); }); const _ = (o, m) => { o.stopImmediatePropagation(), e.emit("fileDownloadEvent", { fileInfos: [m], name: "" }); }, G = (o, m) => { o.stopImmediatePropagation(), !w.value && e.emit("filePreviewEvent", m); }, S = (o, m, b) => { m.checked && (y.value = y.value.filter((C) => C.id !== m.id)), e.emit("fileRemoveEvent", m), b.handleUploadEvent({ type: "remove", file: m }); }, H = (o, m = "preview") => o.formatter ? !0 : m === "preview" ? ["state", "name", "action", "size", "createTime"].findIndex((C) => C === o.field) > -1 : m === "upload" ? ["state", "name", "size"].findIndex((C) => C === o.field) > -1 : !1, D = (o) => !(o.field === "state" && (r.value || !u.value)), O = (o) => o.lastIndexOf(".") > 0 ? o.substring(0, o.lastIndexOf(".")) : "", U = (o) => { if (o.stopImmediatePropagation(), T.value > 1) { let m = ""; m = O(y.value[0].name), e.emit("fileDownloadEvent", { fileInfos: y.value, name: m }); } }, W = (o) => { o.stopImmediatePropagation(), e.emit("fileRemoveEvent", y.value); }, ee = (o) => { const m = P.value; o.checked ? (m.forEach((b) => { b.checked = !0; }), y.value = [...P.value], A.value = !0) : (y.value = [], m.forEach((b) => { b.checked = !1; }), A.value = !1), e.emit("previewMultiSelectedEvent", y.value); }, j = (o, m) => { o && (o.stopImmediatePropagation(), o.stopPropagation()), (!x.value || m.id !== x.value) && (x.value = m.id, e.emit("selectedEvent", m)); }, E = (o) => { const m = y.value.findIndex((Q) => Q.id === o.id), b = m > -1, C = P.value.find((Q) => Q.id === o.id); C && (C.checked = o.checked), o.checked && !b && C && y.value.push(C), !o.checked && b && y.value.splice(m, 1), P.value.length > 0 && (y.value.length === P.value.length ? A.value = !0 : A.value = !1), j(null, C), e.emit("previewMultiSelectedEvent", y.value); }, $ = (o) => { var m; (m = l == null ? void 0 : l.value) == null || m.handleUploadEvent(o); }, le = (o) => { $({ type: "upload", file: o }); }, z = (o, m) => { let b = []; o.files && o.files.length > 0 ? b = o.files : typeof o.file < "u" && (b = [o.file]), m = m || o.type, b.map((C) => { const Q = N.value.findIndex((J) => { var oe; return typeof C < "u" && ((oe = J == null ? void 0 : J.file) == null ? void 0 : oe.id) === C.id; }); Q > -1 && (N.value[Q] = { type: m, file: C }); }); }, ce = (o) => { if (o.files) { const m = o.files.map((b) => b.id); N.value = N.value.filter((b) => !(m.findIndex((Q) => { var J; return Q === ((J = b == null ? void 0 : b.file) == null ? void 0 : J.id); }) > -1)), $({ type: "hide", id: m.join(",") }); } }, se = (o) => { let m = "warning"; (o.type === "cancelled" || o.type === "removed") && (m = "success"); const b = o.hasOwnProperty("message") ? o.message : ""; i.show({ options: { type: m, message: b }, position: "top-center" }); }, ae = (o) => { if (o.type === "addedToQueue" && typeof o.file < "u") N.value.push({ type: o.type, file: o.file }), le(o.file); else if (o.type === "start") z(o, "start"); else if (o.type === "done") { z(o, "done"); const m = (o.files || []).map((b) => ({ checked: !1, id: b.id, name: b.name, size: b.size, createTime: ge(/* @__PURE__ */ new Date(), "yyyy-MM-dd HH:mm:ss") })); a.value = [...m, ...P.value], ce(o), e.emit("fUploadDoneEvent", Te(o.files || [])), e.emit("uploadDoneEvent", Te(o.files || [])); } else if (o.type === "cancelled" || o.type === "removed" || o.type === "error") { const m = a.value.filter((b) => o.files && o.files.findIndex((C) => b.id === C.id) < 0); a.value = [...m], se(o); } else o.type === "rejected" && typeof o.file < "u" && se(o); }; return ve(() => { }), { disabled: s, uploadVisible: u, uploadDisabled: r, downloadButtonDisable: v, previewVisible: h, previewColumns: f, uploadFiles: N, innerFileInfos: P, previewEnableMulti: d, previewMultiSelectedLength: T, previewSelectAllBtnChecked: A, uploadEnableMulti: F, previewCurrentId: x, multiFileRemoveHandler: W, previewMultiSelectChangeHandler: E, fileMultiDownloadHandler: U, selectOrCancelAllHandler: ee, hasColumnHtmlFunc: H, showPreviewStateColumn: D, rowSelectedHandler: j, fileDownloadHandler: _, filePreviewHandler: G, fileRemoveHandler: S, handleStateChange: ae }; } class Lt { constructor(e, l) { // 记录在上传的附件数组 Y(this, "queue"); Y(this, "uploadOpts", { // 默认不限制,0代表不限制 Number.POSITIVE_INFINITY allowedContentTypes: ["*"], maxUploads: 0, /** 单位M,默认是12M,0代表不限制 */ maxFileSize: 12, concurrency: Number.POSITIVE_INFINITY, uploadedCount: 0 }); /** * 服务器端扩展 */ Y(this, "extendServerConfig", null); Y(this, "uploadServerSer"); Y(this, "uploadContext", null); this.stateChangeRecord = e, this.serverToken = l, this.queue = [], this.uploadServerSer = ze.getServerAPI(this.serverToken); } setUploadContext(e) { this.uploadContext = e; } /** * 处理从服务器端返回的结果 */ handleResultFromServer(e) { var l, i; switch (e.type) { case "removed": this.queue = this.queue.filter( (a) => { var s; return ((s = a.progress) == null ? void 0 : s.status) !== X.Remove; } ), e.hasOwnProperty("message") || (e.message = "被删除"), this.stateChangeRecord.value = e; break; case "error": this.queue = this.queue.filter((a) => e.files && e.files.findIndex((s) => a.id === s.id) < 0), (l = this.uploadContext) == null || l.emit("stateChange", e); break; default: (i = this.uploadContext) == null || i.emit("stateChange", e); } } setOptions(e) { e && (this.uploadOpts = Object.assign(this.uploadOpts, e)); } /** * 处理上传的附件信息 * @param incomingFiles */ handleFiles(e) { var i; const l = Array.from(e).reduce( (a, s, u) => { var p; const r = a.length + this.queue.length + 1, h = this.rejectedReason( s.name, r, s.size ); if (h.allowed) a = a.concat(s); else { const d = Fe( s, u ); (p = this.uploadContext) == null || p.emit("stateChange", { type: "rejected", file: d, message: h.message }); } return a; }, [] ); [].map.call(l, (a, s) => { var r; const u = Fe(a, s); this.queue.push(u), (r = this.uploadContext) == null || r.emit("stateChange", { type: "addedToQueue", file: u }); }), (i = this.uploadContext) == null || i.emit("stateChange", { type: "allAddedToQueue" }); } /** * 获取上传被拒绝的理由 * @param name * @param queuelength * @param size * @returns */ rejectedReason(e, l, i) { let a = !1, s = ""; return this.queue.findIndex((r) => r.name === e) > -1 ? s = "上传失败:已存在同名文件" : this.uploadOpts.allowedContentTypes && !Mt(this.uploadOpts.allowedContentTypes, e) ? s = `上传失败:只允许上传${this.uploadOpts.allowedContentTypes.join(",")}类型的文档` : this.exceedMaxUpload(l) ? s = `上传失败:文件总个数超出${this.uploadOpts.maxUploads}限制` : At(this.uploadOpts.maxFileSize, i) ? i === 0 ? s = "上传失败:不允许文件为空" : a = !0 : s = `上传失败:单个文件大小超出${this.uploadOpts.maxFileSize}MB的限制`, { allowed: a, message: s }; } /** * 超出最大上传数值 * @param queuelength * @returns */ exceedMaxUpload(e = 0) { if (!this.uploadOpts || !this.uploadOpts.maxUploads) return !1; const l = this.uploadOpts.uploadedCount || 0; return this.uploadOpts.maxUploads > 0 && (this.uploadOpts.maxUploads <= l || e + l > this.uploadOpts.maxUploads); } /** * 从前端传来事件,进行服务器端方法类型判断 * @param input */ handleUploadEvent(e) { var l, i; switch (e.type) { case "upload": const a = this.queue.findIndex( (r) => r === e.file ); a !== -1 && e.file && this.serverMethod({ files: [this.queue[a]], event: e }); break; case "remove": if (!((l = e == null ? void 0 : e.file) != null && l.id)) return; const s = this.queue.findIndex( (r) => { var h; return r.id === ((h = e == null ? void 0 : e.file) == null ? void 0 : h.id); } ); if (s !== -1 && this.queue[s] && this.queue[s].progress) { const { progress: r } = this.queue[s]; r && (r.status = X.Remove); } this.serverMethod({ files: [e.file], event: e }); break; case "removeAll": const u = this.queue.filter( (r) => { var h; return ((h = r == null ? void 0 : r.progress) == null ? void 0 : h.status) === X.Queue; } ); u.length && ((i = this.uploadContext) == null || i.emit("stateChange", { type: "cancelled", files: u, message: "删除附件成功" }), this.queue = this.queue.filter( (r) => { var h; return ((h = r == null ? void 0 : r.progress) == null ? void 0 : h.status) !== X.Queue; } )), this.queue.length && (e.type = "remove", this.queue.forEach((r) => { r.progress && (r.progress.status = X.Remove); }), this.serverMethod({ files: this.queue, event: e })); break; } } /** * 处理上传的扩展参数 * @param extendSer */ setExtendServerConfig(e) { this.extendServerConfig = e; } /** * 处理服务器接口的方法 * @param upload * @returns */ serverMethod(e) { let l; switch (e.event.type) { case "upload": l = this.upload(e.files, e.event, (i) => this.handleResultFromServer(i)); break; case "removeAll": case "remove": l = this.remove(e.files, e.event, (i) => this.handleResultFromServer(i)); break; default: l = null; } l && l.then((i) => { this.handleResultFromServer(i); }).catch((i) => { this.handleResultFromServer(i); }); } /** * 上传附件 * @param files * @param event * @returns */ upload(e, l, i) { var a; return (a = this.uploadContext) == null || a.emit("stateChange", { type: "start", files: e }), this.uploadServerSer.upload(e, l, this.extendServerConfig, i); } /** * 删除附件 * @param files * @param event * @returns */ remove(e, l, i) { return this.uploadServerSer.remove(e, l, this.extendServerConfig, i); } /** * 重置 */ reset() { this.queue = []; } /** * 销毁 */ destroyed() { this.reset(); } } const ue = /* @__PURE__ */ K({ name: "FUploader", components: { "f-upload-progress": nt, "f-preview-checkbox": Be, "f-file-select": De }, props: he, emits: ["filePreviewEvent", "fileDownloadEvent", "previewMultiSelectedEvent", "selectedEvent", "fileRemoveEvent", "fileRemovedEvent", "fUploadDoneEvent", "uploadDoneEvent"], setup(t, e) { const l = M(), i = new Lt(l, t.uploadServerToken); Ge("uploaderService", i); const a = M(t.customInfo), s = Ue(t.uploadOptions, { // 允许上传的文件类型 allowedContentTypes: ["*"], // 默认不限制附件上传个数 maxUploads: 0, // 单位KB,默认是12M maxFileSize: "12MB" }), u = M(null), { disabled: r, uploadVisible: h, uploadDisabled: p, downloadButtonDisable: d, previewVisible: v, previewColumns: f, uploadFiles: F, innerFileInfos: w, previewEnableMulti: A, previewMultiSelectedLength: y, previewSelectAllBtnChecked: T, uploadEnableMulti: N, previewCurrentId: x, multiFileRemoveHandler: R, previewMultiSelectChangeHandler: P, fileMultiDownloadHandler: _, selectOrCancelAllHandler: G, rowSelectedHandler: S, hasColumnHtmlFunc: H, showPreviewStateColumn: D, fileDownloadHandler: O, filePreviewHandler: U, fileRemoveHandler: W, handleStateChange: ee } = Le(t, e, u); I(l, (c) => { switch (ee(c), c.type) { case "removed": e.emit("fileRemovedEvent", c.files[0]); break; } }); const j = q(() => w.value.length > 0); function E() { var c; return Ne((s == null ? void 0 : s.allowedContentTypes) || []) ? n("li", null, [n("span", null, [k("支持类型:")]), n("span", { class: "support-info--item-detail", style: "margin-right:4px;" }, [(c = s.allowedContentTypes) == null ? void 0 : c.join(""), k(",")])]) : ""; } function $() { return Re((s == null ? void 0 : s.maxFileSize) || "") ? n("li", null, [n("span", null, [k("单个文件限制:")]), n("span", { class: "support-info--item-detail" }, [s.maxFileSize, k(",   ")])]) : ""; } function le() { return ((s == null ? void 0 : s.maxUploads) || 0) > 0 && n("li", null, [n("span", null, [k("文件总数限制:")]), n("span", { class: "support-info--item-detail" }, [s.maxUploads, k("个")])]); } function z() { return h.value && !p.value && !r.value ? n("div", { class: "ffileupload--support-info" }, [a.value ? n("ul", { class: "support-info--wrapper" }, [n("li", null, [n("span", { class: "support-info--item-detail", innerHTML: a.value }, null)])]) : n("ul", { class: "support-info--wrapper" }, [E(), $(), le()])]) : null; } function ce(c) { var g, B, V; return n("div", { class: "uploadAndpreview--title-container" }, [n("div", { class: "ffilepreview--item-icon" }, [n("span", { class: ["ffilepreview--filetype-icon", Se(((g = c.file) == null ? void 0 : g.name) || "")] }, null)]), n("div", { class: "uploadAndpreview--right" }, [n("a", { class: "item-content--title", title: (B = c.file) == null ? void 0 : B.name }, [((V = c.file) == null ? void 0 : V.name) || "无名称"]), n(Z("f-upload-progress"), { status: c.type === "done" ? "success" : "active", percent: Ce(c), maxWidth: 300 }, null)])]); } function se(c) { return n("div", { class: "uploadAndpreview--title-container" }, [n("div", { class: "ffilepreview--item-icon" }, [n("span", { class: ["ffilepreview--filetype-icon", Se(c.name)] }, null)]), n("div", { class: "uploadAndpreview--right" }, [n("a", { class: ["item-content--title", "previewButtonDisable.value?'no-preview':''"], title: c.name, onClick: (g) => U(g, c) }, [c.name])])]); } function ae(c, g, B) { return n("div", { class: "uploadAndpreview--filesize-container" }, [c === "preview" && B ? n("span", null, [Bt(B.size)]) : null, c === "upload" && g ? n("span", null, [Ce(g)]) : null]); } function o(c, g) { return g && g.type === "error" ? n("div", { class: "uploadAndpreview--state-container" }, [n("p", { class: "upload-state--uploaded" }, [n("i", { class: "f-icon f-icon-message_warning text-danger" }, null), n("span", null,