import { computed as M, ref as c, watch as z, resolveComponent as L, openBlock as r, createElementBlock as f, createElementVNode as i, toDisplayString as P, createCommentVNode as h, createVNode as v, unref as u, normalizeStyle as R, withCtx as S, withDirectives as K, createBlock as x, vShow as j } from "vue"; import { d as H } from "./vuedraggable.js"; import { b as q, d as G } from "./upload.js"; import { n as J, ak as Q, al as W, am as X, an as Y, $ as Z, a0 as ee } from "./index2.js"; const le = { class: "s-file-upload-common" }, te = { key: 0, class: "head" }, ae = { class: "label" }, ne = ["onMouseover", "onMouseleave"], ie = ["src"], oe = { class: "tool-wrap" }, se = { class: "left" }, ue = { class: "right move" }, de = { class: "plus-wrap" }, ce = ["accept", "disabled"], re = { class: "preview-content" }, ve = ["src"], pe = { __name: "SCopperUpload", props: { /** * 文件列表(同 PictureUpload 的 data) * @list */ list: { type: Array, default: () => [] }, /** * 标题 * @label */ label: { type: String, default: "" }, /** * 只读(同 PictureUpload 的 disabled) * @readonly */ readonly: { type: Boolean, default: !1 }, /** * 是否显示新增(isAdd=false 等价 PictureUpload 的 ishiddenAdd=true:隐藏添加框且不可删除/拖拽) * @isAdd */ isAdd: { type: Boolean, default: !0 }, /** * 文件类型 * @accept */ accept: { type: String, default: "image/*" }, // 最多可上传数量(同 PictureUpload 的 maxSize) maxFileCount: { type: Number, default: 5 }, // 单文件大小上限,单位 KB(同 PictureUpload 的 fileSize) fileSize: { type: Number, default: 200 }, // FTP 上传目录(同 PictureUpload 的 path),不传时回退 businessTableName path: { type: String, default: void 0 }, // 是否隐藏拖拽排序图标(同 PictureUpload 的 noDrag) noDrag: { type: Boolean, default: !1 }, // 图片列表容器样式(同 PictureUpload 的 picStyle) picStyle: { type: Object, default: () => { } }, // 兼容保留:不传 path 时作为 FTP 目录名 businessTableName: { type: String, default: "sapit-ui-plus-components-upload" }, businessKey: { type: String, default: void 0 }, // 兼容保留(PictureUpload 无上传列表概念,仅声明避免外部传参告警) showUploadList: { type: Boolean, default: !0 }, // 兼容保留( PictureUpload 无此概念,仅声明) listType: { type: String, default: "picture-card" }, showRemoveIcon: { type: Boolean, default: !1 } }, emits: ["change", "handChange", "dragChange"], setup(o, { emit: B }) { const w = B, s = o, p = M(() => s.readonly), $ = () => s.path || s.businessTableName, a = c([]), m = c(!1), y = c(""), C = c(""), d = c(0); z( () => s.list, (l) => { a.value = l || []; }, { immediate: !0, deep: !0 } ); const b = () => { w("change", a.value), w("handChange", a.value); }, A = (l) => { }, E = (l) => { a.value && a.value.length > 1 && a.value.forEach((e, n) => { e.sort = n; }), w("dragChange", a.value), b(); }, N = () => { g.value.click(); }, g = c(null), O = (l) => { const e = l.target.files; if (e && e.length && a.value.length + e.length > s.maxFileCount) { window.$message.warning(window.$l("上传图片,最多可上传") + s.maxFileCount + window.$l("张")); return; } if (e && e.length) { for (let n = 0; n < e.length; n++) if (e[n].size > s.fileSize * 1024) { window.$message.warning( `${window.$l("上传图片大小不能大于")}${s.fileSize}KB` ); return; } } q($(), e).then((n) => { if (n && n.length) for (let t = 0; t < n.length; t++) a.value.push({ sort: t, imageUrl: n[t].imageUrl, uid: n[t].imageUrl, url: n[t].imageUrl }); b(); }).finally(() => { g.value && (g.value.value = ""); }); }, T = (l) => { l.showTool = !0; }, V = (l) => { l.showTool = !1; }, D = (l, e) => { a.value.splice(l, 1), G($(), e.imageUrl || e.uid), b(); }, F = (l = {}) => { d.value = a.value.findIndex((e) => e === l), m.value = !0, C.value = l.name || window.$l("预览"), y.value = l.imageUrl || l.url; }, I = () => { m.value = !1; }, _ = (l) => { d.value = d.value + l < 0 ? 0 : d.value + l > a.value.length - 1 ? a.value.length - 1 : d.value + l; const e = a.value[d.value]; e && (C.value = e.name || window.$l("预览"), y.value = e.imageUrl || e.url); }; return (l, e) => { const n = L("s-modal"); return r(), f("div", le, [ o.label ? (r(), f("div", te, [ i("div", ae, P(o.label), 1) ])) : h("", !0), v(u(H), { modelValue: a.value, "onUpdate:modelValue": e[0] || (e[0] = (t) => a.value = t), onStart: A, onEnd: E, handle: ".move", class: "img-list-wrap", style: R(o.picStyle), disabled: p.value, "item-key": "uid" }, { item: S(({ element: t, index: U }) => [ (r(), f("div", { class: "img-item-wrap", key: t.uid || U, onMouseover: (k) => T(t), onMouseleave: (k) => V(t) }, [ i("img", { class: "upload-img-wrap", src: t.imageUrl || t.url }, null, 8, ie), K(i("div", oe, [ i("div", se, [ v(u(W), { class: "tool-icon-wrap", style: { "margin-right": "8px" }, onClick: (k) => F(t) }, null, 8, ["onClick"]), o.isAdd && !p.value ? (r(), x(u(X), { key: 0, class: "tool-icon-wrap", onClick: (k) => D(U, t) }, null, 8, ["onClick"])) : h("", !0) ]), i("div", ue, [ o.isAdd && !p.value && !o.noDrag ? (r(), x(u(Y), { key: 0 })) : h("", !0) ]) ], 512), [ [j, t.showTool] ]) ], 40, ne)) ]), footer: S(() => [ a.value.length < o.maxFileCount && o.isAdd ? (r(), f("div", { key: 0, class: "img-add-wrap", onClick: N }, [ i("div", de, [ v(u(Q), { class: "plus-icon" }), i("input", { accept: o.accept || "image/*", multiple: !0, type: "file", disabled: p.value, ref_key: "fileInput", ref: g, style: { display: "none" }, onChange: O }, null, 40, ce) ]) ])) : h("", !0) ]), _: 1 }, 8, ["modelValue", "style", "disabled"]), v(n, { value: m.value, "onUpdate:value": e[3] || (e[3] = (t) => m.value = t), title: C.value, onHandCancel: I, width: "800px" }, { default: S(() => [ i("div", re, [ i("div", { class: "prev", onClick: e[1] || (e[1] = (t) => _(-1)) }, [ v(u(Z)) ]), i("img", { alt: "example", class: "view", src: y.value }, null, 8, ve), i("div", { class: "next", onClick: e[2] || (e[2] = (t) => _(1)) }, [ v(u(ee)) ]) ]) ]), _: 1 }, 8, ["value", "title"]) ]); }; } }, we = /* @__PURE__ */ J(pe, [["__scopeId", "data-v-236323b1"]]); export { we as default };