6 changed files with 508 additions and 3 deletions
@ -0,0 +1,58 @@ |
|||||||
|
<template> |
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> |
||||||
|
<BasicForm @register="registerForm" /> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup name="SmsTemplateModal"> |
||||||
|
import { ref, computed, unref } from 'vue' |
||||||
|
import { BasicModal, useModalInner } from '@/components/Modal' |
||||||
|
import { BasicForm, useForm } from '@/components/Form' |
||||||
|
import { formSchema } from './smsTemplate.data' |
||||||
|
import { createSmsTemplateApi, getSmsTemplateApi, updateSmsTemplateApi } from '@/api/system/sms/smsTemplate' |
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'register']) |
||||||
|
const isUpdate = ref(true) |
||||||
|
const rowId = ref() |
||||||
|
|
||||||
|
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ |
||||||
|
labelWidth: 100, |
||||||
|
baseColProps: { span: 24 }, |
||||||
|
schemas: formSchema, |
||||||
|
showActionButtonGroup: false, |
||||||
|
actionColOptions: { |
||||||
|
span: 23 |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { |
||||||
|
resetFields() |
||||||
|
setModalProps({ confirmLoading: false }) |
||||||
|
isUpdate.value = !!data?.isUpdate |
||||||
|
|
||||||
|
if (unref(isUpdate)) { |
||||||
|
const res = await getSmsTemplateApi(data.record.id) |
||||||
|
rowId.value = res.id |
||||||
|
setFieldsValue({ |
||||||
|
...res |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增岗位' : '编辑岗位')) |
||||||
|
|
||||||
|
async function handleSubmit() { |
||||||
|
try { |
||||||
|
const values = await validate() |
||||||
|
setModalProps({ confirmLoading: true }) |
||||||
|
if (unref(isUpdate)) { |
||||||
|
await updateSmsTemplateApi(values) |
||||||
|
} else { |
||||||
|
await createSmsTemplateApi(values) |
||||||
|
} |
||||||
|
closeModal() |
||||||
|
emit('success') |
||||||
|
} finally { |
||||||
|
setModalProps({ confirmLoading: false }) |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
@ -0,0 +1,133 @@ |
|||||||
|
import { getSimpleSmsChannels } from '@/api/system/sms/smsChannel' |
||||||
|
import { getIntDictOptions } from '../../../utils/dict' |
||||||
|
import { BasicColumn, FormSchema, useRender } from '@/components/Table' |
||||||
|
import { DICT_TYPE } from '@/utils/dict' |
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: '日志编号', |
||||||
|
dataIndex: 'id', |
||||||
|
width: 100 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建时间', |
||||||
|
dataIndex: 'createTime', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDate(text) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '手机号', |
||||||
|
dataIndex: 'mobile', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text, record }) => { |
||||||
|
if (record.userType && record.userId) { |
||||||
|
return useRender.renderDict(record.userType, DICT_TYPE.USER_TYPE) + 'record.userId' |
||||||
|
} else { |
||||||
|
return text |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '短信内容', |
||||||
|
dataIndex: 'templateContent', |
||||||
|
width: 300 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '发送状态', |
||||||
|
dataIndex: 'sendStatus', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDict(text, DICT_TYPE.SYSTEM_SMS_SEND_STATUS) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '接收状态', |
||||||
|
dataIndex: 'receiveStatus', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDict(text, DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '短信渠道', |
||||||
|
dataIndex: 'channelCode', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text, record }) => { |
||||||
|
return useRender.renderText(record.channelId, '') || '' + useRender.renderDict(text, DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE) || '' |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '模板编号', |
||||||
|
dataIndex: 'templateId', |
||||||
|
width: 120 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '短信类型', |
||||||
|
dataIndex: 'templateType', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDict(text, DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE) |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
label: '手机号', |
||||||
|
field: 'mobile', |
||||||
|
component: 'Input', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '短信渠道', |
||||||
|
field: 'channelId', |
||||||
|
component: 'ApiSelect', |
||||||
|
componentProps: { |
||||||
|
options: getSimpleSmsChannels(), |
||||||
|
fieldNames: { |
||||||
|
label: 'signature', |
||||||
|
key: 'id', |
||||||
|
value: 'id' |
||||||
|
} |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '模板编号', |
||||||
|
field: 'templateId', |
||||||
|
component: 'Input', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '发送状态', |
||||||
|
field: 'sendStatus', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.SYSTEM_SMS_SEND_STATUS) |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '发送时间', |
||||||
|
field: 'sendTime', |
||||||
|
component: 'RangePicker', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '接收状态', |
||||||
|
field: 'receiveStatus', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS) |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '接收时间', |
||||||
|
field: 'receiveTime', |
||||||
|
component: 'RangePicker', |
||||||
|
colProps: { span: 8 } |
||||||
|
} |
||||||
|
] |
@ -1,3 +1,43 @@ |
|||||||
<template> |
<template> |
||||||
<div>开发中</div> |
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #toolbar> |
||||||
|
<a-button type="warning" @click="handleExport"> 导出 </a-button> |
||||||
</template> |
</template> |
||||||
|
</BasicTable> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup name="SmsLog"> |
||||||
|
import { BasicTable, useTable } from '@/components/Table' |
||||||
|
import { SmsLogExportReqVO, exportSmsLogApi, getSmsLogPageApi } from '@/api/system/sms/smsLog' |
||||||
|
import { columns, searchFormSchema } from './smsLog.data' |
||||||
|
import { useI18n } from '@/hooks/web/useI18n' |
||||||
|
import { useMessage } from '@/hooks/web/useMessage' |
||||||
|
|
||||||
|
const { t } = useI18n() |
||||||
|
const { createConfirm, createMessage } = useMessage() |
||||||
|
const [registerTable, { getForm }] = useTable({ |
||||||
|
title: '短信日志列表', |
||||||
|
api: getSmsLogPageApi, |
||||||
|
columns, |
||||||
|
formConfig: { |
||||||
|
labelWidth: 120, |
||||||
|
schemas: searchFormSchema |
||||||
|
}, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
showIndexColumn: false |
||||||
|
}) |
||||||
|
|
||||||
|
async function handleExport() { |
||||||
|
createConfirm({ |
||||||
|
title: '导出', |
||||||
|
iconType: 'warning', |
||||||
|
content: '是否要导出数据?', |
||||||
|
async onOk() { |
||||||
|
await exportSmsLogApi(getForm().getFieldsValue() as SmsLogExportReqVO) |
||||||
|
createMessage.success(t('common.exportSuccessText')) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
</script> |
||||||
|
@ -0,0 +1,172 @@ |
|||||||
|
import { BasicColumn, FormSchema, useRender } from '@/components/Table' |
||||||
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: '模板编码', |
||||||
|
dataIndex: 'code', |
||||||
|
width: 180 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '模板名称', |
||||||
|
dataIndex: 'name', |
||||||
|
width: 100 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '模板内容', |
||||||
|
dataIndex: 'content', |
||||||
|
width: 300 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '短信类型', |
||||||
|
dataIndex: 'status', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDict(text, DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '开启状态', |
||||||
|
dataIndex: 'status', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '备注', |
||||||
|
dataIndex: 'remark', |
||||||
|
width: 180 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '短信 API 的模板编号', |
||||||
|
dataIndex: 'apiTemplateId', |
||||||
|
width: 180 |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '短信渠道', |
||||||
|
dataIndex: 'channelCode', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDict(text, DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建时间', |
||||||
|
dataIndex: 'createTime', |
||||||
|
width: 180, |
||||||
|
customRender: ({ text }) => { |
||||||
|
return useRender.renderDate(text) |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
label: '短信类型', |
||||||
|
field: 'type', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE) |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '开启状态', |
||||||
|
field: 'status', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '模板编码', |
||||||
|
field: 'code', |
||||||
|
component: 'Input', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '短信 API 的模板编号', |
||||||
|
field: 'apiTemplateId', |
||||||
|
component: 'Input', |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '短信渠道', |
||||||
|
field: 'channelId', |
||||||
|
component: 'Select', |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE) |
||||||
|
}, |
||||||
|
colProps: { span: 8 } |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '创建时间', |
||||||
|
field: 'createTime', |
||||||
|
component: 'RangePicker', |
||||||
|
colProps: { span: 8 } |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
label: '编号', |
||||||
|
field: 'id', |
||||||
|
show: false, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '短信渠道编号', |
||||||
|
field: 'channelId', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '短信类型', |
||||||
|
field: 'type', |
||||||
|
component: 'Select', |
||||||
|
defaultValue: 0, |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '模板编号', |
||||||
|
field: 'code', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '模板名称', |
||||||
|
field: 'name', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '模板内容', |
||||||
|
field: 'content', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '开启状态', |
||||||
|
field: 'status', |
||||||
|
component: 'Select', |
||||||
|
defaultValue: 0, |
||||||
|
componentProps: { |
||||||
|
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '短信 API 模板编号', |
||||||
|
field: 'apiTemplateId', |
||||||
|
required: true, |
||||||
|
component: 'Input' |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '备注', |
||||||
|
field: 'remark', |
||||||
|
component: 'InputTextArea' |
||||||
|
} |
||||||
|
] |
@ -1,3 +1,105 @@ |
|||||||
<template> |
<template> |
||||||
<div>开发中</div> |
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #toolbar> |
||||||
|
<a-button type="primary" @click="handleCreate"> 新增 </a-button> |
||||||
|
<a-button type="warning" @click="handleExport"> 导出 </a-button> |
||||||
</template> |
</template> |
||||||
|
<template #bodyCell="{ column, record }"> |
||||||
|
<template v-if="column.key === 'action'"> |
||||||
|
<TableAction |
||||||
|
:actions="[ |
||||||
|
{ |
||||||
|
icon: 'clarity:note-edit-line', |
||||||
|
label: '测试', |
||||||
|
onClick: handleSendSms.bind(null, record) |
||||||
|
}, |
||||||
|
{ |
||||||
|
icon: 'clarity:note-edit-line', |
||||||
|
label: '修改', |
||||||
|
onClick: handleEdit.bind(null, record) |
||||||
|
}, |
||||||
|
{ |
||||||
|
icon: 'ant-design:delete-outlined', |
||||||
|
color: 'error', |
||||||
|
label: '删除', |
||||||
|
popConfirm: { |
||||||
|
title: '是否确认删除', |
||||||
|
placement: 'left', |
||||||
|
confirm: handleDelete.bind(null, record) |
||||||
|
} |
||||||
|
} |
||||||
|
]" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
</template> |
||||||
|
</BasicTable> |
||||||
|
<SmsTemplateModel @register="registerModal" @success="reload()" /> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
<script lang="ts" setup name="SmsTemplate"> |
||||||
|
import { BasicTable, useTable, TableAction } from '@/components/Table' |
||||||
|
import { SmsTemplateExportReqVO, deleteSmsTemplateApi, exportSmsTemplateApi, getSmsTemplatePageApi } from '@/api/system/sms/smsTemplate' |
||||||
|
import { useModal } from '@/components/Modal' |
||||||
|
import SmsTemplateModel from './SmsTemplateModel.vue' |
||||||
|
import { columns, searchFormSchema } from './smsTemplate.data' |
||||||
|
import { useI18n } from '@/hooks/web/useI18n' |
||||||
|
import { useMessage } from '@/hooks/web/useMessage' |
||||||
|
|
||||||
|
const { t } = useI18n() |
||||||
|
const { createConfirm, createMessage } = useMessage() |
||||||
|
const [registerModal, { openModal }] = useModal() |
||||||
|
const [registerTable, { getForm, reload }] = useTable({ |
||||||
|
title: '短信模版列表', |
||||||
|
api: getSmsTemplatePageApi, |
||||||
|
columns, |
||||||
|
formConfig: { |
||||||
|
labelWidth: 120, |
||||||
|
schemas: searchFormSchema |
||||||
|
}, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
showIndexColumn: false, |
||||||
|
actionColumn: { |
||||||
|
width: 240, |
||||||
|
title: '操作', |
||||||
|
dataIndex: 'action', |
||||||
|
fixed: 'right' |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
function handleCreate() { |
||||||
|
openModal(true, { |
||||||
|
isUpdate: false |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
function handleSendSms(record: Recordable) { |
||||||
|
console.info(record) |
||||||
|
} |
||||||
|
|
||||||
|
function handleEdit(record: Recordable) { |
||||||
|
openModal(true, { |
||||||
|
record, |
||||||
|
isUpdate: true |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
async function handleExport() { |
||||||
|
createConfirm({ |
||||||
|
title: '导出', |
||||||
|
iconType: 'warning', |
||||||
|
content: '是否要导出数据?', |
||||||
|
async onOk() { |
||||||
|
await exportSmsTemplateApi(getForm().getFieldsValue() as SmsTemplateExportReqVO) |
||||||
|
createMessage.success(t('common.exportSuccessText')) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
async function handleDelete(record: Recordable) { |
||||||
|
await deleteSmsTemplateApi(record.id) |
||||||
|
createMessage.success('删除成功') |
||||||
|
reload() |
||||||
|
} |
||||||
|
</script> |
||||||
|
Reference in new issue