refactor: sms

pull/2/head
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,8 +1,23 @@
import request from '@/config/axios'
import type { SmsChannelVO } from './types'
export type SmsChannelVO = {
id: number
status: number
signature: string
remark: string
apiKey: string
apiSecret: string
callbackUrl: string
createTime: string
}
export interface SmsChannelPageReqVO extends PageParam {
signature?: string
code?: string
status?: number
}
// 查询短信渠道列表
export const getSmsChannelPageApi = (params) => {
export const getSmsChannelPageApi = (params: SmsChannelPageReqVO) => {
return request.get({ url: '/system/sms-channel/page', params })
}

View File

@ -1,10 +0,0 @@
export type SmsChannelVO = {
id: number
status: number
signature: string
remark: string
apiKey: string
apiSecret: string
callbackUrl: string
createTime: string
}

View File

@ -1,11 +1,38 @@
import request from '@/config/axios'
export type SmsLogVO = {
id: number
idchannelId: number
templateId: number
mobile: string
userId: number
userType: number
sendStatus: number
receiveStatus: number
templateType: number
templateContent: string
templateParams: Map<string, object>
apiTemplateId: string
sendTime: string
createTime: string
}
export interface SmsLogPageReqVO extends PageParam {
signature?: string
code?: string
status?: number
}
export interface SmsLogExportReqVO {
code?: string
name?: string
status?: number
}
// 查询短信日志列表
export const getSmsLogPageApi = (params) => {
export const getSmsLogPageApi = (params: SmsLogPageReqVO) => {
return request.get({ url: '/system/sms-log/page', params })
}
// 导出短信日志
export const exportSmsLogApi = (params) => {
export const exportSmsLogApi = (params: SmsLogExportReqVO) => {
return request.download({ url: '/system/sms-log/export', params })
}

View File

@ -1,9 +0,0 @@
export type SmsLogVO = {
id: number
idchannelId: number
templateId: number
mobile: string
sendStatus: number
receiveStatus: number
createTime: string
}

View File

@ -1,5 +1,23 @@
import request from '@/config/axios'
import type { SmsTemplateVO } from './types'
export type SmsTemplateVO = {
id: number
type: number
status: number
code: string
name: string
content: string
remark: string
apiTemplateId: string
channelId: number
channelCode: string
createTime: string
}
export type SmsSendVO = {
mobile: string
templateCode: string
templateParams: string
}
// 查询短信模板列表
export const getSmsTemplatePageApi = (params) => {

View File

@ -1,19 +0,0 @@
export type SmsTemplateVO = {
id: number
type: number
status: number
code: string
name: string
content: string
remark: string
apiTemplateId: string
channelId: number
channelCode: string
createTime: string
}
export type SmsSendVO = {
mobile: string
templateCode: string
templateParams: string
}

View File

@ -1,42 +1,18 @@
<template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 操作工具栏 -->
<div class="mb-10px">
<XButton
type="primary"
preIcon="ep:zoom-in"
:title="t('action.add')"
v-hasPermi="['system:sms-channel:create']"
@click="handleCreate()"
/>
</div>
<!-- 列表 -->
<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="primary"
preIcon="ep:zoom-in"
:title="t('action.add')"
v-hasPermi="['system:sms-channel:create']"
@click="handleCreate()"
/>
</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 #action="{ row }">
<template #actionbtns_default="{ row }">
<!-- 操作修改 -->
<XTextButton
preIcon="ep:edit"
@ -49,20 +25,20 @@
preIcon="ep:view"
:title="t('action.detail')"
v-hasPermi="['system:sms-channel:update']"
@click="handleDetail(row)"
@click="handleDetail(row.id)"
/>
<!-- 操作删除 -->
<XTextButton
preIcon="ep:delete"
:title="t('action.del')"
v-hasPermi="['system:sms-channel:delete']"
@click="delList(row.id, false)"
@click="handleDelete(row.id)"
/>
</template>
</Table>
</vxe-grid>
</ContentWrap>
<XModal v-model="dialogVisible" :title="dialogTitle">
<XModal id="smsChannel" v-model="dialogVisible" :title="dialogTitle">
<!-- 对话框(添加 / 修改) -->
<Form
v-if="['create', 'update'].includes(actionType)"
@ -74,7 +50,7 @@
<Descriptions
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"
:data="detailRef"
:data="detailData"
/>
<!-- 操作按钮 -->
<template #footer>
@ -83,41 +59,45 @@
v-if="['create', 'update'].includes(actionType)"
type="primary"
:title="t('action.save')"
:loading="loading"
:loading="actionLoading"
@click="submitForm()"
/>
<!-- 按钮关闭 -->
<XButton :loading="loading" :title="t('dialog.close')" @click="dialogVisible = false" />
<XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
</template>
</XModal>
</template>
<script setup lang="ts">
// import
import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { ElMessage } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
import { VxeGridInstance } from 'vxe-table'
import { FormExpose } from '@/components/Form'
import type { SmsChannelVO } from '@/api/system/sms/smsChannel/types'
import { rules, allSchemas } from './sms.channel.data'
// import
import * as SmsChannelApi from '@/api/system/sms/smsChannel'
const { t } = useI18n() //
import { rules, allSchemas } from './sms.channel.data'
// ========== ==========
const { register, tableObject, methods } = useTable<SmsChannelVO>({
const { t } = useI18n() //
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, delList } = useVxeGrid<SmsChannelApi.SmsChannelVO>({
allSchemas: allSchemas,
getListApi: SmsChannelApi.getSmsChannelPageApi,
delListApi: SmsChannelApi.deleteSmsChannelApi
})
const { getList, setSearchParams, delList } = methods
// ========== CRUD ==========
const loading = ref(false) //
const actionType = ref('') //
//
const dialogVisible = ref(false) //
const dialogTitle = ref('edit') //
const actionType = ref('') //
const actionLoading = ref(false) // Loading
const formRef = ref<FormExpose>() // Ref
const detailData = ref() // Ref
//
const setDialogTile = (type: string) => {
@ -139,43 +119,42 @@ const handleUpdate = async (rowId: number) => {
unref(formRef)?.setValues(res)
}
//
const handleDetail = async (rowId: number) => {
setDialogTile('detail')
const res = await SmsChannelApi.getSmsChannelApi(rowId)
detailData.value = res
}
//
const handleDelete = async (rowId: number) => {
await delList(xGrid, rowId)
}
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as SmsChannelVO
const data = unref(formRef)?.formModel as SmsChannelApi.SmsChannelVO
if (actionType.value === 'create') {
await SmsChannelApi.createSmsChannelApi(data)
ElMessage.success(t('common.createSuccess'))
message.success(t('common.createSuccess'))
} else {
await SmsChannelApi.updateSmsChannelApi(data)
ElMessage.success(t('common.updateSuccess'))
message.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
actionLoading.value = false
//
reloadList(xGrid)
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref
//
const handleDetail = async (row: SmsChannelVO) => {
//
detailRef.value = row
setDialogTile('detail')
}
// ========== ==========
getList()
</script>

View File

@ -1,8 +1,8 @@
import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// 表单校验
@ -14,79 +14,46 @@ export const rules = reactive({
})
// 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: 'signature',
isSearch: true
},
detail: {
show: false
}
},
{
label: '短信签名',
field: 'signature',
search: {
show: true
}
},
{
label: '渠道编码',
field: 'code',
dictType: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE,
search: {
show: true
}
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
search: {
show: true
}
},
{
label: '短信 API 的账号',
field: 'apiKey'
},
{
label: '短信 API 的密钥',
field: 'apiSecret'
},
{
label: '短信发送回调 URL',
field: 'callbackUrl'
},
{
label: t('common.createTime'),
field: 'createTime',
form: {
show: false
{
title: '渠道编码',
field: 'code',
dictType: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE,
isSearch: true
},
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)]
}
}
},
{
label: t('table.action'),
field: 'action',
width: '240px',
form: {
show: false
{
title: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
isSearch: true
},
detail: {
show: false
{
title: '短信 API 的账号',
field: 'apiKey'
},
{
title: '短信 API 的密钥',
field: 'apiSecret'
},
{
title: '短信发送回调 URL',
field: 'callbackUrl'
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
isForm: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)

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)

View File

@ -1,42 +1,18 @@
<template>
<!-- 搜索工作区 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<ContentWrap>
<!-- 操作工具栏 -->
<div class="mb-10px">
<XButton
type="primary"
preIcon="ep:zoom-in"
:title="t('action.add')"
v-hasPermi="['system:sms-channel:create']"
@click="handleCreate()"
/>
</div>
<!-- 列表 -->
<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 #type="{ row }">
<DictTag :type="DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE" :value="row.type" />
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
<!-- 操作新增 -->
<template #toolbar_buttons>
<XButton
type="primary"
preIcon="ep:zoom-in"
:title="t('action.add')"
v-hasPermi="['system:sms-channel:create']"
@click="handleCreate()"
/>
</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 #action="{ row }">
<template #actionbtns_default="{ row }">
<XTextButton
preIcon="ep:cpu"
:title="t('action.test')"
@ -55,20 +31,20 @@
preIcon="ep:view"
:title="t('action.detail')"
v-hasPermi="['system:sms-template:update']"
@click="handleDetail(row)"
@click="handleDetail(row.id)"
/>
<!-- 操作删除 -->
<XTextButton
preIcon="ep:delete"
:title="t('action.del')"
v-hasPermi="['system:sms-template:delete']"
@click="delList(row.id, false)"
@click="handleDelete(row.id)"
/>
</template>
</Table>
</vxe-grid>
</ContentWrap>
<XModal v-model="dialogVisible" :title="dialogTitle">
<XModal id="smsTemplate" v-model="dialogVisible" :title="dialogTitle">
<!-- 对话框(添加 / 修改) -->
<Form
v-if="['create', 'update'].includes(actionType)"
@ -80,7 +56,7 @@
<Descriptions
v-if="actionType === 'detail'"
:schema="allSchemas.detailSchema"
:data="detailRef"
:data="detailData"
/>
<!-- 操作按钮 -->
<template #footer>
@ -89,14 +65,14 @@
v-if="['create', 'update'].includes(actionType)"
type="primary"
:title="t('action.save')"
:loading="loading"
:loading="actionLoading"
@click="submitForm()"
/>
<!-- 按钮关闭 -->
<XButton :loading="loading" :title="t('dialog.close')" @click="dialogVisible = false" />
<XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
</template>
</XModal>
<XModal v-model="sendVisible" title="测试">
<XModal id="sendTest" v-model="sendVisible" title="测试">
<el-form :model="sendSmsForm" :rules="sendSmsRules" label-width="140px">
<el-form-item label="模板内容" prop="content">
<el-input
@ -123,38 +99,47 @@
</el-form>
<!-- 操作按钮 -->
<template #footer>
<XButton type="primary" :title="t('action.test')" :loading="loading" @click="sendSmsTest()" />
<XButton
type="primary"
:title="t('action.test')"
:loading="actionLoading"
@click="sendSmsTest()"
/>
<XButton :title="t('dialog.close')" @click="dialogVisible = false" />
</template>
</XModal>
</template>
<script setup lang="ts">
// import
import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { ElMessage, ElForm, ElFormItem, ElInput } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
import { VxeGridInstance } from 'vxe-table'
import { FormExpose } from '@/components/Form'
import type { SmsTemplateVO } from '@/api/system/sms/smsTemplate/types'
import { rules, allSchemas } from './sms.template.data'
// import
import * as SmsTemplateApi from '@/api/system/sms/smsTemplate'
const { t } = useI18n() //
import { rules, allSchemas } from './sms.template.data'
// ========== ==========
const { register, tableObject, methods } = useTable<SmsTemplateVO>({
const { t } = useI18n() //
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, reloadList, delList } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({
allSchemas: allSchemas,
getListApi: SmsTemplateApi.getSmsTemplatePageApi,
delListApi: SmsTemplateApi.deleteSmsTemplateApi
})
const { getList, setSearchParams, delList } = methods
// ========== CRUD ==========
const loading = ref(false) //
const actionType = ref('') //
//
const dialogVisible = ref(false) //
const dialogTitle = ref('edit') //
const actionType = ref('') //
const actionLoading = ref(false) // Loading
const formRef = ref<FormExpose>() // Ref
const detailData = ref() // Ref
//
const setDialogTile = (type: string) => {
@ -176,42 +161,46 @@ const handleUpdate = async (rowId: number) => {
unref(formRef)?.setValues(res)
}
//
const handleDetail = async (rowId: number) => {
setDialogTile('detail')
//
const res = await SmsTemplateApi.getSmsTemplateApi(rowId)
detailData.value = res
}
//
const handleDelete = async (rowId: number) => {
await delList(xGrid, rowId)
}
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as SmsTemplateVO
const data = unref(formRef)?.formModel as SmsTemplateApi.SmsTemplateVO
if (actionType.value === 'create') {
await SmsTemplateApi.createSmsTemplateApi(data)
ElMessage.success(t('common.createSuccess'))
message.success(t('common.createSuccess'))
} else {
await SmsTemplateApi.updateSmsTemplateApi(data)
ElMessage.success(t('common.updateSuccess'))
message.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
actionLoading.value = false
//
reloadList(xGrid)
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref
//
const handleDetail = async (row: SmsTemplateVO) => {
//
detailRef.value = row
setDialogTile('detail')
}
// ========== ==========
const sendSmsForm = ref({
content: '',
@ -249,10 +238,7 @@ const sendSmsTest = () => {
templateParams: sendSmsForm.value.templateParams
}
SmsTemplateApi.sendSmsApi(data)
ElMessage.info('发送成功')
message.info('发送成功')
sendVisible.value = false
}
// ========== ==========
getList()
</script>

View File

@ -1,8 +1,8 @@
import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// 表单校验
@ -17,86 +17,57 @@ export const rules = reactive({
})
// 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: [
{
label: '模板编码',
field: 'code',
isSearch: true
},
detail: {
show: false
}
},
{
label: '模板编码',
field: 'code',
search: {
show: true
}
},
{
label: '模板名称',
field: 'name',
search: {
show: true
}
},
{
label: '模板内容',
field: 'content'
},
{
label: '短信 API 的模板编号',
field: 'apiTemplateId',
search: {
show: true
}
},
{
label: '短信类型',
field: 'type',
dictType: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS
},
{
label: t('form.remark'),
field: 'remark',
table: {
show: false
}
},
{
label: t('common.createTime'),
field: 'createTime',
form: {
show: false
{
label: '模板名称',
field: 'name',
isSearch: true
},
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)]
{
label: '模板内容',
field: 'content'
},
{
label: '短信 API 的模板编号',
field: 'apiTemplateId',
isSearch: true
},
{
label: '短信类型',
field: 'type',
dictType: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS
},
{
label: t('form.remark'),
field: 'remark',
isTable: false
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
isForm: false,
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
}
}
},
{
label: t('table.action'),
field: 'action',
width: '320px',
form: {
show: false
},
detail: {
show: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)