Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e3660e0b
authored
Apr 15, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REVIEW 站内信模版的发送
parent
97f9560c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
128 deletions
+152
-128
src/api/system/notify/template/index.ts
+8
-15
src/views/system/notify/template/NotifyTemplateForm.vue
+7
-6
src/views/system/notify/template/NotifyTemplateSendForm.vue
+127
-0
src/views/system/notify/template/index.vue
+10
-107
No files found.
src/api/system/notify/template/index.ts
View file @
e3660e0b
import
request
from
'@/config/axios'
import
request
from
'@/config/axios'
export
interface
NotifyTemplateVO
{
export
interface
NotifyTemplateVO
{
id
:
number
|
null
id
?:
number
name
:
string
name
:
string
nickname
:
string
nickname
:
string
code
:
string
code
:
string
content
:
string
content
:
string
type
:
number
|
null
type
:
number
params
:
string
params
:
string
status
:
number
|
null
status
:
number
remark
:
string
remark
:
string
}
}
export
interface
NotifyTemplatePageReqVO
extends
PageParam
{
name
?:
string
code
?:
string
status
?:
number
createTime
?:
Date
[]
}
export
interface
NotifySendReqVO
{
export
interface
NotifySendReqVO
{
userId
:
number
|
null
userId
:
number
|
null
templateCode
:
string
templateCode
:
string
...
@@ -26,22 +19,22 @@ export interface NotifySendReqVO {
...
@@ -26,22 +19,22 @@ export interface NotifySendReqVO {
}
}
// 查询站内信模板列表
// 查询站内信模板列表
export
const
getNotifyTemplatePage
Api
=
async
(
params
:
NotifyTemplatePageReqVO
)
=>
{
export
const
getNotifyTemplatePage
=
async
(
params
:
PageParam
)
=>
{
return
await
request
.
get
({
url
:
'/system/notify-template/page'
,
params
})
return
await
request
.
get
({
url
:
'/system/notify-template/page'
,
params
})
}
}
// 查询站内信模板详情
// 查询站内信模板详情
export
const
getNotifyTemplate
Api
=
async
(
id
:
number
)
=>
{
export
const
getNotifyTemplate
=
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
'/system/notify-template/get?id='
+
id
})
return
await
request
.
get
({
url
:
'/system/notify-template/get?id='
+
id
})
}
}
// 新增站内信模板
// 新增站内信模板
export
const
createNotifyTemplate
Api
=
async
(
data
:
NotifyTemplateVO
)
=>
{
export
const
createNotifyTemplate
=
async
(
data
:
NotifyTemplateVO
)
=>
{
return
await
request
.
post
({
url
:
'/system/notify-template/create'
,
data
})
return
await
request
.
post
({
url
:
'/system/notify-template/create'
,
data
})
}
}
// 修改站内信模板
// 修改站内信模板
export
const
updateNotifyTemplate
Api
=
async
(
data
:
NotifyTemplateVO
)
=>
{
export
const
updateNotifyTemplate
=
async
(
data
:
NotifyTemplateVO
)
=>
{
return
await
request
.
put
({
url
:
'/system/notify-template/update'
,
data
})
return
await
request
.
put
({
url
:
'/system/notify-template/update'
,
data
})
}
}
...
@@ -51,6 +44,6 @@ export const deleteNotifyTemplateApi = async (id: number) => {
...
@@ -51,6 +44,6 @@ export const deleteNotifyTemplateApi = async (id: number) => {
}
}
// 发送站内信
// 发送站内信
export
const
sendNotify
Api
=
(
data
:
NotifySendReqVO
)
=>
{
export
const
sendNotify
=
(
data
:
NotifySendReqVO
)
=>
{
return
request
.
post
({
url
:
'/system/notify-template/send-notify'
,
data
})
return
request
.
post
({
url
:
'/system/notify-template/send-notify'
,
data
})
}
}
src/views/system/notify/template/NotifyTemplateForm.vue
View file @
e3660e0b
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
v-for=
"dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
:key=
"dict.value"
:key=
"dict.value"
:label=
"dict.label"
:label=
"dict.label"
:value=
"
parseInt(dict.value)
"
:value=
"
dict.value
"
/>
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
<el-radio
<el-radio
v-for=
"dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
v-for=
"dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key=
"dict.value"
:key=
"dict.value"
:label=
"
parseInt(dict.value as string)
"
:label=
"
dict.value as string
"
>
>
{{
dict
.
label
}}
{{
dict
.
label
}}
</el-radio>
</el-radio>
...
@@ -81,6 +81,7 @@ const formRules = reactive({
...
@@ -81,6 +81,7 @@ const formRules = reactive({
})
})
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
/** 打开弹窗 */
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
dialogVisible
.
value
=
true
dialogVisible
.
value
=
true
dialogTitle
.
value
=
type
dialogTitle
.
value
=
type
...
@@ -90,7 +91,7 @@ const open = async (type: string, id?: number) => {
...
@@ -90,7 +91,7 @@ const open = async (type: string, id?: number) => {
if
(
id
)
{
if
(
id
)
{
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
formData
.
value
=
await
NotifyTemplateApi
.
getNotifyTemplate
Api
(
id
)
formData
.
value
=
await
NotifyTemplateApi
.
getNotifyTemplate
(
id
)
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
}
}
...
@@ -107,12 +108,12 @@ const submitForm = async () => {
...
@@ -107,12 +108,12 @@ const submitForm = async () => {
if
(
!
valid
)
return
if
(
!
valid
)
return
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
const
data
=
formData
.
value
as
NotifyTemplateApi
.
NotifyTemplateVO
const
data
=
formData
.
value
as
unknown
as
NotifyTemplateApi
.
NotifyTemplateVO
if
(
formType
.
value
===
'create'
)
{
if
(
formType
.
value
===
'create'
)
{
await
NotifyTemplateApi
.
createNotifyTemplate
Api
(
data
)
await
NotifyTemplateApi
.
createNotifyTemplate
(
data
)
message
.
success
(
'新增成功'
)
message
.
success
(
'新增成功'
)
}
else
{
}
else
{
await
NotifyTemplateApi
.
updateNotifyTemplate
Api
(
data
)
await
NotifyTemplateApi
.
updateNotifyTemplate
(
data
)
message
.
success
(
'修改成功'
)
message
.
success
(
'修改成功'
)
}
}
dialogVisible
.
value
=
false
dialogVisible
.
value
=
false
...
...
src/views/system/notify/template/NotifyTemplateSendForm.vue
0 → 100644
View file @
e3660e0b
<
template
>
<Dialog
v-model=
"dialogVisible"
title=
"测试发送"
:max-height=
"500"
>
<el-form
ref=
"formRef"
v-loading=
"formLoading"
:model=
"formData"
:rules=
"formRules"
label-width=
"140px"
>
<el-form-item
label=
"模板内容"
prop=
"content"
>
<el-input
v-model=
"formData.content"
placeholder=
"请输入模板内容"
readonly
type=
"textarea"
/>
</el-form-item>
<el-form-item
label=
"接收人"
prop=
"userId"
>
<el-select
v-model=
"formData.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 formData.params"
:key=
"param"
:label=
"'参数
{' + param + '}'"
:prop="'templateParams.' + param"
>
<el-input
v-model=
"formData.templateParams[param]"
:placeholder=
"'请输入 ' + param + ' 参数'"
/>
</el-form-item>
</el-form>
<template
#
footer
>
<el-button
:disabled=
"formLoading"
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
lang=
"ts"
name=
"SystemNotifyTemplateSendForm"
setup
>
import
*
as
SmsTemplateApi
from
'@/api/system/sms/smsTemplate'
import
*
as
UserApi
from
'@/api/system/user'
import
*
as
NotifyTemplateApi
from
'@/api/system/notify/template'
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formData
=
ref
({
content
:
''
,
params
:
{},
userId
:
null
,
templateCode
:
''
,
templateParams
:
new
Map
()
})
const
formRules
=
reactive
({
userId
:
[{
required
:
true
,
message
:
'用户编号不能为空'
,
trigger
:
'change'
}],
templateCode
:
[{
required
:
true
,
message
:
'模版编号不能为空'
,
trigger
:
'blur'
}],
templateParams
:
{}
})
const
formRef
=
ref
()
// 表单 Ref
const
userOption
=
ref
<
UserApi
.
UserVO
[]
>
([])
const
open
=
async
(
id
:
number
)
=>
{
dialogVisible
.
value
=
true
resetForm
()
// 设置数据
formLoading
.
value
=
true
try
{
const
data
=
await
NotifyTemplateApi
.
getNotifyTemplate
(
id
)
// 设置动态表单
formData
.
value
.
content
=
data
.
content
formData
.
value
.
params
=
data
.
params
formData
.
value
.
templateCode
=
data
.
code
formData
.
value
.
templateParams
=
data
.
params
.
reduce
((
obj
,
item
)
=>
{
obj
[
item
]
=
''
// 给每个动态属性赋值,避免无法读取
return
obj
},
{})
formRules
.
templateParams
=
data
.
params
.
reduce
((
obj
,
item
)
=>
{
obj
[
item
]
=
{
required
:
true
,
message
:
'参数 '
+
item
+
' 不能为空'
,
trigger
:
'blur'
}
return
obj
},
{})
}
finally
{
formLoading
.
value
=
false
}
// 加载用户列表
userOption
.
value
=
await
UserApi
.
getSimpleUserList
()
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 提交表单 */
const
submitForm
=
async
()
=>
{
// 校验表单
if
(
!
formRef
)
return
const
valid
=
await
formRef
.
value
.
validate
()
if
(
!
valid
)
return
// 提交请求
formLoading
.
value
=
true
try
{
const
data
=
formData
.
value
as
SmsTemplateApi
.
SendSmsReqVO
const
logId
=
await
SmsTemplateApi
.
sendSms
(
data
)
if
(
logId
)
{
message
.
success
(
'提交发送成功!发送结果,见发送日志编号:'
+
logId
)
}
dialogVisible
.
value
=
false
}
finally
{
formLoading
.
value
=
false
}
}
/** 重置表单 */
const
resetForm
=
()
=>
{
formData
.
value
=
{
content
:
''
,
params
:
{},
mobile
:
''
,
templateCode
:
''
,
templateParams
:
new
Map
()
}
formRef
.
value
?.
resetFields
()
}
</
script
>
src/views/system/notify/template/index.vue
View file @
e3660e0b
<
template
>
<
template
>
<doc-alert
title=
"站内信配置"
url=
"https://doc.iocoder.cn/notify/"
/>
<doc-alert
title=
"站内信配置"
url=
"https://doc.iocoder.cn/notify/"
/>
<!-- 搜索工作栏 -->
<ContentWrap>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
<el-form
class=
"-mb-15px"
class=
"-mb-15px"
:model=
"queryParams"
:model=
"queryParams"
...
@@ -99,7 +99,6 @@
...
@@ -99,7 +99,6 @@
width=
"200"
width=
"200"
:show-overflow-tooltip=
"true"
:show-overflow-tooltip=
"true"
/>
/>
<el-table-column
label=
"开启状态"
align=
"center"
prop=
"status"
width=
"80"
>
<el-table-column
label=
"开启状态"
align=
"center"
prop=
"status"
width=
"80"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.COMMON_STATUS"
:value=
"scope.row.status"
/>
<dict-tag
:type=
"DICT_TYPE.COMMON_STATUS"
:value=
"scope.row.status"
/>
...
@@ -151,67 +150,22 @@
...
@@ -151,67 +150,22 @@
/>
/>
</ContentWrap>
</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"
/>
<NotifyTemplateForm
ref=
"formRef"
@
success=
"getList"
/>
<!-- 表单弹窗:测试发送 -->
<NotifyTemplateSendForm
ref=
"sendFormRef"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"NotifySmsTemplate"
>
<
script
setup
lang=
"ts"
name=
"NotifySmsTemplate"
>
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
*
as
NotifyTemplateApi
from
'@/api/system/notify/template'
import
*
as
NotifyTemplateApi
from
'@/api/system/notify/template'
import
{
getSimpleUserList
,
UserVO
}
from
'@/api/system/user'
import
NotifyTemplateForm
from
'./NotifyTemplateForm.vue'
import
NotifyTemplateForm
from
'./NotifyTemplateForm.vue'
import
NotifyTemplateSendForm
from
'./NotifyTemplateSendForm.vue'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
loading
=
ref
(
false
)
// 列表的加载中
const
loading
=
ref
(
false
)
// 列表的加载中
const
total
=
ref
(
0
)
// 列表的总页数
const
total
=
ref
(
0
)
// 列表的总页数
const
list
=
ref
([])
// 列表的数据
const
list
=
ref
([])
// 列表的数据
const
queryFormRef
=
ref
()
// 搜索的表单
const
formLoading
=
ref
(
false
)
const
dialogFormVisible
=
ref
(
false
)
const
sendFormRef
=
ref
()
// 表单 Ref
const
queryParams
=
reactive
({
const
queryParams
=
reactive
({
pageNo
:
1
,
pageNo
:
1
,
pageSize
:
10
,
pageSize
:
10
,
...
@@ -220,28 +174,13 @@ const queryParams = reactive({
...
@@ -220,28 +174,13 @@ const queryParams = reactive({
code
:
undefined
,
code
:
undefined
,
createTime
:
[]
createTime
:
[]
})
})
const
queryFormRef
=
ref
()
// 搜索的表单
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
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
loading
.
value
=
true
loading
.
value
=
true
try
{
try
{
const
data
=
await
NotifyTemplateApi
.
getNotifyTemplatePage
Api
(
queryParams
)
const
data
=
await
NotifyTemplateApi
.
getNotifyTemplatePage
(
queryParams
)
list
.
value
=
data
.
list
list
.
value
=
data
.
list
total
.
value
=
data
.
total
total
.
value
=
data
.
total
}
finally
{
}
finally
{
...
@@ -280,50 +219,14 @@ const handleDelete = async (id: number) => {
...
@@ -280,50 +219,14 @@ const handleDelete = async (id: number) => {
}
catch
{}
}
catch
{}
}
}
const
openSendForm
=
(
row
:
any
)
=>
{
/** 发送站内信按钮 */
sendFormData
.
value
.
content
=
row
.
content
const
sendFormRef
=
ref
()
// 表单 Ref
sendFormData
.
value
.
params
=
row
.
params
const
openSendForm
=
(
row
:
NotifyTemplateApi
.
NotifyTemplateVO
)
=>
{
sendFormData
.
value
.
templateCode
=
row
.
code
sendFormRef
.
value
.
open
(
row
.
id
)
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
}
}
}
/** 初始化 **/
/** 初始化 **/
onMounted
(()
=>
{
onMounted
(()
=>
{
getList
()
getList
()
getSimpleUserList
().
then
((
data
)
=>
{
userOption
.
value
=
data
})
})
})
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment