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
9ef85e14
authored
Mar 08, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vue3 重构:配置管理,新增表单
parent
64b249e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
38 deletions
+38
-38
src/api/infra/config/index.ts
+1
-1
src/views/infra/config/form.vue
+33
-33
src/views/infra/config/index.vue
+4
-4
No files found.
src/api/infra/config/index.ts
View file @
9ef85e14
...
@@ -32,7 +32,7 @@ export const getConfigPage = (params: ConfigPageReqVO) => {
...
@@ -32,7 +32,7 @@ export const getConfigPage = (params: ConfigPageReqVO) => {
}
}
// 查询参数详情
// 查询参数详情
export
const
getConfig
Api
=
(
id
:
number
)
=>
{
export
const
getConfig
=
(
id
:
number
)
=>
{
return
request
.
get
({
url
:
'/infra/config/get?id='
+
id
})
return
request
.
get
({
url
:
'/infra/config/get?id='
+
id
})
}
}
...
...
src/views/infra/config/form.vue
View file @
9ef85e14
<
template
>
<
template
>
<XModal
:title=
"modelTitle"
:loading=
"modelLoading"
v-model=
"modelVisible"
>
<!-- TODO 芋艿:Dialog 貌似高度不太对劲 -->
<el-form
ref=
"formRef"
:model=
"form"
:rules=
"rules"
label-width=
"80px"
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
:loading=
"modelLoading"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"80px"
>
<el-form-item
label=
"参数分类"
prop=
"category"
>
<el-form-item
label=
"参数分类"
prop=
"category"
>
<el-input
v-model=
"form.category"
placeholder=
"请输入参数分类"
/>
<el-input
v-model=
"form
Data
.category"
placeholder=
"请输入参数分类"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"参数名称"
prop=
"name"
>
<el-form-item
label=
"参数名称"
prop=
"name"
>
<el-input
v-model=
"form.name"
placeholder=
"请输入参数名称"
/>
<el-input
v-model=
"form
Data
.name"
placeholder=
"请输入参数名称"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"参数键名"
prop=
"key"
>
<el-form-item
label=
"参数键名"
prop=
"key"
>
<el-input
v-model=
"form.key"
placeholder=
"请输入参数键名"
/>
<el-input
v-model=
"form
Data
.key"
placeholder=
"请输入参数键名"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"参数键值"
prop=
"value"
>
<el-form-item
label=
"参数键值"
prop=
"value"
>
<el-input
v-model=
"form.value"
placeholder=
"请输入参数键值"
/>
<el-input
v-model=
"form
Data
.value"
placeholder=
"请输入参数键值"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"是否可见"
prop=
"visible"
>
<el-form-item
label=
"是否可见"
prop=
"visible"
>
<!-- TODO 芋艿:改成组件 -->
<!-- TODO 芋艿:改成组件 -->
<el-radio-group
v-model=
"form.visible"
>
<el-radio-group
v-model=
"form
Data
.visible"
>
<el-radio
:key=
"true"
:label=
"true"
>
是
</el-radio>
<el-radio
:key=
"true"
:label=
"true"
>
是
</el-radio>
<el-radio
:key=
"false"
:label=
"false"
>
否
</el-radio>
<el-radio
:key=
"false"
:label=
"false"
>
否
</el-radio>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
<el-form-item
label=
"备注"
prop=
"remark"
>
<el-form-item
label=
"备注"
prop=
"remark"
>
<el-input
v-model=
"form.remark"
type=
"textarea"
placeholder=
"请输入内容"
/>
<el-input
v-model=
"form
Data
.remark"
type=
"textarea"
placeholder=
"请输入内容"
/>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<template
#
footer
>
<template
#
footer
>
<div
class=
"dialog-footer"
>
<div
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
@
click=
"model
Loading
= false"
>
取 消
</el-button>
<el-button
@
click=
"model
Visible
= false"
>
取 消
</el-button>
</div>
</div>
</
template
>
</
template
>
</
XModal
>
</
Dialog
>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
*
as
ConfigApi
from
'@/api/infra/config'
// import type { FormExpose } from '@/components/Form'
// import type { FormExpose } from '@/components/Form'
import
*
as
PostApi
from
'@/api/system/post'
import
*
as
PostApi
from
'@/api/system/post'
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
// const { proxy } = getCurrentInstance()
const
modelVisible
=
ref
(
false
)
// 弹窗的是否展示
const
modelVisible
=
ref
(
false
)
// 弹窗的是否展示
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
modelTitle
=
ref
(
''
)
// 弹窗的标题
const
modelLoading
=
ref
(
false
)
// 弹窗的 Loading 加载
const
modelLoading
=
ref
(
false
)
// 弹窗的 Loading 加载
const
actionType
=
ref
(
''
)
// 操作
类型:create - 新增;update - 修改
const
formType
=
ref
(
''
)
// 表单的
类型:create - 新增;update - 修改
const
action
Loading
=
ref
(
false
)
// 操作按钮的 Loading 加载
const
form
Loading
=
ref
(
false
)
// 操作按钮的 Loading 加载
cons
t
formRef
=
ref
()
// 表单的 Ref
le
t
formRef
=
ref
()
// 表单的 Ref
const
form
=
reactive
({
const
form
Data
=
reactive
({
id
:
undefined
,
id
:
undefined
,
category
:
undefined
,
category
:
undefined
,
name
:
undefined
,
name
:
undefined
,
...
@@ -53,7 +56,7 @@ const form = reactive({
...
@@ -53,7 +56,7 @@ const form = reactive({
visible
:
true
,
visible
:
true
,
remark
:
undefined
remark
:
undefined
})
})
const
r
ules
=
reactive
({
const
formR
ules
=
reactive
({
category
:
[{
required
:
true
,
message
:
'参数分类不能为空'
,
trigger
:
'blur'
}],
category
:
[{
required
:
true
,
message
:
'参数分类不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'参数名称不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'参数名称不能为空'
,
trigger
:
'blur'
}],
key
:
[{
required
:
true
,
message
:
'参数键名不能为空'
,
trigger
:
'blur'
}],
key
:
[{
required
:
true
,
message
:
'参数键名不能为空'
,
trigger
:
'blur'
}],
...
@@ -67,16 +70,12 @@ const openModal = async (type: string, id?: number) => {
...
@@ -67,16 +70,12 @@ const openModal = async (type: string, id?: number) => {
modelVisible
.
value
=
true
modelVisible
.
value
=
true
modelLoading
.
value
=
true
modelLoading
.
value
=
true
modelTitle
.
value
=
t
(
'action.'
+
type
)
modelTitle
.
value
=
t
(
'action.'
+
type
)
action
Type
.
value
=
type
form
Type
.
value
=
type
// 设置数据
// 设置数据
resetForm
()
resetForm
()
if
(
id
)
{
if
(
id
)
{
// const res = await PostApi.getPostApi(id)
const
data
=
await
ConfigApi
.
getConfig
(
id
)
// if (type === 'update') {
Object
.
assign
(
formData
,
data
)
// unref(formRef)?.setValues(res)
// } else if (type === 'detail') {
// detailData.value = res
// }
}
}
modelLoading
.
value
=
false
modelLoading
.
value
=
false
}
}
...
@@ -91,10 +90,10 @@ const submitForm = async () => {
...
@@ -91,10 +90,10 @@ const submitForm = async () => {
const
valid
=
await
elForm
.
validate
()
const
valid
=
await
elForm
.
validate
()
if
(
!
valid
)
return
if
(
!
valid
)
return
// 提交请求
// 提交请求
action
Loading
.
value
=
true
form
Loading
.
value
=
true
try
{
try
{
const
data
=
unref
(
formRef
)?.
formModel
as
PostApi
.
PostVO
const
data
=
unref
(
formRef
)?.
formModel
as
PostApi
.
PostVO
if
(
action
Type
.
value
===
'create'
)
{
if
(
form
Type
.
value
===
'create'
)
{
await
PostApi
.
createPostApi
(
data
)
await
PostApi
.
createPostApi
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
message
.
success
(
t
(
'common.createSuccess'
))
}
else
{
}
else
{
...
@@ -104,19 +103,20 @@ const submitForm = async () => {
...
@@ -104,19 +103,20 @@ const submitForm = async () => {
modelVisible
.
value
=
false
modelVisible
.
value
=
false
emit
(
'success'
)
emit
(
'success'
)
}
finally
{
}
finally
{
action
Loading
.
value
=
false
form
Loading
.
value
=
false
}
}
}
}
/** 重置表单 */
/** 重置表单 */
const
resetForm
=
()
=>
{
const
resetForm
=
()
=>
{
form
.
id
=
undefined
formData
.
id
=
undefined
form
.
category
=
undefined
formData
.
category
=
undefined
form
.
name
=
undefined
formData
.
name
=
undefined
form
.
key
=
undefined
formData
.
key
=
undefined
form
.
value
=
undefined
formData
.
value
=
undefined
form
.
visible
=
true
formData
.
visible
=
true
form
.
remark
=
undefined
formData
.
remark
=
undefined
formRef
.
value
.
resetFields
()
// proxy.$refs['formRef'].resetFields()
// formRef.value.resetFields() // TODO 芋艿:为什么拿不到
}
}
</
script
>
</
script
>
src/views/infra/config/index.vue
View file @
9ef85e14
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<!-- 搜索工作栏 -->
<!-- 搜索工作栏 -->
<el-form
<el-form
:model=
"queryParams"
:model=
"queryParams"
ref=
"queryForm"
ref=
"queryForm
Ref
"
:inline=
"true"
:inline=
"true"
v-show=
"showSearch"
v-show=
"showSearch"
label-width=
"68px"
label-width=
"68px"
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
type=
"primary"
type=
"primary"
plain
plain
icon=
"el-icon-plus"
icon=
"el-icon-plus"
@
click=
"
handleAdd
"
@
click=
"
openModal('create')
"
v-hasPermi=
"['infra:config:create']"
v-hasPermi=
"['infra:config:create']"
>
>
新增
新增
...
@@ -160,7 +160,7 @@ const queryParams = reactive({
...
@@ -160,7 +160,7 @@ const queryParams = reactive({
type
:
undefined
,
type
:
undefined
,
createTime
:
[]
createTime
:
[]
})
})
const
queryForm
=
ref
()
// 搜索的表单
const
queryForm
Ref
=
ref
()
// 搜索的表单
/** 搜索按钮操作 */
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
const
handleQuery
=
()
=>
{
...
@@ -182,7 +182,7 @@ const getList = async () => {
...
@@ -182,7 +182,7 @@ const getList = async () => {
/** 重置按钮操作 */
/** 重置按钮操作 */
const
resetQuery
=
()
=>
{
const
resetQuery
=
()
=>
{
queryForm
.
value
.
resetFields
()
queryForm
Ref
.
value
.
resetFields
()
handleQuery
()
handleQuery
()
}
}
...
...
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