1. 优化配置管理的 loading 设置

This commit is contained in:
YunaiV 2023-03-09 22:24:55 +08:00
parent d24d9e690a
commit 6f7a785c80

View File

@ -32,7 +32,7 @@
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="colseForm(ruleFormRef)"> </el-button>
</div>
</template>
@ -48,9 +48,8 @@ const message = useMessage() // 消息弹窗
const modelVisible = ref(false) //
const modelTitle = ref('') //
const formLoading = ref(false) // Loading
const formLoading = ref(false) // Loading 12
const formType = ref('') // create - update -
const submitLoading = ref(false) // Loading
// let formRef = ref() // Ref
const formData = reactive({
id: undefined,
@ -95,13 +94,18 @@ defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
if (true) {
formLoading.value = true
console.log('1111')
return
}
const formRef = proxy.$refs['formRef']
//
if (!formRef) return
const valid = await formRef.validate()
if (!valid) return
//
submitLoading.value = true
formLoading.value = true
try {
const data = formData as ConfigApi.ConfigVO
if (formType.value === 'create') {
@ -114,7 +118,7 @@ const submitForm = async () => {
modelVisible.value = false
emit('success')
} finally {
submitLoading.value = false
formLoading.value = false
}
}