mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-09-22 13:01:56 +08:00
REVIEW 站内信模版的发送
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
@@ -99,7 +99,6 @@
|
||||
width="200"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
|
||||
<el-table-column label="开启状态" align="center" prop="status" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||
@@ -151,67 +150,22 @@
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<Dialog v-model="dialogFormVisible" title="测试发送" :max-height="500">
|
||||
<el-form
|
||||
ref="sendFormRef"
|
||||
:model="sendFormData"
|
||||
:rules="sendFormRules"
|
||||
label-width="140px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="模板内容" prop="content">
|
||||
<el-input v-model="sendFormData.content" readonly />
|
||||
</el-form-item>
|
||||
<el-form-item label="接收人" prop="userId">
|
||||
<el-select v-model="sendFormData.userId" placeholder="请选择接收人">
|
||||
<el-option
|
||||
v-for="item in userOption"
|
||||
:key="item.id"
|
||||
:label="item.nickname"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-for="param in sendFormData.params"
|
||||
:key="param"
|
||||
:label="'参数 {' + param + '}'"
|
||||
:prop="'templateParams.' + param"
|
||||
>
|
||||
<el-input
|
||||
v-model="sendFormData.templateParams[param]"
|
||||
:placeholder="'请输入 ' + param + ' 参数'"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm"> 确定 </el-button>
|
||||
</span>
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<NotifyTemplateForm ref="formRef" @success="getList" />
|
||||
<!-- 表单弹窗:测试发送 -->
|
||||
<NotifyTemplateSendForm ref="sendFormRef" />
|
||||
</template>
|
||||
<script setup lang="ts" name="NotifySmsTemplate">
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as NotifyTemplateApi from '@/api/system/notify/template'
|
||||
import { getSimpleUserList, UserVO } from '@/api/system/user'
|
||||
import NotifyTemplateForm from './NotifyTemplateForm.vue'
|
||||
|
||||
import NotifyTemplateSendForm from './NotifyTemplateSendForm.vue'
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
const formLoading = ref(false)
|
||||
const dialogFormVisible = ref(false)
|
||||
const sendFormRef = ref() // 表单 Ref
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
@@ -220,28 +174,13 @@ const queryParams = reactive({
|
||||
code: undefined,
|
||||
createTime: []
|
||||
})
|
||||
|
||||
const sendFormData = ref({
|
||||
content: '',
|
||||
params: {},
|
||||
userId: null,
|
||||
templateCode: '',
|
||||
templateParams: {}
|
||||
})
|
||||
|
||||
const sendFormRules = ref({
|
||||
userId: [{ required: true, message: '用户编号不能为空', trigger: 'change' }],
|
||||
templateCode: [{ required: true, message: '模版编号不能为空', trigger: 'blur' }],
|
||||
templateParams: {}
|
||||
})
|
||||
|
||||
const userOption = ref<UserVO[]>([])
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await NotifyTemplateApi.getNotifyTemplatePageApi(queryParams)
|
||||
const data = await NotifyTemplateApi.getNotifyTemplatePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
@@ -280,50 +219,14 @@ const handleDelete = async (id: number) => {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const openSendForm = (row: any) => {
|
||||
sendFormData.value.content = row.content
|
||||
sendFormData.value.params = row.params
|
||||
sendFormData.value.templateCode = row.code
|
||||
sendFormData.value.templateParams = row.params.reduce(function (obj, item) {
|
||||
obj[item] = undefined
|
||||
return obj
|
||||
}, {})
|
||||
sendFormRules.value.templateParams = row.params.reduce(function (obj, item) {
|
||||
obj[item] = { required: true, message: '参数 ' + item + ' 不能为空', trigger: 'change' }
|
||||
return obj
|
||||
}, {})
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (!sendFormRef) return
|
||||
const valid = await sendFormRef.value.validate()
|
||||
if (!valid) return
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data: NotifyTemplateApi.NotifySendReqVO = {
|
||||
userId: sendFormData.value.userId,
|
||||
templateCode: sendFormData.value.templateCode,
|
||||
templateParams: sendFormData.value.templateParams as unknown as Map<string, Object>
|
||||
}
|
||||
const res = await NotifyTemplateApi.sendNotifyApi(data)
|
||||
if (res) {
|
||||
message.success('提交发送成功!发送结果,见消息记录编号:' + res)
|
||||
}
|
||||
dialogFormVisible.value = false
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
/** 发送站内信按钮 */
|
||||
const sendFormRef = ref() // 表单 Ref
|
||||
const openSendForm = (row: NotifyTemplateApi.NotifyTemplateVO) => {
|
||||
sendFormRef.value.open(row.id)
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
getSimpleUserList().then((data) => {
|
||||
userOption.value = data
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user