UNPKG

epic-designer

Version:

基于vue3的设计器,可视化开发页面表单

107 lines (106 loc) 3.3 kB
import { defineComponent as E, useAttrs as j, ref as n, watch as m, computed as B, createElementBlock as f, openBlock as g, createVNode as v, unref as h, normalizeProps as I, guardReactiveProps as N, withCtx as z, createCommentVNode as A, createElementVNode as x, nextTick as D } from "vue"; /* empty css */ import "vuedraggable"; import { getUUID as L } from "../../../utils/src/common/string.js"; import "@vueuse/core"; import "../../../hooks/src/store/index.js"; import { Upload as R, Image as S, message as u } from "ant-design-vue"; const T = { class: "epic-upload-image" }, $ = { key: 0 }, O = /* @__PURE__ */ E({ __name: "uploadImage", props: { maxCount: { default: 99 }, modelValue: { default: "" } }, emits: ["update:modelValue", "change"], setup(U, { emit: _ }) { const s = U, p = _, C = j(), r = n([]); let l = ""; const i = n(""), c = n(!1), d = (e) => { c.value = e; }; m( () => r.value, (e) => { l = e.filter((t) => t.status === "done").map((t) => t.url).join(","), p("update:modelValue", l), p("change", l); } ), m( () => s.modelValue, (e) => { if (l !== e) { if (e === "") { r.value = []; return; } e && r.value && (r.value = e.split(",").map((t) => ({ name: t, status: "done", uid: L(), url: t }))); } }, { deep: !0, immediate: !0 } ); function w(e) { D(() => { r.value = e; }); } const b = (e) => { var t, a; if (e.file.status !== "uploading") { if (e.file.status === "done") { const o = (a = (t = e.file.response) == null ? void 0 : t.data) == null ? void 0 : a.url; if (!e.file.url && !o) { e.file.status = "error", u.error("上传失败"); return; } e.file.url = o, e.file.thumbUrl = o; } e.file.status === "error" && u.error("upload error"); } }, V = () => { }, P = B(() => ({ ...C, accept: "image/gif,image/jpeg,image/jpg,image/png,image/svg", "onBefore-upload": V, onChange: b, onPreview: k, "file-list": r.value, "list-type": "picture-card", "onUpdate:file-list": w })); function k(e) { e.url && (i.value = e.url, d(!0)); } function y() { i.value && u.error("图片地址无法访问!"); } return (e, t) => (g(), f("div", T, [ v(h(R), I(N(P.value)), { default: z(() => { var a; return [ (((a = r.value) == null ? void 0 : a.length) ?? 0) < s.maxCount ? (g(), f("div", $, t[0] || (t[0] = [ x("span", { class: "icon--epic icon--epic--cloud-upload-outlined mr-2px text-$epic-text-main text-lg" }, null, -1), x("div", { class: "ant-upload-text" }, "点击上传", -1) ]))) : A("", !0) ]; }), _: 1 }, 16), v(h(S), { style: { display: "none" }, src: i.value, preview: { visible: c.value, onVisibleChange: d }, onError: y }, null, 8, ["src", "preview"]) ])); } }); export { O as default };