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

This commit is contained in:
YunaiV 2023-03-09 21:45:39 +08:00
parent 74846a11bd
commit d24d9e690a
3 changed files with 20 additions and 11 deletions

View File

@ -1,7 +1,7 @@
import request from '@/config/axios'
export interface ConfigVO {
id: number
id: number | undefined
category: string
name: string
key: string

View File

@ -86,7 +86,7 @@ const dialogStyle = computed(() => {
<ElScrollbar :style="dialogStyle" v-if="scroll">
<slot></slot>
</ElScrollbar>
<!-- 情况如果 scroll false说明关闭滚动条滚动条 -->
<!-- 情况如果 scroll false说明关闭滚动条滚动条 -->
<slot v-else></slot>
<template v-if="slots.footer" #footer>

View File

@ -1,6 +1,12 @@
<template>
<Dialog :title="modelTitle" v-model="modelVisible" :loading="modelLoading">
<el-form ref="ruleFormRef" :model="formData" :rules="formRules" label-width="80px">
<Dialog :title="modelTitle" v-model="modelVisible">
<el-form
ref="ruleFormRef"
:model="formData"
:rules="formRules"
label-width="80px"
v-loading="formLoading"
>
<el-form-item label="参数分类" prop="category">
<el-input v-model="formData.category" placeholder="请输入参数分类" />
</el-form-item>
@ -42,9 +48,9 @@ const message = useMessage() // 消息弹窗
const modelVisible = ref(false) //
const modelTitle = ref('') //
const modelLoading = ref(false) // Loading
const formLoading = ref(false) // Loading
const formType = ref('') // create - update -
const formLoading = ref(false) // Loading
const submitLoading = ref(false) // Loading
// let formRef = ref() // Ref
const formData = reactive({
id: undefined,
@ -62,7 +68,7 @@ const formRules = reactive({
value: [{ required: true, message: '参数键值不能为空', trigger: 'blur' }],
visible: [{ required: true, message: '是否可见不能为空', trigger: 'blur' }]
})
const ruleFormRef = ref<FormInstance>() // Ref
let ruleFormRef = ref<FormInstance>() // Ref
const { proxy } = getCurrentInstance() as any
@ -74,13 +80,13 @@ const openModal = async (type: string, id?: number) => {
resetForm()
//
if (id) {
modelLoading.value = true
formLoading.value = true
try {
const data = await ConfigApi.getConfig(id)
// TODO reactive使 Object1 reactive ref
Object.assign(formData, data)
} finally {
modelLoading.value = false
formLoading.value = false
}
}
}
@ -95,7 +101,7 @@ const submitForm = async () => {
const valid = await formRef.validate()
if (!valid) return
//
formLoading.value = true
submitLoading.value = true
try {
const data = formData as ConfigApi.ConfigVO
if (formType.value === 'create') {
@ -108,7 +114,7 @@ const submitForm = async () => {
modelVisible.value = false
emit('success')
} finally {
formLoading.value = false
submitLoading.value = false
}
}
@ -121,6 +127,9 @@ const resetForm = () => {
formData.value = ''
formData.visible = true
formData.remark = ''
//
console.log(ruleFormRef)
console.log(ruleFormRef.value)
// proxy.$refs['ruleFormRef'].resetFields()
// setTimeout(() => {
// console.log(ruleFormRef.value, 'formRef.value')