AmAddressFormField.vue
5 days ago
AmAttachmentFormField.vue
5 days ago
AmCheckboxFormField.vue
5 days ago
AmContentFormField.vue
5 days ago
AmDatePickerFormField.vue
5 days ago
AmInputFormField.vue
5 days ago
AmPhoneFormField.vue
5 days ago
AmRadioFormField.vue
5 days ago
AmSelectFormField.vue
5 days ago
AmSocialButton.vue
5 days ago
AmSelectFormField.vue
115 lines
| 1 | <template> |
| 2 | <el-form-item |
| 3 | ref="formFieldRef" |
| 4 | class="am-ff__item" |
| 5 | :prop="props.itemName" |
| 6 | :label-position="props.labelPosition" |
| 7 | > |
| 8 | <template #label> |
| 9 | <span class="am-ff__item-label" v-html="props.label" /> |
| 10 | </template> |
| 11 | <AmSelect |
| 12 | v-model="model" |
| 13 | :fit-input-width="true" |
| 14 | :clearable="props.clearable" |
| 15 | :prefix-icon="props.prefixIcon" |
| 16 | :placeholder="props.placeholder" |
| 17 | :disabled="props.disabled" |
| 18 | :teleported="props.teleported" |
| 19 | :loading="props.loading" |
| 20 | :loading-text="props.loadingText" |
| 21 | > |
| 22 | <AmOption |
| 23 | v-for="(option, i) in props.options" |
| 24 | :key="i" |
| 25 | :label="option.label" |
| 26 | :value="option.value ? option.value : option.label" |
| 27 | /> |
| 28 | </AmSelect> |
| 29 | </el-form-item> |
| 30 | </template> |
| 31 | |
| 32 | <script setup> |
| 33 | // * _components |
| 34 | import AmSelect from '../../_components/select/AmSelect.vue' |
| 35 | import AmOption from '../../_components/select/AmOption.vue' |
| 36 | |
| 37 | // * Import from Vue |
| 38 | import { computed, ref, toRefs } from 'vue' |
| 39 | |
| 40 | // * Form Item Props |
| 41 | let props = defineProps({ |
| 42 | modelValue: { |
| 43 | type: [String, Array, Object, Number, null], |
| 44 | required: true, |
| 45 | }, |
| 46 | itemName: { |
| 47 | type: String, |
| 48 | required: true, |
| 49 | }, |
| 50 | label: { |
| 51 | type: String, |
| 52 | }, |
| 53 | labelPosition: { |
| 54 | type: String, |
| 55 | default: 'top', |
| 56 | }, |
| 57 | options: { |
| 58 | type: Array, |
| 59 | }, |
| 60 | prefixIcon: { |
| 61 | type: [String, Object], |
| 62 | default: '', |
| 63 | }, |
| 64 | placeholder: { |
| 65 | type: String, |
| 66 | default: '', |
| 67 | }, |
| 68 | clearable: { |
| 69 | type: Boolean, |
| 70 | default: true, |
| 71 | }, |
| 72 | disabled: { |
| 73 | type: Boolean, |
| 74 | default: false, |
| 75 | }, |
| 76 | loading: { |
| 77 | type: Boolean, |
| 78 | default: false, |
| 79 | }, |
| 80 | loadingText: { |
| 81 | type: String, |
| 82 | default: 'Loading...', |
| 83 | }, |
| 84 | teleported: { |
| 85 | type: Boolean, |
| 86 | default: true, |
| 87 | }, |
| 88 | }) |
| 89 | |
| 90 | // * Define Emits |
| 91 | const emits = defineEmits(['update:modelValue']) |
| 92 | |
| 93 | // * Component model |
| 94 | let { modelValue } = toRefs(props) |
| 95 | let model = computed({ |
| 96 | get: () => modelValue.value, |
| 97 | set: (val) => { |
| 98 | emits('update:modelValue', val) |
| 99 | }, |
| 100 | }) |
| 101 | |
| 102 | // * Form Item Reference |
| 103 | let formFieldRef = ref(null) |
| 104 | |
| 105 | defineExpose({ |
| 106 | formFieldRef, |
| 107 | }) |
| 108 | </script> |
| 109 | |
| 110 | <script> |
| 111 | export default { |
| 112 | name: 'SelectFormField', |
| 113 | } |
| 114 | </script> |
| 115 |