lwx-test-ui
Version:
lwx-test-ui
61 lines (60 loc) • 2.06 kB
JavaScript
import { defineComponent as g, inject as k, computed as d, ref as x, onMounted as y, resolveComponent as i, createBlock as m, openBlock as s, mergeProps as C, withCtx as V, createElementBlock as I, Fragment as q, renderList as w } from "vue";
import { useGlobalProperties as B } from "../../../hooks/use-global-properties/index.js";
import { selectEmits as P, selectProps as $ } from "./select.js";
const F = /* @__PURE__ */ g({
name: "LwxSelect",
__name: "select",
props: $,
emits: P,
setup(f, { emit: b }) {
const e = f, c = b, a = B(), u = k(a.formItemContextKey, void 0), v = d(() => u ? `请选择${u.label}` : e.placeholder), p = d({
get() {
return e.modelValue;
},
set(l) {
c("update:modelValue", l);
}
}), r = x([]);
y(() => {
var l;
r.value = e.options, e.queryInterface && ((l = a == null ? void 0 : a.$request) == null || l.get(
e.queryInterface,
e.params
).then((t) => {
r.value = t.data;
}));
});
function _(l) {
const t = r.value.find((n) => n[e.props.key] === l);
c("change", l, t);
}
return (l, t) => {
const n = i("el-option"), h = i("el-select");
return s(), m(h, C({
modelValue: p.value,
"onUpdate:modelValue": t[0] || (t[0] = (o) => p.value = o),
class: "lwx-select",
disabled: e.disabled,
clearable: e.clearable,
filterable: e.filterable,
multiple: e.multiple
}, l.$attrs, {
placeholder: v.value,
onChange: _
}), {
default: V(() => [
(s(!0), I(q, null, w(r.value, (o) => (s(), m(n, {
key: o[e.props.key],
label: o[e.props.label],
value: o[e.props.value],
disabled: e != null && e.disabled ? !!o[e.props.disabled] : !1
}, null, 8, ["label", "value", "disabled"]))), 128))
]),
_: 1
}, 16, ["modelValue", "disabled", "clearable", "filterable", "multiple", "placeholder"]);
};
}
});
export {
F as default
};