UNPKG

snowy-designer

Version:

基于Epic-Designer-Pro版本的设计器,可视化开发页面表单

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