epic-designer-dev
Version:
基于vue3的设计器,可视化开发页面表单。在epic-designer的基础上新增了字典选择器
108 lines (107 loc) • 3.42 kB
JavaScript
import { defineComponent as y, useAttrs as E, ref as n, watch as d, computed as B, createElementBlock as f, openBlock as g, createVNode as v, unref as h, normalizeProps as F, 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 "../../../utils/src/manager/pluginManager.js";
import { Form as R, Upload as S, Image as T, message as s } from "ant-design-vue";
const $ = { class: "epic-upload-image" }, q = { key: 0 }, X = /* @__PURE__ */ y({
__name: "uploadImage",
props: {
maxCount: { default: 99 },
modelValue: { default: "" }
},
emits: ["update:modelValue", "change"],
setup(C, { emit: U }) {
const u = C, p = U, _ = R.useInjectFormItemContext(), w = E(), r = n([]);
let a = "";
const i = n(""), m = n(!1), c = (e) => {
m.value = e;
};
d(
() => r.value,
(e) => {
a = e.filter((t) => t.status === "done").map((t) => t.url).join(","), p("update:modelValue", a), p("change", a), _.onFieldChange();
}
), d(
() => u.modelValue,
(e) => {
if (a !== 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 b(e) {
D(() => {
r.value = e;
});
}
const I = (e) => {
var t, o;
if (e.file.status !== "uploading") {
if (e.file.status === "done") {
const l = (o = (t = e.file.response) == null ? void 0 : t.data) == null ? void 0 : o.url;
if (!e.file.url && !l) {
e.file.status = "error", s.error("上传失败");
return;
}
e.file.url = l, e.file.thumbUrl = l;
}
e.file.status === "error" && s.error("upload error");
}
}, V = () => {
}, P = B(() => ({
...w,
accept: "image/gif,image/jpeg,image/jpg,image/png,image/svg",
"onBefore-upload": V,
onChange: I,
onPreview: j,
"file-list": r.value,
"list-type": "picture-card",
"onUpdate:file-list": b
}));
function j(e) {
e.url && (i.value = e.url, c(!0));
}
function k() {
i.value && s.error("图片地址无法访问!");
}
return (e, t) => (g(), f("div", $, [
v(h(S), F(N(P.value)), {
default: z(() => {
var o;
return [
(((o = r.value) == null ? void 0 : o.length) ?? 0) < u.maxCount ? (g(), f("div", q, 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(T), {
style: { display: "none" },
src: i.value,
preview: {
visible: m.value,
onVisibleChange: c
},
onError: k
}, null, 8, ["src", "preview"])
]));
}
});
export {
X as default
};