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