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
AmCheckboxFormField.vue
77 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 | <AmCheckboxGroup v-model="model"> |
| 12 | <AmCheckbox |
| 13 | v-for="(option, i) in props.options" |
| 14 | :key="i" |
| 15 | :label="option.label" |
| 16 | :value="option.value" |
| 17 | /> |
| 18 | </AmCheckboxGroup> |
| 19 | </el-form-item> |
| 20 | </template> |
| 21 | |
| 22 | <script setup> |
| 23 | // * _components |
| 24 | import AmCheckboxGroup from '../../_components/checkbox/AmCheckboxGroup.vue' |
| 25 | import AmCheckbox from '../../_components/checkbox/AmCheckbox.vue' |
| 26 | |
| 27 | // * Import from Vue |
| 28 | import { computed, ref, toRefs } from 'vue' |
| 29 | |
| 30 | // * Form Item Props |
| 31 | let props = defineProps({ |
| 32 | modelValue: { |
| 33 | type: [String, Array, Object, Number], |
| 34 | required: true, |
| 35 | }, |
| 36 | itemName: { |
| 37 | type: String, |
| 38 | required: true, |
| 39 | }, |
| 40 | label: { |
| 41 | type: String, |
| 42 | }, |
| 43 | labelPosition: { |
| 44 | type: String, |
| 45 | default: 'top', |
| 46 | }, |
| 47 | options: { |
| 48 | type: Array, |
| 49 | }, |
| 50 | }) |
| 51 | |
| 52 | // * Define Emits |
| 53 | const emits = defineEmits(['update:modelValue']) |
| 54 | |
| 55 | // * Component model |
| 56 | let { modelValue } = toRefs(props) |
| 57 | let model = computed({ |
| 58 | get: () => modelValue.value, |
| 59 | set: (val) => { |
| 60 | emits('update:modelValue', val) |
| 61 | }, |
| 62 | }) |
| 63 | |
| 64 | // * Form Item Reference |
| 65 | let formFieldRef = ref(null) |
| 66 | |
| 67 | defineExpose({ |
| 68 | formFieldRef, |
| 69 | }) |
| 70 | </script> |
| 71 | |
| 72 | <script> |
| 73 | export default { |
| 74 | name: 'CheckboxFormField', |
| 75 | } |
| 76 | </script> |
| 77 |