mirror of
				https://github.com/continew-org/continew-admin-ui.git
				synced 2025-10-31 00:57:11 +08:00 
			
		
		
		
	feat: 新增短信配置 (#54)
This commit is contained in:
		
							
								
								
									
										87
									
								
								src/apis/system/smsConfig.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								src/apis/system/smsConfig.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,87 @@ | |||||||
|  | import http from '@/utils/http' | ||||||
|  |  | ||||||
|  | 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 getSmsConfig(id: string) { | ||||||
|  |   return http.get<SmsConfigDetailResp>(`${BASE_URL}/${id}`) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** @desc 新增短信服务配置 */ | ||||||
|  | export function addSmsConfig(data: any) { | ||||||
|  |   return http.post(`${BASE_URL}`, data) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** @desc 修改短信服务配置 */ | ||||||
|  | export function updateSmsConfig(data: any, id: string) { | ||||||
|  |   return http.put(`${BASE_URL}/${id}`, data) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** @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) | ||||||
|  | } | ||||||
							
								
								
									
										70
									
								
								src/apis/system/smsRecord.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								src/apis/system/smsRecord.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | |||||||
|  | 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) | ||||||
|  | } | ||||||
							
								
								
									
										173
									
								
								src/views/system/sms/config/SmsConfigAddModal.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								src/views/system/sms/config/SmsConfigAddModal.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,173 @@ | |||||||
