epic-designer-dev
Version:
基于vue3的设计器,可视化开发页面表单。在epic-designer的基础上新增了字典选择器
48 lines (47 loc) • 1.42 kB
JavaScript
import { defineComponent as g, getCurrentInstance as h, h as i } from "vue";
import { ElMessage as c, ElSelect as E, ElOption as U } from "element-plus";
import "element-plus/es/components/select/style/css";
const n = h();
var u, m;
const b = (m = (u = n == null ? void 0 : n.appContext.config.globalProperties.$ELEMENT) == null ? void 0 : u.config) == null ? void 0 : m.http, S = g({
emits: ["update:modelValue"],
async setup(y, { attrs: o, emit: d }) {
function f(t = null) {
d("update:modelValue", t);
}
let l = [], r = !1;
const s = o.dictName || "", p = String(o.apiURL) || "";
if (s)
if (p.trim()) {
r = !0;
const t = p + s;
try {
const e = await b.get({ url: t });
console.log("response", e), l = e, console.log("options", l);
} catch (e) {
throw c.error(e.message), e;
}
} else
c.error("请检查接口地址,不可为空!");
return () => {
const t = {
...o,
key: String(o.multiple),
"onUpdate:modelValue": f
};
return r && (t.options = l.length > 0 ? l : []), i(E, t, {
default: () => {
var e;
return [
(e = t.options) == null ? void 0 : e.map(
(a) => i(U, { label: a.label, value: a.value })
)
];
}
});
};
}
});
export {
S as default
};