Browse Source

form组件修改

master
陈薪名 1 year ago
parent
commit
5846cb543a
  1. 51
      src/components/BasicForm/src/BasicForm.vue

51
src/components/BasicForm/src/BasicForm.vue

@ -274,7 +274,7 @@ const submitForm = async () => {
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
//
if (props.isBusiness) {
const validateForm = await tableFormRef.value.validateForm()
if (!validateForm) {
@ -284,26 +284,34 @@ const submitForm = async () => {
}
return
}
}
//
formLoading.value = true
try {
// const data = unref(formRef)?.formModel as ItempackagingApi.ItempackagingVO
// TODO: as VO props
const data = unref(formRef)?.formModel
if (formType.value === 'create') {
await props.apiCreate(data)
message.success(t('common.createSuccess'))
} else {
await props.apiUpdate(data)
message.success(t('common.updateSuccess'))
//
formLoading.value = true
try {
const data = unref(formRef)?.formModel
emit('submitForm', formType.value, data )
dialogVisible.value = false
} finally {
formLoading.value = false
}
} else {
//
formLoading.value = true
try {
// const data = unref(formRef)?.formModel as ItempackagingApi.ItempackagingVO
const data = unref(formRef)?.formModel
if (formType.value === 'create') {
await props.apiCreate(data)
message.success(t('common.createSuccess'))
} else {
await props.apiUpdate(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
@ -325,7 +333,8 @@ const emit = defineEmits([
'handleAddTable',
'inpuFocus',
'searchTableSuccess',
'opensearchTable'
'opensearchTable',
'submitForm'
])
//
const formSelectChange = (field, val) => {

Loading…
Cancel
Save