refactor(system): 重构短信配置功能模块

This commit is contained in:
2025-03-19 22:39:17 +08:00
parent be7c310f72
commit 470b0d56f9
9 changed files with 376 additions and 383 deletions

View File

@@ -7,5 +7,7 @@ export * from './dict'
export * from './file'
export * from './storage'
export * from './option'
export * from './smsConfig'
export * from './smsLog'
export * from './user-center'
export * from './message'

View File

@@ -1,87 +1,31 @@
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/smsConfig'
export interface SmsConfigResp {
id: string
name: string
supplier: string
accessKeyId: string
accessKeySecret: string
signature: string
templateId: string
weight: string
retryInterval: string
maxRetries: string
maximum: string
supplierConfig: string
isEnable: string
createUser: string
createTime: string
updateUser: string
updateTime: string
createUserString: string
updateUserString: string
disabled: boolean
}
export interface SmsConfigDetailResp {
id: string
name: string
supplier: string
accessKeyId: string
accessKeySecret: string
signature: string
templateId: string
weight: string
retryInterval: string
maxRetries: string
maximum: string
supplierConfig: string
isEnable: string
createUser: string
createTime: string
updateUser: string
updateTime: string
createUserString: string
updateUserString: string
}
export interface SmsConfigQuery {
name: string | undefined
supplier: string | undefined
accessKeyId: string | undefined
signature: string | undefined
templateId: string | undefined
isEnable: string | undefined
sort: Array<string>
}
export interface SmsConfigPageQuery extends SmsConfigQuery, PageQuery {}
/** @desc 查询短信服务配置列表 */
export function listSmsConfig(query: SmsConfigPageQuery) {
return http.get<PageRes<SmsConfigResp[]>>(`${BASE_URL}`, query)
/** @desc 查询短信配置列表 */
export function listSmsConfig(query: T.SmsConfigPageQuery) {
return http.get<PageRes<T.SmsConfigResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询短信服务配置详情 */
/** @desc 查询短信配置详情 */
export function getSmsConfig(id: string) {
return http.get<SmsConfigDetailResp>(`${BASE_URL}/${id}`)
return http.get<T.SmsConfigResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增短信服务配置 */
/** @desc 新增短信配置 */
export function addSmsConfig(data: any) {
return http.post(`${BASE_URL}`, data)
}
/** @desc 修改短信服务配置 */
/** @desc 修改短信配置 */
export function updateSmsConfig(data: any, id: string) {
return http.put(`${BASE_URL}/${id}`, data)
}
/** @desc 删除短信服务配置 */
/** @desc 删除短信配置 */
export function deleteSmsConfig(id: string) {
return http.del(`${BASE_URL}/${id}`)
}
/** @desc 导出短信服务配置 */
export function exportSmsConfig(query: SmsConfigQuery) {
return http.download(`${BASE_URL}/export`, query)
}

26
src/apis/system/smsLog.ts Normal file
View File

@@ -0,0 +1,26 @@
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/smsLog'
/** @desc 查询短信日志列表 */
export function listSmsLog(query: T.SmsLogPageQuery) {
return http.get<PageRes<T.SmsLogResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询短信日志详情 */
export function getSmsLog(id: string) {
return http.get<T.SmsLogResp>(`${BASE_URL}/${id}`)
}
/** @desc 删除短信日志 */
export function deleteSmsLog(id: string) {
return http.del(`${BASE_URL}/${id}`)
}
/** @desc 导出短信日志 */
export function exportSmsLog(query: T.SmsLogQuery) {
return http.download(`${BASE_URL}/export`, query)
}

View File

@@ -1,70 +0,0 @@
import http from '@/utils/http'
const BASE_URL = '/system/smsRecord'
export interface SmsRecordResp {
id: string
configId: string
phone: string
params: string
status: string
resMsg: string
createUser: string
createTime: string
updateUser: string
updateTime: string
createUserString: string
updateUserString: string
disabled: boolean
}
export interface SmsRecordDetailResp {
id: string
configId: string
phone: string
params: string
status: string
resMsg: string
createUser: string
createTime: string
updateUser: string
updateTime: string
createUserString: string
updateUserString: string
}
export interface SmsRecordQuery {
configId: string | undefined
phone: string | undefined
status: string | undefined
sort: Array<string>
}
export interface SmsRecordPageQuery extends SmsRecordQuery, PageQuery {}
/** @desc 查询短信记录列表 */
export function listSmsRecord(query: SmsRecordPageQuery) {
return http.get<PageRes<SmsRecordResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询短信记录详情 */
export function getSmsRecord(id: string) {
return http.get<SmsRecordDetailResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增短信记录 */
export function addSmsRecord(data: any) {
return http.post(`${BASE_URL}`, data)
}
/** @desc 修改短信记录 */
export function updateSmsRecord(data: any, id: string) {
return http.put(`${BASE_URL}/${id}`, data)
}
/** @desc 删除短信记录 */
export function deleteSmsRecord(id: string) {
return http.del(`${BASE_URL}/${id}`)
}
/** @desc 导出短信记录 */
export function exportSmsRecord(query: SmsRecordQuery) {
return http.download(`${BASE_URL}/export`, query)
}

View File

@@ -370,6 +370,60 @@ export interface LoginConfig {
LOGIN_CAPTCHA_ENABLED: OptionResp
}
/** 短信配置类型 */
export interface SmsConfigResp {
id: string
name: string
supplier: string
accessKey: string
secretKey: string
signature: string
templateId: string
weight: string
retryInterval: string
maxRetries: string
maximum: string
supplierConfig: string
status: number
createUser: string
createTime: string
updateUser: string
updateTime: string
createUserString: string
updateUserString: string
disabled: boolean
}
export interface SmsConfigQuery {
name: string | undefined
supplier: string | undefined
accessKey: string | undefined
sort: Array<string>
}
export interface SmsConfigPageQuery extends SmsConfigQuery, PageQuery {}
/** 短信日志类型 */
export interface SmsLogResp {
id: string
configId: string
phone: string
params: string
status: number
resMsg: string
createUser: string
createTime: string
updateUser: string
updateTime: string
createUserString: string
updateUserString: string
}
export interface SmsLogQuery {
configId: string | undefined
phone: string | undefined
status: number | undefined
sort: Array<string>
}
export interface SmsLogPageQuery extends SmsLogQuery, PageQuery {}
/** 绑定三方账号信息 */
export interface BindSocialAccountRes {
source: string

View File

@@ -1,7 +1,6 @@
<template>
<div class="gi_table_page">
<GiTable
title=""
row-key="id"
:data="dataList"
:columns="columns"
@@ -151,8 +150,8 @@ const columns: TableInstance['columns'] = [
return <GiCellTag value={record.clientType} dict={client_type.value} />
},
},
{ title: 'Token 最低活跃频率', dataIndex: 'activeTimeout', slotName: 'activeTimeout', width: 180, align: 'center', render: ({ record }) => `${record.activeTimeout} s` },
{ title: 'Token 有效期', dataIndex: 'timeout', slotName: 'timeout', align: 'center', render: ({ record }) => `${record.timeout} s` },
{ title: 'Token 最低活跃频率', dataIndex: 'activeTimeout', slotName: 'activeTimeout', width: 180, align: 'center', render: ({ record }) => `${record.activeTimeout} ` },
{ title: 'Token 有效期', dataIndex: 'timeout', slotName: 'timeout', align: 'center', render: ({ record }) => `${record.timeout} ` },
{
title: '状态',
dataIndex: 'status',

View File

@@ -1,4 +1,18 @@
<script setup lang="ts">
<template>
<a-drawer
v-model:visible="visible"
:title="title"
:mask-closable="false"
:esc-to-close="false"
:width="width >= 600 ? 600 : '100%'"
@before-ok="save"
@close="reset"
>
<GiForm ref="formRef" v-model="form" :columns="columns" layout="vertical" />
</a-drawer>
</template>
<script setup lang="tsx">
import { Message } from '@arco-design/web-vue'
import { useWindowSize } from '@vueuse/core'
import { addSmsConfig, getSmsConfig, updateSmsConfig } from '@/apis/system/smsConfig'
@@ -15,12 +29,12 @@ const { width } = useWindowSize()
const dataId = ref('')
const visible = ref(false)
const isUpdate = computed(() => !!dataId.value)
const title = computed(() => (isUpdate.value ? '修改短信服务配置' : '新增短信服务配置'))
const title = computed(() => (isUpdate.value ? '修改短信配置' : '新增短信配置'))
const formRef = ref<InstanceType<typeof GiForm>>()
const { dis_enable_status_enum, sms_supplier_enum } = useDict('dis_enable_status_enum', 'sms_supplier_enum')
const [form, resetForm] = useResetReactive({
// todo 待补充
status: 1,
})
const columns: ColumnItem[] = reactive([
@@ -28,29 +42,32 @@ const columns: ColumnItem[] = reactive([
label: '名称',
field: 'name',
type: 'input',
span: 24,
span: 12,
required: true,
props: {
maxLength: 100,
},
},
{
label: '厂商名称标识',
label: '厂商',
field: 'supplier',
type: 'select',
span: 24,
span: 12,
required: true,
props: {
options: sms_supplier_enum,
},
},
{
label: 'Access Key 或 API Key',
field: 'accessKeyId',
label: 'Access Key',
field: 'accessKey',
type: 'input',
span: 24,
required: true,
},
{
label: 'Access Secret 或 API Secret',
field: 'accessKeySecret',
label: 'Secret Key',
field: 'secretKey',
type: 'input',
span: 24,
required: true,
@@ -59,53 +76,77 @@ const columns: ColumnItem[] = reactive([
label: '短信签名',
field: 'signature',
type: 'input',
span: 24,
required: true,
span: 12,
props: {
maxLength: 100,
},
},
{
label: '模板 ID',
field: 'templateId',
type: 'input',
span: 24,
span: 12,
required: true,
props: {
maxLength: 50,
},
},
{
label: '负载均衡权重',
field: 'weight',
type: 'input-number',
span: 24,
span: 12,
props: {
min: 1,
max: 100,
},
},
{
label: '短信自动重试间隔时间(秒)',
label: '重试间隔',
field: 'retryInterval',
type: 'input-number',
span: 24,
span: 12,
slots: {
append: () => (
<span style={{ width: '30px', textAlign: 'center' }}></span>
),
},
props: {
min: 1,
},
},
{
label: '短信重试次数',
label: '重试次数',
field: 'maxRetries',
type: 'input-number',
span: 24,
span: 12,
props: {
min: 0,
},
},
{
label: '当前厂商的发送数量上限',
label: '发送上限',
field: 'maximum',
type: 'input-number',
span: 24,
span: 12,
props: {
min: 1,
},
},
{
label: '各个厂商独立配置',
label: '厂商配置',
field: 'supplierConfig',
type: 'input',
span: 24,
},
{
label: '是否启用',
field: 'isEnable',
type: 'switch',
span: 24,
label: '状态',
field: 'status',
type: 'radio-group',
required: true,
span: 24,
props: {
type: 'button',
options: dis_enable_status_enum,
},
},
@@ -155,19 +196,4 @@ const onUpdate = async (id: string) => {
defineExpose({ onAdd, onUpdate })
</script>
<template>
<a-modal
v-model:visible="visible"
:title="title"
:mask-closable="false"
:esc-to-close="false"
:width="width >= 600 ? 600 : '100%'"
draggable
@before-ok="save"
@close="reset"
>
<GiForm ref="formRef" v-model="form" :columns="columns" />
</a-modal>
</template>
<style scoped lang="scss"></style>

View File

@@ -1,136 +1,27 @@
<script setup lang="ts">
import { reactive, ref } from 'vue'
import SmsConfigAddModal from './SmsConfigAddModal.vue'
import { type SmsConfigQuery, type SmsConfigResp, deleteSmsConfig, exportSmsConfig, listSmsConfig } from '@/apis/system/smsConfig'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useDownload, useTable } from '@/hooks'
import { useDict } from '@/hooks/app'
import { isMobile } from '@/utils'
import has from '@/utils/has'
defineOptions({ name: 'SmsConfig' })
const { dis_enable_status_enum, sms_supplier_enum } = useDict('dis_enable_status_enum', 'sms_supplier_enum')
const queryForm = reactive<SmsConfigQuery>({
name: undefined,
supplier: undefined,
accessKeyId: undefined,
signature: undefined,
templateId: undefined,
isEnable: undefined,
sort: ['id,desc'],
})
const {
tableData: dataList,
loading,
pagination,
search,
handleDelete,
} = useTable((page) => listSmsConfig({ ...queryForm, ...page }), { immediate: true })
const columns = ref<TableInstanceColumns[]>([
// { title: 'ID', dataIndex: 'id', slotName: 'id' },
{ title: '名称', dataIndex: 'name', slotName: 'name', width: 120 },
{ title: '厂商名称', dataIndex: 'supplier', slotName: 'supplier' },
{ title: 'API Key', dataIndex: 'accessKeyId', slotName: 'accessKeyId' },
{ title: 'API Secret', dataIndex: 'accessKeySecret', slotName: 'accessKeySecret' },
{ title: '短信签名', dataIndex: 'signature', slotName: 'signature' },
{ title: '模板 ID', dataIndex: 'templateId', slotName: 'templateId' },
{ title: '负载均衡权重', dataIndex: 'weight', slotName: 'weight' },
{ title: '自动重试间隔时间(秒)', dataIndex: 'retryInterval', slotName: 'retryInterval' },
{ title: '短信重试次数', dataIndex: 'maxRetries', slotName: 'maxRetries' },
{ title: '发送数量上限', dataIndex: 'maximum', slotName: 'maximum' },
{ title: '厂商独立配置', dataIndex: 'supplierConfig', slotName: 'supplierConfig' },
{ title: '是否启用', dataIndex: 'isEnable', slotName: 'isEnable' },
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
{ title: '修改人', dataIndex: 'updateUserString', slotName: 'updateUser' },
{ title: '修改时间', dataIndex: 'updateTime', slotName: 'updateTime' },
{
title: '操作',
dataIndex: 'action',
slotName: 'action',
width: 200,
align: 'center',
fixed: !isMobile() ? 'right' : undefined,
show: has.hasPermOr(['system:smsConfig:detail', 'system:smsConfig:update', 'system:smsConfig:delete']),
},
])
// 重置
const reset = () => {
queryForm.name = undefined
queryForm.supplier = undefined
queryForm.accessKeyId = undefined
queryForm.signature = undefined
queryForm.templateId = undefined
queryForm.isEnable = undefined
search()
}
// 删除
const onDelete = (record: SmsConfigResp) => {
return handleDelete(() => deleteSmsConfig(record.id), {
content: `是否确定删除该条数据?`,
showModal: true,
})
}
// 导出
const onExport = () => {
useDownload(() => exportSmsConfig(queryForm))
}
const SmsConfigAddModalRef = ref<InstanceType<typeof SmsConfigAddModal>>()
// 新增
const onAdd = () => {
SmsConfigAddModalRef.value?.onAdd()
}
// 修改
const onUpdate = (record: SmsConfigResp) => {
SmsConfigAddModalRef.value?.onUpdate(record.id)
}
const router = useRouter()
// 跳转到短信记录页面
const showRecord = (record: SmsConfigResp) => {
router.push({
path: '/system/sms/record',
query: { id: record.id },
})
}
</script>
<template>
<div class="gi_table_page">
<GiTable
title="短信服务配置管理"
row-key="id"
:data="dataList"
:columns="columns"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:scroll="{ x: '100%', y: '100%', minWidth: 1500 }"
:pagination="pagination"
:disabled-tools="['size']"
:disabled-column-keys="['name']"
@refresh="search"
>
<template #toolbar-left>
<a-input-search v-model="queryForm.name" placeholder="请输入名称" allow-clear @search="search" />
<a-input-search v-model="queryForm.name" placeholder="搜索名称" allow-clear @search="search" />
<a-input-search v-model="queryForm.accessKey" placeholder="搜索 Access Key" allow-clear @search="search" />
<a-select
v-model="queryForm.supplier"
:options="sms_supplier_enum"
placeholder="请选择厂商名称标识"
placeholder="请选择厂商"
allow-clear
style="width: 150px"
@change="search"
/>
<a-input-search v-model="queryForm.accessKeyId" placeholder="请输入Access Key 或 API Key" allow-clear @search="search" />
<a-input-search v-model="queryForm.signature" placeholder="请输入短信签名" allow-clear @search="search" />
<a-input-search v-model="queryForm.templateId" placeholder="请输入模板 ID" allow-clear @search="search" />
<a-button @click="reset">
<template #icon><icon-refresh /></template>
<template #default>重置</template>
@@ -141,20 +32,16 @@ const showRecord = (record: SmsConfigResp) => {
<template #icon><icon-plus /></template>
<template #default>新增</template>
</a-button>
<a-button v-permission="['system:smsConfig:export']" @click="onExport">
<template #icon><icon-download /></template>
<template #default>导出</template>
</a-button>
</template>
<template #supplier="{ record }">
<GiCellTag :value="record.supplier" :dict="sms_supplier_enum" />
</template>
<template #isEnable="{ record }">
<GiCellTag :value="record.isEnable" :dict="dis_enable_status_enum" />
<template #accessKey="{ record }">
<CellCopy :content="record.accessKey" />
</template>
<template #action="{ record }">
<a-space>
<a-link v-permission="['system:smsRecord:list']" title="发送记录" @click="showRecord(record)">发送记录</a-link>
<a-link v-permission="['system:smsLog:list']" title="发送记录" @click="onLog(record)">发送记录</a-link>
<a-link v-permission="['system:smsConfig:update']" title="修改" @click="onUpdate(record)">修改</a-link>
<a-link
v-permission="['system:smsConfig:delete']"
@@ -173,4 +60,119 @@ const showRecord = (record: SmsConfigResp) => {
</div>
</template>
<script setup lang="tsx">
import type { TableInstance } from '@arco-design/web-vue'
import SmsConfigAddModal from './SmsConfigAddModal.vue'
import { type SmsConfigQuery, type SmsConfigResp, deleteSmsConfig, listSmsConfig } from '@/apis/system/smsConfig'
import { useTable } from '@/hooks'
import { useDict } from '@/hooks/app'
import { isMobile } from '@/utils'
import has from '@/utils/has'
import GiCellStatus from '@/components/GiCell/GiCellStatus.vue'
defineOptions({ name: 'SystemSmsConfig' })
const { sms_supplier_enum } = useDict('sms_supplier_enum')
const queryForm = reactive<SmsConfigQuery>({
name: undefined,
supplier: undefined,
accessKey: undefined,
sort: ['id,desc'],
})
const {
tableData: dataList,
loading,
pagination,
search,
handleDelete,
} = useTable((page) => listSmsConfig({ ...queryForm, ...page }), { immediate: true })
const columns: TableInstance['columns'] = [
{
title: '序号',
width: 66,
align: 'center',
render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize),
fixed: !isMobile() ? 'left' : undefined,
},
{ title: '名称', dataIndex: 'name', slotName: 'name', width: 120, fixed: !isMobile() ? 'left' : undefined },
{ title: '厂商', dataIndex: 'supplier', slotName: 'supplier', width: 100 },
{ title: 'Access Key', dataIndex: 'accessKey', slotName: 'accessKey', width: 200, ellipsis: true, tooltip: true },
{ title: 'Secret Key', dataIndex: 'secretKey', slotName: 'secretKey', width: 200, ellipsis: true, tooltip: true },
{ title: '短信签名', dataIndex: 'signature', slotName: 'signature', width: 200, ellipsis: true, tooltip: true },
{ title: '模板 ID', dataIndex: 'templateId', slotName: 'templateId', width: 100, align: 'center' },
{
title: '状态',
dataIndex: 'status',
slotName: 'status',
width: 100,
align: 'center',
render: ({ record }) => {
return <GiCellStatus status={record.status} />
},
},
{ title: '负载均衡权重', dataIndex: 'weight', slotName: 'weight', width: 150, align: 'center' },
{
title: '重试间隔',
dataIndex: 'retryInterval',
slotName: 'retryInterval',
width: 120,
align: 'center',
render: ({ record }) => record.retryInterval ? `${record.retryInterval}` : record.retryInterval,
},
{ title: '重试次数', dataIndex: 'maxRetries', slotName: 'maxRetries', width: 100, align: 'center' },
{ title: '发送上限', dataIndex: 'maximum', slotName: 'maximum', width: 100, align: 'center' },
{ title: '创建人', dataIndex: 'createUserString', width: 140, ellipsis: true, tooltip: true, show: false },
{ title: '创建时间', dataIndex: 'createTime', width: 180 },
{ title: '修改人', dataIndex: 'updateUserString', width: 140, ellipsis: true, tooltip: true, show: false },
{ title: '修改时间', dataIndex: 'updateTime', width: 180, show: false },
{
title: '操作',
dataIndex: 'action',
slotName: 'action',
width: 200,
align: 'center',
fixed: !isMobile() ? 'right' : undefined,
show: has.hasPermOr(['system:smsLog:list', 'system:smsConfig:update', 'system:smsConfig:delete']),
},
]
// 重置
const reset = () => {
queryForm.name = undefined
queryForm.supplier = undefined
queryForm.accessKey = undefined
search()
}
// 删除
const onDelete = (record: SmsConfigResp) => {
return handleDelete(() => deleteSmsConfig(record.id), {
content: `是否确定删除配置「${record.name}」?`,
showModal: true,
})
}
const SmsConfigAddModalRef = ref<InstanceType<typeof SmsConfigAddModal>>()
// 新增
const onAdd = () => {
SmsConfigAddModalRef.value?.onAdd()
}
// 修改
const onUpdate = (record: SmsConfigResp) => {
SmsConfigAddModalRef.value?.onUpdate(record.id)
}
const router = useRouter()
// 发送记录
const onLog = (record: SmsConfigResp) => {
router.push({
path: '/system/sms/log',
query: { configId: record.id },
})
}
</script>
<style scoped lang="scss"></style>

View File

@@ -1,84 +1,6 @@
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import { type SmsRecordQuery, type SmsRecordResp, deleteSmsRecord, exportSmsRecord, listSmsRecord } from '@/apis/system/smsRecord'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useDownload, useTable } from '@/hooks'
import { useDict } from '@/hooks/app'
import { isMobile } from '@/utils'
import has from '@/utils/has'
defineOptions({ name: 'SmsRecord' })
const route = useRoute()
const { success_failure_status_enum } = useDict('success_failure_status_enum')
const queryForm = reactive<SmsRecordQuery>({
configId: undefined,
phone: undefined,
status: undefined,
sort: ['id,desc'],
})
const {
tableData: dataList,
loading,
pagination,
search,
handleDelete,
} = useTable((page) => listSmsRecord({ ...queryForm, ...page }), { immediate: false })
const columns = ref<TableInstanceColumns[]>([
// { title: 'ID', dataIndex: 'id', slotName: 'id' },
// { title: 'id', dataIndex: 'configId', slotName: 'configId' },
{ title: '手机号', dataIndex: 'phone', slotName: 'phone' },
{ title: '参数配置', dataIndex: 'params', slotName: 'params' },
{ title: '发送状态', dataIndex: 'status', slotName: 'status' },
{ title: '返回数据', dataIndex: 'resMsg', slotName: 'resMsg', width: 260 },
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
{
title: '操作',
dataIndex: 'action',
slotName: 'action',
width: 160,
align: 'center',
fixed: !isMobile() ? 'right' : undefined,
show: has.hasPermOr(['system:smsRecord:detail', 'system:smsRecord:update', 'system:smsRecord:delete']),
},
])
//
const reset = () => {
queryForm.configId = undefined
queryForm.phone = undefined
queryForm.status = undefined
search()
}
//
const onDelete = (record: SmsRecordResp) => {
return handleDelete(() => deleteSmsRecord(record.id), {
content: `是否确定删除该条数据?`,
showModal: true,
})
}
//
const onExport = () => {
useDownload(() => exportSmsRecord(queryForm))
}
onMounted(() => {
queryForm.configId = route.query!.id as string
search()
})
</script>
<template>
<div class="gi_table_page">
<GiTable
title="短信记录"
row-key="id"
:data="dataList"
:columns="columns"
@@ -90,16 +12,23 @@ onMounted(() => {
@refresh="search"
>
<template #toolbar-left>
<a-input-search v-model="queryForm.configId" placeholder="请输入配置id" disabled @search="search" />
<a-input-search v-model="queryForm.phone" placeholder="请输入手机号" allow-clear @search="search" />
<a-input-search v-model="queryForm.status" placeholder="请输入发送状态" allow-clear @search="search" />
<a-input-search v-model="queryForm.configId" placeholder="请输入配置 ID" allow-clear @search="search" />
<a-input-search v-model="queryForm.phone" placeholder="搜索手机号" allow-clear @search="search" />
<a-select
v-model="queryForm.status"
:options="success_failure_status_enum"
placeholder="请选择发送状态"
allow-clear
style="width: 150px"
@change="search"
/>
<a-button @click="reset">
<template #icon><icon-refresh /></template>
<template #default>重置</template>
</a-button>
</template>
<template #toolbar-right>
<a-button v-permission="['system:smsRecord:export']" @click="onExport">
<a-button v-permission="['system:SmsLog:export']" @click="onExport">
<template #icon><icon-download /></template>
<template #default>导出</template>
</a-button>
@@ -110,7 +39,7 @@ onMounted(() => {
<template #action="{ record }">
<a-space>
<a-link
v-permission="['system:smsRecord:delete']"
v-permission="['system:smsLog:delete']"
status="danger"
:disabled="record.disabled"
:title="record.disabled ? '不可删除' : '删除'"
@@ -124,4 +53,85 @@ onMounted(() => {
</div>
</template>
<script setup lang="ts">
import { useRoute } from 'vue-router'
import type { TableInstance } from '@arco-design/web-vue'
import { type SmsLogQuery, type SmsLogResp, deleteSmsLog, exportSmsLog, listSmsLog } from '@/apis/system/smsLog'
import { useDownload, useTable } from '@/hooks'
import { useDict } from '@/hooks/app'
import { isMobile } from '@/utils'
import has from '@/utils/has'
defineOptions({ name: 'SystemSmsLog' })
const route = useRoute()
const { success_failure_status_enum } = useDict('success_failure_status_enum')
const queryForm = reactive<SmsLogQuery>({
configId: undefined,
phone: undefined,
status: undefined,
sort: ['id,desc'],
})
const {
tableData: dataList,
loading,
pagination,
search,
handleDelete,
} = useTable((page) => listSmsLog({ ...queryForm, ...page }), { immediate: false })
const columns: TableInstance['columns'] = [
{
title: '序号',
width: 66,
align: 'center',
render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize),
fixed: !isMobile() ? 'left' : undefined,
},
{ title: '手机号', dataIndex: 'phone', slotName: 'phone' },
{ title: '参数配置', dataIndex: 'params', slotName: 'params' },
{ title: '发送状态', dataIndex: 'status', slotName: 'status' },
{ title: '返回数据', dataIndex: 'resMsg', slotName: 'resMsg', width: 260 },
{ title: '操作人', dataIndex: 'createUserString', slotName: 'createUser' },
{ title: '操作时间', dataIndex: 'createTime', slotName: 'createTime' },
{
title: '操作',
dataIndex: 'action',
slotName: 'action',
width: 160,
align: 'center',
fixed: !isMobile() ? 'right' : undefined,
show: has.hasPermOr(['system:smsLog:delete']),
},
]
//
const reset = () => {
queryForm.configId = undefined
queryForm.phone = undefined
queryForm.status = undefined
search()
}
//
const onDelete = (record: SmsLogResp) => {
return handleDelete(() => deleteSmsLog(record.id), {
content: `是否确定删除该条数据?`,
showModal: true,
})
}
//
const onExport = () => {
useDownload(() => exportSmsLog(queryForm))
}
onMounted(() => {
queryForm.configId = route.query!.configId as string
search()
})
</script>
<style scoped lang="scss"></style>