epic-designer-dev
Version:
基于vue3的设计器,可视化开发页面表单。在epic-designer的基础上新增了字典选择器
90 lines (89 loc) • 2.32 kB
JavaScript
import { defineComponent as h, ref as U, watch as s, computed as E, h as t } from "vue";
/* empty css */
import "vuedraggable";
import { getFileNameByUrl as S, getUUID as x } from "../../../utils/src/common/string.js";
import "@vueuse/core";
import "../../../hooks/src/store/index.js";
import "../../../utils/src/manager/pluginManager.js";
import { ElUpload as y, ElButton as B, ElMessage as F } from "element-plus";
const M = h({
emits: ["update:modelValue", "change"],
props: {
modelValue: {
default: "",
type: String
}
},
setup(p, { attrs: i, emit: a }) {
const o = U([]);
let r = "";
s(
() => o.value,
(e) => {
console.log("list", e), r = e.filter((l) => l.status === "success").map((l) => l.url).join(","), a("update:modelValue", r), a("change", r);
}
), s(
() => p.modelValue,
(e) => {
if (r !== e) {
if (e === "") {
o.value = [];
return;
}
e !== null && o.value !== null && (o.value = e.split(",").map((l) => ({
id: x(),
name: S(l),
status: "success",
url: l
})));
}
},
{ immediate: !0 }
);
const c = (e, l) => {
o.value = l;
}, d = () => {
}, m = (e, l, v) => {
o.value = v.map((u) => {
var n;
return {
...u,
url: (n = u.response.data) == null ? void 0 : n.url
};
});
}, f = (e) => {
F.error("上传失败"), console.error(e);
}, g = E(() => ({
...i,
onBeforeUpload: d,
onError: f,
onRemove: c,
onSuccess: m,
"file-list": o.value
}));
return () => t("div", null, {
default: () => [
t(y, g.value, {
default: () => [
t(
B,
{},
{
default: () => [
t("span", {
class: "icon--epic icon--epic--cloud-upload-outlined text-lg",
style: { "margin-right": "2px" }
}),
t("span", null, { default: () => "上传文件" })
]
}
)
]
})
]
});
}
});
export {
M as default
};