| 1 | <template> |
| 2 | <div v-if="!readonly" class="field-row three-col"> |
| 3 | <el-form-item label="Name" prop="name" class="field-grow"> |
| 4 | <el-input v-model="form.name" :disabled="editing || readonly" placeholder="my-visitor" /> |
| 5 | </el-form-item> |
| 6 | <ConfigField label="Type" type="select" v-model="form.type" :disabled="editing" |
| 7 | :options="[{ label: 'STCP', value: 'stcp' }, { label: 'SUDP', value: 'sudp' }, { label: 'XTCP', value: 'xtcp' }]" prop="type" /> |
| 8 | <el-form-item label="Enabled" class="switch-field"> |
| 9 | <el-switch v-model="form.enabled" size="small" /> |
| 10 | </el-form-item> |
| 11 | </div> |
| 12 | <div v-else class="field-row three-col"> |
| 13 | <ConfigField label="Name" type="text" :model-value="form.name" readonly class="field-grow" /> |
| 14 | <ConfigField label="Type" type="text" :model-value="form.type.toUpperCase()" readonly /> |
| 15 | <ConfigField label="Enabled" type="switch" :model-value="form.enabled" readonly /> |
| 16 | </div> |
| 17 | </template> |
| 18 | |
| 19 | <script setup lang="ts"> |
| 20 | import { computed } from 'vue' |
| 21 | import type { VisitorFormData } from '../../types' |
| 22 | import ConfigField from '../ConfigField.vue' |
| 23 | |
| 24 | const props = withDefaults(defineProps<{ |
| 25 | modelValue: VisitorFormData |
| 26 | readonly?: boolean |
| 27 | editing?: boolean |
| 28 | }>(), { readonly: false, editing: false }) |
| 29 | |
| 30 | const emit = defineEmits<{ 'update:modelValue': [value: VisitorFormData] }>() |
| 31 | |
| 32 | const form = computed({ |
| 33 | get: () => props.modelValue, |
| 34 | set: (val) => emit('update:modelValue', val), |
| 35 | }) |
| 36 | </script> |
| 37 | |
| 38 | <style scoped lang="scss"> |
| 39 | @use '@/assets/css/form-layout'; |
| 40 | </style> |