var h = (l, f, n) => new Promise((s, t) => { var p = (a) => { try { i(n.next(a)); } catch (r) { t(r); } }, u = (a) => { try { i(n.throw(a)); } catch (r) { t(r); } }, i = (a) => a.done ? s(a.value) : Promise.resolve(a.value).then(p, u); i((n = n.apply(l, f)).next()); }); import { ref as c, reactive as B, watch as y, resolveComponent as S, openBlock as g, createElementBlock as C, createElementVNode as m, toDisplayString as b, createCommentVNode as U, createVNode as v, withCtx as O } from "vue"; import { l as $, W as j } from "./index2.js"; import { d as z } from "./upload.js"; import D from "./CropperModal.js"; import { _ as M } from "./index16.js"; const R = { class: "s-file-upload-common" }, T = { class: "head" }, E = { key: 0, class: "label" }, P = { __name: "SCopperUpload", props: { /** * 文件列表 * @list */ list: { type: Array, default: () => [] }, /** * 标题 * @label */ label: { type: String, default: "" }, /** * 只读 * @readonly */ readonly: { type: Boolean, default: !1 }, /** * 是否显示删除 * @delete */ showRemoveIcon: { type: Boolean, default: !0 }, /** * 是否显示新增 * @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 } }, emits: ["handChange"], setup(l, { emit: f }) { const n = f, s = l, t = c([]), p = c(!1), u = B({}), i = c(""), a = c(); y( () => s.list, (e) => { e && e.length && (t.value = e); }, { immediate: !0 } ), y( () => s.options, (e) => { u.value = e; }, { immediate: !0 } ); const r = (e) => { const o = e.size / 1024 / 1024 < s.sizeLimit; return o || j.warn({ key: "only-you", message: window.$l("提醒"), description: `${window.$l("文件不能大于")}${s.sizeLimit}MB!` }), o; }, _ = (e) => h(this, null, function* () { if (e.file.status === "removed") { n("handChange", t.value); return; } let o = setTimeout(() => { u.value.invariantId = i.value; const d = Object.assign({}, u.value, { img: e.file.thumbUrl, file: e.file }); d && a.value.edit(d), clearTimeout(o); }, 500); }), w = ({ file: e }) => { i.value = e.uid; }, I = (e) => { const o = document.createElement("a"); o.href = z(e.uid), o.download = "test", o.click(); }, N = () => { p.value = !1; for (let e = t.value.length - 1; e >= 0; e--) t.value[e].uid === i.value && t.value[e].status != "done" && t.value.splice(e, 1); }, k = (e) => { p.value = !1; const o = t.value.findIndex((d) => d.uid === e.invariantId); o > -1 ? t.value.splice(o, 1, e) : t.value.push(e), n("handChange", t.value); }; return (e, o) => { const d = S("PlusOutlined"), x = M; return g(), C("div", R, [ m("div", T, [ l.label ? (g(), C("div", E, b(l.label), 1)) : U("", !0) ]), v(x, { "list-type": "picture-card", accept: ".jpg, .png, .jpeg, .PNG, .gif", "before-upload": r, "file-list": t.value, "onUpdate:fileList": o[0] || (o[0] = (L) => t.value = L), "custom-request": w, onChange: _, onDownload: I, disabled: l.readonly, showUploadList: { showRemoveIcon: l.showRemoveIcon, showDownloadIcon: !1 } }, { default: O(() => [ m("span", null, [ v(d), m("div", null, b(e.$l("图片上传")), 1) ]) ]), _: 1 }, 8, ["file-list", "disabled", "showUploadList"]), v(D, { ref_key: "cropperModal", ref: a, onCropperNo: N, onCropperOk: k }, null, 512) ]); }; } }, K = /* @__PURE__ */ $(P, [["__scopeId", "data-v-110ca245"]]); export { K as default };