Vue3 重构:REVIEW 短信渠道
This commit is contained in:
parent
74aeffec12
commit
fa32194772
@ -12,21 +12,8 @@ export interface SmsChannelVO {
|
|||||||
createTime: Date
|
createTime: Date
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmsChannelListVO {
|
|
||||||
id: number
|
|
||||||
code: string
|
|
||||||
signature: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SmsChannelPageReqVO extends PageParam {
|
|
||||||
signature?: string
|
|
||||||
code?: string
|
|
||||||
status?: number
|
|
||||||
createTime?: Date[]
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询短信渠道列表
|
// 查询短信渠道列表
|
||||||
export const getSmsChannelPageApi = (params: SmsChannelPageReqVO) => {
|
export const getSmsChannelPage = (params: PageParam) => {
|
||||||
return request.get({ url: '/system/sms-channel/page', params })
|
return request.get({ url: '/system/sms-channel/page', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,21 +23,21 @@ export function getSimpleSmsChannelList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询短信渠道详情
|
// 查询短信渠道详情
|
||||||
export const getSmsChannelApi = (id: number) => {
|
export const getSmsChannel = (id: number) => {
|
||||||
return request.get({ url: '/system/sms-channel/get?id=' + id })
|
return request.get({ url: '/system/sms-channel/get?id=' + id })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增短信渠道
|
// 新增短信渠道
|
||||||
export const createSmsChannelApi = (data: SmsChannelVO) => {
|
export const createSmsChannel = (data: SmsChannelVO) => {
|
||||||
return request.post({ url: '/system/sms-channel/create', data })
|
return request.post({ url: '/system/sms-channel/create', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改短信渠道
|
// 修改短信渠道
|
||||||
export const updateSmsChannelApi = (data: SmsChannelVO) => {
|
export const updateSmsChannel = (data: SmsChannelVO) => {
|
||||||
return request.put({ url: '/system/sms-channel/update', data })
|
return request.put({ url: '/system/sms-channel/update', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除短信渠道
|
// 删除短信渠道
|
||||||
export const deleteSmsChannelApi = (id: number) => {
|
export const deleteSmsChannel = (id: number) => {
|
||||||
return request.delete({ url: '/system/sms-channel/delete?id=' + id })
|
return request.delete({ url: '/system/sms-channel/delete?id=' + id })
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<Dialog :title="modelTitle" v-model="modelVisible">
|
<Dialog :title="modelTitle" v-model="modelVisible">
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="130px" v-loading="formLoading">
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="130px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
<el-form-item label="短信签名" prop="signature">
|
<el-form-item label="短信签名" prop="signature">
|
||||||
<el-input v-model="form.signature" placeholder="请输入短信签名" />
|
<el-input v-model="formData.signature" placeholder="请输入短信签名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="渠道编码" prop="code">
|
<el-form-item label="渠道编码" prop="code">
|
||||||
<el-select v-model="form.code" placeholder="请选择渠道编码" clearable>
|
<el-select v-model="formData.code" placeholder="请选择渠道编码" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE)"
|
v-for="dict in getStrDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE)"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
:value="dict.value"
|
:value="dict.value"
|
||||||
@ -15,40 +21,39 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="启用状态">
|
<el-form-item label="启用状态">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="formData.status">
|
||||||
<el-radio
|
<el-radio
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="parseInt(dict.value)"
|
:label="dict.value"
|
||||||
>{{ dict.label }}</el-radio
|
|
||||||
>
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input v-model="form.remark" placeholder="请输入备注" />
|
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="短信 API 的账号" prop="apiKey">
|
<el-form-item label="短信 API 的账号" prop="apiKey">
|
||||||
<el-input v-model="form.apiKey" placeholder="请输入短信 API 的账号" />
|
<el-input v-model="formData.apiKey" placeholder="请输入短信 API 的账号" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="短信 API 的密钥" prop="apiSecret">
|
<el-form-item label="短信 API 的密钥" prop="apiSecret">
|
||||||
<el-input v-model="form.apiSecret" placeholder="请输入短信 API 的密钥" />
|
<el-input v-model="formData.apiSecret" placeholder="请输入短信 API 的密钥" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="短信发送回调 URL" prop="callbackUrl">
|
<el-form-item label="短信发送回调 URL" prop="callbackUrl">
|
||||||
<el-input v-model="form.callbackUrl" placeholder="请输入短信发送回调 URL" />
|
<el-input v-model="formData.callbackUrl" placeholder="请输入短信发送回调 URL" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
<el-button @click="modelVisible = false">取 消</el-button>
|
||||||
<el-button @click="modelVisible = false">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||||
import * as SmsChannelApi from '@/api/system/sms/smsChannel'
|
import * as SmsChannelApi from '@/api/system/sms/smsChannel'
|
||||||
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
@ -56,17 +61,17 @@ const modelVisible = ref(false) // 弹窗的是否展示
|
|||||||
const modelTitle = ref('') // 弹窗的标题
|
const modelTitle = ref('') // 弹窗的标题
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
const form = ref({
|
const formData = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
signature: '',
|
signature: '',
|
||||||
code: '',
|
code: '',
|
||||||
status: '',
|
status: CommonStatusEnum.ENABLE,
|
||||||
remark: '',
|
remark: '',
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
apiSecret: '',
|
apiSecret: '',
|
||||||
callbackUrl: ''
|
callbackUrl: ''
|
||||||
})
|
})
|
||||||
const rules = reactive({
|
const formRules = reactive({
|
||||||
signature: [{ required: true, message: '短信签名不能为空', trigger: 'blur' }],
|
signature: [{ required: true, message: '短信签名不能为空', trigger: 'blur' }],
|
||||||
code: [{ required: true, message: '渠道编码不能为空', trigger: 'blur' }],
|
code: [{ required: true, message: '渠道编码不能为空', trigger: 'blur' }],
|
||||||
status: [{ required: true, message: '启用状态不能为空', trigger: 'blur' }],
|
status: [{ required: true, message: '启用状态不能为空', trigger: 'blur' }],
|
||||||
@ -75,7 +80,7 @@ const rules = reactive({
|
|||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const openModal = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
modelVisible.value = true
|
modelVisible.value = true
|
||||||
modelTitle.value = t('action.' + type)
|
modelTitle.value = t('action.' + type)
|
||||||
formType.value = type
|
formType.value = type
|
||||||
@ -84,15 +89,14 @@ const openModal = async (type: string, id?: number) => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
form.value = await SmsChannelApi.getSmsChannelApi(id)
|
formData.value = await SmsChannelApi.getSmsChannel(id)
|
||||||
console.log(form)
|
console.log(formData)
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
|
|
||||||
|
|
||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
@ -106,10 +110,10 @@ const submitForm = async () => {
|
|||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as SmsChannelApi.SmsChannelVO
|
const data = unref(formRef)?.formModel as SmsChannelApi.SmsChannelVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await SmsChannelApi.createSmsChannelApi(data)
|
await SmsChannelApi.createSmsChannel(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
await SmsChannelApi.updateSmsChannelApi(data)
|
await SmsChannelApi.updateSmsChannel(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
modelVisible.value = false
|
modelVisible.value = false
|
||||||
@ -122,11 +126,11 @@ const submitForm = async () => {
|
|||||||
|
|
||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
form.value = {
|
formData.value = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
signature: '',
|
signature: '',
|
||||||
code: '',
|
code: '',
|
||||||
status: '',
|
status: CommonStatusEnum.ENABLE,
|
||||||
remark: '',
|
remark: '',
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
apiSecret: '',
|
apiSecret: '',
|
@ -1,6 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
<el-form-item label="短信签名" prop="signature">
|
<el-form-item label="短信签名" prop="signature">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.signature"
|
v-model="queryParams.signature"
|
||||||
@ -12,10 +18,10 @@
|
|||||||
<el-form-item label="启用状态" prop="status">
|
<el-form-item label="启用状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="请选择启用状态" clearable>
|
<el-select v-model="queryParams.status" placeholder="请选择启用状态" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
:key="parseInt(dict.value)"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
:value="parseInt(dict.value)"
|
:value="dict.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -34,24 +40,17 @@
|
|||||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="openModal('create')"
|
@click="openForm('create')"
|
||||||
v-hasPermi="['system:sms-channel:create']"
|
v-hasPermi="['system:sms-channel:create']"
|
||||||
>
|
>
|
||||||
<Icon icon="ep:plus" class="mr-5px" /> 新增</el-button
|
<Icon icon="ep:plus" class="mr-5px" /> 新增</el-button
|
||||||
>
|
>
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
plain
|
|
||||||
@click="handleExport"
|
|
||||||
:loading="exportLoading"
|
|
||||||
v-hasPermi="['system:sms-channel:export']"
|
|
||||||
>
|
|
||||||
<Icon icon="ep:download" class="mr-5px" /> 导出</el-button
|
|
||||||
>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" align="center">
|
<el-table v-loading="loading" :data="list" align="center">
|
||||||
<el-table-column label="编号" align="center" prop="id" />
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
<el-table-column label="短信签名" align="center" prop="signature" />
|
<el-table-column label="短信签名" align="center" prop="signature" />
|
||||||
@ -71,18 +70,21 @@
|
|||||||
align="center"
|
align="center"
|
||||||
prop="apiKey"
|
prop="apiKey"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
|
width="180"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="短信 API 的密钥"
|
label="短信 API 的密钥"
|
||||||
align="center"
|
align="center"
|
||||||
prop="apiSecret"
|
prop="apiSecret"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
|
width="180"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="短信发送回调 URL"
|
label="短信发送回调 URL"
|
||||||
align="center"
|
align="center"
|
||||||
prop="callbackUrl"
|
prop="callbackUrl"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
|
width="180"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="创建时间"
|
label="创建时间"
|
||||||
@ -96,7 +98,7 @@
|
|||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="openModal('update', scope.row.id)"
|
@click="openForm('update', scope.row.id)"
|
||||||
v-hasPermi="['system:sms-channel:update']"
|
v-hasPermi="['system:sms-channel:update']"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
@ -120,35 +122,22 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<SmsChannelForm ref="modalRef" @success="getList" />
|
<SmsChannelForm ref="formRef" @success="getList" />
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" name="SmsChannel">
|
<script setup lang="ts" name="SmsChannel">
|
||||||
// 业务相关的 import
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import * as SmsChannelApi from '@/api/system/sms/smsChannel'
|
|
||||||
//格式化时间
|
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
//字典
|
import * as SmsChannelApi from '@/api/system/sms/smsChannel'
|
||||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
import SmsChannelForm from './SmsChannelForm.vue'
|
||||||
//表单弹窗:添加/修改
|
|
||||||
import SmsChannelForm from './form.vue'
|
|
||||||
//下载
|
|
||||||
// import download from '@/utils/download'
|
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
// 列表的加载中
|
const loading = ref(false) // 列表的加载中
|
||||||
const loading = ref(true)
|
const total = ref(0) // 列表的总页数
|
||||||
//搜索的表单
|
const list = ref([]) // 列表的数据
|
||||||
const queryFormRef = ref()
|
const queryFormRef = ref() // 搜索的表单
|
||||||
// 列表的总页数
|
|
||||||
const total = ref(0)
|
|
||||||
// 列表的数据
|
|
||||||
const list = ref([])
|
|
||||||
//导出的加载中
|
|
||||||
const exportLoading = ref(false)
|
|
||||||
//查询参数
|
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@ -160,9 +149,8 @@ const queryParams = reactive({
|
|||||||
/** 查询参数列表 */
|
/** 查询参数列表 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
// 执行查询
|
|
||||||
try {
|
try {
|
||||||
const data = await SmsChannelApi.getSmsChannelPageApi(queryParams)
|
const data = await SmsChannelApi.getSmsChannelPage(queryParams)
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
@ -183,26 +171,9 @@ const resetQuery = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
const modalRef = ref()
|
const formRef = ref()
|
||||||
const openModal = (type: string, id?: number) => {
|
const openForm = (type: string, id?: number) => {
|
||||||
modalRef.value.openModal(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出按钮操作 */
|
|
||||||
const handleExport = async () => {
|
|
||||||
try {
|
|
||||||
// 导出的二次确认
|
|
||||||
await message.exportConfirm()
|
|
||||||
// 发起导出
|
|
||||||
exportLoading.value = true
|
|
||||||
await message.info('该功能目前不支持')
|
|
||||||
//导出功能先不考虑
|
|
||||||
// const data = await SmsChannelApi.exportSmsChanelApi(queryParams)
|
|
||||||
// download.excel(data, '短信渠道.xls')
|
|
||||||
} catch {
|
|
||||||
} finally {
|
|
||||||
exportLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
@ -211,7 +182,7 @@ const handleDelete = async (id: number) => {
|
|||||||
// 删除的二次确认
|
// 删除的二次确认
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
// 发起删除
|
// 发起删除
|
||||||
await SmsChannelApi.deleteSmsChannelApi(id)
|
await SmsChannelApi.deleteSmsChannel(id)
|
||||||
message.success(t('common.delSuccess'))
|
message.success(t('common.delSuccess'))
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
|
Loading…
Reference in New Issue
Block a user