var C = (l, r, t) => new Promise((m, c) => { var f = (a) => { try { p(t.next(a)); } catch (u) { c(u); } }, n = (a) => { try { p(t.throw(a)); } catch (u) { c(u); } }, p = (a) => a.done ? m(a.value) : Promise.resolve(a.value).then(f, n); p((t = t.apply(l, r)).next()); }); import { ref as i, reactive as z, watch as b, resolveComponent as g, openBlock as I, createElementBlock as x, createElementVNode as d, toDisplayString as D, createCommentVNode as E, createVNode as v, withCtx as k, pushScopeId as A, popScopeId as $ } from "vue"; import { r as q, v as V } from "./index2.js"; import { d as F, p as G } from "./upload.js"; import H from "./CropperModal.js"; import { _ as K } from "./index6.js"; import { M as W } from "./index7.js"; const J = (l) => (A("data-v-31ce420f"), l = l(), $(), l), Q = { class: "s-file-upload-common" }, X = { class: "head" }, Y = { key: 0, class: "label" }, Z = /* @__PURE__ */ J(() => /* @__PURE__ */ d("div", null, "图片上传", -1)), ee = { class: "preview-content" }, te = ["src"], oe = { __name: "SCopperUpload", props: { /** * 文件列表 * @list */ list: { type: Array, default: () => [] }, /** * 标题 * @label */ label: { type: String, default: "" }, /** * 只读 * @readonly */ readonly: { type: Boolean, default: !1 }, /** * 是否显示删除 * @delete */ showRemoveIcon: { type: Boolean, default: !1 }, /** * 是否显示新增 * @add */ add: { type: Boolean, default: !1 }, maxFileCount: { type: Number, default: 3 }, sizeLimit: { type: Number, default: 50 }, options: { type: Object, default: function() { return { autoCrop: !0, // 是否默认生成截图框 autoCropWidth: 180, // 默认生成截图框宽度 autoCropHeight: 180, // 默认生成截图框高度 fixedBox: !1, // 是否固定截图框大小 不允许改变 previewsCircle: !1, // 预览图是否是原圆形 businessTableName: "sys_user", title: "", invariantId: "" }; } }, businessTableName: { type: String, default: void 0 }, businessKey: { type: String, default: void 0 } }, setup(l) { const r = l, t = i([ // { // uid: '-1', // name: 'xxx.png', // status: 'done', // url: 'https://www.sapit.com.cn/img/title-bg.cbbd159b.png', // thumbUrl: 'https://www.sapit.com.cn/img/title-bg.cbbd159b.png', // }, // { // uid: '-2', // name: 'yyy.png', // status: 'done', // url: 'https://www.sapit.com.cn/img/title-bg.9b284669.png', // thumbUrl: 'https://www.sapit.com.cn/img/title-bg.9b284669.png', // } ]), m = i(!1), c = i(""), f = i(""), n = i(0), p = i(!1), a = z({}), u = i(""), w = i(); b(() => r.list, (e) => { e && e.length && (t.value = e); }, { immediate: !0 }), b(() => r.options, (e) => { a.value = e; }, { immediate: !0 }); const L = (e) => { const o = e.size / 1024 / 1024 < r.sizeLimit; return o || V.warn({ key: "only-you", message: "提醒", description: `文件不能大于${r.sizeLimit}MB!` }), o; }, S = (o) => C(this, [o], function* ({ file: e }) { let s = setTimeout(() => { a.value.invariantId = u.value; const h = Object.assign({}, a.value, { img: e.thumbUrl }); h.img && w.value.edit(h), clearTimeout(s); }, 500); }), N = ({ file: e }) => { u.value = e.uid; }, O = (e) => { const o = document.createElement("a"); o.href = F(e.uid), o.download = "test", o.click(); }, U = () => { p.value = !1; for (let e = t.value.length - 1; e >= 0; e--) t.value[e].uid === u.value && t.value[e].status != "done" && t.value.splice(e, 1); }, B = (e, o) => { p.value = !1, t.value && t.value.length > 0 && t.value.forEach((s) => { s.uid == e && (s.status = "done", s.thumbUrl = o, s.url = G(s.uid)); }); }, M = (e) => { n.value = t.value.findIndex((o) => o.uid === e.uid), m.value = !0, f.value = e.name || "预览", c.value = e.url || e.thumbUrl; }, P = () => { m.value = !1; }, y = (e) => { n.value = n.value + e < 0 ? 0 : n.value + e > t.value.length - 1 ? t.value.length - 1 : n.value + e, f.value = t.value[n.value].name || "预览", c.value = t.value[n.value].url; }; return (e, o) => { const s = g("PlusOutlined"), h = K, R = g("LeftOutlined"), T = g("RightOutlined"), j = W; return I(), x("div", Q, [ d("div", X, [ l.label ? (I(), x("div", Y, D(l.label), 1)) : E("", !0) ]), v(h, { "list-type": "picture-card", accept: ".jpg, .png, .jpeg, .PNG, .gif", onPreview: M, "before-upload": L, "file-list": t.value, "onUpdate:fileList": o[0] || (o[0] = (_) => t.value = _), "custom-request": N, onChange: S, disabled: l.readonly, onDownload: O, showUploadList: { showRemoveIcon: l.showRemoveIcon, showDownloadIcon: !0 } }, { default: k(() => [ d("span", null, [ v(s), Z ]) ]), _: 1 }, 8, ["file-list", "disabled", "showUploadList"]), v(j, { open: m.value, title: f.value, footer: null, onCancel: P, width: "800px" }, { default: k(() => [ d("div", ee, [ d("div", { class: "prev", onClick: o[1] || (o[1] = (_) => y(-1)) }, [ v(R) ]), d("img", { alt: "example", class: "view", src: c.value }, null, 8, te), d("div", { class: "next", onClick: o[2] || (o[2] = (_) => y(1)) }, [ v(T) ]) ]) ]), _: 1 }, 8, ["open", "title"]), v(H, { ref_key: "cropperModal", ref: w, onCropperNo: U, onCropperOk: B }, null, 512) ]); }; } }, re = /* @__PURE__ */ q(oe, [["__scopeId", "data-v-31ce420f"]]); export { re as default };