UNPKG

ai-form-designer

Version:

vue3+adv的设计器,可视化开发页面表单

89 lines (88 loc) 2.22 kB
import { defineComponent as V, ref as o, watch as s, computed as E, h as a, nextTick as U } from "vue"; import { ElUpload as w, ElImageViewer as y, ElMessage as C } from "element-plus"; const P = V({ props: { modelValue: { type: Array, default: () => [] } }, emits: ["update:modelValue"], setup(d, { emit: p, attrs: c }) { const l = o([]), u = o(""), r = o(!1), n = (e) => { r.value = e; }; s(l, (e) => { p("update:modelValue", e); }), s( () => d.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 g = (e, t) => { U(() => { l.value = t; }); }, m = (e, t, i) => { console.log(i); }, f = (e, t, i) => { C.error("上传失败"), console.error(e); }, v = (e) => { }, h = E(() => ({ ...c, "file-list": l.value, "list-type": "picture-card", accept: "image/gif,image/jpeg,image/jpg,image/png,image/svg", onBeforeUpload: v, onChange: g, onSuccess: m, onError: f, onPreview: x })), x = (e) => { e.url && (u.value = e.url, n(!0)); }; return () => a( "div", { class: "epic-upload-image" }, { default: () => [ a(w, h.value, { default: () => [ a("div", { style: { "text-align": "center" } }, { default: () => [ a("span", { class: "icon--epic icon--epic--cloud-upload-outlined mr-2px text-lg" }), a( "div", { class: "ant-upload-text" }, { default: () => "点击上传" } ) ] }) ] }), (() => { if (r.value) return a(y, { urlList: [u.value], onClose: () => { n(!1); } }); })() ] } ); } }); export { P as default };