2019-11-16 10:21:14 +03:00
|
|
|
<template>
|
2020-01-20 18:16:56 +03:00
|
|
|
|
|
|
|
<base-input :label="title"
|
|
|
|
:name="name"
|
|
|
|
:class="formClasses"
|
|
|
|
:error="formError">
|
|
|
|
|
|
|
|
<el-select @input="change" filterable :placeholder="placeholder">
|
|
|
|
|
|
|
|
<template slot="prefix">
|
|
|
|
<span class="el-input__suffix-inner el-select-icon">
|
|
|
|
<i :class="'select-icon-position el-input__icon fa fa-' + icon"></i>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<el-option v-if="!group" v-for="(label, value) in selectOptions"
|
|
|
|
:key="value"
|
|
|
|
:label="label"
|
|
|
|
:value="value">
|
|
|
|
</el-option>
|
|
|
|
|
|
|
|
<el-option-group
|
|
|
|
v-if="group"
|
|
|
|
v-for="(options, name) in selectOptions"
|
|
|
|
:key="name"
|
|
|
|
:label="name">
|
|
|
|
<el-option
|
|
|
|
v-for="(label, value) in options"
|
|
|
|
:key="value"
|
|
|
|
:label="label"
|
|
|
|
:value="value">
|
|
|
|
</el-option>
|
|
|
|
</el-option-group>
|
|
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
|
|
</base-input>
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-01-20 18:16:56 +03:00
|
|
|
import { Select, Option, OptionGroup } from 'element-ui';
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
export default {
|
2020-01-20 18:16:56 +03:00
|
|
|
components: {
|
|
|
|
[Select.name]: Select,
|
|
|
|
[Option.name]: Option,
|
|
|
|
[OptionGroup.name]: OptionGroup,
|
|
|
|
},
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
2020-01-20 18:16:56 +03:00
|
|
|
default: '',
|
|
|
|
description: "Modal header title"
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
2020-01-20 18:16:56 +03:00
|
|
|
placeholder: {
|
2019-11-16 10:21:14 +03:00
|
|
|
type: String,
|
2020-01-20 18:16:56 +03:00
|
|
|
default: '',
|
|
|
|
description: "Modal header title"
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
2020-01-20 18:16:56 +03:00
|
|
|
formClasses: null,
|
|
|
|
formError: null,
|
|
|
|
name: null,
|
|
|
|
value: null,
|
|
|
|
options: null,
|
|
|
|
model: null,
|
|
|
|
icon: {
|
2019-11-16 10:21:14 +03:00
|
|
|
type: String,
|
2020-01-20 18:16:56 +03:00
|
|
|
description: "Prepend icon (left)"
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
2020-01-20 18:16:56 +03:00
|
|
|
|
|
|
|
group: false,
|
|
|
|
multiple:false,
|
|
|
|
disabled:false,
|
|
|
|
collapse: false
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-01-20 18:16:56 +03:00
|
|
|
isOpen: false,
|
|
|
|
selectOptions: this.options,
|
|
|
|
real_model: this.model,
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
toggleDropDown() {
|
|
|
|
this.isOpen = !this.isOpen;
|
|
|
|
this.$emit("change", this.isOpen);
|
|
|
|
},
|
|
|
|
closeDropDown() {
|
|
|
|
this.isOpen = false;
|
|
|
|
this.$emit("change", this.isOpen);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
directives: {
|
|
|
|
'click-outside': {
|
|
|
|
bind: function(el, binding, vNode) {
|
|
|
|
// Provided expression must evaluate to a function.
|
|
|
|
if (typeof binding.value !== 'function') {
|
|
|
|
const compName = vNode.context.name
|
|
|
|
let warn = `[Vue-click-outside:] provided expression '${binding.expression}' is not a function, but has to be`
|
|
|
|
if (compName) { warn += `Found in component '${compName}'` }
|
|
|
|
|
|
|
|
console.warn(warn)
|
|
|
|
}
|
|
|
|
// Define Handler and cache it on the element
|
|
|
|
const bubble = binding.modifiers.bubble
|
|
|
|
const handler = (e) => {
|
|
|
|
if (bubble || (!el.contains(e.target) && el !== e.target)) {
|
|
|
|
binding.value(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
el.__vueClickOutside__ = handler
|
|
|
|
|
|
|
|
// add Event Listeners
|
|
|
|
document.addEventListener('click', handler)
|
|
|
|
},
|
|
|
|
|
|
|
|
unbind: function(el, binding) {
|
|
|
|
// Remove Event Listeners
|
|
|
|
document.removeEventListener('click', el.__vueClickOutside__)
|
|
|
|
el.__vueClickOutside__ = null
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|