UNPKG

snowy-designer

Version:

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

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