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
4e413a10
authored
Nov 09, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
主子表:暂时存储,准备重构
parent
eb9f8c9f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
362 additions
and
0 deletions
+362
-0
src/api/infra/demo02/index.ts
+35
-0
src/views/infra/demo02/DemoStudentContactForm.vue
+71
-0
src/views/infra/demo02/DemoStudentForm.vue
+97
-0
src/views/infra/demo02/index.vue
+159
-0
No files found.
src/api/infra/demo02/index.ts
0 → 100644
View file @
4e413a10
import
request
from
'@/config/axios'
export
interface
DemoStudentVO
{
id
:
number
}
// 查询学生列表
export
const
getDemoStudentPage
=
async
(
params
)
=>
{
return
await
request
.
get
({
url
:
`/infra/demo-student/page`
,
params
})
}
// 查询学生详情
export
const
getDemoStudent
=
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/infra/demo-student/get?id=`
+
id
})
}
// 新增学生
export
const
createDemoStudent
=
async
(
data
:
DemoStudentVO
)
=>
{
return
await
request
.
post
({
url
:
`/infra/demo-student/create`
,
data
})
}
// 修改学生
export
const
updateDemoStudent
=
async
(
data
:
DemoStudentVO
)
=>
{
return
await
request
.
put
({
url
:
`/infra/demo-student/update`
,
data
})
}
// 删除学生
export
const
deleteDemoStudent
=
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/infra/demo-student/delete?id=`
+
id
})
}
// 导出学生 Excel
export
const
exportDemoStudent
=
async
(
params
)
=>
{
return
await
request
.
download
({
url
:
`/infra/demo-student/export-excel`
,
params
})
}
src/views/infra/demo02/DemoStudentContactForm.vue
0 → 100644
View file @
4e413a10
<
template
>
<!--
<el-row
:gutter=
"10"
class=
"mb2"
>
-->
<!--
<el-col
:span=
"1.5"
>
-->
<!--
<el-button
type=
"primary"
@
click=
"handleAdd"
>
添加
</el-button>
-->
<!--
</el-col>
-->
<!--
<el-col
:span=
"1.5"
>
-->
<!--
<el-button
type=
"danger"
>
删除
</el-button>
-->
<!--
</el-col>
-->
<!--
</el-row>
-->
<el-table
:data=
"formData"
@
selection-change=
"handleDemoStudentContactSelectionChange"
ref=
"demoStudentContactRef"
:stripe=
"true"
>
<el-table-column
label=
"序号"
type=
"index"
width=
"100"
/>
<el-table-column
label=
"名字"
prop=
"name"
width=
"300"
>
<template
#
default=
"scope"
>
<el-form-item
label-width=
"0px"
:inline-message=
"true"
>
<el-input
v-model=
"scope.row.name"
placeholder=
"请输入名字"
/>
</el-form-item>
</
template
>
</el-table-column>
<el-table-column
label=
"手机号码"
>
<
template
#
default=
"{ row, $index }"
>
<el-form-item
label-width=
"0px"
:prop=
"`formData.$
{$index}.mobile`"
:rules="formRules.mobile"
:inline-message="true"
>
<el-input
type=
"number"
placeholder=
"输入手机号码"
v-model=
"row.mobile"
/>
</el-form-item>
</
template
>
</el-table-column>
</el-table>
<el-button
@
click=
"handleAdd"
class=
"w-1/1"
>
+ 添加客户信息
</el-button>
</template>
<
script
setup
lang=
"ts"
>
const
formData
=
ref
([
{
name
:
'芋艿'
},
{
name
:
'土豆'
}
])
const
formRules
=
reactive
({
mobile
:
[
required
]
})
const
handleDemoStudentContactSelectionChange
=
(
val
)
=>
{
demoStudentContactList
.
value
=
val
}
const
demoStudentContactRef
=
ref
()
/** 新增按钮操作 */
const
handleAdd
=
()
=>
{
formData
.
value
.
push
({
name
:
'测试'
})
}
/** 删除按钮操作 */
const
handleRemove
=
()
=>
{
formData
.
value
.
push
({
name
:
'测试'
})
}
</
script
>
src/views/infra/demo02/DemoStudentForm.vue
0 → 100644
View file @
4e413a10
<
template
>
<Dialog
:title=
"dialogTitle"
v-model=
"dialogVisible"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"100px"
v-loading=
"formLoading"
>
<el-form-item
label=
"表描述"
prop=
"tableComment"
>
<el-input
v-model=
"formData.tableComment"
placeholder=
"请输入"
/>
</el-form-item>
<el-tabs
v-model=
"activeName"
class=
"demo-tabs"
@
tab-click=
"handleClick"
>
<el-tab-pane
label=
"User"
name=
"first"
>
<DemoStudentContactForm
/>
</el-tab-pane>
<el-tab-pane
label=
"Config"
name=
"second"
>
Config
</el-tab-pane>
<el-tab-pane
label=
"Role"
name=
"third"
>
Role
</el-tab-pane>
<el-tab-pane
label=
"Task"
name=
"fourth"
>
Task
</el-tab-pane>
</el-tabs>
</el-form>
<template
#
footer
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
setup
lang=
"ts"
>
import
*
as
DemoStudentApi
from
'@/api/infra/demo02'
import
DemoStudentContactForm
from
'./DemoStudentContactForm.vue'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
dialogTitle
=
ref
(
''
)
// 弹窗的标题
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formType
=
ref
(
''
)
// 表单的类型:create - 新增;update - 修改
const
formData
=
ref
({
id
:
undefined
,
demoStudentContactList
:
[]
})
const
formRules
=
reactive
({})
const
formRef
=
ref
()
// 表单 Ref
/** 打开弹窗 */
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
dialogVisible
.
value
=
true
dialogTitle
.
value
=
t
(
'action.'
+
type
)
formType
.
value
=
type
// resetForm()
// 修改时,设置数据
if
(
id
)
{
formLoading
.
value
=
true
try
{
formData
.
value
=
await
DemoStudentApi
.
getDemoStudent
(
id
)
}
finally
{
formLoading
.
value
=
false
}
}
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
submitForm
=
async
()
=>
{
// 校验表单
if
(
!
formRef
)
return
const
valid
=
await
formRef
.
value
.
validate
()
if
(
!
valid
)
return
// 提交请求
formLoading
.
value
=
true
try
{
const
data
=
formData
.
value
as
unknown
as
DemoStudentApi
.
DemoStudentVO
if
(
formType
.
value
===
'create'
)
{
await
DemoStudentApi
.
createDemoStudent
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
}
else
{
await
DemoStudentApi
.
updateDemoStudent
(
data
)
message
.
success
(
t
(
'common.updateSuccess'
))
}
dialogVisible
.
value
=
false
// 发送操作成功的事件
emit
(
'success'
)
}
finally
{
formLoading
.
value
=
false
}
}
/** 重置表单 */
const
resetForm
=
()
=>
{
formData
.
value
=
{
id
:
undefined
}
formRef
.
value
?.
resetFields
()
}
</
script
>
src/views/infra/demo02/index.vue
0 → 100644
View file @
4e413a10
<
template
>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
plain
@
click=
"openForm('create')"
v-hasPermi=
"['infra:demo-student:create']"
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
</el-button>
<el-button
type=
"success"
plain
@
click=
"handleExport"
:loading=
"exportLoading"
v-hasPermi=
"['infra:demo-student:export']"
>
<Icon
icon=
"ep:download"
class=
"mr-5px"
/>
导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table
v-loading=
"loading"
:data=
"list"
:stripe=
"true"
:show-overflow-tooltip=
"true"
>
<el-table-column
label=
"编号"
align=
"center"
prop=
"id"
>
<template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.$dictType.toUpperCase()"
:value=
"scope.row.id"
/>
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
>
<
template
#
default=
"scope"
>
<el-button
link
type=
"primary"
@
click=
"openForm('update', scope.row.id)"
v-hasPermi=
"['infra:demo-student:update']"
>
编辑
</el-button>
<el-button
link
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['infra:demo-student:delete']"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total=
"total"
v-model:page=
"queryParams.pageNo"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<DemoStudentForm
ref=
"formRef"
@
success=
"getList"
/>
</template>
<
script
setup
lang=
"ts"
>
import
download
from
'@/utils/download'
import
*
as
DemoStudentApi
from
'@/api/infra/demo02'
import
DemoStudentForm
from
'./DemoStudentForm.vue'
defineOptions
({
name
:
'InfraDemoStudent'
})
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
loading
=
ref
(
true
)
// 列表的加载中
const
total
=
ref
(
0
)
// 列表的总页数
const
list
=
ref
([])
// 列表的数据
const
queryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
exportLoading
=
ref
(
false
)
// 导出的加载中
/** 查询列表 */
const
getList
=
async
()
=>
{
loading
.
value
=
true
try
{
const
data
=
await
DemoStudentApi
.
getDemoStudentPage
(
queryParams
)
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
finally
{
loading
.
value
=
false
}
}
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
getList
()
}
/** 重置按钮操作 */
const
resetQuery
=
()
=>
{
queryFormRef
.
value
.
resetFields
()
handleQuery
()
}
/** 添加/修改操作 */
const
formRef
=
ref
()
const
openForm
=
(
type
:
string
,
id
?:
number
)
=>
{
formRef
.
value
.
open
(
type
,
id
)
}
/** 删除按钮操作 */
const
handleDelete
=
async
(
id
:
number
)
=>
{
try
{
// 删除的二次确认
await
message
.
delConfirm
()
// 发起删除
await
DemoStudentApi
.
deleteDemoStudent
(
id
)
message
.
success
(
t
(
'common.delSuccess'
))
// 刷新列表
await
getList
()
}
catch
{}
}
/** 导出按钮操作 */
const
handleExport
=
async
()
=>
{
try
{
// 导出的二次确认
await
message
.
exportConfirm
()
// 发起导出
exportLoading
.
value
=
true
const
data
=
await
DemoStudentApi
.
exportDemoStudent
(
queryParams
)
download
.
excel
(
data
,
'学生.xls'
)
}
catch
{
}
finally
{
exportLoading
.
value
=
false
}
}
/** 初始化 **/
onMounted
(()
=>
{
getList
()
})
</
script
>
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