mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	refactor: sms
This commit is contained in:
		| @@ -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 }) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,10 +0,0 @@ | ||||
| export type SmsChannelVO = { | ||||
|   id: number | ||||
|   status: number | ||||
|   signature: string | ||||
|   remark: string | ||||
|   apiKey: string | ||||
|   apiSecret: string | ||||
|   callbackUrl: string | ||||
|   createTime: string | ||||
| } | ||||
| @@ -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 }) | ||||
| } | ||||
|   | ||||
| @@ -1,9 +0,0 @@ | ||||
| export type SmsLogVO = { | ||||
|   id: number | ||||
|   idchannelId: number | ||||
|   templateId: number | ||||
|   mobile: string | ||||
|   sendStatus: number | ||||
|   receiveStatus: number | ||||
|   createTime: string | ||||
| } | ||||
| @@ -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) => { | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
| @@ -1,11 +1,9 @@ | ||||
| <template> | ||||
|   <!-- 搜索工作区 --> | ||||
|   <ContentWrap> | ||||
|     <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> | ||||
|   </ContentWrap> | ||||
|   <ContentWrap> | ||||
|     <!-- 操作工具栏 --> | ||||
|     <div class="mb-10px"> | ||||
|     <!-- 列表 --> | ||||
|     <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> | ||||
|       <!-- 操作:新增 --> | ||||
|       <template #toolbar_buttons> | ||||
|         <XButton | ||||
|           type="primary" | ||||
|           preIcon="ep:zoom-in" | ||||
| @@ -13,30 +11,8 @@ | ||||
|           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" /> | ||||
|       </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> | ||||
|   | ||||
| @@ -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[]>([ | ||||
| const crudSchemas = reactive<VxeCrudSchema>({ | ||||
|   primaryKey: 'id', | ||||
|   primaryType: 'seq', | ||||
|   action: true, | ||||
|   columns: [ | ||||
|     { | ||||
|     label: t('common.index'), | ||||
|     field: 'id', | ||||
|     type: 'index', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|     detail: { | ||||
|       show: false | ||||
|     } | ||||
|   }, | ||||
|   { | ||||
|     label: '短信签名', | ||||
|       title: '短信签名', | ||||
|       field: 'signature', | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '渠道编码', | ||||
|       title: '渠道编码', | ||||
|       field: 'code', | ||||
|       dictType: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: t('common.status'), | ||||
|       title: t('common.status'), | ||||
|       field: 'status', | ||||
|       dictType: DICT_TYPE.COMMON_STATUS, | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '短信 API 的账号', | ||||
|       title: '短信 API 的账号', | ||||
|       field: 'apiKey' | ||||
|     }, | ||||
|     { | ||||
|     label: '短信 API 的密钥', | ||||
|       title: '短信 API 的密钥', | ||||
|       field: 'apiSecret' | ||||
|     }, | ||||
|     { | ||||
|     label: '短信发送回调 URL', | ||||
|       title: '短信发送回调 URL', | ||||
|       field: 'callbackUrl' | ||||
|     }, | ||||
|     { | ||||
|     label: t('common.createTime'), | ||||
|       title: t('common.createTime'), | ||||
|       field: 'createTime', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|     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)] | ||||
|       formatter: 'formatDate', | ||||
|       isForm: false | ||||
|     } | ||||
|     } | ||||
|   }, | ||||
|   { | ||||
|     label: t('table.action'), | ||||
|     field: 'action', | ||||
|     width: '240px', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|     detail: { | ||||
|       show: false | ||||
|     } | ||||
|   } | ||||
| ]) | ||||
| export const { allSchemas } = useCrudSchemas(crudSchemas) | ||||
|   ] | ||||
| }) | ||||
| export const { allSchemas } = useVxeCrudSchemas(crudSchemas) | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
| @@ -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[]>([ | ||||
| const crudSchemas = reactive<VxeCrudSchema>({ | ||||
|   primaryKey: 'id', | ||||
|   primaryType: 'seq', | ||||
|   action: true, | ||||
|   columns: [ | ||||
|     { | ||||
|     label: t('common.index'), | ||||
|     field: 'id', | ||||
|     type: 'index', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|     detail: { | ||||
|       show: false | ||||
|     } | ||||
|   }, | ||||
|   { | ||||
|     label: '手机号', | ||||
|       title: '手机号', | ||||
|       field: 'mobile', | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '短信内容', | ||||
|       title: '短信内容', | ||||
|       field: 'templateContent' | ||||
|     }, | ||||
|     { | ||||
|     label: '短信渠道', | ||||
|       title: '短信渠道', | ||||
|       field: 'channelId', | ||||
|       dictType: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '发送状态', | ||||
|       title: '发送状态', | ||||
|       field: 'sendStatus', | ||||
|       dictType: DICT_TYPE.SYSTEM_SMS_SEND_STATUS, | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '接收状态', | ||||
|     field: 'receiveTime', | ||||
|       title: '接收状态', | ||||
|       field: 'receiveStatus', | ||||
|       dictType: DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS, | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '模板编号', | ||||
|       title: '模板编号', | ||||
|       field: 'templateId', | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '短信类型', | ||||
|     field: 'channelId', | ||||
|       title: '短信类型', | ||||
|       field: 'templateType', | ||||
|       dictType: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE, | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|     label: '接收时间', | ||||
|     field: 'receiveTime', | ||||
|     form: { | ||||
|       show: false | ||||
|     } | ||||
|       title: '接收时间', | ||||
|       field: 'receiveTime' | ||||
|     }, | ||||
|     { | ||||
|     label: t('common.createTime'), | ||||
|       title: t('common.createTime'), | ||||
|       field: 'createTime', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|       formatter: 'formatDate', | ||||
|       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)] | ||||
|         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) | ||||
|   | ||||
| @@ -1,11 +1,9 @@ | ||||
| <template> | ||||
|   <!-- 搜索工作区 --> | ||||
|   <ContentWrap> | ||||
|     <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> | ||||
|   </ContentWrap> | ||||
|   <ContentWrap> | ||||
|     <!-- 操作工具栏 --> | ||||
|     <div class="mb-10px"> | ||||
|     <!-- 列表 --> | ||||
|     <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> | ||||
|       <!-- 操作:新增 --> | ||||
|       <template #toolbar_buttons> | ||||
|         <XButton | ||||
|           type="primary" | ||||
|           preIcon="ep:zoom-in" | ||||
| @@ -13,30 +11,8 @@ | ||||
|           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" /> | ||||
|       </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> | ||||
|   | ||||
| @@ -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,31 +17,20 @@ export const rules = reactive({ | ||||
| }) | ||||
|  | ||||
| // CrudSchema | ||||
| const crudSchemas = reactive<CrudSchema[]>([ | ||||
|   { | ||||
|     label: t('common.index'), | ||||
|     field: 'id', | ||||
|     type: 'index', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|     detail: { | ||||
|       show: false | ||||
|     } | ||||
|   }, | ||||
| const crudSchemas = reactive<VxeCrudSchema>({ | ||||
|   primaryKey: 'id', | ||||
|   primaryType: 'seq', | ||||
|   action: true, | ||||
|   columns: [ | ||||
|     { | ||||
|       label: '模板编码', | ||||
|       field: 'code', | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|       label: '模板名称', | ||||
|       field: 'name', | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|       label: '模板内容', | ||||
| @@ -50,9 +39,7 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||||
|     { | ||||
|       label: '短信 API 的模板编号', | ||||
|       field: 'apiTemplateId', | ||||
|     search: { | ||||
|       show: true | ||||
|     } | ||||
|       isSearch: true | ||||
|     }, | ||||
|     { | ||||
|       label: '短信类型', | ||||
| @@ -67,36 +54,20 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||||
|     { | ||||
|       label: t('form.remark'), | ||||
|       field: 'remark', | ||||
|     table: { | ||||
|       show: false | ||||
|     } | ||||
|       isTable: false | ||||
|     }, | ||||
|     { | ||||
|     label: t('common.createTime'), | ||||
|       title: t('common.createTime'), | ||||
|       field: 'createTime', | ||||
|     form: { | ||||
|       show: false | ||||
|     }, | ||||
|       formatter: 'formatDate', | ||||
|       isForm: false, | ||||
|       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)] | ||||
|         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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 xingyu
					xingyu