epic-designer-gold
Version:
基于vue3的设计器,可视化开发页面表单
91 lines (90 loc) • 2.38 kB
JavaScript
import { defineComponent as x, ref as U, watch as i, inject as b, computed as V, h as t, nextTick as y } from "vue";
import { ElUpload as A, ElButton as B, ElMessage as n } from "element-plus";
import { a as C, u as F } from "./index-B1s67XDZ.js";
const { t: d } = F(), S = x({
props: {
modelValue: {
type: Array,
default: () => []
}
},
emits: ["update:modelValue"],
setup(s, { emit: p, attrs: r }) {
const l = U([]);
i(l, (e) => {
p("update:modelValue", e);
});
const c = b("disabled", { value: !1 });
i(
() => s.modelValue,
(e) => {
if (e != null && e.length > 0 && l.value != null) {
if (l.value === e) return;
l.value.length = 0, l.value.push(...e);
}
},
{ deep: !0, immediate: !0 }
);
const f = (e, o) => {
y(() => {
l.value = o;
});
}, m = (e) => {
var a, u;
let o = e.url || ((u = (a = e == null ? void 0 : e.response) == null ? void 0 : a.data) == null ? void 0 : u.url);
window.open(o);
}, h = (e) => {
}, g = (e, o, a) => {
e.code !== 200 && n.error(e.msg || d("uploadFailed"));
}, v = (e, o, a) => {
n.error(d("uploadFailed")), console.error(e);
}, w = (e, o) => {
let { limit: a } = r;
n.warning(`最多只能上传 ${a} 个文件`);
}, E = V(() => ({
...r,
"file-list": l.value,
onBeforeUpload: h,
onChange: f,
onSuccess: g,
onError: v,
onPreview: m,
onExceed: w
}));
return () => t("div", null, {
default: () => [
t(
A,
{
...E.value,
headers: {
Authorization: `Bearer ${C.get("Admin-Token")}`
}
},
{
default: () => [
t(
B,
{
disabled: c.value
},
{
default: () => [
t("span", {
class: "icon--epic icon--epic--cloud-upload-outlined text-lg",
style: { "margin-right": "2px" }
}),
t("span", null, { default: () => d("fileUpload") })
]
}
)
]
}
)
]
});
}
});
export {
S as default
};