refactor: sms

This commit is contained in:
xingyu
2022-11-15 20:43:02 +08:00
parent 12ac097b47
commit 09e61f7ef3
12 changed files with 361 additions and 487 deletions

View File

@ -1,41 +1,23 @@
<template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 列表 -->
<Table
:columns="allSchemas.tableColumns"
:selection="false"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
@register="register"
>
<template #code="{ row }">
<DictTag :type="DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE" :value="row.code" />
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
<!-- 操作导出 -->
<template #toolbar_buttons>
<XButton
type="warning"
preIcon="ep:download"
:title="t('action.export')"
@click="handleExport()"
/>
</template>
<template #status="{ row }">
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template>
<template #createTime="{ row }">
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template #receiveTime="{ row }">
<span>{{ dayjs(row.receiveTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template #action="{ row }">
<template #actionbtns_default="{ row }">
<XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
</template>
</Table>
</vxe-grid>
</ContentWrap>
<XModal v-model="dialogVisible" :title="dialogTitle">
<XModal id="smsLog" v-model="dialogVisible" :title="dialogTitle">
<!-- 对话框(详情) -->
<Descriptions
v-if="actionType === 'detail'"
@ -50,33 +32,37 @@
</template>
<script setup lang="ts">
// 全局相关的 import
import { ref } from 'vue'
import dayjs from 'dayjs'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import type { SmsLogVO } from '@/api/system/sms/smsLog/types'
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
import { VxeGridInstance } from 'vxe-table'
import { allSchemas } from './sms.log.data'
import * as SmsLoglApi from '@/api/system/sms/smsLog'
const { t } = useI18n() // 国际化
// ========== 列表相关 ==========
const { register, tableObject, methods } = useTable<SmsLogVO>({
getListApi: SmsLoglApi.getSmsLogPageApi
// 列表相关的变量
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
const { gridOptions, exportList } = useVxeGrid<SmsLoglApi.SmsLogVO>({
allSchemas: allSchemas,
getListApi: SmsLoglApi.getSmsLogPageApi,
exportListApi: SmsLoglApi.exportSmsLogApi
})
const { getList, setSearchParams } = methods
// ========== CRUD 相关 ==========
const actionType = ref('') // 操作按钮的类型
// 弹窗相关的变量
const dialogVisible = ref(false) // 是否显示弹出层
const dialogTitle = ref(t('action.detail')) // 弹出层标题
const dialogTitle = ref('edit') // 弹出层标题
const actionType = ref('') // 操作按钮的类型
// ========== 详情相关 ==========
const detailRef = ref() // 详情 Ref
const handleDetail = (row: SmsLogVO) => {
const handleDetail = (row: SmsLoglApi.SmsLogVO) => {
// 设置数据
detailRef.value = row
dialogVisible.value = true
}
// ========== 初始化 ==========
getList()
// 导出操作
const handleExport = async () => {
await exportList(xGrid, '短信日志.xls')
}
</script>

View File

@ -1,105 +1,68 @@
import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
{
label: t('common.index'),
field: 'id',
type: 'index',
form: {
show: false
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: 'seq',
action: true,
columns: [
{
title: '手机号',
field: 'mobile',
isSearch: true
},
detail: {
show: false
}
},
{
label: '手机号',
field: 'mobile',
search: {
show: true
}
},
{
label: '短信内容',
field: 'templateContent'
},
{
label: '短信渠道',
field: 'channelId',
dictType: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE,
search: {
show: true
}
},
{
label: '发送状态',
field: 'sendStatus',
dictType: DICT_TYPE.SYSTEM_SMS_SEND_STATUS,
search: {
show: true
}
},
{
label: '接收状态',
field: 'receiveTime',
dictType: DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS,
search: {
show: true
}
},
{
label: '模板编号',
field: 'templateId',
search: {
show: true
}
},
{
label: '短信类型',
field: 'channelId',
dictType: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE,
search: {
show: true
}
},
{
label: '接收时间',
field: 'receiveTime',
form: {
show: false
}
},
{
label: t('common.createTime'),
field: 'createTime',
form: {
show: false
{
title: '短信内容',
field: 'templateContent'
},
search: {
show: true,
component: 'DatePicker',
componentProps: {
type: 'daterange',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
{
title: '短信渠道',
field: 'channelId',
dictType: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE,
isSearch: true
},
{
title: '发送状态',
field: 'sendStatus',
dictType: DICT_TYPE.SYSTEM_SMS_SEND_STATUS,
isSearch: true
},
{
title: '接收状态',
field: 'receiveStatus',
dictType: DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS,
isSearch: true
},
{
title: '模板编号',
field: 'templateId',
isSearch: true
},
{
title: '短信类型',
field: 'templateType',
dictType: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE,
isSearch: true
},
{
title: '接收时间',
field: 'receiveTime'
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
}
}
},
{
label: t('table.action'),
field: 'action',
width: '80px',
form: {
show: false
},
detail: {
show: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)