Skip to content

Commit 0f4c74f

Browse files
committed
Vue3 重构:邮件日志的列表
1 parent 3c75d60 commit 0f4c74f

File tree

5 files changed

+49
-22
lines changed

5 files changed

+49
-22
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,12 @@ export interface MailLogVO {
1919
sendException: string
2020
}
2121

22-
export interface MailLogPageReqVO extends PageParam {
23-
userId?: number
24-
userType?: number
25-
toMail?: string
26-
accountId?: number
27-
templateId?: number
28-
sendStatus?: number
29-
sendTime?: Date[]
30-
}
31-
3222
// 查询邮件日志列表
33-
export const getMailLogPageApi = async (params: MailLogPageReqVO) => {
23+
export const getMailLogPage = async (params: PageParam) => {
3424
return await request.get({ url: '/system/mail-log/page', params })
3525
}
3626

3727
// 查询邮件日志详情
38-
export const getMailLogApi = async (id: number) => {
28+
export const getMailLog = async (id: number) => {
3929
return await request.get({ url: '/system/mail-log/get?id=' + id })
4030
}

src/types/descriptions.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export interface DescriptionsSchema {
88
labelAlign?: 'left' | 'center' | 'right'
99
className?: string
1010
labelClassName?: string
11-
dateFormat?: string
12-
dictType?: string
11+
dateFormat?: string // add by 星语:支持时间的格式化
12+
dictType?: string // add by 星语:支持 dict 字典数据
1313
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<Dialog title="详情" v-model="modelVisible" :scroll="true" :max-height="500">
3+
<Descriptions :schema="allSchemas.detailSchema" :data="detailData">
4+
<!-- 展示 HTML 内容 -->
5+
<template #templateContent="{ row }">
6+
<div v-html="row.templateContent"></div>
7+
</template>
8+
</Descriptions>
9+
</Dialog>
10+
</template>
11+
<script setup lang="ts">
12+
import * as MailLogApi from '@/api/system/mail/log'
13+
import { allSchemas } from './log.data'
14+
15+
const modelVisible = ref(false) // 弹窗的是否展示
16+
const detailLoading = ref(false) // 表单的加载中
17+
const detailData = ref() // 详情数据
18+
19+
/** 打开弹窗 */
20+
const openModal = async (id: number) => {
21+
modelVisible.value = true
22+
// 设置数据
23+
detailLoading.value = true
24+
try {
25+
detailData.value = await MailLogApi.getMailLog(id)
26+
} finally {
27+
detailLoading.value = false
28+
}
29+
}
30+
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
31+
</script>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<el-button
2121
link
2222
type="primary"
23-
@click="openModal('update', row.id)"
23+
@click="openModal(row.id)"
2424
v-hasPermi="['system:mail-log:query']"
2525
>
2626
详情
@@ -30,26 +30,26 @@
3030
</content-wrap>
3131

3232
<!-- 表单弹窗:添加/修改 -->
33-
<!-- <mail-account-form ref="modalRef" @success="getList" />-->
33+
<mail-log-detail ref="modalRef" @success="getList" />
3434
</template>
3535
<script setup lang="ts" name="MailLog">
3636
import { allSchemas } from './log.data'
3737
import * as MailLogApi from '@/api/system/mail/log'
38-
// import MailAccountForm from './form.vue'
38+
import MailLogDetail from './detail.vue'
3939
4040
// tableObject:表格的属性对象,可获得分页大小、条数等属性
4141
// tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
4242
// 详细可见:https://kailong110120130.gitee.io/vue-element-plus-admin-doc/components/table.html#usetable
4343
const { tableObject, tableMethods } = useTable({
44-
getListApi: MailLogApi.getMailLogPageApi // 分页接口
44+
getListApi: MailLogApi.getMailLogPage // 分页接口
4545
})
4646
// 获得表格的各种操作
4747
const { getList, setSearchParams } = tableMethods
4848
4949
/** 添加/修改操作 */
5050
const modalRef = ref()
51-
const openModal = (type: string, id?: number) => {
52-
modalRef.value.openModal(type, id)
51+
const openModal = (id: number) => {
52+
modalRef.value.openModal(id)
5353
}
5454
5555
/** 初始化 **/

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const crudSchemas = reactive<CrudSchema[]>([
2323
type: 'daterange',
2424
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
2525
}
26+
},
27+
detail: {
28+
dateFormat: 'YYYY-MM-DD HH:mm:ss'
2629
}
2730
},
2831
{
@@ -116,12 +119,15 @@ const crudSchemas = reactive<CrudSchema[]>([
116119
label: '创建时间',
117120
field: 'createTime',
118121
isTable: false,
119-
formatter: dateFormatter
122+
formatter: dateFormatter,
123+
detail: {
124+
dateFormat: 'YYYY-MM-DD HH:mm:ss'
125+
}
120126
},
121127
{
122128
label: '操作',
123129
field: 'action',
124-
isForm: false
130+
isDetail: false
125131
}
126132
])
127133
export const { allSchemas } = useCrudSchemas(crudSchemas)

0 commit comments

Comments
 (0)