diff --git a/src/views/tools/Forms.vue b/src/views/tools/Forms.vue index 6cc7b97..d266f54 100644 --- a/src/views/tools/Forms.vue +++ b/src/views/tools/Forms.vue @@ -2,6 +2,7 @@ import { computed, ref } from 'vue' import { useCityAutocompleteConfig, useCitySelectPageConfig } from '@/services/city/CityService' import { $i18nMsg } from '@/messages' +import { ElMessage } from 'element-plus' const defaultCity = ref({}) @@ -149,7 +150,37 @@ const formOptions = computed(() => { } }] }) -const userDto = ref({}) +const userDto = ref({ + contacts: [{ + name: 'Jerry', + phone: '1234567890' + }] +}) +/** + * @type {CommonFormOption[]} + */ +const contactsOptions = ref([{ + label: '联系人姓名', + prop: 'name', + required: true +}, { + label: '联系电话', + prop: 'phone', + required: true +}]) + +const addContact = () => { + if (userDto.value.contacts.length < 3) { + userDto.value.contacts.push({}) + } else { + ElMessage.error('联系人不能超过3个') + } +} + +const deleteContact = idx => { + userDto.value.contacts.splice(idx, 1) +} + const submitForm = (form) => { console.info(form) form.validate((valid) => { @@ -171,11 +202,43 @@ const submitForm = (form) => { label-width="120px" @submit-form="submitForm" > +