yk-element-components-v2
Version:
162 lines (161 loc) • 5.2 kB
JavaScript
function p(t, e, s, a, i, n, u, h) {
var l = typeof t == "function" ? t.options : t;
e && (l.render = e, l.staticRenderFns = s, l._compiled = !0), a && (l.functional = !0), n && (l._scopeId = "data-v-" + n);
var r;
if (u ? (r = function(o) {
o = o || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !o && typeof __VUE_SSR_CONTEXT__ < "u" && (o = __VUE_SSR_CONTEXT__), i && i.call(this, o), o && o._registeredComponents && o._registeredComponents.add(u);
}, l._ssrRegister = r) : i && (r = h ? function() {
i.call(
this,
(l.functional ? this.parent : this).$root.$options.shadowRoot
);
} : i), r)
if (l.functional) {
l._injectStyles = r;
var d = l.render;
l.render = function(_, f) {
return r.call(f), d(_, f);
};
} else {
var c = l.beforeCreate;
l.beforeCreate = c ? [].concat(c, r) : [r];
}
return {
exports: t,
options: l
};
}
const m = {
props: {
remote: {
type: Boolean,
default: !1
},
disabled: {
type: Boolean,
default: !1
},
clearable: {
type: Boolean,
default: !0
},
labelKey: {
type: String,
default: ""
},
valueKey: {
type: String,
default: ""
},
placeholder: {
type: String,
default: "\u8BF7\u9009\u62E9"
},
size: {
type: String,
default: "small"
},
data: {
type: Array,
default: () => []
},
optionColumn: {
type: Array,
default: () => []
},
filterable: {
type: Boolean,
default: !0
},
value: {
type: String,
default: ""
}
},
data() {
return {
selectValue: "",
showData: [],
customValue: !1,
selectInfo: {}
};
},
watch: {
data(t) {
this.showData = JSON.parse(JSON.stringify(t));
},
value(t) {
this.selectValue = t, t || this.setCustomValue();
}
},
mounted() {
this.showData = JSON.parse(JSON.stringify(this.data)), this.selectValue = this.value, this.setCustomValue(this.selectValue);
},
methods: {
selected() {
this.disabled || (this.$refs.custom_select.focus(), this.customValue = !1);
},
setOption(t) {
t ? this.showData = JSON.parse(JSON.stringify(this.data)) : this.setCustomValue(this.selectValue), this.$emit("visible-change", t);
},
clear(t) {
this.showData = JSON.parse(JSON.stringify(this.data)), this.setCustomValue(), this.selectValue = "", this.$emit("input", ""), this.$emit("clear", t);
},
blur(t) {
this.$emit("blur", t);
},
focus(t) {
this.$emit("focus", t);
},
setCustomValue(t) {
t ? (this.data.forEach((e) => {
t == e[this.valueKey ? this.valueKey : "value"] && (this.selectInfo = e);
}), this.customValue = !0) : (this.customValue = !1, this.selectInfo = {});
},
selectChange(t) {
this.setCustomValue(t), this.$emit("input", t), this.$emit("change", t);
},
remoteMethod(t) {
if (this.remote) {
this.$emit("remoteMethod", t);
return;
}
let e = [];
t ? e = this.data.filter((s) => {
let a = !1;
return this.optionColumn.forEach((i) => {
s[i.key].indexOf(t) != -1 && (a = !0);
}), a;
}) : e = this.data, this.showData = JSON.parse(JSON.stringify(e));
}
}
};
var v = function() {
var e = this, s = e._self._c;
return s("div", { staticClass: "custom_select_box" }, [e.customValue ? s("div", { staticClass: "custom_value", class: { disabledBg: e.disabled }, on: { click: e.selected } }, [s("img", { attrs: { src: e.selectInfo.image } }), s("div", [e._v(e._s(e.labelKey ? e.selectInfo[e.labelKey] : e.selectInfo.label))]), e.disabled ? e._e() : s("i", { staticClass: "el-icon-circle-close", on: { click: function(a) {
return a.stopPropagation(), e.clear.apply(null, arguments);
} } })]) : e._e(), s("el-select", { ref: "custom_select", attrs: { size: e.size, placeholder: e.placeholder, "popper-class": "custom_select", filterable: !0, disabled: e.disabled, clearable: e.clearable, remote: "", "reserve-keyword": "", "remote-method": e.remoteMethod }, on: { "visible-change": e.setOption, clear: e.clear, blur: e.blur, focus: e.focus, change: e.selectChange }, model: { value: e.selectValue, callback: function(a) {
e.selectValue = a;
}, expression: "selectValue" } }, e._l(e.showData, function(a, i) {
return s("el-option", { key: "f" + i, attrs: { label: e.labelKey ? a[e.labelKey] : a.label, value: e.valueKey ? a[e.valueKey] : a.value } }, [s("div", { staticClass: "custom_select_option" }, [s("img", { attrs: { src: a.image } }), s("div", { staticStyle: { "margin-left": "10px" } }, e._l(e.optionColumn, function(n, u) {
return s("div", { key: "child" + u }, [e._v(" " + e._s(n.name) + e._s(n.name ? ":" : "") + " " + e._s(a[n.key]) + " ")]);
}), 0)])]);
}), 1)], 1);
}, y = [], b = /* @__PURE__ */ p(
m,
v,
y,
!1,
null,
null,
null,
null
);
const g = b.exports, C = {
install(t) {
t.component("yk-custom-select", g);
}
};
export {
C as default
};