UNPKG

epic-designer

Version:

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

96 lines (95 loc) 2.97 kB
import { defineComponent as k, useAttrs as w, ref as B, watch as i, computed as P, createElementBlock as V, openBlock as s, createVNode as b, unref as p, normalizeProps as N, guardReactiveProps as E, withCtx as d, createBlock as j, createCommentVNode as y, createElementVNode as c, nextTick as z } from "vue"; /* empty css */ import "vuedraggable"; import { getUUID as A } from "../../../utils/src/common/string.js"; import "@vueuse/core"; import "../../../hooks/src/store/index.js"; import { Upload as D, Button as F, message as m } from "ant-design-vue"; const I = { class: "epic-upload-file" }, J = /* @__PURE__ */ k({ __name: "uploadFile", props: { maxCount: { default: 99 }, modelValue: { default: "" } }, emits: ["update:modelValue", "change"], setup(f, { emit: g }) { const u = f, n = g, v = w(), r = B([]); let o = ""; i( () => r.value, (e) => { o = e.filter((t) => t.status === "done").map((t) => t.url).join(","), n("update:modelValue", o), n("change", o); } ), i( () => u.modelValue, (e) => { if (o !== e) { if (e === "") { r.value = []; return; } e && r.value && (r.value = e.split(",").map((t) => ({ name: t, status: "done", uid: A(), url: t }))); } }, { deep: !0, immediate: !0 } ); function h(e) { z(() => { r.value = e; }); } const x = (e) => { var t, l; if (e.file.status !== "uploading") { if (e.file.status === "done") { const a = (l = (t = e.file.response) == null ? void 0 : t.data) == null ? void 0 : l.url; if (!e.file.url && !a) { e.file.status = "error", m.error("上传失败"); return; } e.file.url = a, e.file.thumbUrl = a; } e.file.status === "error" && m.error("upload error"); } }, _ = () => { }, U = P(() => ({ ...v, "onBefore-upload": _, onChange: x, onPreview: C, "file-list": r.value, "onUpdate:file-list": h })); function C(e) { console.log(e), e.url && window.open(e.url, "_blank"); } return (e, t) => (s(), V("div", I, [ b(p(D), N(E(U.value)), { default: d(() => { var l; return [ (((l = r.value) == null ? void 0 : l.length) ?? 0) < u.maxCount ? (s(), j(p(F), { key: 0, class: "flex items-center" }, { default: d(() => t[0] || (t[0] = [ c("span", { class: "icon--epic icon--epic--cloud-upload-outlined text-lg" }, null, -1), c("div", { class: "ant-upload-text" }, "上传文件", -1) ])), _: 1 })) : y("", !0) ]; }), _: 1 }, 16) ])); } }); export { J as default };