Skip to content

Commit 3f2a77f

Browse files
committed
Vue3 重构:邮件账号的重构部分提交
1 parent 96e0ce9 commit 3f2a77f

File tree

6 files changed

+46
-38
lines changed

6 files changed

+46
-38
lines changed

src/api/system/mail/account/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ export interface MailAccountVO {
1111
}
1212

1313
// 查询邮箱账号列表
14-
export const getMailAccountPageApi = async (params: PageParam) => {
14+
export const getMailAccountPage = async (params: PageParam) => {
1515
return await request.get({ url: '/system/mail-account/page', params })
1616
}
1717

1818
// 查询邮箱账号详情
19-
export const getMailAccountApi = async (id: number) => {
19+
export const getMailAccount = async (id: number) => {
2020
return await request.get({ url: '/system/mail-account/get?id=' + id })
2121
}
2222

2323
// 新增邮箱账号
24-
export const createMailAccountApi = async (data: MailAccountVO) => {
24+
export const createMailAccount = async (data: MailAccountVO) => {
2525
return await request.post({ url: '/system/mail-account/create', data })
2626
}
2727

2828
// 修改邮箱账号
29-
export const updateMailAccountApi = async (data: MailAccountVO) => {
29+
export const updateMailAccount = async (data: MailAccountVO) => {
3030
return await request.put({ url: '/system/mail-account/update', data })
3131
}
3232

3333
// 删除邮箱账号
34-
export const deleteMailAccountApi = async (id: number) => {
34+
export const deleteMailAccount = async (id: number) => {
3535
return await request.delete({ url: '/system/mail-account/delete?id=' + id })
3636
}
3737

3838
// 获得邮箱账号精简列表
39-
export const getSimpleMailAccounts = async () => {
39+
export const getSimpleMailAccountList = async () => {
4040
return request.get({ url: '/system/mail-account/list-all-simple' })
4141
}

src/views/system/mail/account/account.data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const crudSchemas = reactive<CrudSchema[]>([
7777
{
7878
label: '操作',
7979
field: 'action',
80-
width: '260px',
8180
form: {
8281
show: false
8382
}

src/views/system/mail/account/form.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const openModal = async (type: string, id?: number) => {
3131
if (id) {
3232
formLoading.value = true
3333
try {
34-
const data = await MailAccountApi.getMailAccountApi(id)
34+
const data = await MailAccountApi.getMailAccount(id)
3535
formRef.value.setValues(data)
3636
} finally {
3737
formLoading.value = false
@@ -52,10 +52,10 @@ const submitForm = async () => {
5252
try {
5353
const data = formRef.value.formModel as MailAccountApi.MailAccountVO
5454
if (formType.value === 'create') {
55-
await MailAccountApi.createMailAccountApi(data)
55+
await MailAccountApi.createMailAccount(data)
5656
message.success(t('common.createSuccess'))
5757
} else {
58-
await MailAccountApi.updateMailAccountApi(data)
58+
await MailAccountApi.updateMailAccount(data)
5959
message.success(t('common.updateSuccess'))
6060
}
6161
modelVisible.value = false
Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
<template>
2+
<!-- 搜索工作栏 -->
23
<ContentWrap>
3-
<!-- TODO @芋艿:setSearchParams -->
4-
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
4+
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
5+
<!-- 新增等操作按钮 -->
6+
<template #actionMore>
7+
<el-button
8+
type="primary"
9+
@click="openModal('create')"
10+
v-hasPermi="['system:mail-account:create']"
11+
>
12+
<Icon icon="ep:plus" class="mr-5px" /> 新增
13+
</el-button>
14+
</template>
15+
</Search>
516
</ContentWrap>
617

7-
<el-button
8-
type="primary"
9-
@click="openModal('create')"
10-
v-hasPermi="['system:mail-account:create']"
11-
>
12-
<Icon icon="ep:plus" class="mr-5px" /> 新增
13-
</el-button>
14-
18+
<!-- 列表 -->
1519
<ContentWrap>
1620
<Table
17-
v-model:pageSize="tableObject.pageSize"
18-
v-model:currentPage="tableObject.currentPage"
1921
:columns="allSchemas.tableColumns"
2022
:data="tableObject.tableList"
2123
:loading="tableObject.loading"
2224
:pagination="{
2325
total: tableObject.total
2426
}"
25-
@register="register"
27+
v-model:pageSize="tableObject.pageSize"
28+
v-model:currentPage="tableObject.currentPage"
2629
>
2730
<template #action="{ row }">
2831
<el-button
@@ -37,7 +40,7 @@
3740
link
3841
type="danger"
3942
v-hasPermi="['system:mail-account:delete']"
40-
@click="delList(row.id, false)"
43+
@click="handleDelete(row.id)"
4144
>
4245
删除
4346
</el-button>
@@ -46,31 +49,37 @@
4649
</ContentWrap>
4750

4851
<!-- 表单弹窗:添加/修改 -->
49-
<mail-account-form ref="modalRef" @success="getList" />
52+
<MailAccountForm ref="modalRef" @success="getList" />
5053
</template>
5154
<script setup lang="ts" name="MailAccount">
5255
import { allSchemas } from './account.data'
5356
import { useTable } from '@/hooks/web/useTable'
5457
import * as MailAccountApi from '@/api/system/mail/account'
5558
import MailAccountForm from './form.vue'
5659
57-
// const { t } = useI18n() // 国际化
58-
// const message = useMessage() // 消息弹窗
59-
60-
const { register, tableObject, methods } = useTable<MailAccountApi.MailAccountVO>({
61-
getListApi: MailAccountApi.getMailAccountPageApi,
62-
delListApi: MailAccountApi.deleteMailAccountApi
60+
// https://kailong110120130.gitee.io/vue-element-plus-admin-doc/components/table.html#usetable
61+
// tableObject:表格的属性对象,可获得分页大小、条数等属性
62+
// tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
63+
const { tableObject, tableMethods } = useTable({
64+
getListApi: MailAccountApi.getMailAccountPage, // 分页接口
65+
delListApi: MailAccountApi.deleteMailAccount // 删除接口
6366
})
64-
65-
const { getList, setSearchParams } = methods
66-
67-
const { delList } = methods
67+
// 获得表格的各种操作
68+
const { getList, setSearchParams } = tableMethods
6869
6970
/** 添加/修改操作 */
7071
const modalRef = ref()
7172
const openModal = (type: string, id?: number) => {
7273
modalRef.value.openModal(type, id)
7374
}
7475
75-
getList()
76+
/** 删除按钮操作 */
77+
const handleDelete = (id: number) => {
78+
tableMethods.delList(id, false)
79+
}
80+
81+
/** 初始化 **/
82+
onMounted(() => {
83+
getList()
84+
})
7685
</script>

src/views/system/mail/log/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const handleDetail = async (rowId: number) => {
9191
9292
// ========== 初始化 ==========
9393
onMounted(() => {
94-
MailAccountApi.getSimpleMailAccounts().then((data) => {
94+
MailAccountApi.getSimpleMailAccountList().then((data) => {
9595
accountOptions.value = data
9696
})
9797
})

src/views/system/mail/template/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ const sendTest = async () => {
266266
267267
// ========== 初始化 ==========
268268
onMounted(() => {
269-
MailAccountApi.getSimpleMailAccounts().then((data) => {
269+
MailAccountApi.getSimpleMailAccountList().then((data) => {
270270
accountOptions.value = data
271271
})
272272
})

0 commit comments

Comments
 (0)