UNPKG

epic-designer-gold

Version:

基于vue3的设计器,可视化开发页面表单

92 lines (91 loc) 2.44 kB
import { defineComponent as y, ref as U, watch as i, inject as b, computed as T, h as t, nextTick as V } from "vue"; import { ElUpload as A, ElButton as B, ElMessage as n } from "element-plus"; import { a as s, u as C } from "./index-B1s67XDZ.js"; const { t: r } = C(), k = y({ props: { modelValue: { type: Array, default: () => [] } }, emits: ["update:modelValue"], setup(p, { emit: c, attrs: d }) { const l = U([]); i(l, (e) => { c("update:modelValue", e); }); const f = b("disabled", { value: !1 }); i( () => p.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 m = (e, a) => { V(() => { l.value = a; }); }, h = (e) => { var o, u; let a = e.url || ((u = (o = e == null ? void 0 : e.response) == null ? void 0 : o.data) == null ? void 0 : u.url); window.open(a); }, g = (e) => { }, v = (e, a, o) => { e.code !== 200 && n.error(e.msg || r("uploadFailed")); }, w = (e, a, o) => { n.error(r("uploadFailed")), console.error(e); }, E = (e, a) => { let { limit: o } = d; n.warning(`最多只能上传 ${o} 个文件`); }, x = T(() => ({ ...d, "file-list": l.value, onBeforeUpload: g, onChange: m, onSuccess: v, onError: w, onPreview: h, onExceed: E })); return () => t("div", null, { default: () => [ t( A, { ...x.value, headers: { Authorization: `Bearer ${s.get("Admin-Token")}`, "X-Tenant-Gray": s.get("X-Tenant-Gray") } }, { default: () => [ t( B, { disabled: f.value }, { default: () => [ t("span", { class: "icon--epic icon--epic--cloud-upload-outlined text-lg", style: { "margin-right": "2px" } }), t("span", null, { default: () => r("fileUpload") }) ] } ) ] } ) ] }); } }); export { k as default };