UNPKG

lwx-test-ui

Version:

lwx-test-ui

53 lines (52 loc) 1.82 kB
import { defineComponent as C, inject as V, ref as g, computed as m, onMounted as h, resolveComponent as p, createBlock as d, openBlock as r, mergeProps as k, withCtx as x, createElementBlock as $, Fragment as B, renderList as P } from "vue"; import { useGlobalProperties as w } from "../../../hooks/use-global-properties/index.js"; import { dicEmits as y, dicProps as E } from "./dic.js"; const j = /* @__PURE__ */ C({ name: "LwxDic", __name: "dic", props: E, emits: y, setup(i, { emit: b }) { const e = i, n = b, u = w(), s = V(u.formItemContextKey, void 0), t = g([]), c = m({ get() { return e.modelValue; }, set(o) { n("update:modelValue", o); } }), f = m(() => s ? `请选择${s.label}` : e.placeholder); return h(() => { u.$request.get( `${e.url}/${e.code}`, {} ).then((o) => { t.value = o.data, e.isNumber && (t.value = t.value.map((l) => (l.value = Number(l.value), l))), n("resultCallback", t.value); }); }), (o, l) => { const v = p("el-option"), _ = p("el-select"); return r(), d(_, k({ modelValue: c.value, "onUpdate:modelValue": l[0] || (l[0] = (a) => c.value = a) }, o.$attrs, { placeholder: f.value, "default-first-option": "", multiple: e.multiple, clearable: e.clearable, disabled: e.disabled, filterable: e.filterable }), { default: x(() => [ (r(!0), $(B, null, P(t.value, (a) => (r(), d(v, { key: a.value, label: a.label, value: a.value }, null, 8, ["label", "value"]))), 128)) ]), _: 1 }, 16, ["modelValue", "placeholder", "multiple", "clearable", "disabled", "filterable"]); }; } }); export { j as default };