|
| 1 | +<template> |
| 2 | + <ValidationProvider |
| 3 | + v-slot="{ errors: veeErrors }" |
| 4 | + tag="div" |
| 5 | + :name="validationLabel" |
| 6 | + :vid="veeId" |
| 7 | + :rules="veeRules" |
| 8 | + :skip-if-empty="skipIfEmpty" |
| 9 | + :required="required" |
| 10 | + :immediate="immediateValidation" |
| 11 | + class="e-form-container" |
| 12 | + > |
| 13 | + <v-autocomplete |
| 14 | + v-bind="$attrs" |
| 15 | + :filled="filled" |
| 16 | + :hide-details="hideDetails" |
| 17 | + :error-messages="veeErrors.concat(errorMessages)" |
| 18 | + :label="labelOrEntityFieldLabel" |
| 19 | + :class="[inputClass]" |
| 20 | + :readonly="readonly" |
| 21 | + :append-icon="readonly ? null : '$dropdown'" |
| 22 | + :filter="filter" |
| 23 | + v-on="$listeners" |
| 24 | + > |
| 25 | + <!-- passing through all slots --> |
| 26 | + <slot v-for="(_, name) in $slots" :slot="name" :name="name" /> |
| 27 | + <template v-for="(_, name) in $scopedSlots" :slot="name" slot-scope="slotData"> |
| 28 | + <slot :name="name" v-bind="slotData" /> |
| 29 | + </template> |
| 30 | + </v-autocomplete> |
| 31 | + </ValidationProvider> |
| 32 | +</template> |
| 33 | + |
| 34 | +<script> |
| 35 | +import { ValidationProvider } from 'vee-validate' |
| 36 | +import { formComponentPropsMixin } from '@/mixins/formComponentPropsMixin.js' |
| 37 | +import { formComponentMixin } from '@/mixins/formComponentMixin.js' |
| 38 | +
|
| 39 | +export default { |
| 40 | + name: 'EAutocomplete', |
| 41 | + components: { ValidationProvider }, |
| 42 | + mixins: [formComponentPropsMixin, formComponentMixin], |
| 43 | + props: { |
| 44 | + immediateValidation: { type: Boolean, default: false }, |
| 45 | + skipIfEmpty: { type: Boolean, default: true }, |
| 46 | + readonly: { type: Boolean, default: false }, |
| 47 | + }, |
| 48 | + methods: { |
| 49 | + filter(item, queryText, itemText) { |
| 50 | + return queryText |
| 51 | + .toLocaleLowerCase() |
| 52 | + .split(/\s+/g) |
| 53 | + .every((part) => { |
| 54 | + return itemText.toLocaleLowerCase().indexOf(part) > -1 |
| 55 | + }) |
| 56 | + }, |
| 57 | + }, |
| 58 | +} |
| 59 | +</script> |
| 60 | + |
| 61 | +<style scoped> |
| 62 | +[required]:deep(label::after) { |
| 63 | + content: '\a0*'; |
| 64 | + font-size: 12px; |
| 65 | + color: #d32f2f; |
| 66 | +} |
| 67 | +[required]:deep(.v-input--is-label-active label::after) { |
| 68 | + color: gray; |
| 69 | +} |
| 70 | +</style> |
0 commit comments