Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d24d9e69
authored
Mar 09, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 优化配置管理的 loading 设置
parent
74846a11
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
src/api/infra/config/index.ts
+1
-1
src/components/Dialog/src/Dialog.vue
+1
-1
src/views/infra/config/form.vue
+18
-9
No files found.
src/api/infra/config/index.ts
View file @
d24d9e69
import
request
from
'@/config/axios'
import
request
from
'@/config/axios'
export
interface
ConfigVO
{
export
interface
ConfigVO
{
id
:
number
id
:
number
|
undefined
category
:
string
category
:
string
name
:
string
name
:
string
key
:
string
key
:
string
...
...
src/components/Dialog/src/Dialog.vue
View file @
d24d9e69
...
@@ -86,7 +86,7 @@ const dialogStyle = computed(() => {
...
@@ -86,7 +86,7 @@ const dialogStyle = computed(() => {
<ElScrollbar
:style=
"dialogStyle"
v-if=
"scroll"
>
<ElScrollbar
:style=
"dialogStyle"
v-if=
"scroll"
>
<slot></slot>
<slot></slot>
</ElScrollbar>
</ElScrollbar>
<!-- 情况
一
:如果 scroll 为 false,说明关闭滚动条滚动条 -->
<!-- 情况
二
:如果 scroll 为 false,说明关闭滚动条滚动条 -->
<slot
v-else
></slot>
<slot
v-else
></slot>
<
template
v-if=
"slots.footer"
#
footer
>
<
template
v-if=
"slots.footer"
#
footer
>
...
...
src/views/infra/config/form.vue
View file @
d24d9e69
<
template
>
<
template
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
:loading=
"modelLoading"
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
>
<el-form
ref=
"ruleFormRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"80px"
>
<el-form
ref=
"ruleFormRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"80px"
v-loading=
"formLoading"
>
<el-form-item
label=
"参数分类"
prop=
"category"
>
<el-form-item
label=
"参数分类"
prop=
"category"
>
<el-input
v-model=
"formData.category"
placeholder=
"请输入参数分类"
/>
<el-input
v-model=
"formData.category"
placeholder=
"请输入参数分类"
/>
</el-form-item>
</el-form-item>
...
@@ -42,9 +48,9 @@ const message = useMessage() // 消息弹窗
...
@@ -42,9 +48,9 @@ const message = useMessage() // 消息弹窗
const
modelVisible
=
ref
(
false
)
// 弹窗的是否展示
const
modelVisible
=
ref
(
false
)
// 弹窗的是否展示
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
modelLoading
=
ref
(
false
)
// 弹窗的
Loading 加载
const
formLoading
=
ref
(
false
)
// 表单的数据
Loading 加载
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
formLoading
=
ref
(
false
)
// 操作按钮的 Loading 加载
const
submitLoading
=
ref
(
false
)
// 操作按钮的 Loading 加载:避免重复提交
// let formRef = ref() // 表单的 Ref
// let formRef = ref() // 表单的 Ref
const
formData
=
reactive
({
const
formData
=
reactive
({
id
:
undefined
,
id
:
undefined
,
...
@@ -62,7 +68,7 @@ const formRules = reactive({
...
@@ -62,7 +68,7 @@ const formRules = reactive({
value
:
[{
required
:
true
,
message
:
'参数键值不能为空'
,
trigger
:
'blur'
}],
value
:
[{
required
:
true
,
message
:
'参数键值不能为空'
,
trigger
:
'blur'
}],
visible
:
[{
required
:
true
,
message
:
'是否可见不能为空'
,
trigger
:
'blur'
}]
visible
:
[{
required
:
true
,
message
:
'是否可见不能为空'
,
trigger
:
'blur'
}]
})
})
cons
t
ruleFormRef
=
ref
<
FormInstance
>
()
// 表单 Ref
le
t
ruleFormRef
=
ref
<
FormInstance
>
()
// 表单 Ref
const
{
proxy
}
=
getCurrentInstance
()
as
any
const
{
proxy
}
=
getCurrentInstance
()
as
any
...
@@ -74,13 +80,13 @@ const openModal = async (type: string, id?: number) => {
...
@@ -74,13 +80,13 @@ const openModal = async (type: string, id?: number) => {
resetForm
()
resetForm
()
// 修改时,设置数据
// 修改时,设置数据
if
(
id
)
{
if
(
id
)
{
model
Loading
.
value
=
true
form
Loading
.
value
=
true
try
{
try
{
const
data
=
await
ConfigApi
.
getConfig
(
id
)
const
data
=
await
ConfigApi
.
getConfig
(
id
)
// TODO 规范纠结点:因为用 reactive,所以需要使用 Object;可以替换的方案,1)把 reactive 改成 ref;
// TODO 规范纠结点:因为用 reactive,所以需要使用 Object;可以替换的方案,1)把 reactive 改成 ref;
Object
.
assign
(
formData
,
data
)
Object
.
assign
(
formData
,
data
)
}
finally
{
}
finally
{
model
Loading
.
value
=
false
form
Loading
.
value
=
false
}
}
}
}
}
}
...
@@ -95,7 +101,7 @@ const submitForm = async () => {
...
@@ -95,7 +101,7 @@ const submitForm = async () => {
const
valid
=
await
formRef
.
validate
()
const
valid
=
await
formRef
.
validate
()
if
(
!
valid
)
return
if
(
!
valid
)
return
// 提交请求
// 提交请求
form
Loading
.
value
=
true
submit
Loading
.
value
=
true
try
{
try
{
const
data
=
formData
as
ConfigApi
.
ConfigVO
const
data
=
formData
as
ConfigApi
.
ConfigVO
if
(
formType
.
value
===
'create'
)
{
if
(
formType
.
value
===
'create'
)
{
...
@@ -108,7 +114,7 @@ const submitForm = async () => {
...
@@ -108,7 +114,7 @@ const submitForm = async () => {
modelVisible
.
value
=
false
modelVisible
.
value
=
false
emit
(
'success'
)
emit
(
'success'
)
}
finally
{
}
finally
{
form
Loading
.
value
=
false
submit
Loading
.
value
=
false
}
}
}
}
...
@@ -121,6 +127,9 @@ const resetForm = () => {
...
@@ -121,6 +127,9 @@ const resetForm = () => {
formData
.
value
=
''
formData
.
value
=
''
formData
.
visible
=
true
formData
.
visible
=
true
formData
.
remark
=
''
formData
.
remark
=
''
// 重置表单
console
.
log
(
ruleFormRef
)
console
.
log
(
ruleFormRef
.
value
)
// proxy.$refs['ruleFormRef'].resetFields()
// proxy.$refs['ruleFormRef'].resetFields()
// setTimeout(() => {
// setTimeout(() => {
// console.log(ruleFormRef.value, 'formRef.value')
// console.log(ruleFormRef.value, 'formRef.value')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment