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
cd781711
authored
Jun 06, 2025
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 优化代码生成 demo01, 增加批量删除示例
parent
c351a693
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
41 deletions
+92
-41
src/api/infra/demo/demo01/index.ts
+34
-24
src/views/infra/demo/demo01/Demo01ContactForm.vue
+9
-6
src/views/infra/demo/demo01/index.vue
+49
-11
No files found.
src/api/infra/demo/demo01/index.ts
View file @
cd781711
import
request
from
'@/config/axios'
import
request
from
'@/config/axios'
import
type
{
Dayjs
}
from
'dayjs'
export
interface
Demo01ContactVO
{
/** 示例联系人信息 */
id
:
number
export
interface
Demo01Contact
{
name
:
string
id
:
number
// 编号
sex
:
number
name
?:
string
// 名字
birthday
:
Date
sex
?:
number
// 性别
description
:
string
birthday
?:
string
|
Dayjs
// 出生年
avatar
:
string
description
?:
string
// 简介
avatar
:
string
// 头像
}
}
// 查询示例联系人分页
// 示例联系人 API
export
const
getDemo01ContactPage
=
async
(
params
)
=>
{
export
const
Demo01ContactApi
=
{
// 查询示例联系人分页
getDemo01ContactPage
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/infra/demo01-contact/page`
,
params
})
return
await
request
.
get
({
url
:
`/infra/demo01-contact/page`
,
params
})
}
},
// 查询示例联系人详情
// 查询示例联系人详情
export
const
getDemo01Contact
=
async
(
id
:
number
)
=>
{
getDemo01Contact
:
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/infra/demo01-contact/get?id=`
+
id
})
return
await
request
.
get
({
url
:
`/infra/demo01-contact/get?id=`
+
id
})
}
},
// 新增示例联系人
// 新增示例联系人
export
const
createDemo01Contact
=
async
(
data
:
Demo01ContactVO
)
=>
{
createDemo01Contact
:
async
(
data
:
Demo01Contact
)
=>
{
return
await
request
.
post
({
url
:
`/infra/demo01-contact/create`
,
data
})
return
await
request
.
post
({
url
:
`/infra/demo01-contact/create`
,
data
})
}
},
// 修改示例联系人
// 修改示例联系人
export
const
updateDemo01Contact
=
async
(
data
:
Demo01ContactVO
)
=>
{
updateDemo01Contact
:
async
(
data
:
Demo01Contact
)
=>
{
return
await
request
.
put
({
url
:
`/infra/demo01-contact/update`
,
data
})
return
await
request
.
put
({
url
:
`/infra/demo01-contact/update`
,
data
})
}
},
// 删除示例联系人
// 删除示例联系人
export
const
deleteDemo01Contact
=
async
(
id
:
number
)
=>
{
deleteDemo01Contact
:
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/infra/demo01-contact/delete?id=`
+
id
})
return
await
request
.
delete
({
url
:
`/infra/demo01-contact/delete?id=`
+
id
})
}
},
/** 批量删除示例联系人 */
deleteDemo01ContactList
:
async
(
ids
:
number
[])
=>
{
return
await
request
.
delete
({
url
:
`/infra/demo01-contact/delete-list?ids=
${
ids
.
join
(
','
)}
`
})
},
// 导出示例联系人 Excel
// 导出示例联系人 Excel
export
const
exportDemo01Contact
=
async
(
params
)
=>
{
exportDemo01Contact
:
async
(
params
)
=>
{
return
await
request
.
download
({
url
:
`/infra/demo01-contact/export-excel`
,
params
})
return
await
request
.
download
({
url
:
`/infra/demo01-contact/export-excel`
,
params
})
}
}
}
src/views/infra/demo/demo01/Demo01ContactForm.vue
View file @
cd781711
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<el-radio
<el-radio
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
:key=
"dict.value"
:key=
"dict.value"
:
value
=
"dict.value"
:
label
=
"dict.value"
>
>
{{
dict
.
label
}}
{{
dict
.
label
}}
</el-radio>
</el-radio>
...
@@ -44,7 +44,10 @@
...
@@ -44,7 +44,10 @@
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
getIntDictOptions
,
DICT_TYPE
}
from
'@/utils/dict'
import
{
getIntDictOptions
,
DICT_TYPE
}
from
'@/utils/dict'
import
*
as
Demo01ContactApi
from
'@/api/infra/demo/demo01'
import
{
Demo01ContactApi
,
Demo01Contact
}
from
'@/api/infra/demo/demo01'
/** 示例联系人 表单 */
defineOptions
({
name
:
'Demo01ContactForm'
})
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
...
@@ -59,13 +62,13 @@ const formData = ref({
...
@@ -59,13 +62,13 @@ const formData = ref({
sex
:
undefined
,
sex
:
undefined
,
birthday
:
undefined
,
birthday
:
undefined
,
description
:
undefined
,
description
:
undefined
,
avatar
:
undefined
avatar
:
undefined
,
})
})
const
formRules
=
reactive
({
const
formRules
=
reactive
({
name
:
[{
required
:
true
,
message
:
'名字不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'名字不能为空'
,
trigger
:
'blur'
}],
sex
:
[{
required
:
true
,
message
:
'性别不能为空'
,
trigger
:
'blur'
}],
sex
:
[{
required
:
true
,
message
:
'性别不能为空'
,
trigger
:
'blur'
}],
birthday
:
[{
required
:
true
,
message
:
'出生年不能为空'
,
trigger
:
'blur'
}],
birthday
:
[{
required
:
true
,
message
:
'出生年不能为空'
,
trigger
:
'blur'
}],
description
:
[{
required
:
true
,
message
:
'简介不能为空'
,
trigger
:
'blur'
}]
description
:
[{
required
:
true
,
message
:
'简介不能为空'
,
trigger
:
'blur'
}]
,
})
})
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
...
@@ -95,7 +98,7 @@ const submitForm = async () => {
...
@@ -95,7 +98,7 @@ const submitForm = async () => {
// 提交请求
// 提交请求
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
const
data
=
formData
.
value
as
unknown
as
Demo01Contact
Api
.
Demo01ContactVO
const
data
=
formData
.
value
as
unknown
as
Demo01Contact
if
(
formType
.
value
===
'create'
)
{
if
(
formType
.
value
===
'create'
)
{
await
Demo01ContactApi
.
createDemo01Contact
(
data
)
await
Demo01ContactApi
.
createDemo01Contact
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
message
.
success
(
t
(
'common.createSuccess'
))
...
@@ -119,7 +122,7 @@ const resetForm = () => {
...
@@ -119,7 +122,7 @@ const resetForm = () => {
sex
:
undefined
,
sex
:
undefined
,
birthday
:
undefined
,
birthday
:
undefined
,
description
:
undefined
,
description
:
undefined
,
avatar
:
undefined
avatar
:
undefined
,
}
}
formRef
.
value
?.
resetFields
()
formRef
.
value
?.
resetFields
()
}
}
...
...
src/views/infra/demo/demo01/index.vue
View file @
cd781711
<
template
>
<
template
>
<doc-alert
title=
"代码生成(单表)"
url=
"https://doc.iocoder.cn/new-feature/"
/>
<ContentWrap>
<ContentWrap>
<!-- 搜索工作栏 -->
<!-- 搜索工作栏 -->
<el-form
<el-form
...
@@ -20,7 +18,12 @@
...
@@ -20,7 +18,12 @@
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"性别"
prop=
"sex"
>
<el-form-item
label=
"性别"
prop=
"sex"
>
<el-select
v-model=
"queryParams.sex"
placeholder=
"请选择性别"
clearable
class=
"!w-240px"
>
<el-select
v-model=
"queryParams.sex"
placeholder=
"请选择性别"
clearable
class=
"!w-240px"
>
<el-option
<el-option
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)"
:key=
"dict.value"
:key=
"dict.value"
...
@@ -37,7 +40,7 @@
...
@@ -37,7 +40,7 @@
start-placeholder=
"开始日期"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
end-placeholder=
"结束日期"
:default-time=
"[new Date('1 00:00:00'), new Date('1 23:59:59')]"
:default-time=
"[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class=
"!w-2
4
0px"
class=
"!w-2
2
0px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
...
@@ -60,13 +63,30 @@
...
@@ -60,13 +63,30 @@
>
>
<Icon
icon=
"ep:download"
class=
"mr-5px"
/>
导出
<Icon
icon=
"ep:download"
class=
"mr-5px"
/>
导出
</el-button>
</el-button>
<el-button
type=
"danger"
plain
:disabled=
"isEmpty(checkedIds)"
@
click=
"handleDeleteBatch"
v-hasPermi=
"['infra:demo01-contact:delete']"
>
<Icon
icon=
"ep:delete"
class=
"mr-5px"
/>
批量删除
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</ContentWrap>
</ContentWrap>
<!-- 列表 -->
<!-- 列表 -->
<ContentWrap>
<ContentWrap>
<el-table
v-loading=
"loading"
:data=
"list"
:stripe=
"true"
:show-overflow-tooltip=
"true"
>
<el-table
row-key=
"id"
v-loading=
"loading"
:data=
"list"
:stripe=
"true"
:show-overflow-tooltip=
"true"
@
selection-change=
"handleRowCheckboxChange"
>
<el-table-column
type=
"selection"
width=
"55"
/>
<el-table-column
label=
"编号"
align=
"center"
prop=
"id"
/>
<el-table-column
label=
"编号"
align=
"center"
prop=
"id"
/>
<el-table-column
label=
"名字"
align=
"center"
prop=
"name"
/>
<el-table-column
label=
"名字"
align=
"center"
prop=
"name"
/>
<el-table-column
label=
"性别"
align=
"center"
prop=
"sex"
>
<el-table-column
label=
"性别"
align=
"center"
prop=
"sex"
>
...
@@ -90,7 +110,7 @@
...
@@ -90,7 +110,7 @@
:formatter=
"dateFormatter"
:formatter=
"dateFormatter"
width=
"180px"
width=
"180px"
/>
/>
<el-table-column
label=
"操作"
align=
"center"
>
<el-table-column
label=
"操作"
align=
"center"
min-width=
"120px"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<el-button
<el-button
link
link
...
@@ -126,25 +146,27 @@
...
@@ -126,25 +146,27 @@
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
getIntDictOptions
,
DICT_TYPE
}
from
'@/utils/dict'
import
{
getIntDictOptions
,
DICT_TYPE
}
from
'@/utils/dict'
import
{
isEmpty
}
from
'@/utils/is'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
download
from
'@/utils/download'
import
download
from
'@/utils/download'
import
*
as
Demo01ContactApi
from
'@/api/infra/demo/demo01'
import
{
Demo01ContactApi
,
Demo01Contact
}
from
'@/api/infra/demo/demo01'
import
Demo01ContactForm
from
'./Demo01ContactForm.vue'
import
Demo01ContactForm
from
'./Demo01ContactForm.vue'
/** 示例联系人 列表 */
defineOptions
({
name
:
'Demo01Contact'
})
defineOptions
({
name
:
'Demo01Contact'
})
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
loading
=
ref
(
true
)
// 列表的加载中
const
loading
=
ref
(
true
)
// 列表的加载中
const
list
=
ref
([])
// 列表的数据
const
list
=
ref
<
Demo01Contact
[]
>
([])
// 列表的数据
const
total
=
ref
(
0
)
// 列表的总页数
const
total
=
ref
(
0
)
// 列表的总页数
const
queryParams
=
reactive
({
const
queryParams
=
reactive
({
pageNo
:
1
,
pageNo
:
1
,
pageSize
:
10
,
pageSize
:
10
,
name
:
null
,
name
:
undefined
,
sex
:
null
,
sex
:
undefined
,
createTime
:
[]
createTime
:
[]
,
})
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
queryFormRef
=
ref
()
// 搜索的表单
const
exportLoading
=
ref
(
false
)
// 导出的加载中
const
exportLoading
=
ref
(
false
)
// 导出的加载中
...
@@ -192,6 +214,22 @@ const handleDelete = async (id: number) => {
...
@@ -192,6 +214,22 @@ const handleDelete = async (id: number) => {
}
catch
{}
}
catch
{}
}
}
/** 批量删除示例联系人 */
const
handleDeleteBatch
=
async
()
=>
{
try
{
// 删除的二次确认
await
message
.
delConfirm
()
await
Demo01ContactApi
.
deleteDemo01ContactList
(
checkedIds
.
value
);
message
.
success
(
t
(
'common.delSuccess'
))
await
getList
();
}
catch
{}
}
const
checkedIds
=
ref
<
number
[]
>
([])
const
handleRowCheckboxChange
=
(
records
:
Demo01Contact
[])
=>
{
checkedIds
.
value
=
records
.
map
((
item
)
=>
item
.
id
);
}
/** 导出按钮操作 */
/** 导出按钮操作 */
const
handleExport
=
async
()
=>
{
const
handleExport
=
async
()
=>
{
try
{
try
{
...
...
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