|  | <script setup lang="ts"> | ||||||
|  | import { Message } from '@arco-design/web-vue' | ||||||
|  | import { useWindowSize } from '@vueuse/core' | ||||||
|  | import { addSmsConfig, getSmsConfig, updateSmsConfig } from '@/apis/system/smsConfig' | ||||||
|  | import { type ColumnItem, GiForm } from '@/components/GiForm' | ||||||
|  | import { useResetReactive } from '@/hooks' | ||||||
|  | import { useDict } from '@/hooks/app' | ||||||
|  |  | ||||||
|  | const emit = defineEmits<{ | ||||||
|  |   (e: 'save-success'): void | ||||||
|  | }>() | ||||||
|  |  | ||||||
|  | const { width } = useWindowSize() | ||||||
|  |  | ||||||
|  | const dataId = ref('') | ||||||
|  | const visible = ref(false) | ||||||
|  | const isUpdate = computed(() => !!dataId.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 待补充 | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | const columns: ColumnItem[] = reactive([ | ||||||
|  |   { | ||||||
|  |     label: '名称', | ||||||
|  |     field: 'name', | ||||||
|  |     type: 'input', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '厂商名称标识', | ||||||
|  |     field: 'supplier', | ||||||
|  |     type: 'select', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |     props: { | ||||||
|  |       options: sms_supplier_enum, | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: 'Access Key 或 API Key', | ||||||
|  |     field: 'accessKeyId', | ||||||
|  |     type: 'input', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: 'Access Secret 或 API Secret', | ||||||
|  |     field: 'accessKeySecret', | ||||||
|  |     type: 'input', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '短信签名', | ||||||
|  |     field: 'signature', | ||||||
|  |     type: 'input', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '模板 ID', | ||||||
|  |     field: 'templateId', | ||||||
|  |     type: 'input', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '负载均衡权重', | ||||||
|  |     field: 'weight', | ||||||
|  |     type: 'input-number', | ||||||
|  |     span: 24, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '短信自动重试间隔时间(秒)', | ||||||
|  |     field: 'retryInterval', | ||||||
|  |     type: 'input-number', | ||||||
|  |     span: 24, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '短信重试次数', | ||||||
|  |     field: 'maxRetries', | ||||||
|  |     type: 'input-number', | ||||||
|  |     span: 24, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '当前厂商的发送数量上限', | ||||||
|  |     field: 'maximum', | ||||||
|  |     type: 'input-number', | ||||||
|  |     span: 24, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '各个厂商独立配置', | ||||||
|  |     field: 'supplierConfig', | ||||||
|  |     type: 'input', | ||||||
|  |     span: 24, | ||||||
|  |   }, | ||||||
|  |   { | ||||||
|  |     label: '是否启用', | ||||||
|  |     field: 'isEnable', | ||||||
|  |     type: 'switch', | ||||||
|  |     span: 24, | ||||||
|  |     required: true, | ||||||
|  |     props: { | ||||||
|  |       options: dis_enable_status_enum, | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  | ]) | ||||||
|  |  | ||||||
|  | // 重置 | ||||||
|  | const reset = () => { | ||||||
|  |   formRef.value?.formRef?.resetFields() | ||||||
|  |   resetForm() | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 保存 | ||||||
|  | const save = async () => { | ||||||
|  |   try { | ||||||
|  |     const isInvalid = await formRef.value?.formRef?.validate() | ||||||
|  |     if (isInvalid) return false | ||||||
|  |     if (isUpdate.value) { | ||||||
|  |       await updateSmsConfig(form, dataId.value) | ||||||
|  |       Message.success('修改成功') | ||||||
|  |     } else { | ||||||
|  |       await addSmsConfig(form) | ||||||
|  |       Message.success('新增成功') | ||||||
|  |     } | ||||||
|  |     emit('save-success') | ||||||
|  |     return true | ||||||
|  |   } catch (error) { | ||||||
|  |     return false | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 新增 | ||||||
|  | const onAdd = async () => { | ||||||
|  |   reset() | ||||||
|  |   dataId.value = '' | ||||||
|  |   visible.value = true | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // 修改 | ||||||
|  | const onUpdate = async (id: string) => { | ||||||
|  |   reset() | ||||||
|  |   dataId.value = id | ||||||
|  |   const { data } = await getSmsConfig(id) | ||||||
|  |   Object.assign(form, data) | ||||||
|  |   visible.value = true | ||||||
|  | } | ||||||
|  |  | ||||||
|  | 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> | ||||||
							
								
								
									
										176
									
								
								src/views/system/sms/config/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								src/views/system/sms/config/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,176 @@ | |||||||
|  | <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 }" | ||||||
|  |       :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-select | ||||||
|  |           v-model="queryForm.supplier" | ||||||
|  |           :options="sms_supplier_enum" | ||||||
|  |           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> | ||||||
|  |         </a-button> | ||||||
|  |       </template> | ||||||
|  |       <template #toolbar-right> | ||||||
|  |         <a-button v-permission="['system:smsConfig:add']" type="primary" @click="onAdd"> | ||||||
|  |           <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> | ||||||
|  |       <template #action="{ record }"> | ||||||
|  |         <a-space> | ||||||
|  |           <a-link v-permission="['system:smsRecord:list']" title="发送记录" @click="showRecord(record)">发送记录</a-link> | ||||||
|  |           <a-link v-permission="['system:smsConfig:update']" title="修改" @click="onUpdate(record)">修改</a-link> | ||||||
|  |           <a-link | ||||||
|  |             v-permission="['system:smsConfig:delete']" | ||||||
|  |             status="danger" | ||||||
|  |             :disabled="record.disabled" | ||||||
|  |             :title="record.disabled ? '不可删除' : '删除'" | ||||||
|  |             @click="onDelete(record)" | ||||||
|  |           > | ||||||
|  |             删除 | ||||||
|  |           </a-link> | ||||||
|  |         </a-space> | ||||||
|  |       </template> | ||||||
|  |     </GiTable> | ||||||
|  |  | ||||||
|  |     <SmsConfigAddModal ref="SmsConfigAddModalRef" @save-success="search" /> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <style scoped lang="scss"></style> | ||||||
							
								
								
									
										127
									
								
								src/views/system/sms/record/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								src/views/system/sms/record/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,127 @@ | |||||||
|  | <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" | ||||||
|  |       :loading="loading" | ||||||
|  |       :scroll="{ x: '100%', y: '100%', minWidth: 1000 }" | ||||||
|  |       :pagination="pagination" | ||||||
|  |       :disabled-tools="['size']" | ||||||
|  |       :disabled-column-keys="['name']" | ||||||
|  |       @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-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"> | ||||||
|  |           <template #icon><icon-download /></template> | ||||||
|  |           <template #default>导出</template> | ||||||
|  |         </a-button> | ||||||
|  |       </template> | ||||||
|  |       <template #status="{ record }"> | ||||||
|  |         <GiCellTag :value="record.status" :dict="success_failure_status_enum" /> | ||||||
|  |       </template> | ||||||
|  |       <template #action="{ record }"> | ||||||
|  |         <a-space> | ||||||
|  |           <a-link | ||||||
|  |             v-permission="['system:smsRecord:delete']" | ||||||
|  |             status="danger" | ||||||
|  |             :disabled="record.disabled" | ||||||
|  |             :title="record.disabled ? '不可删除' : '删除'" | ||||||
|  |             @click="onDelete(record)" | ||||||
|  |           > | ||||||
|  |             删除 | ||||||
|  |           </a-link> | ||||||
|  |         </a-space> | ||||||
|  |       </template> | ||||||
|  |     </GiTable> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <style scoped lang="scss"></style> | ||||||
		Reference in New Issue
	
	Block a user
	 luoqiz
					luoqiz